From e51a74befce7c76ba75b91bec57e047b985350f3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 19 Mar 2020 22:16:58 +0100 Subject: [PATCH] percentage implemented --- Multi-Period-Daily/User.bot.js | 12 ++++++++++-- Multi-Period-Market/User.bot.js | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Multi-Period-Daily/User.bot.js b/Multi-Period-Daily/User.bot.js index 92edb34fa..716521695 100644 --- a/Multi-Period-Daily/User.bot.js +++ b/Multi-Period-Daily/User.bot.js @@ -229,7 +229,8 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each function buildCandles() { try { - + let fromDate = new Date(contextVariables.lastCandleFile.valueOf()) + let lastDate = new Date() if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> Entering function."); } let outputCandles; @@ -255,6 +256,11 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each return; } + /* Telling the world we are alive and doing well */ + let currentDateString = contextVariables.lastCandleFile.getUTCFullYear() + '-' + utilities.pad(contextVariables.lastCandleFile.getUTCMonth() + 1, 2) + '-' + utilities.pad(contextVariables.lastCandleFile.getUTCDate(), 2); + let currentDate = new Date(contextVariables.lastCandleFile) + bot.processHeartBeat(currentDateString, global.getPercentage(fromDate, currentDate, lastDate)) + /* We prepere the arrays that will accumulate all the information for each output file. @@ -784,7 +790,9 @@ Read the candles and volumes from Exchange Raw Data and produce a file for each thisReport.file.beginingOfMarket = beginingOfMarket.toUTCString() thisReport.save(callBack); - logger.newInternalLoop(bot.codeName, bot.process, lastFileDate); + if (global.areEqualDates(lastFileDate, new Date()) === false) { + logger.newInternalLoop(bot.codeName, bot.process, lastFileDate); + } } catch (err) { logger.write(MODULE_NAME, "[ERROR] start -> writeStatusReport -> err = " + err.stack); diff --git a/Multi-Period-Market/User.bot.js b/Multi-Period-Market/User.bot.js index 71e16bd6c..a0e16255b 100644 --- a/Multi-Period-Market/User.bot.js +++ b/Multi-Period-Market/User.bot.js @@ -378,6 +378,9 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> Entering function."); } + let fromDate = new Date(contextVariables.lastCandleFile.valueOf()) + let lastDate = new Date() + /* Firstly we prepere the arrays that will accumulate all the information for each output file. */ @@ -404,9 +407,7 @@ contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() + ONE_DAY_IN_MILISECONDS); if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandles -> advanceTime -> New processing time @ " + contextVariables.lastCandleFile.getUTCFullYear() + "/" + (contextVariables.lastCandleFile.getUTCMonth() + 1) + "/" + contextVariables.lastCandleFile.getUTCDate() + "."); } - - logger.newInternalLoop(bot.codeName, bot.process, contextVariables.lastCandleFile); - + /* Validation that we are not going past the head of the market. */ if (contextVariables.lastCandleFile.valueOf() > contextVariables.maxCandleFile.valueOf()) { @@ -417,6 +418,15 @@ return; } + if (global.areEqualDates(contextVariables.lastCandleFile, new Date()) === false) { + logger.newInternalLoop(bot.codeName, bot.process, contextVariables.lastCandleFile); + } + + /* Telling the world we are alive and doing well */ + let currentDateString = contextVariables.lastCandleFile.getUTCFullYear() + '-' + utilities.pad(contextVariables.lastCandleFile.getUTCMonth() + 1, 2) + '-' + utilities.pad(contextVariables.lastCandleFile.getUTCDate(), 2); + let currentDate = new Date(contextVariables.lastCandleFile) + bot.processHeartBeat(currentDateString, global.getPercentage(fromDate, currentDate, lastDate)) + periodsLoop(); }