Dates in process heartbeat

This commit is contained in:
Luis Fernando Molina committed 2019-10-05 14:51:46 +02:00
1 parent 606b183257
commit b945ecdfbb
6 files changed
+37 -23

No files matched your search

+6 -4
View File
@@ -119,7 +119,8 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Entering function."); }
/* Loop Heartbeat sent to the UI */
processHearBeat()
bot.processHeartBeat = processHeartBeat
processHeartBeat()
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
@@ -801,7 +802,7 @@
/* We show we reached the end of the loop. */
processHearBeat()
processHeartBeat()
/* Here we check if we must stop the loop gracefully. */
@@ -929,9 +930,10 @@
}
}
function processHearBeat() {
function processHeartBeat(processingDate) {
let event = {
seconds: (new Date()).getSeconds()
seconds: (new Date()).getSeconds(),
processingDate: processingDate
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event)
}
+4
View File
@@ -542,6 +542,10 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriodsDailyFiles -> periodsLoop -> Entering function."); }
/* Telling the world we are alive and doing well */
let processingDate = bot.multiPeriodDailyProcessDatetime.getUTCFullYear() + '-' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCMonth() + 1, 2) + '-' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCDate(), 2);
bot.processHeartBeat(processingDate)
/*
We will iterate through all posible periods.
+15 -11
View File
@@ -306,7 +306,7 @@
let n;
let botNeverRan = true;
bot.multiPeriodDailyProcessDatetime = new Date(contextVariables.lastFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well when we advance time at the begining of the loop.
bot.multiPeriodProcessDatetime = new Date(contextVariables.lastFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well when we advance time at the begining of the loop.
advanceTime();
@@ -316,21 +316,21 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> advanceTime -> Entering function."); }
bot.multiPeriodDailyProcessDatetime = new Date(bot.multiPeriodDailyProcessDatetime.valueOf() + ONE_DAY_IN_MILISECONDS);
previousDay = new Date(bot.multiPeriodDailyProcessDatetime.valueOf() - ONE_DAY_IN_MILISECONDS);
bot.multiPeriodProcessDatetime = new Date(bot.multiPeriodProcessDatetime.valueOf() + ONE_DAY_IN_MILISECONDS);
previousDay = new Date(bot.multiPeriodProcessDatetime.valueOf() - ONE_DAY_IN_MILISECONDS);
console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " " + "bot.multiPeriodDailyProcessDatetime = " + bot.multiPeriodDailyProcessDatetime.toISOString());
console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " " + "bot.multiPeriodProcessDatetime = " + bot.multiPeriodProcessDatetime.toISOString());
if (global.WRITE_LOGS_TO_FILES === 'true') {
logger.newInternalLoop(bot.codeName, bot.process);
}
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> advanceTime -> bot.multiPeriodDailyProcessDatetime = " + bot.multiPeriodDailyProcessDatetime); }
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> advanceTime -> bot.multiPeriodProcessDatetime = " + bot.multiPeriodProcessDatetime); }
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> advanceTime -> previousDay = " + previousDay); }
/* Validation that we are not going past the head of the market. */
if (bot.multiPeriodDailyProcessDatetime.valueOf() > contextVariables.dateEndOfMarket.valueOf()) {
if (bot.multiPeriodProcessDatetime.valueOf() > contextVariables.dateEndOfMarket.valueOf()) {
const logText = "Head of the market found @ " + previousDay.getUTCFullYear() + "/" + (previousDay.getUTCMonth() + 1) + "/" + previousDay.getUTCDate() + ".";
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> advanceTime -> " + logText); }
@@ -354,6 +354,10 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> periodsLoop -> Entering function."); }
/* Telling the world we are alive and doing well */
let processingDate = bot.multiPeriodProcessDatetime.getUTCFullYear() + '-' + utilities.pad(bot.multiPeriodProcessDatetime.getUTCMonth() + 1, 2) + '-' + utilities.pad(bot.multiPeriodProcessDatetime.getUTCDate(), 2);
bot.processHeartBeat(processingDate)
/*
We will iterate through all posible periods.
@@ -410,7 +414,7 @@
let previousFile;
let currentFile;
if (bot.multiPeriodDailyProcessDatetime.valueOf() > contextVariables.dateBeginOfMarket.valueOf()) {
if (bot.multiPeriodProcessDatetime.valueOf() > contextVariables.dateBeginOfMarket.valueOf()) {
getPreviousFile();
} else {
previousFile = [];
@@ -493,7 +497,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> Entering function."); }
let dateForPath = bot.multiPeriodDailyProcessDatetime.getUTCFullYear() + '/' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCDate(), 2);
let dateForPath = bot.multiPeriodProcessDatetime.getUTCFullYear() + '/' + utilities.pad(bot.multiPeriodProcessDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.multiPeriodProcessDatetime.getUTCDate(), 2);
let filePath
if (dependency.dataSet === "Multi-Period-Daily") {
filePath = dependency.product + '/' + dependency.dataSet + "/" + outputPeriodLabel + "/" + dateForPath;
@@ -600,7 +604,7 @@
dataFiles,
timePeriod,
outputPeriodLabel,
bot.multiPeriodDailyProcessDatetime,
bot.multiPeriodProcessDatetime,
contextVariables.dateBeginOfMarket,
contextVariables.dateEndOfMarket,
interExecutionMemoryArray[n],
@@ -669,7 +673,7 @@
return;
}
writeStatusReport(bot.multiPeriodDailyProcessDatetime, advanceTime);
writeStatusReport(bot.multiPeriodProcessDatetime, advanceTime);
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> controlLoop -> onWritten -> err = "+ err.stack);
@@ -704,7 +708,7 @@
let folderName = bot.products[productIndex].codeName;
writeDataRange(contextVariables.dateBeginOfMarket, bot.multiPeriodDailyProcessDatetime, folderName, controlLoop);
writeDataRange(contextVariables.dateBeginOfMarket, bot.multiPeriodProcessDatetime, folderName, controlLoop);
}
function controlLoop() {
+6 -4
View File
@@ -121,7 +121,8 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Entering function."); }
/* Loop Heartbeat sent to the UI */
processHearBeat()
bot.processHeartBeat = processHeartBeat
processHeartBeat()
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
@@ -547,7 +548,7 @@
/* We show we reached the end of the loop. */
processHearBeat()
processHeartBeat()
/* Here we check if we must stop the loop gracefully. */
@@ -701,9 +702,10 @@
}
}
function processHearBeat() {
function processHeartBeat(processingDate) {
let event = {
seconds: (new Date()).getSeconds()
seconds: (new Date()).getSeconds(),
processingDate: processingDate
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event)
}
+2 -2
View File
@@ -61,7 +61,7 @@
bot.startMode = "Backtest"
bot.resumeExecution = false;
bot.hasTheBotJustStarted = true
bot.multiPeriodDailyProcessDatetime = bot.VALUES_TO_USE.timeRange.initialDatetime
bot.multiPeriodProcessDatetime = bot.VALUES_TO_USE.timeRange.initialDatetime
}
function startLiveTrading(message) {
@@ -93,7 +93,7 @@
bot.VALUES_TO_USE.timeRange.initialDatetime = new Date()
}
bot.resumeExecution = false;
bot.multiPeriodDailyProcessDatetime = bot.VALUES_TO_USE.timeRange.initialDatetime
bot.multiPeriodProcessDatetime = bot.VALUES_TO_USE.timeRange.initialDatetime
bot.hasTheBotJustStarted = true
}
+4 -2
View File
@@ -127,6 +127,7 @@
/* Heartbeats sent to the UI */
bot.sessionHeartBeat = sessionHeartBeat
bot.processHeartBeat = processHeartBeat
processHeartBeat()
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
@@ -1053,9 +1054,10 @@
}
}
function processHeartBeat() {
function processHeartBeat(processingDate) {
let event = {
seconds: (new Date()).getSeconds()
seconds: (new Date()).getSeconds(),
processingDate: processingDate
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event)
}