From f7eeb387401964582efffc36539000a20f182fa6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 14 Mar 2018 10:08:44 +0100 Subject: [PATCH] Entering Function Logs all set at Multi Period Market --- .vs/AAOlivia-Indicator-Bot/v15/.suo | Bin 22016 -> 23040 bytes Multi-Period-Market/Interval.js | 100 ++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 19 deletions(-) diff --git a/.vs/AAOlivia-Indicator-Bot/v15/.suo b/.vs/AAOlivia-Indicator-Bot/v15/.suo index 7c1d225f960cca7456256c68f4ae3f61fc93f45a..d8fd7cb27e4f3fbd3cc66112fb5e9e114680b9b7 100644 GIT binary patch delta 779 zcmYjP&rcIk5Z<@lLczCC+EQ&LrESn4QnH2GP=8=+Yoj1`OG@;h@#4{giEBb)G(8Z{ z+W7~d@n~Yqdh_JSlep6X_lYH4XGv7CF-psb&i}ok+#!Bnjv4u6w zz)=8ydc7V;1Hi}T2jTX_sv$-wqfZW%f7D(-`TSj&^jtrn-9Vn4K*JQLK!vJrbeNoa z+(e+w#bACSi1TkaT%QH}9maP6kiZZy2!wzUU=%=G+87W4V!%aU9GC&#Hf<4gw~c$E zGrZ|;&h3d1r}#SVfgGzvw+3gaoHgjDb%$yRi=4bIQ^%zLL@!}WzC5a`%V~o)lKZCM zmYB-+ukL~^xi6lb9}M1r^No(oW!f!1q^;sR$!(uiDCCSbs5-t%;dnvvTh6G-cFJ%! z;wz#*Q?G>1BQH$B4IpvTIA=f_a4VSNWY8R4z$Fj7WCiF&aNn~vR(?Ct zq9K(^1<2EDGjJ1^4IghumqNXA<9$v(j8+Wk<4T{A#<)IW85&G70xuCI_~=fROObiD z%>ox9S!b@K%XYj7-kkg7WJ+8z5t3=k7I^bw#fTzC2I{l9FWBI$w@KA7AG-?>p;=Y^?dcR6JeaIMm~O3wm7Z&xmC_PYk9U~ jn%Y#jk$BHLwX{qh;^tNtiCZ Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> yearAssigend = " + yearAssigend); } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> monthAssigned = " + monthAssigned); } charlyAzureFileStorage.initialize("Charly"); bruceAzureFileStorage.initialize("Bruce"); @@ -78,9 +79,7 @@ Read the candles and volumes from Bruce and produce a single Index File for each try { - if (LOG_INFO === true) { - logger.write("[INFO] Entering function 'start'"); - } + if (FULL_LOG === true) { logger.write("[INFO] start -> Entering function."); } let nextIntervalExecution = false; // This tell weather the Interval module will be executed again or not. By default it will not unless some hole have been found in the current execution. let nextIntervalLapse; // With this we can request the next execution wait time. @@ -97,6 +96,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each try { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> Entering function."); } + let reportFilePath; let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json" @@ -104,6 +105,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function getHistoricTrades() { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getHistoricTrades -> Entering function."); } + /* We need to know where is the begining of the market, since that will help us know where the Index Files should start. @@ -116,6 +119,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onStatusReportReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getHistoricTrades -> onStatusReportReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getHistoricTrades -> onStatusReportReceived -> text = " + text); } + let statusReport; try { @@ -138,6 +144,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function getOneMinDailyCandlesVolumes() { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getOneMinDailyCandlesVolumes -> Entering function."); } + /* We need to discover the maxCandle file, which is the last file with candles we can use as input. */ let date = new Date(); @@ -150,6 +158,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onStatusReportReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getOneMinDailyCandlesVolumes -> onStatusReportReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getOneMinDailyCandlesVolumes -> onStatusReportReceived -> text = " + text); } + let statusReport; try { @@ -178,6 +189,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function getThisProcessReport() { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getThisProcessReport -> Entering function."); } + /* If the process run and was interrupted, there should be a status report that allows us to resume execution. */ reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process; @@ -186,6 +199,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onStatusReportReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getThisProcessReport -> onStatusReportReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> getStatusReport -> getThisProcessReport -> onStatusReportReceived -> text = " + text); } + let statusReport; try { @@ -236,6 +252,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each try { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> Entering function."); } + let n = 0 // loop Variable representing each possible period as defined at the periods array. let allPreviousCandles = []; @@ -246,6 +264,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function loopBody() { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> Entering function."); } + let folderName = global.marketFilesPeriods[n][1]; let previousCandles; @@ -255,6 +275,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function getCandles() { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getCandles -> Entering function."); } + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; let filePath = EXCHANGE_NAME + "/Output/" + CANDLES_FOLDER_NAME + "/" + bot.process + "/" + folderName; @@ -263,6 +285,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFileReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> text = " + text); } + let candlesFile; try { @@ -285,6 +310,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function getVolumes() { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> Entering function."); } + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; let filePath = EXCHANGE_NAME + "/Output/" + VOLUMES_FOLDER_NAME + "/" + bot.process + "/" + folderName; @@ -293,6 +320,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFileReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> text = " + text); } + let volumesFile; try { @@ -320,6 +350,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function controlLoop() { + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> controlLoop -> Entering function."); } + n++; if (n < global.marketFilesPeriods.length) { @@ -345,6 +377,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each try { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> Entering function."); } + /* Firstly we prepere the arrays that will accumulate all the information for each output file. @@ -368,6 +402,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function advanceTime() { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> advanceTime -> Entering function."); } + lastCandleFile = new Date(lastCandleFile.valueOf() + ONE_DAY_IN_MILISECONDS); const logText = "[INFO] New processing time @ " + lastCandleFile.getUTCFullYear() + "/" + (lastCandleFile.getUTCMonth() + 1) + "/" + lastCandleFile.getUTCDate() + "."; @@ -395,6 +431,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function periodsLoop() { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> Entering function."); } + /* We will iterate through all posible periods. @@ -407,6 +445,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function loopBody() { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> Entering function."); } + let previousCandles; let previousVolumes; @@ -484,6 +524,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function nextCandleFile() { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> Entering function."); } + let dateForPath = lastCandleFile.getUTCFullYear() + '/' + utilities.pad(lastCandleFile.getUTCMonth() + 1, 2) + '/' + utilities.pad(lastCandleFile.getUTCDate(), 2); let fileName = market.assetA + '_' + market.assetB + ".json" let filePath = EXCHANGE_NAME + "/Output/" + CANDLES_FOLDER_NAME + '/' + CANDLES_ONE_MIN + '/' + dateForPath; @@ -492,6 +534,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFileReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> nextCandleFile -> onFileReceived -> text = " + text); } + let candlesFile; try { @@ -588,6 +633,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function nextVolumeFile() { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> Entering function."); } + let dateForPath = lastCandleFile.getUTCFullYear() + '/' + utilities.pad(lastCandleFile.getUTCMonth() + 1, 2) + '/' + utilities.pad(lastCandleFile.getUTCDate(), 2); let fileName = market.assetA + '_' + market.assetB + ".json" let filePath = EXCHANGE_NAME + "/Output/" + VOLUMES_FOLDER_NAME + '/' + VOLUMES_ONE_MIN + '/' + dateForPath; @@ -596,6 +643,9 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFileReceived(text) { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> loopBody -> nextVolumeFile -> onFileReceived -> text = " + text); } + let volumesFile; try { @@ -668,6 +718,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function controlLoop() { + if (FULL_LOG === true) { logger.write("[INFO] start -> buildCandles -> periodsLoop -> controlLoop -> Entering function."); } + n++; if (n < global.marketFilesPeriods.length) { @@ -693,6 +745,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function writeFiles(candles, volumes, folderName, callBack) { + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> Entering function."); } + /* Here we will write the contents of the Candles and Volumens files. @@ -705,6 +759,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function writeCandles() { + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> writeCandles -> Entering function."); } + let separator = ""; let fileRecordCounter = 0; @@ -732,13 +788,15 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFolderCreated() { + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> writeCandles -> onFolderCreated -> Entering function."); } + oliviaAzureFileStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated); function onFileCreated() { - const logText = "[WARN] Finished with File @ " + market.assetA + "_" + market.assetB + ", " + fileRecordCounter + " records inserted into " + filePath + "/" + fileName + ""; - console.log(logText); - logger.write(logText); + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> writeCandles -> onFolderCreated -> onFileCreated -> Entering function."); } + + logger.write("[WARN] Finished with File @ " + market.assetA + "_" + market.assetB + ", " + fileRecordCounter + " records inserted into " + filePath + "/" + fileName ); writeVolumes(); } @@ -748,6 +806,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function writeVolumes() { + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> writeVolumes -> Entering function."); } + let separator = ""; let fileRecordCounter = 0; @@ -775,13 +835,15 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFolderCreated() { + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> writeVolumes -> onFolderCreated -> Entering function."); } + oliviaAzureFileStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated); function onFileCreated() { - const logText = "[WARN] Finished with File @ " + market.assetA + "_" + market.assetB + ", " + fileRecordCounter + " records inserted into " + filePath + "/" + fileName + ""; - console.log(logText); - logger.write(logText); + if (FULL_LOG === true) { logger.write("[INFO] start -> writeFiles -> writeVolumes -> onFolderCreated -> onFileCreated -> Entering function."); } + + logger.write("[WARN] Finished with File @ " + market.assetA + "_" + market.assetB + ", " + fileRecordCounter + " records inserted into " + filePath + "/" + fileName); callBack(); } @@ -798,9 +860,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function writeStatusReport(lastFileDate, callBack) { - if (LOG_INFO === true) { - logger.write("[INFO] Entering function 'writeStatusReport'"); - } + if (FULL_LOG === true) { logger.write("[INFO] start -> writeStatusReport -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> writeStatusReport -> lastFileDate = " + lastFileDate); } try { @@ -812,6 +873,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each try { + if (FULL_LOG === true) { logger.write("[INFO] start -> writeStatusReport -> onFolderCreated -> Entering function."); } + let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json"; let report = { @@ -828,9 +891,8 @@ Read the candles and volumes from Bruce and produce a single Index File for each function onFileCreated() { - if (LOG_INFO === true) { - logger.write("[INFO] 'writeStatusReport' - Content written: " + fileContent); - } + if (FULL_LOG === true) { logger.write("[INFO] start -> writeStatusReport -> onFolderCreated -> onFileCreated -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> writeStatusReport -> onFolderCreated -> onFileCreated -> fileContent = " + fileContent); } callBack(); }