From f52aaa40fd80a791278268fa0795d72b413ce8a5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 26 May 2021 22:09:44 +0200 Subject: [PATCH] bug fixed Bollinger Bands with hardcoded Data Mine Name --- .../BollingerBandsMultiTimeFrameDaily.js | 50 ++++++------------- .../BollingerBandsMultiTimeFrameMarket.js | 9 ++-- .../CandlesVolumesMultiTimeFrameDaily.js | 5 +- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js index 8e56e0107..17c179a4a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameDaily.js @@ -12,15 +12,15 @@ let fileStorage = TS.projects.superalgos.taskModules.fileStorage.newFileStorage(processIndex); - let statusDependencies; + let statusDependenciesModule; let beginingOfMarket return thisObject; - function initialize(pStatusDependencies, callBackFunction) { + function initialize(pStatusDependenciesModule, callBackFunction) { try { - statusDependencies = pStatusDependencies; + statusDependenciesModule = pStatusDependenciesModule; callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { @@ -52,16 +52,11 @@ function getContextVariables() { try { - let thisReport; - let reportKey; - let statusReport; + let thisReport + let statusReport /* We look first for Exchange Raw Data in order to get when the market starts. */ - reportKey = "Masters" + "-" + "Exchange-Raw-Data" + "-" + "Historic-OHLCVs" - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> getContextVariables -> reportKey = " + reportKey) - - statusReport = statusDependencies.statusReports.get(reportKey); + statusReport = statusDependenciesModule.reportsByMainUtility.get('Market Starting Point') if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, @@ -77,11 +72,9 @@ return; } - thisReport = statusDependencies.statusReports.get(reportKey).file; + thisReport = statusReport.file if (thisReport.beginingOfMarket === undefined) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey); TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[HINT] start -> getContextVariables -> It is too early too run this process since the trade history of the market is not there yet."); @@ -103,12 +96,8 @@ thisReport.beginingOfMarket.minutes + TS.projects.superalgos.globals.timeConstants.GMT_SECONDS); - /* Second, we get the report from Candles Volumes, to know when the marted ends. */ - reportKey = "Masters" + "-" + "Candles-Volumes" + "-" + "Multi-Time-Frame-Daily" - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> getContextVariables -> reportKey = " + reportKey) - - statusReport = statusDependencies.statusReports.get(reportKey); + /* Second, we get the report from Exchange Raw Data, to know when the marted ends. */ + statusReport = statusDependenciesModule.reportsByMainUtility.get('Market Ending Point') if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, @@ -124,11 +113,9 @@ return; } - thisReport = statusDependencies.statusReports.get(reportKey).file; + thisReport = statusReport.file if (thisReport.lastFile === undefined) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey); let customOK = { result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, @@ -143,11 +130,7 @@ contextVariables.maxBandFile = new Date(thisReport.lastFile.valueOf()); /* Finally we get our own Status Report. */ - reportKey = "Masters" + "-" + "Bollinger-Bands" + "-" + "Multi-Time-Frame-Daily" - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> getContextVariables -> reportKey = " + reportKey) - - statusReport = statusDependencies.statusReports.get(reportKey); + statusReport = statusDependenciesModule.reportsByMainUtility.get('Self Reference') if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, @@ -163,15 +146,13 @@ return; } - thisReport = statusDependencies.statusReports.get(reportKey).file; + thisReport = statusReport.file if (thisReport.lastFile !== undefined) { beginingOfMarket = new Date(thisReport.beginingOfMarket); if (beginingOfMarket.valueOf() !== contextVariables.datetimeBeginingOfMarketFile.valueOf()) { // Reset Mechanism for Begining of the Market - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey); beginingOfMarket = new Date( contextVariables.datetimeBeginingOfMarketFile.getUTCFullYear() + "-" + @@ -244,9 +225,9 @@ "[ERROR] start -> getContextVariables -> err = " + err.stack); if (err.message === "Cannot read property 'file' of undefined") { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. "); + "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependenciesModule declarations are correct. "); TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); + "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependenciesModule.keys)); } callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } @@ -841,8 +822,7 @@ TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> writeStatusReport -> lastFileDate = " + lastFileDate) try { - let reportKey = "Masters" + "-" + "Bollinger-Bands" + "-" + "Multi-Time-Frame-Daily" - let thisReport = statusDependencies.statusReports.get(reportKey); + let thisReport = statusDependenciesModule.reportsByMainUtility.get('Self Reference') thisReport.file.lastExecution = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_DATETIME; thisReport.file.lastFile = lastFileDate; diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameMarket.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameMarket.js index 9fd5b4565..dd560d0b0 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameMarket.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiTimeFrameMarket.js @@ -10,14 +10,14 @@ start: start } - let statusDependencies + let statusDependenciesModule let fileStorage = TS.projects.superalgos.taskModules.fileStorage.newFileStorage(processIndex) return thisObject - function initialize(pStatusDependencies, callBackFunction) { + function initialize(pStatusDependenciesModule, callBackFunction) { try { - statusDependencies = pStatusDependencies; + statusDependenciesModule = pStatusDependenciesModule; callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); } catch (err) { @@ -396,8 +396,7 @@ function writeStatusReport(callBack) { try { - let reportKey = "Masters" + "-" + "Bollinger-Bands" + "-" + "Multi-Time-Frame-Market" - let thisReport = statusDependencies.statusReports.get(reportKey); + let thisReport = statusDependenciesModule.reportsByMainUtility.get('Self Reference') thisReport.file.lastExecution = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_DATETIME; thisReport.save(callBack); diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js index 60c82ab02..36a72409f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiTimeFrameDaily.js @@ -67,7 +67,8 @@ return; } - thisReport = statusReport.file; + thisReport = statusReport.file + if (thisReport.beginingOfMarket === undefined) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[HINT] start -> getContextVariables -> It is too early too run this process since the trade history of the market is not there yet."); @@ -108,6 +109,7 @@ } thisReport = statusReport.file + if (thisReport.lastFile === undefined) { let customOK = { result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, @@ -143,6 +145,7 @@ } thisReport = statusReport.file + if (thisReport.lastFile !== undefined) { beginingOfMarket = new Date(thisReport.beginingOfMarket) if (beginingOfMarket.valueOf() !== contextVariables.datetimeBeginingOfMarketFile.valueOf()) { // Reset Mechanism for Begining of the Market