From 70774efa5591a1866ff588609a15c5524be7d4a7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 Jan 2021 10:28:24 +0100 Subject: [PATCH] Session Errors Handling / UX improved --- ...-session-error-label-property-missing.json | 12 ++++- ...rror-initial-balance-property-missing.json | 12 ++++- ...sion-error-key-reference-node-missing.json | 16 +++++++ ...ror-exchange-account-key-node-missing.json | 16 +++++++ ...ssion-error-codename-property-missing.json | 24 ++++++++++ ...session-error-secret-property-missing.json | 24 ++++++++++ .../Bot-Modules/Trading-Bot/TradingSession.js | 48 +++++++++++++++---- .../TS/Function-Libraries/SessionFunctions.js | 9 ++++ 8 files changed, 149 insertions(+), 12 deletions(-) create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-010-ts-trading-session-error-key-reference-node-missing.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-011-ts-trading-session-error-exchange-account-key-node-missing.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-012-ts-trading-session-error-codename-property-missing.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-013-ts-trading-session-error-secret-property-missing.json diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-005-ts-trading-session-error-label-property-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-005-ts-trading-session-error-label-property-missing.json index 37f319df9..d670abbee 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-005-ts-trading-session-error-label-property-missing.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-005-ts-trading-session-error-label-property-missing.json @@ -14,8 +14,16 @@ }, { "style": "Title", - "text": "Example", - "updated": 1611332609003 + "text": "Property Missing", + "updated": 1611392835535 + }, + { + "style": "Json", + "text": "label" + }, + { + "style": "Title", + "text": "Example" }, { "style": "Json", diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-009-ts-trading-session-error-initial-balance-property-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-009-ts-trading-session-error-initial-balance-property-missing.json index ef4853b16..48671bdcd 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-009-ts-trading-session-error-initial-balance-property-missing.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-009-ts-trading-session-error-initial-balance-property-missing.json @@ -9,8 +9,16 @@ "paragraphs": [ { "style": "Success", - "text": "Check the config at the Node reporting this error and make sure that this property exists. ", - "updated": 1611335725336 + "text": "Check the config at the Node reporting this error and make sure that this property exists.", + "updated": 1611392878438 + }, + { + "style": "Title", + "text": "Property Missing" + }, + { + "style": "Json", + "text": "initialBalance" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-010-ts-trading-session-error-key-reference-node-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-010-ts-trading-session-error-key-reference-node-missing.json new file mode 100644 index 000000000..de818c2af --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-010-ts-trading-session-error-key-reference-node-missing.json @@ -0,0 +1,16 @@ +{ + "topic": "TS Trading Session Errors", + "pageNumber": "10", + "type": "TS Trading Session Error - Key Reference Node Missing", + "definition": { + "text": "For a Live Trading Session or a Forward Testing Session you need to provide an Exchange API Key to access your Exchange account. In order to do that you need to add a Key Reference Node which references an Exchange Account Key Node with your keys.", + "updated": 1611392529450 + }, + "paragraphs": [ + { + "style": "Success", + "text": "At the Task Node where this error poped up, add a Key Reference Node and reference from it an Exchange Account Key with it. Then you can try to run the Trading Session again.", + "updated": 1611392617497 + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-011-ts-trading-session-error-exchange-account-key-node-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-011-ts-trading-session-error-exchange-account-key-node-missing.json new file mode 100644 index 000000000..794dd7d40 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-011-ts-trading-session-error-exchange-account-key-node-missing.json @@ -0,0 +1,16 @@ +{ + "topic": "TS Trading Session Errors", + "pageNumber": "11", + "type": "TS Trading Session Error - Exchange Account Key Node Missing", + "definition": { + "text": "An Exchange Account Key Node is expected and needed in order to run a Live Trading Session or an Forward Testing Session.", + "updated": 1611392704049 + }, + "paragraphs": [ + { + "style": "Success", + "text": "From the Key Reference Node where this error poped up, you need to reference an Account Exchange Key holding your keys to access your account at the Exchange.", + "updated": 1611392779124 + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-012-ts-trading-session-error-codename-property-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-012-ts-trading-session-error-codename-property-missing.json new file mode 100644 index 000000000..d8bea34cd --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-012-ts-trading-session-error-codename-property-missing.json @@ -0,0 +1,24 @@ +{ + "topic": "TS Trading Session Errors", + "pageNumber": "12", + "type": "TS Trading Session Error - Codename Property Missing", + "definition": { + "text": "A property called codeName is expeceted at the Exchange Account Key Node config.", + "updated": 1611392953689 + }, + "paragraphs": [ + { + "style": "Success", + "text": "Add this property and assign to it the value of your account key taken from the Exchange website.", + "updated": 1611393012580 + }, + { + "style": "Title", + "text": "Property Missing" + }, + { + "style": "Json", + "text": "codeName" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-013-ts-trading-session-error-secret-property-missing.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-013-ts-trading-session-error-secret-property-missing.json new file mode 100644 index 000000000..35d805eb2 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-trading-session-errors-013-ts-trading-session-error-secret-property-missing.json @@ -0,0 +1,24 @@ +{ + "topic": "TS Trading Session Errors", + "pageNumber": "13", + "type": "TS Trading Session Error - Secret Property Missing", + "definition": { + "text": "A property called secret is expeceted at the Exchange Account Key Node config.", + "updated": 1611393059925 + }, + "paragraphs": [ + { + "style": "Success", + "text": "Add this property and assign to it the value of your account key secret taken from the Exchange website.", + "updated": 1611393087867 + }, + { + "style": "Title", + "text": "Property Missing" + }, + { + "style": "Json", + "text": " secret" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/TradingSession.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/TradingSession.js index b037b52fc..28dae13be 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/TradingSession.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/TradingSession.js @@ -517,31 +517,63 @@ function checkKey() { if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference === undefined) { - let errorMessage = "Key Reference not defined. Please check that and try again." + let errorMessage = "Key Reference Node Missing" TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage) + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS Trading Session Error - ' + errorMessage, + placeholder: {} + } + + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.taskConstants.TASK_NODE, errorMessage, docs) return false } if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent === undefined) { - let errorMessage = "Key Reference not referencing an Exchange Account Key. Please check that and try again." + let errorMessage = "Exchange Account Key Node Missing" TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage) + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS Trading Session Error - ' + errorMessage, + placeholder: {} + } + + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference, errorMessage, docs) return false } if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.codeName === undefined) { - let errorMessage = "Key 'codeName' undefined. Paste there you key. Please check that and try again." + let errorMessage = "Codename Property Missing" TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage) + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS Trading Session Error - ' + errorMessage, + placeholder: {} + } + + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent, errorMessage, docs) return false } if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.secret === undefined) { - let errorMessage = "Key 'secret' undefined. Paste there you key secret. Please check that and try again." + let errorMessage = "Secret Property Missing" TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage) + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS Trading Session Error - ' + errorMessage, + placeholder: {} + } + + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent, errorMessage, docs) return false } return true diff --git a/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js b/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js index ffb4b9a42..4cfc063ee 100644 --- a/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js +++ b/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js @@ -77,6 +77,15 @@ exports.newSuperalgosFunctionLibrariesSessionFunctions = function () { TS.projects.superalgos.globals.taskConstants.EVENT_SERVER_CLIENT_MODULE_OBJECT.raiseEvent( TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_KEY, 'Error', event) + if (node !== undefined && node.id !== TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.id) { + event = { + warningMessage: "Session could not be ran. Check the Workspace Map for Nodes with errors." + } + + TS.projects.superalgos.globals.taskConstants.EVENT_SERVER_CLIENT_MODULE_OBJECT.raiseEvent( + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_KEY, 'Warning', event) + } + if (TS.projects.superalgos.globals.taskVariables.IS_TASK_STOPPING === true) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_STOPPING = true TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[IMPORTANT] sessionError -> Stopping the Session now. ')