diff --git a/Projects/Superalgos/TS/Globals/ProcessVariables.js b/Projects/Superalgos/TS/Globals/ProcessVariables.js index 1fc3e9857..9d1c231ca 100644 --- a/Projects/Superalgos/TS/Globals/ProcessVariables.js +++ b/Projects/Superalgos/TS/Globals/ProcessVariables.js @@ -16,18 +16,19 @@ exports.newSuperalgosGlobalsProcessVariables = function () { What it is stored here depends very much on what the process is about and what it needs to do. Following is a list of known properties of this object. - PROCESS_KEY This is the key used in events related to the Process - SESSION_KEY This is the key used in events related to the Session - SESSION_FOLDER_NAME This is the folder name for Session related data and logs. - MAIN_LOOP_COUNTER This is the counter of main loops for a bot process. - LOGS_TO_DELETE_QUEUE This stores the logs that need to be deleted, for auto mantainance. - SOCIAL_BOTS_MODULE This is the module that controls social bots. - SESSION_STATUS This tell us the status of the session at any given time. - IS_SESSION_STOPPING This tell us if a session is in the process of being stopped. - IS_SESSION_RESUMING This tell us if a session is resuming from the state at the previous execution. - IS_SESSION_FIRST_LOOP This tell us if we are at the execution of the first loop of the bot related to this session. - SIMULATION_STATE This is the state of a simulaation, as it is loaded from disk. - PROCESS_DATETIME When processing daily files, this holds the date of the file being processed. + PROCESS_KEY This is the key used in events related to the Process + SESSION_KEY This is the key used in events related to the Session + SESSION_FOLDER_NAME This is the folder name for Session related data and logs. + MAIN_LOOP_COUNTER This is the counter of main loops for a bot process. + LOGS_TO_DELETE_QUEUE This stores the logs that need to be deleted, for auto mantainance. + SOCIAL_BOTS_MODULE This is the module that controls social bots. + SESSION_STATUS This tell us the status of the session at any given time. + IS_SESSION_STOPPING This tell us if a session is in the process of being stopped. + IS_SESSION_RESUMING This tell us if a session is resuming from the state at the previous execution. + IS_SESSION_FIRST_LOOP This tell us if we are at the execution of the first loop of the bot related to this session. + SIMULATION_STATE This is the state of a simulaation, as it is loaded from disk. + PROCESS_DATETIME This holds the date currently being processed. + DAILY_FILES_PROCESS_DATETIME When processing daily files, this holds the date of the file being processed. */ return thisObject } \ No newline at end of file diff --git a/TaskServer/DebugLog.js b/TaskServer/DebugLog.js index 7cad3a8fc..47e1bd0cd 100644 --- a/TaskServer/DebugLog.js +++ b/TaskServer/DebugLog.js @@ -87,7 +87,7 @@ exports.newDebugLog = function (processIndex) { percentage = percentage.toFixed(2) + " %" } - if (date === undefined) { date = thisObject.TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_DATETIME } + if (date === undefined) { date = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_DATETIME } date = date.getUTCFullYear() + '-' + strPad(date.getUTCMonth() + 1, 2, "0") + '-' + strPad(date.getUTCDate(), 2, "0"); logLoop(date, percentage, " Internal Loop # ") diff --git a/TaskServer/MultiPeriodDaily.js b/TaskServer/MultiPeriodDaily.js index 505b52431..82b3c30fd 100644 --- a/TaskServer/MultiPeriodDaily.js +++ b/TaskServer/MultiPeriodDaily.js @@ -214,21 +214,21 @@ let n; let botNeverRan = true; - bot.multiPeriodDailyProcessDatetime = new Date(contextVariables.lastFile.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well when we advance time at the begining of the loop. - let fromDate = new Date(bot.multiPeriodDailyProcessDatetime.valueOf()) + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME = new Date(contextVariables.lastFile.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) // Go back one day to start well when we advance time at the begining of the loop. + let fromDate = new Date(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf()) let lastDate = new Date() advanceTime() function advanceTime() { - bot.multiPeriodDailyProcessDatetime = new Date(bot.multiPeriodDailyProcessDatetime.valueOf() + TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) - previousDay = new Date(bot.multiPeriodDailyProcessDatetime.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME = new Date(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf() + TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + previousDay = new Date(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) - logger.write(MODULE_NAME, "[INFO] start -> processTimeFrames -> advanceTime -> bot.multiPeriodDailyProcessDatetime = " + bot.multiPeriodDailyProcessDatetime) + logger.write(MODULE_NAME, "[INFO] start -> processTimeFrames -> advanceTime -> TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME = " + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME) logger.write(MODULE_NAME, "[INFO] start -> processTimeFrames -> advanceTime -> previousDay = " + previousDay) /* Validation that we are not going past the head of the market. */ - if (bot.multiPeriodDailyProcessDatetime.valueOf() > contextVariables.dateEndOfMarket.valueOf()) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf() > contextVariables.dateEndOfMarket.valueOf()) { const logText = "Head of the market found @ " + previousDay.getUTCFullYear() + "/" + (previousDay.getUTCMonth() + 1) + "/" + previousDay.getUTCDate() + "."; logger.write(MODULE_NAME, "[INFO] start -> processTimeFrames -> advanceTime -> " + logText) @@ -239,8 +239,8 @@ } /* Telling the world we are alive and doing well */ - let currentDateString = bot.multiPeriodDailyProcessDatetime.getUTCFullYear() + '-' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCMonth() + 1, 2) + '-' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCDate(), 2) - let currentDate = new Date(bot.multiPeriodDailyProcessDatetime) + let currentDateString = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.getUTCFullYear() + '-' + utilities.pad(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.getUTCMonth() + 1, 2) + '-' + utilities.pad(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.getUTCDate(), 2) + let currentDate = new Date(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME) let percentage = TS.projects.superalgos.utilities.dateTimeFunctions.getPercentage(fromDate, currentDate, lastDate) TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, currentDateString, percentage) @@ -312,7 +312,7 @@ let previousFile let currentFile - if (bot.multiPeriodDailyProcessDatetime.valueOf() > contextVariables.dateBeginOfMarket.valueOf()) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.valueOf() > contextVariables.dateBeginOfMarket.valueOf()) { getPreviousFile() } else { previousFile = [] @@ -367,7 +367,7 @@ } function getCurrentFile() { - let dateForPath = bot.multiPeriodDailyProcessDatetime.getUTCFullYear() + '/' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCDate(), 2) + let dateForPath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.getUTCFullYear() + '/' + utilities.pad(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.getUTCMonth() + 1, 2) + '/' + utilities.pad(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME.getUTCDate(), 2) let filePath if (dependency.referenceParent.config.codeName === "Multi-Period-Daily") { filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath; @@ -425,7 +425,7 @@ dataFiles, timeFrame, timeFrameLabel, - bot.multiPeriodDailyProcessDatetime, + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME, interExecutionMemoryArray[n], onOutputGenerated) @@ -455,7 +455,7 @@ callBackFunction(err) return } - writeStatusReport(bot.multiPeriodDailyProcessDatetime, advanceTime) + writeStatusReport(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME, advanceTime) } } } @@ -468,7 +468,7 @@ function productLoopBody() { let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName; - writeDataRange(contextVariables.dateBeginOfMarket, bot.multiPeriodDailyProcessDatetime, productCodeName, controlLoop) + writeDataRange(contextVariables.dateBeginOfMarket, TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).DAILY_FILES_PROCESS_DATETIME, productCodeName, controlLoop) } function controlLoop() {