Merge pull request #483 from Luis-Fernando-Molina/develop

Contribution: Error Handling Improved in a few modules of the LF Trading Bot
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-01-26 18:24:20 +01:00
commit ca8b36fb9e
11 files changed
+379 -16

No files matched your search

@@ -3,8 +3,8 @@
"pageNumber": "38",
"type": "TS LF Trading Bot Error - Order Quoted Asset Node Missing",
"definition": {
"text": "A Order Quoted Asset Node was expected but not found at the node where the error poped up.",
"updated": 1611650168650
"text": "An Order Quoted Asset Node was expected but not found at the node where the error poped up.",
"updated": 1611677527859
},
"paragraphs": [
{
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "46",
"type": "TS LF Trading Bot Error - Stage Base Asset Node Missing",
"definition": {
"text": "A Stage Base Asset Asset Node was expected but not found at the node where the error poped up.",
"updated": 1611677607596
},
"paragraphs": [
{
"style": "Error",
"text": "Stage Base Asset Node Missing",
"updated": 1611678203390
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "47",
"type": "TS LF Trading Bot Error - Stage Quoted Asset Node Missing",
"definition": {
"text": "A Stage Quoted Asset Asset Node was expected but not found at the node where the error poped up.",
"updated": 1611677624495
},
"paragraphs": [
{
"style": "Error",
"text": "Stage Quoted Asset Node Missing",
"updated": 1611678239797
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "48",
"type": "TS LF Trading Bot Error - Target Size Node Missing",
"definition": {
"text": "A Target Size Node was expected but not found at the node where the error poped up.",
"updated": 1611677647791
},
"paragraphs": [
{
"style": "Error",
"text": "Target Size Node Missing",
"updated": 1611678342962
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "49",
"type": "TS LF Trading Bot Error - Size Placed Node Missing",
"definition": {
"text": "A Size Placed Node was expected but not found at the node where the error poped up.",
"updated": 1611677675945
},
"paragraphs": [
{
"style": "Error",
"text": "Size Placed Node Missing",
"updated": 1611678372361
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,101 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "50",
"type": "TS LF Trading Bot Error - Snapshot Unexpected Error",
"definition": {
"text": "The Trading Bot found an Unexpected Error during the generation of a Snapshot. The trading process continued but the task of generating the Snapshot was aborted.",
"updated": 1611681073241
},
"paragraphs": [
{
"style": "Error",
"text": "Snapshot Unexpected Error",
"updated": 1611680863486
},
{
"style": "Title",
"text": "Error Details"
},
{
"style": "Text",
"text": "In the following section you will find the specific information received when this error occured."
},
{
"style": "Text",
"text": "You will only see it if you opened this page as a result of the error actually happening.",
"updated": 1611680880668
},
{
"style": "Subtitle",
"text": "Error Message"
},
{
"style": "Text",
"text": "The following is the Error Message of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorMessage"
},
{
"style": "Subtitle",
"text": "Error Stack"
},
{
"style": "Text",
"text": "The following is the Error Stack of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorStack"
},
{
"style": "Subtitle",
"text": "Error Code"
},
{
"style": "Text",
"text": "The follwing is the Error Code of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorCode"
},
{
"style": "Subtitle",
"text": "Error Details"
},
{
"style": "Text",
"text": "The follwing are all the Error details of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorDetails"
},
{
"style": "Subtitle",
"text": "Node Name"
},
{
"style": "Text",
"text": "The follwing is the node's name of the Node most related to this error:"
},
{
"style": "Placeholder",
"text": "nodeName"
},
{
"style": "Subtitle",
"text": "Node Code"
},
{
"style": "Text",
"text": "The follwing is the code stored at the node that produced the error at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "nodeCode"
}
]
}
@@ -0,0 +1,119 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "51",
"type": "TS LF Trading Bot Error - Snapshot Instruction Evaluation Error",
"definition": {
"text": "This error occured while evaluation an instruction as part of the process of generating a Snapshot. This did not prevent the Snapshot to be created but that instruction value was set to zero.",
"updated": 1611681320900
},
"paragraphs": [
{
"style": "Error",
"text": "Snapshot Instruction Evaluation Error",
"updated": 1611681105978
},
{
"style": "Title",
"text": "Error Details"
},
{
"style": "Text",
"text": "In the following section you will find the specific information received when this error occured."
},
{
"style": "Note",
"text": "You will only see it if you opened this page as a result of the error actually happening."
},
{
"style": "Subtitle",
"text": "Error Message"
},
{
"style": "Text",
"text": "The following is the Error Message of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorMessage"
},
{
"style": "Subtitle",
"text": "Error Stack"
},
{
"style": "Text",
"text": "The following is the Error Stack of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorStack"
},
{
"style": "Subtitle",
"text": "Error Code"
},
{
"style": "Text",
"text": "The follwing is the Error Code of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorCode"
},
{
"style": "Subtitle",
"text": "Error Details"
},
{
"style": "Text",
"text": "The follwing are all the Error details of the Exception that occured at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "errorDetails"
},
{
"style": "Subtitle",
"text": "Node Name"
},
{
"style": "Text",
"text": "The follwing is the node's name of the Node most related to this error:"
},
{
"style": "Placeholder",
"text": "nodeName"
},
{
"style": "Subtitle",
"text": "Node Code"
},
{
"style": "Text",
"text": "The follwing is the code stored at the node that produced the error at the LF Trading Bot:"
},
{
"style": "Placeholder",
"text": "nodeCode"
},
{
"style": "Subtitle",
"text": "Context Info",
"updated": 1611681195733
},
{
"style": "Text",
"text": "The follwing is the context information preserved when the error occured:",
"updated": 1611681225358
},
{
"style": "Placeholder",
"text": "contextInfo",
"updated": 1611681233411
},
{
"style": "Text",
"text": ""
}
]
}
@@ -240,6 +240,18 @@ exports.newSuperalgosBotModulesSnapshots = function (processIndex) {
let value = eval(instruction)
values.push(value)
} catch (err) {
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS LF Trading Bot Error - Snapshot Instruction Evaluation Error',
placeholder: {}
}
let contextInfo = {
instruction: instruction
}
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, nodeWithCode.name, nodeWithCode.code, undefined, undefined, contextInfo)
tradingSystem.errors.push([nodeWithCode.id, 'Instruction ' + instruction + ' evalueates with error ' + err.message])
values.push(0)
}
@@ -248,7 +260,15 @@ exports.newSuperalgosBotModulesSnapshots = function (processIndex) {
}
}
} catch (err) {
tradingSystem.errors.push([nodeWithCode.id, err.message])
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS LF Trading Bot Error - Snapshot Unexpected Error',
placeholder: {}
}
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, err, nodeWithCode.name, nodeWithCode.code, undefined)
tradingSystem.errors.push([nodeWithCode.id, err.message, docs])
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] runSimulation -> addCodeToSnapshot -> nodeWithCode.code = ' + nodeWithCode.code)
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] runSimulation -> addCodeToSnapshot -> err = ' + err.stack)
}
@@ -51,16 +51,16 @@ exports.newSuperalgosBotModulesTradingExecution = function (processIndex) {
) {
try {
/* Trading Engine Stage Validations */
if (tradingEngineStage.stageBaseAsset === undefined) { badDefinitionUnhandledException(undefined, 'stageBaseAsset === undefined', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'stageBaseAsset.targetSize === undefined', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.sizePlaced === undefined) { badDefinitionUnhandledException(undefined, 'stageBaseAsset.sizePlaced === undefined', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'stageBaseAsset.sizeFilled === undefined', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'stageBaseAsset.feesPaid === undefined', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset === undefined) { badDefinitionUnhandledException(undefined, 'stageQuotedAsset === undefined', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'stageQuotedAsset.targetSize === undefined', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.sizePlaced === undefined) { badDefinitionUnhandledException(undefined, 'stageQuotedAsset.sizePlaced === undefined', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'stageQuotedAsset.sizeFilled === undefined', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'stageQuotedAsset.feesPaid === undefined', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset === undefined) { badDefinitionUnhandledException(undefined, 'Stage Base Asset Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'Target Size Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.sizePlaced === undefined) { badDefinitionUnhandledException(undefined, 'Size Placed Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'Size Filled Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageBaseAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'Fees Paid Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset === undefined) { badDefinitionUnhandledException(undefined, 'Stage Quoted Asset Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'Target Size Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.sizePlaced === undefined) { badDefinitionUnhandledException(undefined, 'Size Placed Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'Size Filled Node Missing', tradingEngineStage) }
if (tradingEngineStage.stageQuotedAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'Fees Paid Node Missing', tradingEngineStage) }
await checkExecutionAlgorithms(executionNode)
@@ -89,7 +89,15 @@ exports.newSuperalgosBotModulesTradingExecution = function (processIndex) {
}
function badDefinitionUnhandledException(err, message, node) {
tradingSystem.errors.push([node.id, message])
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS LF Trading Bot Error - ' + message,
placeholder: {}
}
tradingSystem.errors.push([node.id, message, docs])
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> " + message);
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> node.name = " + node.name);
@@ -98,7 +106,7 @@ exports.newSuperalgosBotModulesTradingExecution = function (processIndex) {
if (err !== undefined) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> err.stack = " + err.stack);
}
throw 'Please fix the problem and try again.'
throw 'Error Already Recorded'
}
}
@@ -526,6 +526,6 @@ exports.newSuperalgosBotModulesTradingPosition = function (processIndex) {
if (err !== undefined) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> err.stack = " + err.stack);
}
throw 'Please fix the problem and try again.'
throw 'Error Already Recorded'
}
}
@@ -380,6 +380,13 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) {
}
function initializeStageTargetSize() {
/*
Validations that all needed nodes are there.
*/
if (tradingEngine.current.strategyOpenStage.stageBaseAsset === undefined) { badDefinitionUnhandledException(undefined, 'Stage Base Asset Node Missing', tradingEngine.current.strategyOpenStage) }
if (tradingEngine.current.strategyOpenStage.stageBaseAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'Target Size Node Missing', tradingEngine.current.strategyOpenStage.stageBaseAsset) }
if (tradingEngine.current.strategyOpenStage.stageQuotedAsset === undefined) { badDefinitionUnhandledException(undefined, 'Stage Quoted Asset Node Missing', tradingEngine.current.strategyOpenStage) }
if (tradingEngine.current.strategyOpenStage.stageQuotedAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'Target Size Node Missing', tradingEngine.current.strategyOpenStage.stageQuotedAsset) }
/*
Here we will transform the position size into targets for each asset of the stage.
*/
@@ -851,6 +858,13 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) {
}
function initializeStageTargetSize() {
/*
Validations that all needed nodes are there.
*/
if (tradingEngine.current.strategyCloseStage.stageBaseAsset === undefined) { badDefinitionUnhandledException(undefined, 'Stage Base Asset Node Missing', tradingEngine.current.strategyCloseStage) }
if (tradingEngine.current.strategyCloseStage.stageBaseAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'Target Size Node Missing', tradingEngine.current.strategyCloseStage.stageBaseAsset) }
if (tradingEngine.current.strategyCloseStage.stageQuotedAsset === undefined) { badDefinitionUnhandledException(undefined, 'Stage Quoted Asset Node Missing', tradingEngine.current.strategyCloseStage) }
if (tradingEngine.current.strategyCloseStage.stageQuotedAsset.targetSize === undefined) { badDefinitionUnhandledException(undefined, 'Target Size Node Missing', tradingEngine.current.strategyCloseStage.stageQuotedAsset) }
/*
Here we will transform the position size into targets for each asset of the stage.
*/
@@ -1126,4 +1140,25 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) {
function updateStatistics() {
}
function badDefinitionUnhandledException(err, message, node) {
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS LF Trading Bot Error - ' + message,
placeholder: {}
}
tradingSystem.errors.push([node.id, message, docs])
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> " + message);
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> node.name = " + node.name);
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> node.type = " + node.type);
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> node.config = " + JSON.stringify(node.config));
if (err !== undefined) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> err.stack = " + err.stack);
}
throw 'Error Already Recorded'
}
}