diff --git a/.gitignore b/.gitignore index d9ffcb1be..f57a84efa 100644 --- a/.gitignore +++ b/.gitignore @@ -9,10 +9,4 @@ bin/* *.cache node_modules/* exchange/Auth0.js -configs/Email.Config.json - -configs/User.Profile.json -configs/Execution.Config.json -configs/Secret.Keys.json -*.env -*.vscode* \ No newline at end of file +.env diff --git a/Assistant.js b/Assistant.js index d4fbb4346..28f5c0065 100644 --- a/Assistant.js +++ b/Assistant.js @@ -30,7 +30,8 @@ rememberThis: rememberThis, remindMeOf: remindMeOf, truncDecimals: truncDecimals, - sendEmail: sendEmail + sendEmail: sendEmail, + addExtraData: addExtraData }; let utilities = UTILITIES.newCloudUtilities(bot, logger); @@ -1363,6 +1364,11 @@ return; } + function addExtraData(pExtraDataArray) { + + context.extraData = pExtraDataArray; + } + function truncDecimals(pFloatValue, pDecimals) { if (!pDecimals) pDecimals = 8; // Default value diff --git a/Context.js b/Context.js index df5cd196f..1d272378a 100644 --- a/Context.js +++ b/Context.js @@ -45,7 +45,8 @@ messageBody: "" }, initialize: initialize, - saveThemAll: saveThemAll + saveThemAll: saveThemAll, + extraData: [] }; /* @@ -492,7 +493,9 @@ thisObject.newHistoryRecord.messageBody ]; - thisObject.executionHistory.push(newRecord); + let recordWithExtraData = newRecord.concat(thisObject.extraData); + + thisObject.executionHistory.push(recordWithExtraData); let fileContent = JSON.stringify(thisObject.executionHistory); diff --git a/MultiPeriodDaily.js b/MultiPeriodDaily.js index 562cd2f3f..5d54bc0b6 100644 --- a/MultiPeriodDaily.js +++ b/MultiPeriodDaily.js @@ -233,8 +233,13 @@ if (thisReport.lastFile !== undefined) { - contextVariables.lastFile = new Date(thisReport.lastFile); + if (bot.hasTheBotJustStarted === true && processConfig.framework.startDate.resumeExecution === "false") { + + startFromBegining(); + return; + } + contextVariables.lastFile = new Date(thisReport.lastFile); interExecutionMemoryArray = thisReport.interExecutionMemoryArray; processTimePeriods(); @@ -246,10 +251,16 @@ In the case when there is no status report, we assume like the last processed file is the one on the date of Begining of Market. */ + startFromBegining(); + return; + } + + function startFromBegining() { + contextVariables.lastFile = new Date(contextVariables.dateBeginOfMarket.getUTCFullYear() + "-" + (contextVariables.dateBeginOfMarket.getUTCMonth() + 1) + "-" + contextVariables.dateBeginOfMarket.getUTCDate() + " " + "00:00" + GMT_SECONDS); - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> thisReport.lastFile === undefined"); } - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> contextVariables.lastFile = " + contextVariables.lastFile); } + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> startFromBegining -> thisReport.lastFile === undefined"); } + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> startFromBegining -> contextVariables.lastFile = " + contextVariables.lastFile); } /* The first time the process is running is the right time to create the data structure that is going to be shared across different executions. @@ -258,14 +269,13 @@ interExecutionMemoryArray = []; - for (let i = 0; i < global.dailyFilePeriods.length; i++) - { + for (let i = 0; i < global.dailyFilePeriods.length; i++) { let emptyObject = {}; interExecutionMemoryArray.push(emptyObject); } processTimePeriods(); - return; + } } catch (err) { @@ -734,6 +744,7 @@ thisReport.file.interExecutionMemoryArray = interExecutionMemoryArray; thisReport.save(callBack); + bot.hasTheBotJustStarted = false; } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.message); diff --git a/Root.js b/Root.js index 0b125f7c0..158a8ac82 100644 --- a/Root.js +++ b/Root.js @@ -288,11 +288,13 @@ processConfig.timePeriod = global.EXECUTION_CONFIG.timePeriod } - if (processConfig.framework.name === "Multi-Period-Daily") { - processConfig.framework.startDate.fixedDate = processConfig.startMode.noTime.beginDatetime; - processConfig.framework.startDate.resumeExecution = processConfig.startMode.noTime.resumeExecution; + if (processConfig.framework !== undefined) { + if (processConfig.framework.name === "Multi-Period-Daily") { + processConfig.framework.startDate.fixedDate = processConfig.startMode.noTime.beginDatetime; + processConfig.framework.startDate.resumeExecution = processConfig.startMode.noTime.resumeExecution; + } } - + try { /* We test each type of start Mode to get what to run and how. */