Downloading Data Improved
This commit is contained in:
1 parent
90b368c56e
commit
bf4edec2e0
79 files changed
+394
-259
No files matched your search
@@ -56,11 +56,12 @@
|
||||
|
||||
let market = bot.market;
|
||||
|
||||
let lastTradeFileAvailable; // Datetime of the last file certified by the Hole Fixing process as without permanent holes.
|
||||
let lastTradeFileProcessed; // Datetime of the last file certified by the Hole Fixing process as without permanent holes.
|
||||
let firstTradeFile; // Datetime of the first trade file in the whole market history.
|
||||
let lastTradeFileSaved; // Datetime of the last verified file without holes.
|
||||
let lastCandleClose; // Value of the last candle close.
|
||||
let lastTradeFile; // Datetime pointing to the last Trade File sucessfuly processed and included in the last file.
|
||||
let beginingOfMarket
|
||||
|
||||
getContextVariables();
|
||||
|
||||
@@ -114,25 +115,39 @@
|
||||
|
||||
thisReport = statusDependencies.statusReports.get(reportKey).file;
|
||||
|
||||
if (thisReport.lastFile === undefined) {
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Undefined Last File. -> reportKey = " + reportKey);
|
||||
logger.write(MODULE_NAME, "[HINT] start -> getContextVariables -> If the status report does not exist we will point the lasCandleFile to the last day of the previous month.");
|
||||
if (thisReport.lastFile === undefined) { // Means this is the first time ever this process runs.
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running for the very first time. -> reportKey = " + reportKey);
|
||||
|
||||
lastTradeFileAvailable = new Date(processDate.valueOf() - ONE_DAY_IN_MILISECONDS);
|
||||
findLastCandleCloseValue();
|
||||
return;
|
||||
}
|
||||
lastCandleClose = 0;
|
||||
lastTradeFileProcessed = new Date(firstTradeFile.valueOf() - ONE_DAY_IN_MILISECONDS)
|
||||
beginingOfMarket = new Date(firstTradeFile.valueOf())
|
||||
|
||||
lastTradeFileAvailable = new Date(thisReport.lastTradeFile.year + "-" + thisReport.lastTradeFile.month + "-" + thisReport.lastTradeFile.days + " " + "00:00" + GMT_SECONDS);
|
||||
lastCandleClose = thisReport.candleClose;
|
||||
|
||||
if (thisReport.fileComplete === true) {
|
||||
buildCandlesAndVolumes();
|
||||
|
||||
} else {
|
||||
lastTradeFile = new Date(thisReport.lastTradeFile.year + "-" + thisReport.lastTradeFile.month + "-" + thisReport.lastTradeFile.days + " " + thisReport.lastTradeFile.hours + ":" + thisReport.lastTradeFile.minutes + GMT_SECONDS);
|
||||
findPreviousContent();
|
||||
}
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running not for the very first time. -> reportKey = " + reportKey);
|
||||
|
||||
lastTradeFileProcessed = new Date(thisReport.lastTradeFile.year + "-" + thisReport.lastTradeFile.month + "-" + thisReport.lastTradeFile.days + " " + "00:00" + GMT_SECONDS);
|
||||
lastCandleClose = thisReport.candleClose;
|
||||
beginingOfMarket = new Date(thisReport.beginingOfMarket.year + "-" + thisReport.beginingOfMarket.month + "-" + thisReport.beginingOfMarket.days + " " + thisReport.beginingOfMarket.hours + ":" + thisReport.beginingOfMarket.minutes + GMT_SECONDS);
|
||||
|
||||
if (beginingOfMarket.valueOf() !== firstTradeFile.valueOf()) { // Reset Mechanism for Begining of the Market
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(firstTradeFile.valueOf())
|
||||
lastTradeFileProcessed = new Date(firstTradeFile.valueOf() - ONE_DAY_IN_MILISECONDS)
|
||||
lastCandleClose = 0
|
||||
buildCandlesAndVolumes()
|
||||
return
|
||||
}
|
||||
|
||||
if (thisReport.fileComplete === true) {
|
||||
buildCandlesAndVolumes();
|
||||
} else {
|
||||
lastTradeFile = new Date(thisReport.lastTradeFile.year + "-" + thisReport.lastTradeFile.month + "-" + thisReport.lastTradeFile.days + " " + thisReport.lastTradeFile.hours + ":" + thisReport.lastTradeFile.minutes + GMT_SECONDS);
|
||||
findPreviousContent();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> err = " + err.stack);
|
||||
if (err.message === "Cannot read property 'file' of undefined") {
|
||||
@@ -161,7 +176,7 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> getCandles -> Entering function."); }
|
||||
|
||||
let fileName = '' + market.baseAsset + '_' + market.quotedAsset + '.json';
|
||||
let dateForPath = lastTradeFileAvailable.getUTCFullYear() + '/' + utilities.pad(lastTradeFileAvailable.getUTCMonth() + 1, 2) + '/' + utilities.pad(lastTradeFileAvailable.getUTCDate(), 2);
|
||||
let dateForPath = lastTradeFileProcessed.getUTCFullYear() + '/' + utilities.pad(lastTradeFileProcessed.getUTCMonth() + 1, 2) + '/' + utilities.pad(lastTradeFileProcessed.getUTCDate(), 2);
|
||||
let filePath = bot.filePathRoot + "/Output/" + CANDLES_FOLDER_NAME + '/' + CANDLES_ONE_MIN + '/' + dateForPath;
|
||||
filePath += '/' + fileName
|
||||
|
||||
@@ -212,7 +227,7 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> getVolumes -> Entering function."); }
|
||||
|
||||
let fileName = '' + market.baseAsset + '_' + market.quotedAsset + '.json';
|
||||
let dateForPath = lastTradeFileAvailable.getUTCFullYear() + '/' + utilities.pad(lastTradeFileAvailable.getUTCMonth() + 1, 2) + '/' + utilities.pad(lastTradeFileAvailable.getUTCDate(), 2);
|
||||
let dateForPath = lastTradeFileProcessed.getUTCFullYear() + '/' + utilities.pad(lastTradeFileProcessed.getUTCMonth() + 1, 2) + '/' + utilities.pad(lastTradeFileProcessed.getUTCDate(), 2);
|
||||
let filePath = bot.filePathRoot + "/Output/" + VOLUMES_FOLDER_NAME + '/' + VOLUMES_ONE_MIN + '/' + dateForPath;
|
||||
filePath += '/' + fileName
|
||||
|
||||
@@ -241,7 +256,7 @@
|
||||
|
||||
volumesFile = JSON.parse(text);
|
||||
previousVolumes = volumesFile;
|
||||
lastTradeFileAvailable = new Date(lastTradeFileAvailable.valueOf() - ONE_DAY_IN_MILISECONDS); // We know that after the next call a new day will be added.
|
||||
lastTradeFileProcessed = new Date(lastTradeFileProcessed.valueOf() - ONE_DAY_IN_MILISECONDS); // We know that after the next call a new day will be added.
|
||||
buildCandlesAndVolumes(previousCandles, previousVolumes);
|
||||
|
||||
} catch (err) {
|
||||
@@ -266,131 +281,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function findLastCandleCloseValue() {
|
||||
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> Entering function."); }
|
||||
|
||||
/*
|
||||
We will search and find for the last trade before the begining of the current candle and that will give us the last close value.
|
||||
Before going backwards, we need to be sure we are not at the begining of the market.
|
||||
*/
|
||||
|
||||
if ((Number((new Date()).getUTCFullYear()) === firstTradeFile.getUTCFullYear() && parseInt(((new Date()).getUTCMonth() + 1)) === firstTradeFile.getUTCMonth() + 1)) {
|
||||
|
||||
/*
|
||||
We are at the begining of the market, so we will set everyting to build the first candle.
|
||||
*/
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> Begining of the market detected."); }
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> Entering market = " + JSON.stringify(market)); }
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> lastCandleClose = " + lastCandleClose); }
|
||||
|
||||
lastTradeFileAvailable = new Date(firstTradeFile.getUTCFullYear() + "-" + (firstTradeFile.getUTCMonth() + 1) + "-" + firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
lastTradeFileAvailable = new Date(lastTradeFileAvailable.valueOf() - ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
lastCandleClose = 0;
|
||||
buildCandlesAndVolumes();
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
We are not at the begining of the market, so we need scan backwards the trade files until we find a non empty one and get the last trade.
|
||||
*/
|
||||
|
||||
let date = new Date(processDate.valueOf());
|
||||
|
||||
loopStart();
|
||||
|
||||
function loopStart() {
|
||||
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> loopStart -> Entering function."); }
|
||||
|
||||
date = new Date(date.valueOf() - 60 * 1000);
|
||||
|
||||
let dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2);
|
||||
let fileName = market.baseAsset + '_' + market.quotedAsset + ".json"
|
||||
let filePathRoot = bot.dataMine + "/" + "AACharly" + "/" + bot.exchange;
|
||||
let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
|
||||
filePath += '/' + fileName
|
||||
|
||||
fileStorage.getTextFile(filePath, onFileReceived);
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> findPreviousContent -> loopStart -> reading file at dateForPath = " + dateForPath);
|
||||
|
||||
function onFileReceived(err, text) {
|
||||
|
||||
let tradesFile;
|
||||
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> Entering function."); }
|
||||
|
||||
/*
|
||||
There is a situation at the end of each month where the process might have been started at the new month before dependent processes have
|
||||
created the expected file. For those cases we will retry instead of just aborting the process.
|
||||
*/
|
||||
if (err.result === global.CUSTOM_FAIL_RESPONSE.result && err.message === 'File does not exist.') {
|
||||
logger.write(MODULE_NAME, "[WARN] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> err received = " + err.stack);
|
||||
logger.write(MODULE_NAME, "[WARN] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> text received = " + text);
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> err received = " + err.stack);
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> text received = " + text);
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOG_FILE_CONTENT === true) {
|
||||
logger.write(MODULE_NAME, "[INFO] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> text = " + text);
|
||||
}
|
||||
|
||||
tradesFile = JSON.parse(text);
|
||||
|
||||
if (tradesFile.length > 0) {
|
||||
|
||||
lastCandleClose = tradesFile[tradesFile.length - 1][2]; // Position 2 is the rate at which the trade was executed.
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> Trades found at " + filePath + " for market " + market.baseAsset + '_' + market.quotedAsset + ".");
|
||||
logger.write(MODULE_NAME, "[INFO] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> lastCandleClose = " + lastCandleClose);
|
||||
|
||||
buildCandlesAndVolumes();
|
||||
|
||||
} else {
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> NO Trades found at " + filePath + " for market " + market.baseAsset + '_' + market.quotedAsset + ".");
|
||||
|
||||
loopStart();
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> err = " + err.stack);
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> filePath = " + filePath);
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> text = " + text);
|
||||
logger.write(MODULE_NAME, "[HINT] start -> findLastCandleCloseValue -> loopStart -> onFileReceived -> Empty or corrupt volume file found.");
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> loopStart -> err = " + err.stack);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findLastCandleCloseValue -> err = " + err.stack);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function buildCandlesAndVolumes(previousCandles, previousVolumes) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandlesAndVolumes -> Entering function."); }
|
||||
@@ -412,9 +302,9 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> buildCandlesAndVolumes -> nextFile -> Entering function."); }
|
||||
|
||||
lastTradeFileAvailable = new Date(lastTradeFileAvailable.valueOf() + ONE_DAY_IN_MILISECONDS);
|
||||
lastTradeFileProcessed = new Date(lastTradeFileProcessed.valueOf() + ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
let date = new Date(lastTradeFileAvailable.valueOf() - 60 * 1000);
|
||||
let date = new Date(lastTradeFileProcessed.valueOf() - 60 * 1000);
|
||||
|
||||
if (date.valueOf() < firstTradeFile.valueOf()) { // At the special case where we are at the begining of the market, this might be true.
|
||||
date = new Date(firstTradeFile.valueOf() - 60 * 1000);
|
||||
@@ -481,9 +371,9 @@
|
||||
|
||||
/* Check if we are outside the current Day / File */
|
||||
|
||||
if (date.getUTCDate() !== lastTradeFileAvailable.getUTCDate()) {
|
||||
if (date.getUTCDate() !== lastTradeFileProcessed.getUTCDate()) {
|
||||
|
||||
writeFiles(lastTradeFileAvailable, candles, volumes, true, onFilesWritten);
|
||||
writeFiles(lastTradeFileProcessed, candles, volumes, true, onFilesWritten);
|
||||
|
||||
return;
|
||||
|
||||
@@ -497,7 +387,7 @@
|
||||
|
||||
if (date.valueOf() > lastTradeFileSaved.valueOf()) {
|
||||
|
||||
writeFiles(lastTradeFileAvailable, candles, volumes, false, onFilesWritten);
|
||||
writeFiles(lastTradeFileProcessed, candles, volumes, false, onFilesWritten);
|
||||
return;
|
||||
|
||||
function onFilesWritten() {
|
||||
@@ -881,6 +771,13 @@
|
||||
hours: lastTradeFile.getUTCHours(),
|
||||
minutes: lastTradeFile.getUTCMinutes()
|
||||
},
|
||||
beginingOfMarket: {
|
||||
year: beginingOfMarket.getUTCFullYear(),
|
||||
month: (beginingOfMarket.getUTCMonth() + 1),
|
||||
days: beginingOfMarket.getUTCDate(),
|
||||
hours: beginingOfMarket.getUTCHours(),
|
||||
minutes: beginingOfMarket.getUTCMinutes()
|
||||
},
|
||||
candleClose: candleClose,
|
||||
fileComplete: isFileComplete
|
||||
};
|
||||
|
||||
@@ -33,6 +33,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
|
||||
let lastId
|
||||
let firstId
|
||||
let exchange
|
||||
let uiStartDate = new Date(bot.uiStartDate)
|
||||
|
||||
const limit = 1000
|
||||
|
||||
@@ -110,8 +111,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
|
||||
async function begin() {
|
||||
|
||||
getContextVariables()
|
||||
defineSince()
|
||||
|
||||
|
||||
await getFirstId()
|
||||
await getTrades()
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
@@ -144,6 +144,25 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
|
||||
} else { // This means this is the first time this process run.
|
||||
beginingOfMarket = new Date()
|
||||
}
|
||||
|
||||
defineSince()
|
||||
function defineSince() {
|
||||
if (thisReport.file.uiStartDate === undefined) {
|
||||
thisReport.file.uiStartDate = uiStartDate
|
||||
} else {
|
||||
thisReport.file.uiStartDate = new Date(thisReport.file.uiStartDate)
|
||||
}
|
||||
|
||||
if (uiStartDate.valueOf() !== thisReport.file.uiStartDate.valueOf()) {
|
||||
since = uiStartDate.valueOf()
|
||||
initialProcessTimestamp = since
|
||||
beginingOfMarket = new Date(uiStartDate.valueOf())
|
||||
} else {
|
||||
since = lastFileSaved.valueOf()
|
||||
initialProcessTimestamp = lastFileSaved.valueOf()
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> getContextVariables -> err = " + err.stack);
|
||||
if (err.message === "Cannot read property 'file' of undefined") {
|
||||
@@ -154,20 +173,6 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
|
||||
}
|
||||
}
|
||||
|
||||
function defineSince() {
|
||||
|
||||
let uiStartDate = new Date(bot.uiStartDate)
|
||||
|
||||
if (uiStartDate.valueOf() < beginingOfMarket.valueOf()) {
|
||||
since = (new Date(bot.uiStartDate)).valueOf()
|
||||
initialProcessTimestamp = since
|
||||
beginingOfMarket = new Date(uiStartDate.valueOf())
|
||||
} else {
|
||||
since = lastFileSaved.valueOf()
|
||||
initialProcessTimestamp = lastFileSaved.valueOf()
|
||||
}
|
||||
}
|
||||
|
||||
async function getFirstId() {
|
||||
try {
|
||||
/* We need the first id only when we are going to fetch trades based on id and it is the first time the process runs*/
|
||||
@@ -367,6 +372,16 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
|
||||
}
|
||||
function createMissingEmptyFiles(begin, end) {
|
||||
|
||||
/*
|
||||
If this range is too wide, we will consider this means that the begin is before the begining of this market at this exchange.
|
||||
In that case we will change the begin and the beginingOfMarket
|
||||
*/
|
||||
|
||||
if ((end - begin) / 60 / 24 > 7) {
|
||||
begin = end
|
||||
beginingOfMarket = new Date(end * ONE_MINUTE)
|
||||
}
|
||||
|
||||
for (let j = begin + 1; j < end; j++) {
|
||||
let fileName = bot.market.baseAsset + '_' + bot.market.quotedAsset + '.json'
|
||||
filesToCreate++
|
||||
@@ -436,7 +451,8 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
|
||||
days: beginingOfMarket.getUTCDate(),
|
||||
hours: beginingOfMarket.getUTCHours(),
|
||||
minutes: beginingOfMarket.getUTCMinutes()
|
||||
}
|
||||
},
|
||||
uiStartDate: uiStartDate.toUTCString()
|
||||
};
|
||||
|
||||
if (fetchType === "by Id") {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
let utilities = UTILITIES.newCloudUtilities(bot, logger);
|
||||
|
||||
let statusDependencies;
|
||||
let beginingOfMarket
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -178,6 +179,19 @@
|
||||
|
||||
if (thisReport.lastFile !== undefined) {
|
||||
|
||||
beginingOfMarket = new Date(thisReport.beginingOfMarket);
|
||||
|
||||
if (beginingOfMarket.valueOf() !== contextVariables.firstTradeFile.valueOf()) { // Reset Mechanism for Begining of the Market
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastBandFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastBandFile = new Date(contextVariables.lastBandFile.valueOf() + ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
buildBands();
|
||||
return;
|
||||
}
|
||||
|
||||
contextVariables.lastBandFile = new Date(thisReport.lastFile);
|
||||
|
||||
/*
|
||||
@@ -205,6 +219,8 @@
|
||||
contextVariables.lastBandFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastBandFile = new Date(contextVariables.lastBandFile.valueOf() + ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.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.lastBandFile = " + contextVariables.lastBandFile); }
|
||||
|
||||
@@ -852,6 +868,7 @@
|
||||
|
||||
thisReport.file.lastExecution = bot.processDatetime;
|
||||
thisReport.file.lastFile = lastFileDate;
|
||||
thisReport.file.beginingOfMarket = beginingOfMarket.toUTCString()
|
||||
thisReport.save(callBack);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
let utilities = UTILITIES.newCloudUtilities(bot, logger);
|
||||
|
||||
let statusDependencies;
|
||||
let beginingOfMarket
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -176,6 +177,20 @@ Read the candles and volumes from Bruce and produce a file for each day and for
|
||||
thisReport = statusDependencies.statusReports.get(reportKey).file;
|
||||
|
||||
if (thisReport.lastFile !== undefined) {
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running not for the very first time. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(thisReport.beginingOfMarket);
|
||||
|
||||
if (beginingOfMarket.valueOf() !== contextVariables.firstTradeFile.valueOf()) { // Reset Mechanism for Begining of the Market
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well.
|
||||
|
||||
buildCandles();
|
||||
return;
|
||||
}
|
||||
|
||||
contextVariables.lastCandleFile = new Date(thisReport.lastFile);
|
||||
|
||||
@@ -190,7 +205,9 @@ Read the candles and volumes from Bruce and produce a file for each day and for
|
||||
return;
|
||||
|
||||
} else {
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running for the very first time. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well.
|
||||
|
||||
@@ -756,6 +773,7 @@ Read the candles and volumes from Bruce and produce a file for each day and for
|
||||
|
||||
thisReport.file.lastExecution = bot.processDatetime;
|
||||
thisReport.file.lastFile = lastFileDate;
|
||||
thisReport.file.beginingOfMarket = beginingOfMarket.toUTCString()
|
||||
thisReport.save(callBack);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
let utilities = UTILITIES.newCloudUtilities(bot, logger);
|
||||
|
||||
let statusDependencies;
|
||||
let beginingOfMarket
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -185,6 +186,20 @@
|
||||
thisReport = statusDependencies.statusReports.get(reportKey).file;
|
||||
|
||||
if (thisReport.lastFile !== undefined) {
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running not for the very first time. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(thisReport.beginingOfMarket);
|
||||
|
||||
if (beginingOfMarket.valueOf() !== contextVariables.firstTradeFile.valueOf()) { // Reset Mechanism for Begining of the Market
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well.
|
||||
|
||||
buildCandles();
|
||||
return;
|
||||
}
|
||||
|
||||
contextVariables.lastCandleFile = new Date(thisReport.lastFile);
|
||||
|
||||
@@ -199,7 +214,9 @@
|
||||
return;
|
||||
|
||||
} else {
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Process Running for the very first time. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well.
|
||||
|
||||
@@ -874,6 +891,7 @@
|
||||
|
||||
thisReport.file.lastExecution = bot.processDatetime;
|
||||
thisReport.file.lastFile = lastFileDate;
|
||||
thisReport.file.beginingOfMarket = beginingOfMarket.toUTCString()
|
||||
thisReport.save(callBack);
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
let utilities = UTILITIES.newCloudUtilities(bot, logger);
|
||||
|
||||
let statusDependencies;
|
||||
let beginingOfMarket
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -185,6 +186,19 @@
|
||||
|
||||
if (thisReport.lastFile !== undefined) {
|
||||
|
||||
beginingOfMarket = new Date(thisReport.beginingOfMarket);
|
||||
|
||||
if (beginingOfMarket.valueOf() !== contextVariables.firstTradeFile.valueOf()) { // Reset Mechanism for Begining of the Market
|
||||
logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Reset Mechanism for Begining of the Market Activated. -> reportKey = " + reportKey);
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() + ONE_DAY_IN_MILISECONDS)
|
||||
|
||||
buildStairs();
|
||||
return;
|
||||
}
|
||||
|
||||
contextVariables.lastCandleFile = new Date(thisReport.lastFile);
|
||||
|
||||
/*
|
||||
@@ -213,6 +227,8 @@
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
contextVariables.lastCandleFile = new Date(contextVariables.lastCandleFile.valueOf() + ONE_DAY_IN_MILISECONDS)
|
||||
|
||||
beginingOfMarket = new Date(contextVariables.firstTradeFile.getUTCFullYear() + "-" + (contextVariables.firstTradeFile.getUTCMonth() + 1) + "-" + contextVariables.firstTradeFile.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.lastCandleFile = " + contextVariables.lastCandleFile); }
|
||||
|
||||
@@ -1606,6 +1622,7 @@
|
||||
|
||||
thisReport.file.lastExecution = bot.processDatetime;
|
||||
thisReport.file.lastFile = lastFileDate;
|
||||
thisReport.file.beginingOfMarket = beginingOfMarket.toUTCString()
|
||||
thisReport.save(callBack);
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user