diff --git a/.vs/AACloud/v15/.suo b/.vs/AACloud/v15/.suo index e77727f3a..a755e4915 100644 Binary files a/.vs/AACloud/v15/.suo and b/.vs/AACloud/v15/.suo differ diff --git a/Context.js b/Context.js index 741c0eaa9..c8eefe7a6 100644 --- a/Context.js +++ b/Context.js @@ -178,7 +178,7 @@ if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); } let fileName = "Execution.History.json" - let filePath = global.FILE_PATH_ROOT + "/Output/" + bot.process; + let filePath = bot.filePathRoot + "/Output/" + bot.process; if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> filePath = " + filePath); } @@ -239,7 +239,7 @@ let fileName = "Execution.Context.json" let dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2); - let filePath = global.FILE_PATH_ROOT + "/Output/" + bot.process + '/' + dateForPath; + let filePath = bot.filePathRoot + "/Output/" + bot.process + '/' + dateForPath; if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionContext -> filePath = " + filePath); } @@ -399,7 +399,7 @@ let fileName = "Execution.Context.json" let dateForPath = global.processDatetime.getUTCFullYear() + '/' + utilities.pad(global.processDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(global.processDatetime.getUTCDate(), 2) + '/' + utilities.pad(global.processDatetime.getUTCHours(), 2) + '/' + utilities.pad(global.processDatetime.getUTCMinutes(), 2); - let filePath = global.FILE_PATH_ROOT + "/Output/" + bot.process + '/' + dateForPath; + let filePath = bot.filePathRoot + "/Output/" + bot.process + '/' + dateForPath; if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> filePath = " + filePath); } @@ -459,7 +459,7 @@ if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> Entering function."); } let fileName = "Execution.History.json" - let filePath = global.FILE_PATH_ROOT + "/Output/" + bot.process; + let filePath = bot.filePathRoot + "/Output/" + bot.process; if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> filePath = " + filePath); } diff --git a/Run.js b/Run.js index da2b7b5f8..f859c51a1 100644 --- a/Run.js +++ b/Run.js @@ -25,35 +25,12 @@ global.EXCHANGE_SIMULATION_MODE = JSON.parse(global.PLATFORM_CONFIG.exchangeSimu global.STORAGE_CONN_STRING_FOLDER = global.PLATFORM_CONFIG.storageConnStringFolder; // 'Testnet', 'Mixed' or 'Production', or whatever folder name the conn strings files are into. -/* Now we will read the config of the bot from the path we obtained on the VM config. */ - -let botConfig; - -try { - - botConfig = JSON.parse(fs.readFileSync(global.PLATFORM_CONFIG.bot.path + '/this.bot.config.json', 'utf8')); -} -catch (err) { - console.log("[ERROR] 'readConfig' - ERROR : " + err.message); - return; -} - -let bot = { // TODO > REPLACE THIS FOR THE ENTIRE BOT CONFIGURATION. NOTE THAT NAME NOW IS CODENAME - "name": botConfig.displayName, - "type": botConfig.type, - "version": botConfig.version, - "devTeam": botConfig.devTeam -}; - /* Now we will run according to what we see at the config file. */ const ROOT_DIR = './'; const MODULE_NAME = "Run"; const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); -const logger = DEBUG_MODULE.newDebugLog(); -logger.fileName = MODULE_NAME; -logger.bot = botConfig; process.on('uncaughtException', function (err) { logger.write('uncaughtException - ' + err.message); @@ -140,9 +117,6 @@ global.dailyFilePeriods = global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods); -/* File Path Root */ - -global.FILE_PATH_ROOT = botConfig.devTeam + "/" + botConfig.codeName + "." + botConfig.version.major + "." + botConfig.version.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + botConfig.dataSetVersion; /* Loop Counter */ @@ -162,6 +136,40 @@ const TRADING_BOT_MAIN_LOOP_MODULE = require('./Trading Bot Main Loop'); const INDICATOR_BOT_MAIN_LOOP_MODULE = require('./Indicator Bot Main Loop'); const EXTRACTION_BOT_MAIN_LOOP_MODULE = require('./Extraction Bot Main Loop'); +/* Loop through all the processes configured to be run by this Node.js Instance. */ + +let logger; + +for (let p = 0; p < global.PLATFORM_CONFIG.executionList; p++) { + + let listItem = PLATFORM_CONFIG.executionList[p]; + + /* Now we will read the config of the bot from the path we obtained at the AACloud config. */ + + let botConfig; + + try { + + botConfig = JSON.parse(fs.readFileSync(global.PLATFORM_CONFIG.bot.path + '/this.bot.config.json', 'utf8')); + } + catch (err) { + console.log("[ERROR] 'readConfig' - ERROR : " + err.message); + return; + } + + logger = DEBUG_MODULE.newDebugLog(); + logger.fileName = MODULE_NAME; + logger.bot = botConfig; + + /* File Path Root */ + + bot.filePathRoot + botConfig.filePathRoot = botConfig.devTeam + "/" + botConfig.codeName + "." + botConfig.version.major + "." + botConfig.version.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + botConfig.dataSetVersion; + + +} + + /* Now we will see which are the script Arguments. We expect the name of the process to run, since that is what it should be defined at the Task Scheduller. */ let processToRun = process.argv[2]; @@ -226,7 +234,7 @@ for (let i = 0; i < botConfig.processes.length; i++) { let month = pad((new Date()).getUTCMonth() + 1, 2); let year = (new Date()).getUTCFullYear(); - switch (bot.type) { + switch (botConfig.type) { case 'Extraction': { runExtractionBot(processConfig, month, year); return; diff --git a/Status Report.js b/Status Report.js index 2d2c37fc5..19a764726 100644 --- a/Status Report.js +++ b/Status Report.js @@ -173,7 +173,7 @@ } let fileName = "Status.Report.json" - let filePath = global.FILE_PATH_ROOT + "/Reports/" + owner.process + timePath; + let filePath = bot.filePathRoot + "/Reports/" + owner.process + timePath; if (FULL_LOG === true) { logger.write("[INFO] save -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] save -> filePath = " + filePath); } diff --git a/this.config.json b/this.config.json index 539bb127a..b347619d5 100644 --- a/this.config.json +++ b/this.config.json @@ -8,6 +8,12 @@ "bot": { "path": "../Bots/AAMasters/AAMariam-Trading-Bot" }, + "executionList": [ + { + "botPath": "../Bots/AAMasters/AAMariam-Trading-Bot", + "process": "Trading-Process" + } + ], "stopGracefully": "false", "exchangeSimulationMode": "false", "storageConnStringFolder": "Production",