diff --git a/Multi-Period-Daily/User.bot.js b/Multi-Period-Daily/User.bot.js index e39d563f5..03066c5d4 100644 --- a/Multi-Period-Daily/User.bot.js +++ b/Multi-Period-Daily/User.bot.js @@ -104,11 +104,7 @@ LRCIndicator.prototype.calculate = function (price) { } exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE) { -<<<<<<< HEAD const FULL_LOG = true; -======= - const FULL_LOG = false; ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d const LOG_FILE_CONTENT = false; const USE_PARTIAL_LAST_CANDLE = true; // When running live the last candle generated is a partial candle. @@ -293,11 +289,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> advanceTime -> Entering function."); } -<<<<<<< HEAD - executionTime = new Date(lastCandles[2] + (ONE_MIN_IN_MILISECONDS*30)); -======= executionTime = new Date(lastCandles[10] + ONE_MIN_IN_MILISECONDS); ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> advanceTime -> New processing time @ " + executionTime.toISOString()); } @@ -332,11 +324,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, isTimeToRun(); function isTimeToRun() { -<<<<<<< HEAD - let nextExecution = lastCandles[2] + outputPeriod; -======= let nextExecution = lastCandles[n] + outputPeriod; ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d if (executionTime.valueOf() >= nextExecution) { getLRCPoints(); } else { @@ -609,11 +597,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, } // We keep a record of the last candle used for the time period -<<<<<<< HEAD - lastCandles[2] = lrcPoint[0]; -======= lastCandles[n] = lrcPoint[0]; ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d controlLoop(); } @@ -642,11 +626,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, } // We keep a record of the last candle used for the time period -<<<<<<< HEAD - lastCandles[2] = lrcPoint[0]; -======= lastCandles[n] = lrcPoint[0]; ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d controlLoop(); } @@ -670,11 +650,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, loopBody(); } else { -<<<<<<< HEAD - let lastOneMinuteCandle = lastCandles[2]; -======= let lastOneMinuteCandle = lastCandles[10]; ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d writeDataRange(lastOneMinuteCandle, onWritten); function onWritten(err) { diff --git a/Multi-Period-Market/User.bot.js b/Multi-Period-Market/User.bot.js index 3898a6652..350ff1c96 100644 --- a/Multi-Period-Market/User.bot.js +++ b/Multi-Period-Market/User.bot.js @@ -1,4 +1,3 @@ -<<<<<<< HEAD var LRCIndicator = function (settings) { this.input = 'price'; this.depth = settings; @@ -105,9 +104,6 @@ LRCIndicator.prototype.calculate = function (price) { } exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE) { -======= -exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, BLOB_STORAGE) { ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d 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. @@ -411,7 +407,7 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, * Otherwise, continue with the one from the servers. * */ - let localDate = new Date(); + let localDate = new Date(); let now = new Date(Date.UTC( localDate.getUTCFullYear(), @@ -523,16 +519,9 @@ exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, try { -<<<<<<< HEAD if (FULL_LOG === true) { logger.write("[INFO] start -> savePoint -> Entering function."); } let filePath = bot.filePathRoot + "/Output/LRC-Points/Multi-Period-Market/" + folderName; -======= - 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-Points/Multi-Period-Daily/" + folderName + "/" + datePath; ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d let fileName = market.assetA + '_' + market.assetB + ".json" if (FULL_LOG === true) { logger.write("[INFO] start -> buildLRCPoints -> periodsLoop -> loopBody -> getCurrentContent -> fileName = " + fileName); } @@ -723,114 +712,3 @@ 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/this.bot.config.json b/this.bot.config.json index f90eb38e4..6994d3c35 100644 --- a/this.bot.config.json +++ b/this.bot.config.json @@ -11,13 +11,8 @@ "dataSetVersion": "dataSet.V1", "processes": [ { -<<<<<<< HEAD "name": "Multi-Period-Market", "description": "Produces files with the LRC Points for the entire market.", -======= - "name": "Multi-Period-Daily", - "description": "Produces files with the LRC Points on a daily format.", ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d "startMode": { "allMonths": { "run": "false", @@ -44,7 +39,6 @@ "statusDependencies": [ { "devTeam": "AAVikings", -<<<<<<< HEAD "bot": "AAGauss", "botVersion": { "major": 1, @@ -94,8 +88,6 @@ "statusDependencies": [ { "devTeam": "AAVikings", -======= ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d "bot": "AAGauss", "botVersion": { "major": 1, @@ -134,11 +126,7 @@ { "codeName": "Multi-Period-Daily", "type": "Daily Files", -<<<<<<< HEAD "validPeriods": [ "30-min" ], -======= - "validPeriods": [ "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], ->>>>>>> efa5470188c576eca370cc465a9a63946bdb4e8d "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": {