From 9c1ada6fa6f911880aaca835bddc8bb0bc210379 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 22 Feb 2018 11:48:14 +0100 Subject: [PATCH] Ready for debug --- .vs/AATom/v15/.suo | Bin 24064 -> 24576 bytes AATom.njsproj | 4 +- .../Interval.js | 160 +----------------- this.bot.config.json | 25 +-- 4 files changed, 13 insertions(+), 176 deletions(-) rename {Candle-Stairs => Candles-Volumes-Stairs-Market}/Interval.js (84%) diff --git a/.vs/AATom/v15/.suo b/.vs/AATom/v15/.suo index 4788f600911ae6f3dd8430e8c935ca3172b99a18..a86eef86739a64b48cffeab49207cc2aff756a79 100644 GIT binary patch delta 1010 zcmbVLO-vI(6rS0(P|7YWQlvr^v;}Kop`zF=pmak)ek2G;;Xs5Y_JA#--7O$UgkYkH zT2EftY}A_(^&pA->7C`QCfqyqS43J33EC z(}dZMiULI8US(DtUYIOmF$P?Sb9)K+ zVyYFY(WyaPLDa%YQzp1lEyviL>lkT6_z~?07TbE-JQ?Fv+5%Dj0j-A(zKLf$(jhRt z+mJel3Qu74h^UEMp4C@J@v|@q~ROOroTh1PSw7iAn;bheUR~M&uC^!kh|mDUTMwpyx4t z{+|^F%Q`GXCT`-v?|E!}2@aX~$Os{@P+qBd%lo;kktymcbKw}CGZ2!=j!!hz1 zIVoFl`uoDs-k{=aRRcW{#n~8$gn}weRbGIB%d_+_O7|gDeyu#&T zNPi$)bW7P09=J8D+?3(QW9(ZCl5xDGXEe`*G#kPG3igheDWnsdA~OmL9ve(cImsO> zOi8pyzD)}8DhGVKXol`;eash!kW_)x0jo7;aB)WQ-L_%vYw0Wd!20jC)wf*}(44D4 KckayuH2(v+0X_Wy delta 350 zcmZoTz}T>daYHT>$9(Sc{i`oCDsL`j>t>w9vW4;A#z1ezNlZDc0dZlr`!^S|1u^n6 z3NSD*Cp^D=@|A* - + @@ -41,7 +41,7 @@ - + diff --git a/Candle-Stairs/Interval.js b/Candles-Volumes-Stairs-Market/Interval.js similarity index 84% rename from Candle-Stairs/Interval.js rename to Candles-Volumes-Stairs-Market/Interval.js index d201b57dc..8927c3283 100644 --- a/Candle-Stairs/Interval.js +++ b/Candles-Volumes-Stairs-Market/Interval.js @@ -37,6 +37,7 @@ let charlyAzureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); let bruceAzureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); let oliviaAzureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); + let tomAzureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); let utilities = UTILITIES.newUtilities(bot); @@ -79,7 +80,7 @@ This process is going to do the following: -Read the candles and volumes from Bruce and produce a single Index File for each market with daily candles and volumes. +Read the candles and volumes from Olivia and produce for each market two files with candles stairs and volumes stairs respectively. */ @@ -101,10 +102,6 @@ Read the candles and volumes from Bruce and produce a single Index File for each assetB: "" }; - let lastCandleFile; // Datetime of the last file included on the Index File. - let firstTradeFile; // Datetime of the first trade file in the whole market history. - let maxCandleFile; // Datetime of the last file available to be included in the Index File. - let periods = '[' + '[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' + @@ -208,7 +205,7 @@ Read the candles and volumes from Bruce and produce a single Index File for each if (market.status === markets.ENABLED) { - getStatusReport(); + buildStairs(); } else { @@ -217,8 +214,6 @@ Read the candles and volumes from Bruce and produce a single Index File for each return; } - - } catch (err) { const logText = "[ERROR] 'openMarket' - ERROR : " + err.message; @@ -250,145 +245,6 @@ Read the candles and volumes from Bruce and produce a single Index File for each */ - function getStatusReport() { - - try { - - let reportFilePath; - let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json" - - getHistoricTrades(); - - function getHistoricTrades() { - - /* - - We need to know where is the begining of the market, since that will help us know where the Index Files should start. - - */ - - reportFilePath = EXCHANGE_NAME + "/Processes/" + "Poloniex-Historic-Trades"; - - charlyAzureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true); - - function onStatusReportReceived(text) { - - let statusReport; - - try { - - statusReport = JSON.parse(text); - - firstTradeFile = new Date(statusReport.lastFile.year + "-" + statusReport.lastFile.month + "-" + statusReport.lastFile.days + " " + statusReport.lastFile.hours + ":" + statusReport.lastFile.minutes + GMT_SECONDS); - - getOneMinDailyCandlesVolumes(); - - } catch (err) { - - const logText = "[INFO] 'getStatusReport' - Failed to read main Historic Trades Status Report for market " + market.assetA + '_' + market.assetB + " . Skipping it. "; - logger.write(logText); - - closeAndOpenMarket(); - } - } - } - - function getOneMinDailyCandlesVolumes() { - - /* We need to discover the maxCandle file, which is the last file with candles we can use as input. */ - - let date = new Date(); - let currentYear = date.getUTCFullYear(); - let currentMonth = utilities.pad(date.getUTCMonth() + 1,2); - - reportFilePath = EXCHANGE_NAME + "/Processes/" + "One-Min-Daily-Candles-Volumes" + "/" + currentYear + "/" + currentMonth; - - bruceAzureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true); - - function onStatusReportReceived(text) { - - let statusReport; - - try { - - statusReport = JSON.parse(text); - - maxCandleFile = new Date(statusReport.lastFile.year + "-" + statusReport.lastFile.month + "-" + statusReport.lastFile.days + " " + "00:00" + GMT_SECONDS); - - getThisProcessReport(); - - } catch (err) { - - /* - - It might happen that the file content is corrupt or it does not exist. In either case we will point our lastCandleFile - to the last day of the previous month. - - */ - - maxCandleFile = new Date(date.valueOf() - ONE_DAY_IN_MILISECONDS); - getThisProcessReport(); - - } - } - } - - function getThisProcessReport() { - - /* 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; - - oliviaAzureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true); - - function onStatusReportReceived(text) { - - let statusReport; - - try { - - statusReport = JSON.parse(text); - - lastCandleFile = new Date(statusReport.lastFile.year + "-" + statusReport.lastFile.month + "-" + statusReport.lastFile.days + " " + "00:00" + GMT_SECONDS); - - /* - - Here we assume that the last day written might contain incomplete information. This actually happens every time the head of the market is reached. - For that reason we go back one day, the partial information is discarded and added again with whatever new info is available. - - */ - - lastCandleFile = new Date(lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); - - findPreviousContent(); - - } catch (err) { - - /* - - It might happen that the file content is corrupt or it does not exist. In either case we will point our lastCandleFile - to the begining of the market. - - */ - - lastCandleFile = new Date(firstTradeFile.getUTCFullYear() + "-" + (firstTradeFile.getUTCMonth() + 1) + "-" + firstTradeFile.getUTCDate() + " " + "00:00" + GMT_SECONDS); - - lastCandleFile = new Date(lastCandleFile.valueOf() - ONE_DAY_IN_MILISECONDS); // Go back one day to start well. - - buildCandles(); - - } - } - } - - } - catch (err) { - const logText = "[ERROR] 'getStatusReport' - ERROR : " + err.message; - logger.write(logText); - closeMarket(); - } - } - function buildStairs() { periodsLoop(); @@ -964,14 +820,14 @@ Read the candles and volumes from Bruce and produce a single Index File for each } else { - writeStatusReport(lastCandleFile, advanceTime); + writeStatusReport(); } } } - function writeStatusReport(lastFileDate, callBack) { + function writeStatusReport() { if (LOG_INFO === true) { logger.write("[INFO] Entering function 'writeStatusReport'"); @@ -981,12 +837,14 @@ Read the candles and volumes from Bruce and produce a single Index File for each let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process; - utilities.createFolderIfNeeded(reportFilePath, oliviaAzureFileStorage, onFolderCreated); + utilities.createFolderIfNeeded(reportFilePath, tomAzureFileStorage, onFolderCreated); function onFolderCreated() { try { + let lastFileDate = new Date(); + let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json"; let report = { @@ -1007,7 +865,7 @@ Read the candles and volumes from Bruce and produce a single Index File for each logger.write("[INFO] 'writeStatusReport' - Content written: " + fileContent); } - callBack(); + closeAndOpenMarket(); } } catch (err) { diff --git a/this.bot.config.json b/this.bot.config.json index e5ac6787f..c2d9e74bd 100644 --- a/this.bot.config.json +++ b/this.bot.config.json @@ -7,8 +7,8 @@ }, "processes": [ { - "name": "Multi-Period-Market", - "description": "Produces different files with multi-period candles and volumes for entire markets.", + "name": "Candles-Volumes-Stairs-Market", + "description": "Produces for each market two files with candles stairs and volumes stairs respectively.", "startMode": { "allMonths": { "run": "false", @@ -26,27 +26,6 @@ }, "intervalLapse": 3600000, "intervalMaxLoops": -1 - }, - { - "name": "Multi-Period-Daily", - "description": "Produces different files with multi-period candles and volumes on a daily format.", - "startMode": { - "allMonths": { - "run": "false", - "minYear": "", - "maxYear": "" - }, - "oneMonth": { - "run": "false", - "year": "", - "month": "" - }, - "noTime": { - "run": "true" - } - }, - "intervalLapse": 60000, - "intervalMaxLoops": -1 } ] }