diff --git a/DebugLog.js b/DebugLog.js index 50b83f7f8..8f82f1c19 100644 --- a/DebugLog.js +++ b/DebugLog.js @@ -60,13 +60,6 @@ internalLoopCounter++; - if (global.CURRENT_EXECUTION_AT === "Browser") { - - //console.log("[INFO] DebugLog -> persist -> We do not persist logs while running at the Browser"); - return; - - } - let contentToPersist = accumulatedLog; accumulatedLog = "["; @@ -149,20 +142,12 @@ if (global.CURRENT_EXECUTION_AT === "IDE") { - console.log("AACloud" + spacePad(pModule, 50) + " : " + pMessage); + console.log("CloneExecutor" + spacePad(pModule, 50) + " : " + pMessage); } if (disableLogging === true) { return; } - if (global.CURRENT_EXECUTION_AT === "Browser") { - - /* Only at the browser we send the messages to the console. At the Cloud it does not make sense. */ - - console.log("AACloud" + spacePad(pModule, 50) + " : " + pMessage); - return; - } - if (global.CURRENT_EXECUTION_AT === "Node") { /* Only ERRORs go to the cloud console. */ @@ -170,7 +155,7 @@ if (pMessage.indexOf("[ERROR]") >= 0) { let now = new Date; - console.log("Loop." + pad(thisObject.bot.loopCounter, 8) + " " + now.toUTCString() + " AACloud " + spacePad(pModule, 20) + " : " + pMessage); + console.log("Loop." + pad(thisObject.bot.loopCounter, 8) + " " + now.toUTCString() + " CloneExecutor " + spacePad(pModule, 20) + " : " + pMessage); } } diff --git a/Exchange/ExchangeAPI.js b/Exchange/ExchangeAPI.js index 6e8f68098..1f29542b4 100644 --- a/Exchange/ExchangeAPI.js +++ b/Exchange/ExchangeAPI.js @@ -45,9 +45,7 @@ let auth = require('../utils/auth') let authTokenCloud = await auth.authenticate() accessToken = 'Bearer ' + authTokenCloud - } else if (global.CURRENT_EXECUTION_AT === "Browser") { - accessToken = 'Bearer ' + authToken - } + } let keyVaultAPI = createKeyVaultAPIClient(accessToken, keyId, cloneId) apiClient = api.newAPIClient(keyVaultAPI, logger); diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index b6dbe7ae5..8d1b4209c 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -47,25 +47,11 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { let filePath; - - switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. - case "Node": { - if (global.RUN_AS_TEAM) { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. - } 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": { - 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; - } - default: { - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; } + + if (global.RUN_AS_TEAM) { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + } 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. } const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire'); @@ -84,23 +70,8 @@ USER_BOT_MODULE = pMODULE; - switch (global.CURRENT_EXECUTION_AT) { - case "Node": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO; - break; - } - default: { - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - } - + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; + cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded); function onCommonsDownloaded(err, pMODULE) { @@ -714,34 +685,8 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. - case "Node": { - filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. - break; - } - case "Browser": { - if (global.SHALL_BOT_STOP === false) { - continueCallBack(); - } else { - stopCallBack(); - } - return; - } - default: { - logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - logger.persist(); - clearInterval(fixedTimeLoopIntervalHandle); - clearTimeout(nextLoopTimeoutHandle); - clearTimeout(checkLoopHealthHandle); - bot.enableCheckLoopHealth = false; - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - } - + let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. + let fileName = "this.config.json"; cloudStorage.getTextFile(filePath, fileName, onFileReceived); diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index 591aa6648..6de54adc5 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -50,25 +50,10 @@ let filePath; - switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. - case "Node": { - if (global.RUN_AS_TEAM) { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. - } 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": { - 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; - } - default: { - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } + if (global.RUN_AS_TEAM) { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + } 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. } const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire'); @@ -87,22 +72,7 @@ USER_BOT_MODULE = pMODULE; - switch (global.CURRENT_EXECUTION_AT) { - case "Node": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO; - break; - } - default: { - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - } + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded); @@ -948,34 +918,8 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. - case "Node": { - filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. - break; - } - case "Browser": { - if (global.SHALL_BOT_STOP === false) { - continueCallBack(); - } else { - stopCallBack(); - } - return; - } - default: { - logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - logger.persist(); - clearInterval(fixedTimeLoopIntervalHandle); - clearTimeout(nextLoopTimeoutHandle); - clearTimeout(checkLoopHealthHandle); - bot.enableCheckLoopHealth = false; - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - } - + let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. + let fileName = "this.config.json"; cloudStorage.getTextFile(filePath, fileName, onFileReceived); diff --git a/Root.js b/Root.js index 1cf6532fa..240117a74 100644 --- a/Root.js +++ b/Root.js @@ -74,7 +74,7 @@ let cloudStorage; - let logDisplace = "AACloud" + " "; + let logDisplace = "CloneExecutor" + " "; let UI_COMMANDS; return thisObject; @@ -137,21 +137,7 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { - case "Node": { - filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + "AACloud"; // DevTeam Members bots only are run at the browser. - break; - } - default: { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); - } - } + let filePath = global.DEV_TEAM + "/" + "CloneExecutor"; // DevTeams bots only are run at the cloud. let fileName = "this.config.json"; @@ -230,7 +216,7 @@ continue; } - /* Now we will read the config of the bot from the path we obtained at the AACloud config. */ + /* Now we will read the config of the bot from the path we obtained at the CloneExecutor config. */ let botConfig; @@ -250,28 +236,7 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { - case "Node": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + listItem.repo; // DevTeams bots only are run at the cloud. - - console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> Getting Bot Config from the devTeams's Bot. "); - console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> filePath = " + filePath); - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO; // DevTeam Members bots only are run at the browser. - - console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> Getting Bot Config from the endUser's Bot. "); - console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> global.USER_LOGGED_IN = " + global.USER_LOGGED_IN); - console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> filePath = " + filePath); - break; - } - default: { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); - } - } + let filePath = global.DEV_TEAM + "/" + "bots" + "/" + listItem.repo; // DevTeams bots only are run at the cloud. let fileName = "this.bot.config.json"; @@ -342,27 +307,11 @@ let processConfig = botConfig.processes[i]; - switch (global.CURRENT_EXECUTION_AT) { - case "Node": { - processConfig.startMode = global.EXECUTION_CONFIG.startMode // Override file storage configuration - if(global.EXECUTION_CONFIG.timePeriod){ - processConfig.timePeriod = global.EXECUTION_CONFIG.timePeriod - } - break; - } - case "Browser": { - let startMode = { - live: { run: "false" }, - backtest: { run: "false", waitTime: 5000 }, - competition: { run: "false" } - } - let browserStartMode = global.CURRENT_START_MODE.toLowerCase() - startMode[browserStartMode].run = "true" - - processConfig.startMode = startMode - break; - } + processConfig.startMode = global.EXECUTION_CONFIG.startMode // Override file storage configuration + if(global.EXECUTION_CONFIG.timePeriod){ + processConfig.timePeriod = global.EXECUTION_CONFIG.timePeriod } + try { /* We test each type of start Mode to get what to run and how. */ @@ -593,7 +542,7 @@ if (processFound === false) { - console.log(logDisplace + "Root : [ERROR] start -> findProcess -> Process listed at the configuration file of AACloud not found at the configuration file of the bot."); + console.log(logDisplace + "Root : [ERROR] start -> findProcess -> Process listed at the configuration file of CloneExecutor not found at the configuration file of the bot."); console.log(logDisplace + "Root : [ERROR] start -> findProcess -> listItem.process = " + listItem.process); } diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 4aceb006b..14ad87b49 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -61,16 +61,12 @@ break; } - case "Browser": { - 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 "IDE": { filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // This works like Cloud except of a few things. break; } default: { - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); + parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Node' or 'IDE'."); parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); callBackFunction(global.DEFAULT_FAIL_RESPONSE); return; @@ -93,23 +89,8 @@ USER_BOT_MODULE = pMODULE; - switch (global.CURRENT_EXECUTION_AT) { - case "Node": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO; - break; - } - default: { - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - } - + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; + cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded); function onCommonsDownloaded(err, pMODULE) { @@ -1131,34 +1112,8 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. - case "Node": { - filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. - break; - } - case "Browser": { - if (global.SHALL_BOT_STOP === false) { - continueCallBack(); - } else { - stopCallBack(); - } - return; - } - default: { - logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'."); - logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT); - logger.persist(); - clearInterval(fixedTimeLoopIntervalHandle); - clearTimeout(nextLoopTimeoutHandle); - clearTimeout(checkLoopHealthHandle); - bot.enableCheckLoopHealth = false; - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - } - + let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud. + let fileName = "this.config.json"; cloudStorage.getTextFile(filePath, fileName, onFileReceived);