From 3554d061f3eeb206f4bf7a667f85a7141cee9fc3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 17 Jan 2021 09:29:55 +0100 Subject: [PATCH] Bug Fixed: Data Dependencies Filter wrongly considering nodes like Conditions with draft code. --- .../Low-Frequency-Trading/TradingProcess.js | 29 ++++++++++++++++++- .../Superalgos/TS/Globals/ProcessConstants.js | 2 +- .../TS/Process-Modules/DataDependencies.js | 5 +++- .../Superalgos/TS/Task-Modules/DebugLog.js | 2 +- .../Function-Libraries/DependenciesFilter.js | 13 ++++++++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index ecd6796af..2dde20fdb 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -101,7 +101,12 @@ Here is the point where we sync one and the other. */ let tradingProcessDate = TS.projects.superalgos.utilities.dateTimeFunctions.removeTime(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingEngine.current.episode.processDate.value) - await processSingleFiles() + + if (await processSingleFiles() === false) { + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Waiting for Data Mining to be run') + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) + return + } if (await processMarketFiles() === false) { TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Waiting for Data Mining to be run') @@ -343,6 +348,16 @@ /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) + if (response.err.message === 'File does not exist.') { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") + return false + } + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } @@ -393,6 +408,12 @@ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) if (response.err.message === 'File does not exist.') { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") return false } @@ -516,6 +537,12 @@ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) if (response.err.message === 'File does not exist.') { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") return false } if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { diff --git a/Projects/Superalgos/TS/Globals/ProcessConstants.js b/Projects/Superalgos/TS/Globals/ProcessConstants.js index e859d86fb..4c24329c9 100644 --- a/Projects/Superalgos/TS/Globals/ProcessConstants.js +++ b/Projects/Superalgos/TS/Globals/ProcessConstants.js @@ -13,7 +13,7 @@ exports.newSuperalgosGlobalsProcessConstants = function () { TRADING_SYSTEM_NODE This is a Trading System node structure. TRADING_ENGINE_NODE This is a Trading Engine node structure. SESSION_NODE This is a Trading Session node structure. - DEPENDENCY_FILTER This is the counter of main loops for a bot process. + DEPENDENCY_FILTER This is an array that defines which indicators and at which time frame are dependencies for a process. */ return thisObject } \ No newline at end of file diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index a4e9ed86d..9f5a0d468 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -18,10 +18,13 @@ try { /* Basic Valdidations */ if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies !== undefined) { + /* + First we will get all the data dependencies of the bot, as defined at the Trading Mine. + */ thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') if (thisObject.nodeArray.length === 0) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all."); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } /* diff --git a/Projects/Superalgos/TS/Task-Modules/DebugLog.js b/Projects/Superalgos/TS/Task-Modules/DebugLog.js index 8eafe8571..a3ffccb94 100644 --- a/Projects/Superalgos/TS/Task-Modules/DebugLog.js +++ b/Projects/Superalgos/TS/Task-Modules/DebugLog.js @@ -170,7 +170,7 @@ exports.newSuperalgosTaskModulesDebugLog = function (processIndex) { let logLine = '\r\n' + message; if (message.indexOf("ERROR") > 0) { - let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName + let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName console.log('*********** ' + message + ' @ ' + key) } diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index c768cb46a..a3eb3d60e 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -1,4 +1,13 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { + /* + The function will scen a node branch, most likely a Trading System, + looking into the code property of each node. It will analyze it's + content and try to make a list of all indicators mentioned at the code + text and at which time frames they are mentioned. + + It is important to note that all node that are not of the type + Javascript Code are going to be filtered out. + */ thisObject = { createFilter: createFilter } @@ -12,7 +21,9 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { return Array.from(filters.keys()) function recursiveFilter(node) { - filter(node.code) + if (node.type === 'Javascript Code') { + filter(node.code) + } let schemaDocument = getSchemaDocument(node) if (schemaDocument !== undefined) {