diff --git a/Commons.js b/Commons.js index 2d335e8dd..86c24b94e 100644 --- a/Commons.js +++ b/Commons.js @@ -590,6 +590,11 @@ /* Main Simulation Loop: We go thourgh all the candles at this time period. */ let i + + /* For Loop Level heartbeat */ + let loopingDay + let previousLoopingDay + initializeLoop() function initializeLoop() { @@ -666,6 +671,17 @@ last: candle.close } + /* We will produce a simulation level heartbeat in order to inform the user this is running. */ + + loopingDay = new Date(Math.trunc(candle.begin / ONE_DAY_IN_MILISECONDS) * ONE_DAY_IN_MILISECONDS) + if (loopingDay.valueOf() !== previousLoopingDay) { + if (FULL_LOG === true) {logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Simulation Loop # " + i + " @ " + (loopingDay.toLocaleString()))} + console.log("Jason -> " + MODULE_NAME + " -> runSimulation -> loop -> Simulation Loop # " + i + " @ " + (loopingDay.toLocaleString())) + + bot.hearBeat() // tell the world we are alive and doing well + } + previousLoopingDay = loopingDay.valueOf() + /* If any of the needed indicators is missing, then that period is not calculated */ if (candle.end < initialDate.valueOf()) { @@ -2708,9 +2724,19 @@ function controlLoop() { if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> controlLoop -> Entering function."); } + + /* Checking if we should continue processing this loop or not.*/ + if (global.STOP_PROCESSING === true) { + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> controlLoop -> We are going to stop here bacause we were requested to stop processing."); } + console.log("[INFO] runSimulation -> controlLoop -> We are going to stop here bacause we were requested to stop processing.") + afterLoop() + return + } + i++ if (i < candles.length) { - process.nextTick(loop) + // process.nextTick(loop) + setTimeout(loop, 100) } else { afterLoop() } diff --git a/Multi-Period/User.Bot.js b/Multi-Period/User.Bot.js index 7e8d47bfb..7d818ef4e 100644 --- a/Multi-Period/User.Bot.js +++ b/Multi-Period/User.Bot.js @@ -481,6 +481,9 @@ } + /* Emit event that signals that simulation files were updated */ + global.SYSTEM_EVENT_HANDLER.raiseEvent('Jason-Multi-Period', 'Simulation Files Updated') + callBackFunction(global.DEFAULT_OK_RESPONSE); } @@ -956,6 +959,9 @@ } + /* Emit event that signals that simulation files were updated */ + global.SYSTEM_EVENT_HANDLER.raiseEvent('Jason-Multi-Period', 'Simulation Files Updated') + callBackFunction(global.DEFAULT_OK_RESPONSE); } diff --git a/this.bot.config.json b/this.bot.config.json index 48109984a..68d242ab3 100644 --- a/this.bot.config.json +++ b/this.bot.config.json @@ -40,7 +40,7 @@ "01-min" ], "startDate": { - "fixedDate": "2018-07-01" + "takeItFromStatusDependency": 2 }, "endDate": { "takeItFromStatusDependency": 1