From a1e51ff9f8e5f50f7abebf9d94df9467f6b47bb8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 18:14:55 +0100 Subject: [PATCH] Mechanism to change Begining of the Market IMplemented --- Multi-Period-Daily/User.bot.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Multi-Period-Daily/User.bot.js b/Multi-Period-Daily/User.bot.js index c7fea7ed0..c33377ea2 100644 --- a/Multi-Period-Daily/User.bot.js +++ b/Multi-Period-Daily/User.bot.js @@ -25,6 +25,7 @@ let utilities = UTILITIES.newCloudUtilities(bot, logger); let statusDependencies; + let beginingOfMarket return thisObject; @@ -176,6 +177,20 @@ Read the candles and volumes from Bruce and produce a file for each day and for thisReport = statusDependencies.statusReports.get(reportKey).file; if (thisReport.lastFile !== undefined) { + logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running not for the very first time. -> reportKey = " + reportKey); + + beginingOfMarket = new Date(thisReport.beginingOfMarket.year + "-" + thisReport.beginingOfMarket.month + "-" + thisReport.beginingOfMarket.days + " " + thisReport.beginingOfMarket.hours + ":" + thisReport.beginingOfMarket.minutes + GMT_SECONDS); + + if (beginingOfMarket.valueOf() !== contextVariables.firstTradeFile.valueOf()) { // Reset Mechanism for Begining of the Market + logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey); + + beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS); + contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS); + contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well. + + buildCandles(); + return; + } contextVariables.lastCandleFile = new Date(thisReport.lastFile); @@ -190,7 +205,9 @@ Read the candles and volumes from Bruce and produce a file for each day and for return; } else { + logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running for the very first time. -> reportKey = " + reportKey); + beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS); contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS); contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well. @@ -756,6 +773,7 @@ Read the candles and volumes from Bruce and produce a file for each day and for thisReport.file.lastExecution = bot.processDatetime; thisReport.file.lastFile = lastFileDate; + thisReport.file.beginingOfMarket = beginingOfMarket.toUTCString() thisReport.save(callBack); }