diff --git a/Exchange/wrappers/binanceClient.js b/Exchange/wrappers/binanceClient.js index a46ca7d24..e9208e283 100644 --- a/Exchange/wrappers/binanceClient.js +++ b/Exchange/wrappers/binanceClient.js @@ -309,7 +309,7 @@ return (exchangeErr, exchangeResponse) => { let error; - /* This function analizes the different situations we might encounter trying to access Poloniex and returns appropiate standard errors. */ + /* This function analizes the different situations we might encounter trying to access Binance and returns appropiate standard errors. */ let stringExchangeErr = JSON.stringify(exchangeErr); let stringExchangeResponse = JSON.stringify(exchangeResponse); diff --git a/MultiPeriodDaily.js b/MultiPeriodDaily.js index 7807f7126..4127b0c15 100644 --- a/MultiPeriodDaily.js +++ b/MultiPeriodDaily.js @@ -3,7 +3,6 @@ const FULL_LOG = true; const LOG_FILE_CONTENT = false; const MODULE_NAME = "Multi Period Daily"; - const EXCHANGE_NAME = "Poloniex"; const commons = COMMONS.newCommons(bot, logger, UTILITIES); const GMT_SECONDS = ':00.000 GMT+0000'; const ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000; diff --git a/MultiPeriodMarket.js b/MultiPeriodMarket.js index 20ade8176..9f8d7853f 100644 --- a/MultiPeriodMarket.js +++ b/MultiPeriodMarket.js @@ -2,11 +2,8 @@ const FULL_LOG = true; const LOG_FILE_CONTENT = false; - const MODULE_NAME = "Multi Period Market"; - const EXCHANGE_NAME = "Poloniex"; - const commons = COMMONS.newCommons(bot, logger, UTILITIES); thisObject = { diff --git a/Project.njsproj b/Project.njsproj index c9cb27126..79b200eb5 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -33,6 +33,7 @@ Code + Code @@ -66,7 +67,7 @@ Code - + Code diff --git a/Root.js b/Root.js index 86f99e4c1..1d8ebc007 100644 --- a/Root.js +++ b/Root.js @@ -188,7 +188,7 @@ const TRADING_BOT_MAIN_LOOP_MODULE = require('./TradingBotProcessMainLoop'); const INDICATOR_BOT_MAIN_LOOP_MODULE = require('./IndicatorBotProcessMainLoop'); - const EXTRACTION_BOT_MAIN_LOOP_MODULE = require('./ExtractionBotProcessMainLoop'); + const EXTRACTION_BOT_MAIN_LOOP_MODULE = require('./SensorBotProcessMainLoop'); /* Loop through all the processes configured to be run by this Node.js Instance. */ @@ -328,8 +328,8 @@ if (FULL_LOG === true) { console.log(logDisplace + "Root : [INFO] start -> findProcess -> startProcess -> Ready to start process."); } switch (botConfig.type) { - case 'Extraction': { - runExtractionBot(newInstanceBotConfig, processConfig, padMonth, year); + case 'Sensor': { + runSensorBot(newInstanceBotConfig, processConfig, padMonth, year); break; } case 'Indicator': { @@ -367,8 +367,8 @@ }; switch (botConfig.type) { - case 'Extraction': { - runExtractionBot(botConfig, processConfig, month, year); + case 'Sensor': { + runSensorBot(botConfig, processConfig, month, year); break; } case 'Indicator': { @@ -397,8 +397,8 @@ } switch (botConfig.type) { - case 'Extraction': { - runExtractionBot(botConfig, processConfig, month, year); + case 'Sensor': { + runSensorBot(botConfig, processConfig, month, year); break; } case 'Indicator': { @@ -423,8 +423,8 @@ let year = (new Date()).getUTCFullYear(); switch (botConfig.type) { - case 'Extraction': { - runExtractionBot(botConfig, processConfig, month, year); + case 'Sensor': { + runSensorBot(botConfig, processConfig, month, year); break; } default: { @@ -532,7 +532,7 @@ } - function runExtractionBot(pBotConfig, pProcessConfig, pMonth, pYear) { + function runSensorBot(pBotConfig, pProcessConfig, pMonth, pYear) { try { @@ -542,11 +542,11 @@ logger = DEBUG_MODULE.newDebugLog(); logger.bot = pBotConfig; - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runExtractionBot -> Entering function."); } - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runExtractionBot -> pMonth = " + pMonth); } - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runExtractionBot -> pYear = " + pYear); } + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runSensorBot -> Entering function."); } + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runSensorBot -> pMonth = " + pMonth); } + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runSensorBot -> pYear = " + pYear); } - let extractionBotMainLoop = EXTRACTION_BOT_MAIN_LOOP_MODULE.newExtractionBotProcessMainLoop(pBotConfig, logger); + let extractionBotMainLoop = EXTRACTION_BOT_MAIN_LOOP_MODULE.newSensorBotProcessMainLoop(pBotConfig, logger); extractionBotMainLoop.initialize(UI_COMMANDS, pProcessConfig, onInitializeReady); function onInitializeReady(err) { @@ -568,38 +568,38 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully."); - logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId); + logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully."); + logger.write(MODULE_NAME, "[INFO] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId); - console.log(logDisplace + "Root : [INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> botId = " + botId); - console.log(logDisplace + "Root : [INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully."); + console.log(logDisplace + "Root : [INFO] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> botId = " + botId); + console.log(logDisplace + "Root : [INFO] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully."); logger.persist(); } else { - logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message); - logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. "); - logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bye."); - logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId); + logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message); + logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. "); + logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bye."); + logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId); - console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> botId = " + botId); - console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution was aborted."); + console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> botId = " + botId); + console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> whenStartFinishes -> Bot execution was aborted."); logger.persist(); } } } else { - logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> err = " + err.message); - logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> Bot will not be started. "); - console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> err = " + err.message); + logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> err = " + err.message); + logger.write(MODULE_NAME, "[ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> Bot will not be started. "); + console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runSensorBot -> onInitializeReady -> err = " + err.message); logger.persist(); } } } catch (err) { - console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runExtractionBot -> err = " + err.message); + console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runSensorBot -> err = " + err.message); } } diff --git a/Run.js b/Run.js index 59cefc5fa..8231644e9 100644 --- a/Run.js +++ b/Run.js @@ -7,7 +7,7 @@ global.AT_BREAKPOINT = false; // This is used only when running at the browser. global.RUN_AS_TEAM = false; /* Default parameters can be changed by the execution configuration */ -global.EXCHANGE_NAME = "Poloniex"; +global.EXCHANGE_NAME = process.env.EXCHANGE_NAME; global.MARKET = { assetA: "USDT", assetB: "BTC" @@ -72,7 +72,7 @@ function readExecutionConfiguration() { backtest: backtest, competition: competition } - } else if (process.env.TYPE === 'Indicator' || process.env.TYPE === 'Extraction') { + } else if (process.env.TYPE === 'Indicator' || process.env.TYPE === 'Sensor') { let allMonths = { run: "false", minYear: process.env.MIN_YEAR, diff --git a/ExtractionBotProcessMainLoop.js b/SensorBotProcessMainLoop.js similarity index 99% rename from ExtractionBotProcessMainLoop.js rename to SensorBotProcessMainLoop.js index db8f5b7c7..7ce23337c 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/SensorBotProcessMainLoop.js @@ -1,8 +1,8 @@ -exports.newExtractionBotProcessMainLoop = function newExtractionBotProcessMainLoop(bot, parentLogger) { +exports.newSensorBotProcessMainLoop = function newSensorBotProcessMainLoop(bot, parentLogger) { const ROOT_DIR = './'; - const MODULE_NAME = "Extraction Bot Process Main Loop"; + const MODULE_NAME = "Sensor Bot Process Main Loop"; const FULL_LOG = true; let USER_BOT_MODULE; @@ -246,7 +246,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeExchangeAPI -> Entering function."); } - exchangeAPI = EXCHANGE_API.newExchangeAPI(logger, process.env.EXCHANGE_NAME); + exchangeAPI = EXCHANGE_API.newExchangeAPI(logger, global.EXCHANGE_NAME); exchangeAPI.initialize(onInizialized); @@ -581,7 +581,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> onContinue -> Entering function."); } - /* Extraction bots are going to be executed after a configured period of time after the last execution ended. This is to avoid overlapping executions. */ + /* Sensor bots are going to be executed after a configured period of time after the last execution ended. This is to avoid overlapping executions. */ switch (nextWaitTime) { case 'Normal': { diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index ac051348f..610635efb 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -598,7 +598,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeExchangeAPI -> Entering function."); } - exchangeAPI = EXCHANGE_API.newExchangeAPI(logger, process.env.EXCHANGE_NAME); + exchangeAPI = EXCHANGE_API.newExchangeAPI(logger, global.EXCHANGE_NAME); exchangeAPI.initialize(onInizialized); diff --git a/package-lock.json b/package-lock.json index 7ba6dd109..e8e2796f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { - "name": "AACloud", + "name": "CloneExecutor", "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@superalgos/mqservice": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@superalgos/mqservice/-/mqservice-0.0.3.tgz", - "integrity": "sha512-7beJRbcylkzND1MnWdEIrmtrqOyFvRsS131JKk6Xap5fFpS8kPpXKHEY50K97qwBnbTJZSJyNvSjafJPRUNjqQ==" + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@superalgos/mqservice/-/mqservice-0.0.9.tgz", + "integrity": "sha512-YH4BrDAE1+WmxBLu2JeVXzp/QiZwaKLLe6M+bh6ErliNGvGSOoB36/P5Vgmw6MDU81y6OU+hn5LqoRzESBW/CQ==" }, "@types/async": { "version": "2.0.49", @@ -304,6 +304,16 @@ "delayed-stream": "1.0.0" } }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -444,6 +454,11 @@ } } }, + "formidable": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", + "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==" + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -709,6 +724,16 @@ "inherits": "2.0.1" } }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", + "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==" + }, "mime-db": { "version": "1.36.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", @@ -837,6 +862,11 @@ "resolved": "http://registry.npmjs.org/sax/-/sax-0.5.8.tgz", "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=" }, + "semver": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", + "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==" + }, "simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -871,6 +901,76 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, + "superagent": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.0.2.tgz", + "integrity": "sha512-CqeqvwByDJuLwhcO6NOSuPatyQOIZX/TlvD5GJnXg5tzBTth2xQGZGdAZdo/kX+BtzvwJFX2IGGczTZgEIT7Wg==", + "requires": { + "component-emitter": "1.2.1", + "cookiejar": "2.1.2", + "debug": "4.1.1", + "form-data": "2.3.3", + "formidable": "1.2.1", + "methods": "1.1.2", + "mime": "2.4.0", + "qs": "6.7.0", + "readable-stream": "3.2.0", + "semver": "6.0.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "2.1.1" + } + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.7", + "mime-types": "2.1.20" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "2.0.3", + "string_decoder": "1.2.0", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "requires": { + "safe-buffer": "5.1.2" + } + } + } + }, "symbol-observable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", diff --git a/package.json b/package.json index 4e4e3afd8..16b2e2cd9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "AACloud", + "name": "CloneExecutor", "version": "1.0.0", "description": "", "main": "Run.js", @@ -22,6 +22,7 @@ "nonce": "^1.0.4", "querystring": "^0.2.0", "retry": "^0.12.0", + "superagent": "^5.0.2", "underscore": "^1.9.1", "winston": "^3.1.0" }