From f9c333a85c57d25cdc1d81dca5dddd1e710f4314 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 18 Mar 2018 16:35:25 +0100 Subject: [PATCH] global.processDatetime moved to bot object --- .vs/AACloud/v15/.suo | Bin 86016 -> 68608 bytes Assistant.js | 6 +++--- Context.js | 6 +++--- Datasource.js | 8 ++++---- Extraction Bot Main Loop.js | 2 +- Indicator Bot Main Loop.js | 2 +- Trading Bot Main Loop.js | 3 +-- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.vs/AACloud/v15/.suo b/.vs/AACloud/v15/.suo index 1cb2334681cecf89b31ace000e85430829885af1..58e375e057c7625a32b4ebdf5d2e20a30b90e3d2 100644 GIT binary patch delta 3620 zcmeH~e^6A{7035J9{U3pa1jAzm1P$c6>-I1h>$F>AS%Lw)ZdBV&lqFe%8JHP0pq0B z*c9GTH~vT@4`MQ@HOe!Z#%Q3})=5*1#WBWKg=x(gJ0)oZ+tkMG_b!hgn$F~(&h($& zozI+e&pr3Pd(XM|zPHu&fz>aIwJv5oUUZ*PzSa`j{-HSj!r3+JLmu$f7qB?83&FHGU49 zK_9Btx&J8WJAoNwf)Y>wEMO$i0`3PDS%Q4T%ZUPgSnstd=Jb6^T86Z5G(?V0gu2FkWYf8 zpcIsWWnej20agO;*9*CW>~(ItWXv`&eiQ`IdpGE`Zq%k&X^U}-@D!ta#;w9?Mio&7 zdcJx1X6bV^tir(DqWOPP{(DI=E9OCeW|GmP-Gj*fhfEZU4<*dlmj$@X5dzu0q9U5j zf?|no44`viOByWksEn{N1LJqxa?qDU^28QWwsAtR4Y@pk78EMGJ5-6b++m6^@&S{q zPCYh{|I+H~rg-eTm=tdzOKPIXucW>f@}w3T*aDdNx$ZZ2rCz2>XOaT{2J0c^>lmF- zw<3`lX!IDHeiLkbb5h9|N62AR-T-fMg7KvLGlz{DS~0 zo*%A+PYM;uvejnLEQWLG!yUGkh)W)_bZzx7n>`Ay*8I}#+{a3qU7$7^5d6htR!KG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QZ$eV2(2yO^GQc zAWfk{;!uCn;79X3z<7LaCo@LuO-NZ`XGa0= z`Exyi?BrO`wMW27PwYUa$H7ei~eJgPf1?XR;hZrUtdkb(B3 zAo0%XVw8AfQPXl}hpSDtWSiM+UAKqWQjPex)|zgF>XUA8pEiKLO)cy};)#aCA8A#h z{XMb$rqxK}{`r*w;(p*_LeD7?4(?m2eAC~iNWk)dtFw9L-^QjLT z{h{Vs44iJN)#wE$(;tJIzW!-@%HqrD)`Gv?#YYq62U2{aCBAh*YocFWNC~YODgBRA z2N&8+eXB%6-b0!LB{qHYD$i!TMPC&B_q1c4xnde4GD;(~H@_K9pcX&{GgafEd) lx*7D#4-T}wtp6r`W5!fT`_%ka;VO_6P4553_~QMB{{qg?tbPCh diff --git a/Assistant.js b/Assistant.js index 7d7081b63..1bb495387 100644 --- a/Assistant.js +++ b/Assistant.js @@ -63,7 +63,7 @@ any reason stops being updated. */ - if (candle.begin < global.processDatetime.valueOf() - 2 * 60 * 1000) { + if (candle.begin < bot.processDatetime.valueOf() - 2 * 60 * 1000) { logger.write("[ERROR] initialize -> Candles more than two minutes old. Retrying later."); callBack(global.DEFAULT_RETRY_RESPONSE); @@ -632,7 +632,7 @@ rate: pRate, amountA: pAmountA, amountB: pAmountB, - date: (global.processDatetime.valueOf()), + date: (bot.processDatetime.valueOf()), status: "open", trades: [] }; @@ -724,7 +724,7 @@ rate: pNewRate, amountA: pPosition.amountB * pNewRate, amountB: pPosition.amountB, - date: (global.processDatetime.valueOf()), + date: (bot.processDatetime.valueOf()), status: "open", trades: [] }; diff --git a/Context.js b/Context.js index c8eefe7a6..14b13d575 100644 --- a/Context.js +++ b/Context.js @@ -103,7 +103,7 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - thisObject.newHistoryRecord.date = global.processDatetime; + thisObject.newHistoryRecord.date = bot.processDatetime; getStatusReport(onDone); @@ -398,7 +398,7 @@ if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> Entering function."); } let fileName = "Execution.Context.json" - let dateForPath = global.processDatetime.getUTCFullYear() + '/' + utilities.pad(global.processDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(global.processDatetime.getUTCDate(), 2) + '/' + utilities.pad(global.processDatetime.getUTCHours(), 2) + '/' + utilities.pad(global.processDatetime.getUTCMinutes(), 2); + let dateForPath = bot.processDatetime.getUTCFullYear() + '/' + utilities.pad(bot.processDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.processDatetime.getUTCDate(), 2) + '/' + utilities.pad(bot.processDatetime.getUTCHours(), 2) + '/' + utilities.pad(bot.processDatetime.getUTCMinutes(), 2); let filePath = bot.filePathRoot + "/Output/" + bot.process + '/' + dateForPath; if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> fileName = " + fileName); } @@ -534,7 +534,7 @@ if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> Entering function."); } - statusReportModule.file.lastExecution = global.processDatetime; + statusReportModule.file.lastExecution = bot.processDatetime; statusReportModule.save(callBack); } diff --git a/Datasource.js b/Datasource.js index e602b5dfa..54c6993c7 100644 --- a/Datasource.js +++ b/Datasource.js @@ -178,7 +178,7 @@ let periodTime = global.dailyFilePeriods[i][0]; let periodName = global.dailyFilePeriods[i][1]; - getFile(oliviaAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", periodName, global.processDatetime, onFileReceived, callBack); + getFile(oliviaAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", periodName, bot.processDatetime, onFileReceived, callBack); function onFileReceived(err, file) { @@ -253,7 +253,7 @@ let timePeriod = candle.end - candle.begin + 1; // In miliseconds. (remember each candle spans a period minus one milisecond) - if (candle.begin >= global.processDatetime.valueOf() - timePeriod * 10 && candle.begin <= global.processDatetime.valueOf()) { + if (candle.begin >= bot.processDatetime.valueOf() - timePeriod * 10 && candle.begin <= bot.processDatetime.valueOf()) { candlesArray.push(candle); @@ -357,7 +357,7 @@ let periodTime = global.dailyFilePeriods[i][0]; let periodName = global.dailyFilePeriods[i][1]; - getFile(tomAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", periodName, global.processDatetime, onFileReceived, callBack); + getFile(tomAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", periodName, bot.processDatetime, onFileReceived, callBack); function onFileReceived(err, file) { @@ -436,7 +436,7 @@ stairs.lastMin = pStairsFile[i][10]; stairs.lastMax = pStairsFile[i][11]; - if (global.processDatetime.valueOf() >= stairs.begin && global.processDatetime.valueOf() <= stairs.end) { + if (bot.processDatetime.valueOf() >= stairs.begin && bot.processDatetime.valueOf() <= stairs.end) { thisObject.stairsMap.set(pPeriodName, stairs); diff --git a/Extraction Bot Main Loop.js b/Extraction Bot Main Loop.js index f6c2c15d1..8fce769a2 100644 --- a/Extraction Bot Main Loop.js +++ b/Extraction Bot Main Loop.js @@ -71,7 +71,7 @@ /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ - global.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. + bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ diff --git a/Indicator Bot Main Loop.js b/Indicator Bot Main Loop.js index 484fcd81d..09042037c 100644 --- a/Indicator Bot Main Loop.js +++ b/Indicator Bot Main Loop.js @@ -70,7 +70,7 @@ /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ - global.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. + bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ diff --git a/Trading Bot Main Loop.js b/Trading Bot Main Loop.js index acb803908..5404743f6 100644 --- a/Trading Bot Main Loop.js +++ b/Trading Bot Main Loop.js @@ -75,8 +75,7 @@ /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ - global.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. - global.processDatetime = new Date(global.processDatetime.valueOf() - 30 * 24 * 60 * 60 * 1000); // we go 30 days back in time since candles are currently not up to date. + bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */