From 3af01296d3a3eb7dcb450bcd631a0badae66ad6b Mon Sep 17 00:00:00 2001 From: Matias Date: Fri, 22 Mar 2019 18:33:18 +0100 Subject: [PATCH] Individual parameters --- Root.js | 4 +-- Run.js | 43 ++++++++++++++++--------------- TradingBotProcessMainLoop.js | 28 ++++++++++----------- package-lock.json | 49 ------------------------------------ package.json | 1 - 5 files changed, 37 insertions(+), 88 deletions(-) diff --git a/Root.js b/Root.js index 6938a84ed..f2c4737fb 100644 --- a/Root.js +++ b/Root.js @@ -345,8 +345,8 @@ switch (global.CURRENT_EXECUTION_AT) { case "Cloud": { processConfig.startMode = global.EXECUTION_CONFIG.startMode // Override file storage configuration - if(global.EXECUTION_CONFIG.timePeriod){ - processConfig.timePeriod = Number(global.EXECUTION_CONFIG.timePeriod) + if(global.TIME_PERIOD){ + processConfig.timePeriod = global.TIME_PERIOD } break; } diff --git a/Run.js b/Run.js index 52f7889a5..0610f0498 100644 --- a/Run.js +++ b/Run.js @@ -137,30 +137,29 @@ function readExecutionConfiguration() { } function getTimePeriod(){ - if(process.env.EXECUTION_PARAMETERS !== undefined){ + if(process.env.TIME_PERIOD !== undefined){ try { - let executionParameters = JSON.parse(process.env.EXECUTION_PARAMETERS) let timePeriodMap = new Map() - timePeriodMap.set("24-hs","86400000") - timePeriodMap.set("12-hs","43200000") - timePeriodMap.set("08-hs","28800000") - timePeriodMap.set("06-hs","21600000") - timePeriodMap.set("04-hs","14400000") - timePeriodMap.set("03-hs","10800000") - timePeriodMap.set("02-hs","7200000") - timePeriodMap.set("01-hs","3600000") - timePeriodMap.set("45-min","2700000") - timePeriodMap.set("40-min","2400000") - timePeriodMap.set("30-min","1800000") - timePeriodMap.set("20-min","1200000") - timePeriodMap.set("15-min","900000") - timePeriodMap.set("10-min","600000") - timePeriodMap.set("05-min","300000") - timePeriodMap.set("04-min","240000") - timePeriodMap.set("03-min","180000") - timePeriodMap.set("02-min","120000") - timePeriodMap.set("01-min","60000") - return timePeriodMap.get(executionParameters.timePeriod) + timePeriodMap.set("24-hs", 86400000) + timePeriodMap.set("12-hs", 43200000) + timePeriodMap.set("08-hs", 28800000) + timePeriodMap.set("06-hs", 21600000) + timePeriodMap.set("04-hs", 14400000) + timePeriodMap.set("03-hs", 10800000) + timePeriodMap.set("02-hs", 7200000) + timePeriodMap.set("01-hs", 3600000) + timePeriodMap.set("45-min", 2700000) + timePeriodMap.set("40-min", 2400000) + timePeriodMap.set("30-min", 1800000) + timePeriodMap.set("20-min", 1200000) + timePeriodMap.set("15-min", 900000) + timePeriodMap.set("10-min", 600000) + timePeriodMap.set("05-min", 300000) + timePeriodMap.set("04-min", 240000) + timePeriodMap.set("03-min", 180000) + timePeriodMap.set("02-min", 120000) + timePeriodMap.set("01-min", 60000) + return timePeriodMap.get(process.env.TIME_PERIOD) } catch (error) { console.log( "[WARN] Run -> readExecutionConfiguration -> getTimePeriod -> Error: ", error); } diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 9d6e6cab5..0f5185b48 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -14,7 +14,7 @@ const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog'); let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble. - let nextLoopTimeoutHandle; + let nextLoopTimeoutHandle; let checkLoopHealthHandle; let thisObject = { @@ -25,7 +25,7 @@ bot["botCache"] = new Map(); let processConfig; let cloudStorage; - let UI_COMMANDS; + let UI_COMMANDS; return thisObject; @@ -58,7 +58,7 @@ } else { filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. } - + break; } case "Browser": { @@ -145,7 +145,7 @@ try { if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[INFO] run -> Entering function."); } - bot.enableCheckLoopHealth = true; + bot.enableCheckLoopHealth = true; let fixedTimeLoopIntervalHandle; @@ -248,7 +248,7 @@ } else { - bot.processDatetime = new Date(bot.backtest.beginDatetime); // Set the starting time as the configured beginDatetime. + bot.processDatetime = new Date(bot.backtest.beginDatetime); // Set the starting time as the configured beginDatetime. } @@ -263,7 +263,7 @@ } else { - bot.processDatetime = new Date(bot.processDatetime.valueOf() + timePeriod); // We advance time here. + bot.processDatetime = new Date(bot.processDatetime.valueOf() + timePeriod); // We advance time here. if (UI_COMMANDS.eventHandler !== undefined) { @@ -276,11 +276,11 @@ if (UI_COMMANDS.endDatetime !== undefined) { - endDatetime = new Date(UI_COMMANDS.endDatetime.valueOf()); + endDatetime = new Date(UI_COMMANDS.endDatetime.valueOf()); } else { - endDatetime = new Date(bot.backtest.endDatetime); + endDatetime = new Date(bot.backtest.endDatetime); } @@ -381,7 +381,7 @@ + " " + bot.startMode + " Entered into Main Loop # " + pad(Number(bot.loopCounter), 8) + " bot.processDatetime = " + bot.processDatetime.toISOString()); /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ - + let exchangeAPI; let assistant; let userBot; @@ -537,7 +537,7 @@ callBackFunction(err); } } - + function initializeContext() { try { @@ -864,7 +864,7 @@ clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); - bot.enableCheckLoopHealth = false; + bot.enableCheckLoopHealth = false; callBackFunction(err); return; } @@ -1007,7 +1007,7 @@ nextWaitTime = 'Normal'; loopControl(nextWaitTime); - + } catch (err) { logger.write(MODULE_NAME, "[ERROR] run -> loop -> updateClonesModule -> err = " + err.message); logger.write(MODULE_NAME, "[ERROR] run -> loop -> updateClonesModule -> Execution will continue anyways. "); @@ -1167,7 +1167,7 @@ if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - /* + /* If for any reason this config file cannot be read, we are not going to abort the loop for that. Instead we are going to assume that there are no instructions to stop and we will keep the show running. */ @@ -1217,7 +1217,7 @@ } } catch (err) { - parentLogger.write(MODULE_NAME, "[ERROR] run -> loop -> err = " + err.message); + parentLogger.write(MODULE_NAME, "[ERROR] run -> loop -> err = " + err.stack); clearInterval(fixedTimeLoopIntervalHandle); clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); diff --git a/package-lock.json b/package-lock.json index 1180a7ec5..72604727b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,45 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@azure/ms-rest-js": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-1.2.3.tgz", - "integrity": "sha512-eROQ034b+9v0Hd3wETKi/EwF5pqS3VRAk1Lm8iKVPOP8v30f6Zfzsi420MRfBMsbNCx/mE2N0L65Px7tvcGfVg==", - "requires": { - "axios": "^0.18.0", - "form-data": "^2.3.2", - "tough-cookie": "^2.4.3", - "tslib": "^1.9.2", - "uuid": "^3.2.1", - "xml2js": "^0.4.19" - }, - "dependencies": { - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, - "xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" - } - } - } - }, - "@azure/storage-blob": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-10.3.0.tgz", - "integrity": "sha512-KZbJ3q8RpAdeIB5Em1lgXkiq7Mll9bSHHbHavOFMepkkF7HQa3Sez9FdkAVIkVVWK5YoBlshBGZ+mtiSQiS9Fw==", - "requires": { - "@azure/ms-rest-js": "1.2.3", - "events": "3.0.0", - "tslib": "^1.9.3" - } - }, "@types/async": { "version": "2.0.49", "resolved": "https://registry.npmjs.org/@types/async/-/async-2.0.49.tgz", @@ -410,11 +371,6 @@ "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" }, - "events": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", - "integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==" - }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -934,11 +890,6 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index 321b779f7..90a19c944 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "author": "Luis-Fernando-Molina", "license": "ISC", "dependencies": { - "@azure/storage-blob": "^10.3.0", "apollo-boost": "^0.1.16", "assert": "^1.4.1", "axios": "^0.18.0",