From 066dc0689b5dbe2337a8f14a6b0ceda7888345d6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 25 Mar 2019 12:08:02 +0100 Subject: [PATCH 1/4] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 402b59b95..f57a84efa 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ bin/* *.cache node_modules/* exchange/Auth0.js +.env From 2e82e7e22821ded3317395e81d2dd39a7c47e37b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 25 Mar 2019 18:11:29 +0100 Subject: [PATCH 2/4] Supports Begin Date and Resume Execution on Multi Period Daily Framework --- MultiPeriodDaily.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) 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); From ada66e41c837d6335d4a0cf6aa7879320056d9e5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 26 Mar 2019 13:35:20 +0100 Subject: [PATCH 3/4] BUG corrected. Framework is not required on every bot --- Root.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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. */ From 1a1301af87687e505335f2ebf6f82dfb2840b8ad Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 26 Mar 2019 17:12:20 +0100 Subject: [PATCH 4/4] Extradata on execution history --- Assistant.js | 8 +++++++- Context.js | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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);