From efa5470188c576eca370cc465a9a63946bdb4e8d Mon Sep 17 00:00:00 2001 From: Matias Benitez Date: Mon, 4 Jun 2018 18:26:53 -0300 Subject: [PATCH] Bot Update Including several changes. --- Multi-Period-Daily/LRCIndicator.js | 112 ----- Multi-Period-Daily/User.bot.js | 320 ++++++++++--- Multi-Period-Market/LRCIndicator.js | 112 ----- Multi-Period-Market/User.bot.js | 117 ++++- Project.njsproj | 4 +- package-lock.json | 670 ---------------------------- package.json | 13 + this.bot.config.json | 50 ++- 8 files changed, 409 insertions(+), 989 deletions(-) delete mode 100644 Multi-Period-Daily/LRCIndicator.js delete mode 100644 Multi-Period-Market/LRCIndicator.js delete mode 100644 package-lock.json create mode 100644 package.json diff --git a/Multi-Period-Daily/LRCIndicator.js b/Multi-Period-Daily/LRCIndicator.js deleted file mode 100644 index 89f6d00c6..000000000 --- a/Multi-Period-Daily/LRCIndicator.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Linear regression curve. SRC: Gekko - */ - -//var log = require('../../core/log'); - -var LRCIndicator = function(settings) { - this.input = 'price'; - this.depth = settings; - this.result = false; - this.age = 0; - this.history = []; - this.x = []; - /* - * Do not use array(depth) as it might not be implemented - */ - for (var i = 0; i < this.depth; i++) { - this.history.push(0.0); - this.x.push(i); - } - - // log.debug("Created LRC indicator with h: ", this.depth); -} - -LRCIndicator.prototype.update = function(price) { - // We need sufficient history to get the right result. - if(this.result === false && this.age < this.depth) { - - this.history[this.age] = price; - this.age++; - this.result = false; - // log.debug("Waiting for sufficient age: ", this.age, " out of ", this.depth); - return; - } - - this.age++; - // shift history - for (var i = 0; i < (this.depth - 1); i++) { - this.history[i] = this.history[i+1]; - } - this.history[this.depth-1] = price; - - this.calculate(price); - - // log.debug("Checking LRC: ", this.result.toFixed(8), "\tH: ", this.age); - return; -} - -/* - * Least squares linear regression fitting. - */ -function linreg(values_x, values_y) { - var sum_x = 0; - var sum_y = 0; - var sum_xy = 0; - var sum_xx = 0; - var count = 0; - - /* - * We'll use those variables for faster read/write access. - */ - var x = 0; - var y = 0; - var values_length = values_x.length; - - if (values_length != values_y.length) { - throw new Error('The parameters values_x and values_y need to have same size!'); - } - - /* - * Nothing to do. - */ - if (values_length === 0) { - return [ [], [] ]; - } - - /* - * Calculate the sum for each of the parts necessary. - */ - for (var v = 0; v < values_length; v++) { - x = values_x[v]; - y = values_y[v]; - sum_x += x; - sum_y += y; - sum_xx += x*x; - sum_xy += x*y; - count++; - } - - /* - * Calculate m and b for the formula: y = x * m + b - * - */ - var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x); - var b = (sum_y/count) - (m*sum_x)/count; - - return [m, b]; -} - - -/* - * Handle calculations - */ -LRCIndicator.prototype.calculate = function(price) { - // get the reg - var reg = linreg(this.x, this.history); - - // y = a * x + b - this.result = ((this.depth-1) * reg[0]) + reg[1]; -} - -module.exports = LRCIndicator; \ No newline at end of file diff --git a/Multi-Period-Daily/User.bot.js b/Multi-Period-Daily/User.bot.js index 5db94ce30..c2a04af37 100644 --- a/Multi-Period-Daily/User.bot.js +++ b/Multi-Period-Daily/User.bot.js @@ -1,7 +1,110 @@ -var LRCIndicator = require('./LRCIndicator'); +var LRCIndicator = function (settings) { + this.input = 'price'; + this.depth = settings; + this.result = false; + this.age = 0; + this.history = []; + this.x = []; + /* + * Do not use array(depth) as it might not be implemented + */ + for (var i = 0; i < this.depth; i++) { + this.history.push(0.0); + this.x.push(i); + } -exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE, FILE_STORAGE) { - const FULL_LOG = true; + // log.debug("Created LRC indicator with h: ", this.depth); +} + +LRCIndicator.prototype.update = function (price) { + // We need sufficient history to get the right result. + if (this.result === false && this.age < this.depth) { + + this.history[this.age] = price; + this.age++; + this.result = false; + // log.debug("Waiting for sufficient age: ", this.age, " out of ", this.depth); + return; + } + + this.age++; + // shift history + for (var i = 0; i < (this.depth - 1); i++) { + this.history[i] = this.history[i + 1]; + } + this.history[this.depth - 1] = price; + + this.calculate(price); + + // log.debug("Checking LRC: ", this.result.toFixed(8), "\tH: ", this.age); + return; +} + +/* + * Least squares linear regression fitting. + */ +function linreg(values_x, values_y) { + var sum_x = 0; + var sum_y = 0; + var sum_xy = 0; + var sum_xx = 0; + var count = 0; + + /* + * We'll use those variables for faster read/write access. + */ + var x = 0; + var y = 0; + var values_length = values_x.length; + + if (values_length != values_y.length) { + throw new Error('The parameters values_x and values_y need to have same size!'); + } + + /* + * Nothing to do. + */ + if (values_length === 0) { + return [[], []]; + } + + /* + * Calculate the sum for each of the parts necessary. + */ + for (var v = 0; v < values_length; v++) { + x = values_x[v]; + y = values_y[v]; + sum_x += x; + sum_y += y; + sum_xx += x * x; + sum_xy += x * y; + count++; + } + + /* + * Calculate m and b for the formula: y = x * m + b + * + */ + var m = (count * sum_xy - sum_x * sum_y) / (count * sum_xx - sum_x * sum_x); + var b = (sum_y / count) - (m * sum_x) / count; + + return [m, b]; +} + + +/* + * Handle calculations + */ +LRCIndicator.prototype.calculate = function (price) { + // get the reg + var reg = linreg(this.x, this.history); + + // y = a * x + b + this.result = ((this.depth - 1) * reg[0]) + reg[1]; +} + +exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE) { + const FULL_LOG = false; const LOG_FILE_CONTENT = false; const USE_PARTIAL_LAST_CANDLE = true; // When running live the last candle generated is a partial candle. @@ -23,8 +126,9 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, }; let gaussStorage = BLOB_STORAGE.newBlobStorage(bot); + let oliviaStorage = BLOB_STORAGE.newBlobStorage(bot); - let utilities = UTILITIES.newUtilities(bot); + let utilities = UTILITIES.newCloudUtilities(bot); let statusDependencies; @@ -40,14 +144,14 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, statusDependencies = pStatusDependencies; - gaussStorage.initialize({ bot: "AAGauss", devTeam: "AAMasters" }, onGaussInizialized); + gaussStorage.initialize(bot.devTeam, onGaussInizialized); function onGaussInizialized(err) { if (err.result === global.DEFAULT_OK_RESPONSE.result) { if (FULL_LOG === true) { logger.write("[INFO] initialize -> onGaussInizialized -> Initialization Succeed."); } - callBackFunction(global.DEFAULT_OK_RESPONSE); + oliviaStorage.initialize("AAMasters", onOliviaInizialized); } else { logger.write("[ERROR] initialize -> onGaussInizialized -> err = " + err.message); @@ -55,6 +159,19 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, } } + function onOliviaInizialized(err) { + + if (err.result === global.DEFAULT_OK_RESPONSE.result) { + + if (FULL_LOG === true) { logger.write("[INFO] initialize -> onOliviaInizialized -> Initialization Succeed."); } + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } else { + logger.write("[ERROR] initialize -> onOliviaInizialized -> err = " + err.message); + callBackFunction(err); + } + } + } catch (err) { logger.write("[ERROR] initialize -> err = " + err.message); callBackFunction(global.DEFAULT_FAIL_RESPONSE); @@ -62,7 +179,15 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, } /* - TODO Create Description + This process will do the following: + For every period on the market: + a. Get olivia files for the current execution time + i. If the file exist, validate we can get 63 candles + 1) 63 candles exist, proceed + 2) 63 candles doesn't exist, call for previous execution day until have 63 + ii. File doesn't exist, wait until get the files + b. Once we have the 63 candles, calculate LRC + c. Save LRC points */ function start(callBackFunction) { @@ -108,9 +233,9 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, return; } - maxCandleTime = new Date(Date.UTC(thisReport.lastFile.year, thisReport.lastFile.month - 1, thisReport.lastFile.days, thisReport.lastFile.hours, thisReport.lastFile.minutes)); + maxCandleTime = new Date(thisReport.lastFile); - reportKey = "AAMasters" + "-" + "AAGauss" + "-" + "Multi-Period-Daily" + "-" + "dataSet.V1"; + reportKey = "AAVikings" + "-" + "AAGauss" + "-" + "Multi-Period-Daily" + "-" + "dataSet.V1"; if (FULL_LOG === true) { logger.write("[INFO] start -> getContextVariables -> reportKey = " + reportKey); } if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") { @@ -121,9 +246,9 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, thisReport = statusDependencies.statusReports.get(reportKey).file; if (thisReport.lastCandles !== undefined) { - logger.write("[INFO] start -> getContextVariables -> thisReport.lastCandles: " + JSON.stringify(thisReport.lastCandles)); - lastCandles = thisReport.lastCandles; + if (FULL_LOG === true) { logger.write("[INFO] start -> getContextVariables -> thisReport.lastCandles: " + JSON.stringify(thisReport.lastCandles)) }; + lastCandles = thisReport.lastCandles; buildLRCPoints(); } else { @@ -136,7 +261,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, lastCandles.push(0); } - lastCandles[10] = new Date(Date.UTC(2018, 3).valueOf()); + lastCandles[10] = new Date(Date.UTC(2018, 3)).valueOf(); if (FULL_LOG === true) { logger.write("[INFO] start -> getContextVariables -> Starting at: " + new Date(lastCandles[10]).toISOString()); } @@ -164,7 +289,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> advanceTime -> Entering function."); } - executionTime = new Date(lastCandles[10].valueOf() + ONE_MIN_IN_MILISECONDS); + executionTime = new Date(lastCandles[10] + ONE_MIN_IN_MILISECONDS); if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> advanceTime -> New processing time @ " + executionTime.toISOString()); } @@ -191,7 +316,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, function loopBody() { - if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCChannels -> periodsLoop -> loopBody -> Entering function. Time: " + executionTime.toISOString() + ". Loop: "+n); } + if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> periodsLoop -> loopBody -> Entering function. Time: " + executionTime.toISOString() + ". Loop: "+n); } const outputPeriod = global.dailyFilePeriods[n][0]; const folderName = global.dailyFilePeriods[n][1]; @@ -199,11 +324,10 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, isTimeToRun(); function isTimeToRun() { - let nextExecution = lastCandles[n].valueOf() + outputPeriod; + let nextExecution = lastCandles[n] + outputPeriod; if (executionTime.valueOf() >= nextExecution) { getLRCPoints(); } else { - if (FULL_LOG === true) logger.write("[INFO] start -> periodsLoop -> loopBody -> It's not time to run this period. Next Execution: " + new Date(nextExecution).toISOString()); controlLoop(); @@ -248,8 +372,10 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, if (LOG_FILE_CONTENT === true) { logger.write("[INFO] Candle Date: " + new Date(candle.begin).toISOString() + ". Process Date: " + executionTime.toISOString()); } - if (candleArray.length < maxLRCDepth && candle.begin <= executionTime.valueOf()) { - candleArray.push(candleFile[i]); + let lastCandle = executionTime.valueOf() - (outputPeriod * maxLRCDepth); + + if (candleArray.length < maxLRCDepth && candle.begin > lastCandle && candle.begin <= executionTime.valueOf()) { + candleArray.push(candle); } } @@ -258,17 +384,17 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, if (candleArray.length >= maxLRCDepth) { if (FULL_LOG === true) { logger.write("[INFO] start -> getLRCPoints -> All candles available proceed with LRC calculations."); } - let lrcChannel = performLRCCalculations(candleArray); - saveChannel(lrcChannel); + let lrcPoint = performLRCCalculations(candleArray); + savePoint(lrcPoint); } else if (backwardsCount <= maxBackwardsCount) { - if (FULL_LOG === true) { logger.write("[INFO] start -> getChannelTilt -> Getting file for day before."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> getLRCPoints -> Getting file for day before."); } queryDate.setDate(queryDate.getDate() - 1); getDailyFile(queryDate, onDailyFileReceived); backwardsCount++; } else { - logger.write("[ERROR] start -> getChannelTilt -> Not enough history to calculate LRC."); + logger.write("[ERROR] start -> getLRCPoints -> Not enough history to calculate LRC."); callBack(global.DEFAULT_RETRY_RESPONSE); } } @@ -282,7 +408,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, let filePath = "AAMasters/AAOlivia.1.0/AACloud.1.1/Poloniex/dataSet.V1/Output/Candles/Multi-Period-Daily/" + folderName + "/" + datePath; let fileName = market.assetA + '_' + market.assetB + ".json" - gaussStorage.getTextFile(filePath, fileName, onFileReceived); + oliviaStorage.getTextFile(filePath, fileName, onFileReceived); function onFileReceived(err, text) { if (err.result === global.DEFAULT_OK_RESPONSE.result) { @@ -310,7 +436,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, * It's needed to order since it's possible that we need to get another file and it will put an older candle at the end of the array. */ candleArray.sort(function (a, b) { - return a[4] - b[4]; + return a.begin - b.begin; }); if (USE_PARTIAL_LAST_CANDLE === false) candleArray = candleArray.slice(0, candleArray.length - 1); @@ -318,33 +444,29 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, let lrcPoints = []; lrcPoints.push(0); //firstCandleBeginTime 0 lrcPoints.push(0); //firstCandleEndTime 1 - lrcPoints.push(0); //lastCandleBeginTime 2 - lrcPoints.push(0); //lastCandleEndTime 3 - lrcPoints.push(0); //minimumChannelValue 4 - lrcPoints.push(0); //middleChannelValue 5 - lrcPoints.push(0); //maximumChannelValue 6 + lrcPoints.push(0); //minimumPointValue 2 + lrcPoints.push(0); //middlePointValue 3 + lrcPoints.push(0); //maximumPointValue 4 if (LOG_FILE_CONTENT === true) - lrcPoints.push(candleArray); //Entire candle array 7 + lrcPoints.push(candleArray); //Entire candle array 5 calculateLRC(candleArray, lrcPoints); let lastCandle = candleArray[0]; let firstCandle = candleArray[candleArray.length - 1]; - lrcPoints[0] = firstCandle[4]; - lrcPoints[1] = firstCandle[5]; - lrcPoints[2] = lastCandle[4]; - lrcPoints[3] = lastCandle[5]; + lrcPoints[0] = firstCandle.begin; + lrcPoints[1] = firstCandle.end; if (FULL_LOG === true) { - logger.write("[INFO] start -> getChannelTilt -> performLRCCalculations -> LRC Points calculation results: " + JSON.stringify(lrcPoints)); } + logger.write("[INFO] start -> getLRCPoints -> performLRCCalculations -> LRC Points calculation results: " + JSON.stringify(lrcPoints)); } return lrcPoints; } function calculateLRC(candlesArray, lrcPoints) { - if (FULL_LOG === true) { logger.write("[INFO] start -> getChannelTilt -> calculateLRC -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> getLRCPoints -> calculateLRC -> Entering function."); } let lrcMinIndicator = new LRCIndicator(15); let lrcMidIndicator = new LRCIndicator(30); @@ -352,7 +474,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, for (let i = 0; i < candlesArray.length; i++) { let tempCandle = candlesArray[i]; - let averagePrice = (tempCandle[0] + tempCandle[1] + tempCandle[2] + tempCandle[3]) / 4; // TODO Check which price should be take to get the LRC + let averagePrice = (tempCandle.min + tempCandle.max + tempCandle.open + tempCandle.close) / 4; // TODO Check which price should be take to get the LRC lrcMinIndicator.update(averagePrice); lrcMidIndicator.update(averagePrice); @@ -363,29 +485,28 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, * Only if there is enough history the result will be calculated */ if (lrcMinIndicator.result != false && lrcMidIndicator.result != false && lrcMaxIndicator.result != false) { - lrcPoints[4] = lrcMinIndicator.result; - lrcPoints[5] = lrcMidIndicator.result; - lrcPoints[6] = lrcMaxIndicator.result; + lrcPoints[2] = lrcMinIndicator.result; + lrcPoints[3] = lrcMidIndicator.result; + lrcPoints[4] = lrcMaxIndicator.result; return lrcPoints; } else { - logger.write("[ERROR] start -> getChannelTilt -> calculateLRC -> There is not enough history to calculate the LRC."); + logger.write("[ERROR] start -> getLRCPoints -> calculateLRC -> There is not enough history to calculate the LRC."); callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } - function saveChannel(lrcChannel) { + function savePoint(lrcPoint) { try { - if (FULL_LOG === true) { logger.write("[INFO] start -> saveChannel -> Entering function."); } - let fileContent; + if (FULL_LOG === true) { logger.write("[INFO] start -> savePoint -> Entering function."); } let datePath = executionTime.getUTCFullYear() + "/" + utilities.pad(executionTime.getUTCMonth() + 1, 2) + "/" + utilities.pad(executionTime.getUTCDate(), 2); - let filePath = bot.filePathRoot + "/Output/LRC-Channel/Multi-Period-Daily/" + folderName + "/" + datePath; + let filePath = bot.filePathRoot + "/Output/LRC-Points/Multi-Period-Daily/" + folderName + "/" + datePath; let fileName = market.assetA + '_' + market.assetB + ".json" - if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCChannels -> periodsLoop -> loopBody -> getCurrentContent -> fileName = " + fileName); } - if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCChannels -> periodsLoop -> loopBody -> getCurrentContent -> filePath = " + filePath); } + if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> periodsLoop -> loopBody -> getCurrentContent -> fileName = " + fileName); } + if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> periodsLoop -> loopBody -> getCurrentContent -> filePath = " + filePath); } gaussStorage.getTextFile(filePath, fileName, onFileRetrieved); @@ -409,11 +530,10 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, if (FULL_LOG === true) { logger.write("[INFO] start -> onFileRetrieved -> Daily file exist, appending content."); } - fileContent = JSON.parse(text); + let fileContent = JSON.parse(text); appendToFile(fileContent); } - function createFolders(filePath) { try { @@ -455,29 +575,29 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, function createFile() { - if (FULL_LOG === true) { logger.write("[INFO] start -> saveChannel -> createFile -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> savePoint -> createFile -> Entering function."); } let existingContent = []; - existingContent.push(lrcChannel); + existingContent.push(lrcPoint); gaussStorage.createTextFile(filePath, fileName, JSON.stringify(existingContent), onFileCreated); function onFileCreated(err) { - if (FULL_LOG === true) { logger.write("[INFO] start -> saveChannel -> onFileCreated -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> savePoint -> onFileCreated -> Entering function."); } if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - logger.write("[ERROR] start -> saveChannel -> onFileCreated -> err = " + err.message); + logger.write("[ERROR] start -> savePoint -> onFileCreated -> err = " + err.message); callBackFunction(err); return; } if (LOG_FILE_CONTENT === true) { - logger.write("[INFO] start -> saveChannel -> onFileCreated -> Content written = " + JSON.stringify(existingContent)); + logger.write("[INFO] start -> savePoint -> onFileCreated -> Content written = " + JSON.stringify(existingContent)); } // We keep a record of the last candle used for the time period - lastCandles[n] = lrcChannel[0]; + lastCandles[n] = lrcPoint[0]; controlLoop(); } @@ -485,34 +605,34 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, function appendToFile(fileContent) { - if (FULL_LOG === true) { logger.write("[INFO] start -> saveChannel -> appendToFile -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> savePoint -> appendToFile -> Entering function."); } - fileContent.push(lrcChannel); + fileContent.push(lrcPoint); gaussStorage.createTextFile(filePath, fileName, JSON.stringify(fileContent), onExistingFileUpdated); function onExistingFileUpdated(err) { - if (FULL_LOG === true) { logger.write("[INFO] start -> saveChannel -> onExistingFileUpdated -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> savePoint -> onExistingFileUpdated -> Entering function."); } if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - logger.write("[ERROR] start -> saveChannel -> onExistingFileUpdated -> err = " + err.message); + logger.write("[ERROR] start -> savePoint -> onExistingFileUpdated -> err = " + err.message); callBackFunction(err); return; } if (LOG_FILE_CONTENT === true) { - logger.write("[INFO] start -> saveChannel -> onExistingFileUpdated -> Content written = " + JSON.stringify(fileContent)); + logger.write("[INFO] start -> savePoint -> onExistingFileUpdated -> Content written = " + JSON.stringify(fileContent)); } // We keep a record of the last candle used for the time period - lastCandles[n] = lrcChannel[0]; + lastCandles[n] = lrcPoint[0]; controlLoop(); } } } catch (err) { - logger.write("[ERROR] start -> saveChannel -> err = " + err.message); + logger.write("[ERROR] start -> savePoint -> err = " + err.message); callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } @@ -521,7 +641,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, function controlLoop() { - if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCChannels -> periodsLoop -> controlLoop -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> periodsLoop -> controlLoop -> Entering function."); } n++; @@ -530,12 +650,80 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, loopBody(); } else { - - writeStatusReport(); + let lastOneMinuteCandle = lastCandles[10]; + writeDataRange(lastOneMinuteCandle, onWritten); + function onWritten(err) { + + if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> periodsLoop -> controlLoop -> onWritten -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + logger.write("[ERROR] writeDataRanges -> writeDataRanges -> onWritten -> err = " + err.message); + callBack(err); + return; + } + + writeStatusReport(); + } } } + } + + function writeDataRange(lastOneMinuteCandle, callBack) { + try { + + if (FULL_LOG === true) { logger.write("[INFO] start -> writeDataRange -> Entering function."); } + + let dataRange = { + begin: 1522540800000,//TODO: 1424373300000, + end: lastOneMinuteCandle.valueOf() + }; + + let fileContentDataRange = JSON.stringify(dataRange); + + let fileName = 'Data.Range.' + market.assetA + '_' + market.assetB + '.json'; + let filePath = bot.filePathRoot + "/Output/LRC-Points/" + bot.process; + + if (FULL_LOG === true) { logger.write("[INFO] start -> writeDataRange -> fileName = " + fileName); } + if (FULL_LOG === true) { logger.write("[INFO] start -> writeDataRange -> filePath = " + filePath); } + + utilities.createFolderIfNeeded(filePath, gaussStorage, onFolderCreated); + + function onFolderCreated(err) { + + if (FULL_LOG === true) { logger.write("[INFO] start -> writeDataRange -> onFolderCreated -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + logger.write("[ERROR] start -> writeDataRange -> onFolderCreated -> err = " + err.message); + callBack(err); + return; + } + + gaussStorage.createTextFile(filePath, fileName, fileContentDataRange + '\n', onFileCreated); + + function onFileCreated(err) { + + if (FULL_LOG === true) { logger.write("[INFO] start -> writeDataRange -> onFolderCreated -> onFileCreated -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + logger.write("[ERROR] start -> writeDataRange -> onFolderCreated -> onFileCreated -> err = " + err.message); + callBack(err); + return; + } + + if (LOG_FILE_CONTENT === true) { + logger.write("[INFO] start -> writeDataRange -> onFolderCreated -> onFileCreated -> Content written = " + fileContentDataRange); + } + + callBack(global.DEFAULT_OK_RESPONSE); + } + } + } + catch (err) { + logger.write("[ERROR] start -> writeDataRange -> err = " + err.message); + callBack(global.DEFAULT_FAIL_RESPONSE); + } } function writeStatusReport() { @@ -571,10 +759,10 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, } } - } catch (err) { logger.write("[ERROR] start -> err = " + err.message); callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } + }; diff --git a/Multi-Period-Market/LRCIndicator.js b/Multi-Period-Market/LRCIndicator.js deleted file mode 100644 index 89f6d00c6..000000000 --- a/Multi-Period-Market/LRCIndicator.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Linear regression curve. SRC: Gekko - */ - -//var log = require('../../core/log'); - -var LRCIndicator = function(settings) { - this.input = 'price'; - this.depth = settings; - this.result = false; - this.age = 0; - this.history = []; - this.x = []; - /* - * Do not use array(depth) as it might not be implemented - */ - for (var i = 0; i < this.depth; i++) { - this.history.push(0.0); - this.x.push(i); - } - - // log.debug("Created LRC indicator with h: ", this.depth); -} - -LRCIndicator.prototype.update = function(price) { - // We need sufficient history to get the right result. - if(this.result === false && this.age < this.depth) { - - this.history[this.age] = price; - this.age++; - this.result = false; - // log.debug("Waiting for sufficient age: ", this.age, " out of ", this.depth); - return; - } - - this.age++; - // shift history - for (var i = 0; i < (this.depth - 1); i++) { - this.history[i] = this.history[i+1]; - } - this.history[this.depth-1] = price; - - this.calculate(price); - - // log.debug("Checking LRC: ", this.result.toFixed(8), "\tH: ", this.age); - return; -} - -/* - * Least squares linear regression fitting. - */ -function linreg(values_x, values_y) { - var sum_x = 0; - var sum_y = 0; - var sum_xy = 0; - var sum_xx = 0; - var count = 0; - - /* - * We'll use those variables for faster read/write access. - */ - var x = 0; - var y = 0; - var values_length = values_x.length; - - if (values_length != values_y.length) { - throw new Error('The parameters values_x and values_y need to have same size!'); - } - - /* - * Nothing to do. - */ - if (values_length === 0) { - return [ [], [] ]; - } - - /* - * Calculate the sum for each of the parts necessary. - */ - for (var v = 0; v < values_length; v++) { - x = values_x[v]; - y = values_y[v]; - sum_x += x; - sum_y += y; - sum_xx += x*x; - sum_xy += x*y; - count++; - } - - /* - * Calculate m and b for the formula: y = x * m + b - * - */ - var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x); - var b = (sum_y/count) - (m*sum_x)/count; - - return [m, b]; -} - - -/* - * Handle calculations - */ -LRCIndicator.prototype.calculate = function(price) { - // get the reg - var reg = linreg(this.x, this.history); - - // y = a * x + b - this.result = ((this.depth-1) * reg[0]) + reg[1]; -} - -module.exports = LRCIndicator; \ No newline at end of file diff --git a/Multi-Period-Market/User.bot.js b/Multi-Period-Market/User.bot.js index 5db94ce30..3cb5ecb23 100644 --- a/Multi-Period-Market/User.bot.js +++ b/Multi-Period-Market/User.bot.js @@ -1,6 +1,4 @@ -var LRCIndicator = require('./LRCIndicator'); - -exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE, FILE_STORAGE) { +exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; const USE_PARTIAL_LAST_CANDLE = true; // When running live the last candle generated is a partial candle. @@ -381,7 +379,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, if (FULL_LOG === true) { logger.write("[INFO] start -> saveChannel -> Entering function."); } let fileContent; let datePath = executionTime.getUTCFullYear() + "/" + utilities.pad(executionTime.getUTCMonth() + 1, 2) + "/" + utilities.pad(executionTime.getUTCDate(), 2); - let filePath = bot.filePathRoot + "/Output/LRC-Channel/Multi-Period-Daily/" + folderName + "/" + datePath; + let filePath = bot.filePathRoot + "/Output/LRC-Points/Multi-Period-Daily/" + folderName + "/" + datePath; let fileName = market.assetA + '_' + market.assetB + ".json" if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCChannels -> periodsLoop -> loopBody -> getCurrentContent -> fileName = " + fileName); } @@ -578,3 +576,114 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, } } }; + +/* + * Linear regression curve. SRC: Gekko + */ + +//var log = require('../../core/log'); + +var LRCIndicator = function (settings) { + this.input = 'price'; + this.depth = settings; + this.result = false; + this.age = 0; + this.history = []; + this.x = []; + /* + * Do not use array(depth) as it might not be implemented + */ + for (var i = 0; i < this.depth; i++) { + this.history.push(0.0); + this.x.push(i); + } + + // log.debug("Created LRC indicator with h: ", this.depth); +} + +LRCIndicator.prototype.update = function (price) { + // We need sufficient history to get the right result. + if (this.result === false && this.age < this.depth) { + + this.history[this.age] = price; + this.age++; + this.result = false; + // log.debug("Waiting for sufficient age: ", this.age, " out of ", this.depth); + return; + } + + this.age++; + // shift history + for (var i = 0; i < (this.depth - 1); i++) { + this.history[i] = this.history[i + 1]; + } + this.history[this.depth - 1] = price; + + this.calculate(price); + + // log.debug("Checking LRC: ", this.result.toFixed(8), "\tH: ", this.age); + return; +} + +/* + * Least squares linear regression fitting. + */ +function linreg(values_x, values_y) { + var sum_x = 0; + var sum_y = 0; + var sum_xy = 0; + var sum_xx = 0; + var count = 0; + + /* + * We'll use those variables for faster read/write access. + */ + var x = 0; + var y = 0; + var values_length = values_x.length; + + if (values_length != values_y.length) { + throw new Error('The parameters values_x and values_y need to have same size!'); + } + + /* + * Nothing to do. + */ + if (values_length === 0) { + return [[], []]; + } + + /* + * Calculate the sum for each of the parts necessary. + */ + for (var v = 0; v < values_length; v++) { + x = values_x[v]; + y = values_y[v]; + sum_x += x; + sum_y += y; + sum_xx += x * x; + sum_xy += x * y; + count++; + } + + /* + * Calculate m and b for the formula: y = x * m + b + * + */ + var m = (count * sum_xy - sum_x * sum_y) / (count * sum_xx - sum_x * sum_x); + var b = (sum_y / count) - (m * sum_x) / count; + + return [m, b]; +} + + +/* + * Handle calculations + */ +LRCIndicator.prototype.calculate = function (price) { + // get the reg + var reg = linreg(this.x, this.history); + + // y = a * x + b + this.result = ((this.depth - 1) * reg[0]) + reg[1]; +} diff --git a/Project.njsproj b/Project.njsproj index cdb446a78..1e068c9eb 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -15,6 +15,7 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) Project + True @@ -23,8 +24,7 @@ Code - - + diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 87c40254f..000000000 --- a/package-lock.json +++ /dev/null @@ -1,670 +0,0 @@ -{ - "name": "AACharly", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "ajv": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.0.tgz", - "integrity": "sha1-6yhAdG6dxIvV4GOjbj/UAMXqtak=", - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" - } - }, - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" - }, - "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" - }, - "azure-storage": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/azure-storage/-/azure-storage-2.6.0.tgz", - "integrity": "sha1-hHR+5UpL0ZS7lg+J8+/4nWes8c8=", - "requires": { - "browserify-mime": "1.2.9", - "extend": "1.2.1", - "json-edm-parser": "0.1.2", - "md5.js": "1.3.4", - "readable-stream": "2.0.6", - "request": "2.81.0", - "underscore": "1.8.3", - "uuid": "3.1.0", - "validator": "3.35.0", - "xml2js": "0.2.7", - "xmlbuilder": "0.4.3" - }, - "dependencies": { - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=" - }, - "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" - }, - "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "requires": { - "hoek": "2.16.3" - } - }, - "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "requires": { - "boom": "2.10.1" - } - }, - "extend": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz", - "integrity": "sha1-oPX9bPyDpf5J72mNYOyKYk3UV2w=" - }, - "form-data": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - } - }, - "har-schema": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=" - }, - "har-validator": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" - }, - "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" - } - }, - "performance-now": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" - }, - "qs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" - }, - "request": { - "version": "2.81.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" - }, - "dependencies": { - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" - } - } - }, - "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "requires": { - "hoek": "2.16.3" - } - } - } - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "requires": { - "hoek": "4.2.0" - } - }, - "browserify-mime": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/browserify-mime/-/browserify-mime-1.2.9.tgz", - "integrity": "sha1-rrGvKN5sDXpqLOQK22j/GEIq8x8=" - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, - "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "requires": { - "delayed-stream": "1.0.0" - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "requires": { - "boom": "5.2.0" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "requires": { - "hoek": "4.2.0" - } - } - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { - "assert-plus": "1.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" - }, - "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "1.0.0" - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "requires": { - "ajv": "5.5.0", - "har-schema": "2.0.0" - } - }, - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" - } - }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.0", - "sntp": "2.1.0" - } - }, - "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true - }, - "json-edm-parser": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/json-edm-parser/-/json-edm-parser-0.1.2.tgz", - "integrity": "sha1-HmCw/vG8CvZ7wNFG393lSGzWFbQ=", - "requires": { - "jsonparse": "1.2.0" - } - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" - }, - "jsonparse": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.2.0.tgz", - "integrity": "sha1-XAxWhRBxYOcv50ib3eoLRMK8Z70=" - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", - "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" - } - }, - "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" - }, - "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", - "requires": { - "mime-db": "1.30.0" - } - }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=" - }, - "nonce": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/nonce/-/nonce-1.0.4.tgz", - "integrity": "sha1-7nMCrejBvvR28wG4yR9cxRpIdhI=" - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", - "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.1", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" - }, - "sax": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.2.tgz", - "integrity": "sha1-c1/6o5oc/4/7lZjwIjq9sDqfsuo=" - }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "requires": { - "hoek": "4.2.0" - } - }, - "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" - }, - "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { - "safe-buffer": "5.1.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true - }, - "underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" - }, - "validator": { - "version": "3.35.0", - "resolved": "https://registry.npmjs.org/validator/-/validator-3.35.0.tgz", - "integrity": "sha1-PwcklALB/I/Ak8MsbkPXKnnModw=" - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { - "assert-plus": "1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "1.3.0" - } - }, - "xml2js": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.7.tgz", - "integrity": "sha1-GDhRi7AXQcrgh4urSRXklMMjBq8=", - "requires": { - "sax": "0.5.2" - } - }, - "xmlbuilder": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.3.tgz", - "integrity": "sha1-xGFLp04K0ZbmCcknLNnh3bKKilg=" - } - } -} diff --git a/package.json b/package.json new file mode 100644 index 000000000..67ad4c636 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "AAGauss", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Matias-Benitez", + "license": "ISC", + "dependencies": { + } +} diff --git a/this.bot.config.json b/this.bot.config.json index 055d12565..f53d75989 100644 --- a/this.bot.config.json +++ b/this.bot.config.json @@ -7,38 +7,38 @@ "minor": 0, "patch": 0 }, - "devTeam": "AAMasters", + "devTeam": "AAVikings", "dataSetVersion": "dataSet.V1", "processes": [ { "name": "Multi-Period-Daily", - "description": "Produces files with the LRC Channel on a daily format.", + "description": "Produces files with the LRC Points on a daily format.", "startMode": { "allMonths": { - "run": "false", - "minYear": "", - "maxYear": "" + "run": "false", + "minYear": "", + "maxYear": "" }, "oneMonth": { - "run": "false", - "year": "", - "month": "" + "run": "false", + "year": "", + "month": "" }, "noTime": { - "run": "true" + "run": "true" }, "fixedInterval": { - "run": "false", - "interval": 0 + "run": "false", + "interval": 0 } - }, - "normalWaitTime": 100, + }, + "normalWaitTime": 50, "retryWaitTime": 10000, "sleepWaitTime": 3600000, "comaWaitTime": 86400000, "statusDependencies": [ { - "devTeam": "AAMasters", + "devTeam": "AAVikings", "bot": "AAGauss", "botVersion": { "major": 1, @@ -62,8 +62,8 @@ ], "products": [ { - "codeName": "LRCChannel", - "displayName": "LRCChannel", + "codeName": "LRCPoints", + "displayName": "LRCPoints", "description": "Two sets of files per period that contains LRC points.", "storageAccount": "aagauss", "dataSets": [ @@ -71,8 +71,12 @@ "codeName": "Multi-Period-Daily", "type": "Daily Files", "validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], - "filePath": "AAMasters/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Channel/Multi-Period-Daily/@Period/@Year/@Month/@Day", - "fileName": "@AssetA_@AssetB.json" + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } } ], "exchangeList": [ @@ -80,11 +84,11 @@ "name": "Poloniex" } ], - "plotter": { - "devTeam": "AAMasters", - "codeName": "PlotterLinearRegressionCurve", - "moduleName": "LRC" - } + "plotter": { + "devTeam": "AAVikings", + "codeName": "PlotterLinearRegressionCurve", + "moduleName": "LRC" + } } ]