diff --git a/.vs/AACloud/v15/.suo b/.vs/AACloud/v15/.suo index 3b5b7b810..6cc63b41b 100644 Binary files a/.vs/AACloud/v15/.suo and b/.vs/AACloud/v15/.suo differ diff --git a/Dependencies.js b/Dependencies.js index ae562375e..acd80df80 100644 --- a/Dependencies.js +++ b/Dependencies.js @@ -27,7 +27,7 @@ return thisObject; - function initialize(pDependenciesConfig, callBackFunction) { + function initialize(pDependenciesConfig, pMonth, pYear, callBackFunction) { try { @@ -45,7 +45,7 @@ let statusReportModule = STATUS_REPORT.newStatusReport(BOT, DEBUG_MODULE, FILE_STORAGE, UTILITIES); - statusReportModule.initialize(pDependenciesConfig[i], onInitilized); + statusReportModule.initialize(pDependenciesConfig[i], pMonth, pYear, onInitilized); function onInitilized(err) { @@ -69,7 +69,7 @@ switch (err.result) { case global.DEFAULT_OK_RESPONSE.result: { - logger.write("[INFO] initialize -> onLoad -> Execution finished well. :-)"); + logger.write("[INFO] initialize -> onLoad -> Execution finished well -> bot = " + pDependenciesConfig[i].bot); addReport(); return; @@ -80,7 +80,7 @@ if (err.message === "Status Report was never created.") { logger.write("[ERROR] initialize -> onLoad -> err.message = " + err.message); - logger.write("[ERROR] initialize -> onLoad -> pDependenciesConfig[i] = " + JSON.stringify(pDependenciesConfig[i])); + logger.write("[ERROR] initialize -> onLoad -> Report Not Found. -> bot = " + pDependenciesConfig[i].bot); addReport(); return; } else { diff --git a/Extraction Bot Main Loop.js b/Extraction Bot Main Loop.js index a449645d9..e37f7d5cd 100644 --- a/Extraction Bot Main Loop.js +++ b/Extraction Bot Main Loop.js @@ -45,7 +45,7 @@ } } - function run(callBackFunction) { + function run(pMonth, pYear, callBackFunction) { try { if (FULL_LOG === true) { logger.write("[INFO] run -> Entering function."); } @@ -87,7 +87,7 @@ dependencies = DEPENDENCIES.newDependencies(bot, DEBUG_MODULE, STATUS_REPORT, FILE_STORAGE, UTILITIES); - dependencies.initialize(processConfig.dependencies, onInizialized); + dependencies.initialize(processConfig.dependencies, pMonth, pYear, onInizialized); function onInizialized(err) { @@ -118,7 +118,7 @@ usertBot = USER_BOT_MODULE.newUserBot(bot, COMMONS_MODULE, UTILITIES, DEBUG_MODULE, FILE_STORAGE, STATUS_REPORT, POLONIEX_CLIENT_MODULE); - usertBot.initialize(dependencies, onInizialized, undefined, undefined); + usertBot.initialize(dependencies, pMonth, pYear, onInizialized); function onInizialized(err) { diff --git a/Indicator Bot Main Loop.js b/Indicator Bot Main Loop.js index 282d4bdf0..56b7b1129 100644 --- a/Indicator Bot Main Loop.js +++ b/Indicator Bot Main Loop.js @@ -45,7 +45,7 @@ } } - function run(callBackFunction) { + function run(pMonth, pYear, callBackFunction) { try { if (FULL_LOG === true) { logger.write("[INFO] run -> Entering function."); } @@ -85,7 +85,7 @@ dependencies = DEPENDENCIES.newDependencies(bot, DEBUG_MODULE, STATUS_REPORT, FILE_STORAGE, UTILITIES); - dependencies.initialize(processConfig.dependencies, onInizialized); + dependencies.initialize(processConfig.dependencies, pMonth, pYear, onInizialized); function onInizialized(err) { @@ -116,7 +116,7 @@ usertBot = USER_BOT_MODULE.newUserBot(bot, COMMONS_MODULE, UTILITIES, DEBUG_MODULE, FILE_STORAGE); - usertBot.initialize(dependencies, onInizialized, undefined, undefined); + usertBot.initialize(dependencies, pMonth, pYear, onInizialized); function onInizialized(err) { diff --git a/Project.njsproj b/Project.njsproj index 566e4c4e7..0a0aa8aa4 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -13,7 +13,7 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) Project - Multi-Period-Market + Multi-Period-Daily C:\Program Files\nodejs\node.exe False diff --git a/Run.js b/Run.js index 210c0fb0d..da2b7b5f8 100644 --- a/Run.js +++ b/Run.js @@ -148,6 +148,13 @@ global.FILE_PATH_ROOT = botConfig.devTeam + "/" + botConfig.codeName + "." + bot global.loopCointer = 0; +/* Small Function to fix numbers into strings in a cool way. */ + +function pad(str, max) { + str = str.toString(); + return str.length < max ? pad("0" + str, max) : str; +} + /* Some LAGACY code starts here. Pending for clean up. */ const INTERVAL_EXECUTOR_MODULE = require('./Interval Executor'); @@ -215,24 +222,25 @@ for (let i = 0; i < botConfig.processes.length; i++) { if (processConfig.startMode.noTime.run === "true") { - startProcess(); - function startProcess() { - switch (bot.type) { - case 'Extraction': { - runExtractionBot(processConfig); - return; - } - case 'Indicator': { - runIndicatorBot(processConfig); - return; - } - case 'Trading': { - runTradingBot(processConfig); - return; - } + let month = pad((new Date()).getUTCMonth() + 1, 2); + let year = (new Date()).getUTCFullYear(); + + switch (bot.type) { + case 'Extraction': { + runExtractionBot(processConfig, month, year); + return; + } + case 'Indicator': { + runIndicatorBot(processConfig, month, year); + return; + } + case 'Trading': { + runTradingBot(processConfig); + return; } } + } } catch (err) { @@ -242,7 +250,7 @@ for (let i = 0; i < botConfig.processes.length; i++) { } } -function runExtractionBot(pProcessConfig) { +function runExtractionBot(pProcessConfig, pMonth, pYear) { try { if (FULL_LOG === true) { logger.write("[INFO] runExtractionBot -> Entering function."); } @@ -254,7 +262,7 @@ function runExtractionBot(pProcessConfig) { if (err.result === global.DEFAULT_OK_RESPONSE.result) { - extractionBotMainLoop.run(whenRunFinishes); + extractionBotMainLoop.run(pMonth, pYear, whenRunFinishes); function whenRunFinishes(err) { @@ -282,7 +290,7 @@ function runExtractionBot(pProcessConfig) { } } -function runIndicatorBot(pProcessConfig) { +function runIndicatorBot(pProcessConfig, pMonth, pYear) { try { if (FULL_LOG === true) { logger.write("[INFO] runIndicatorBot -> Entering function."); } @@ -294,7 +302,7 @@ function runIndicatorBot(pProcessConfig) { if (err.result === global.DEFAULT_OK_RESPONSE.result) { - indicatorBotMainLoop.run(whenRunFinishes); + indicatorBotMainLoop.run(pMonth, pYear, whenRunFinishes); function whenRunFinishes(err) { diff --git a/Status Report.js b/Status Report.js index 7868fe353..2d2c37fc5 100644 --- a/Status Report.js +++ b/Status Report.js @@ -35,17 +35,31 @@ let cloudStorage = FILE_STORAGE.newFileStorage(bot); + let month; + let year; + let timePath = ''; + return thisObject; - function initialize(pOwner, callBackFunction) { + function initialize(pOwner, pMonth, pYear, callBackFunction) { try { logger.fileName = MODULE_NAME + "." + pOwner.bot; + owner = pOwner; + month = pMonth; + year = pYear; + + if (owner.dataSetSection === "Month") { + + logger.fileName = MODULE_NAME + "." + pOwner.bot + "." + year + "." + month; + + timePath = "/" + year + "/" + month; + } + if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } - owner = pOwner; initializeStorage(); @@ -80,7 +94,7 @@ let rootPath = owner.devTeam + "/" + owner.bot + "." + owner.botVersion.major + "." + owner.botVersion.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + owner.dataSetVersion; let fileName = "Status.Report.json" - let filePath = rootPath + "/Reports/" + owner.process; + let filePath = rootPath + "/Reports/" + owner.process + timePath; if (FULL_LOG === true) { logger.write("[INFO] initialize -> load -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] initialize -> load -> filePath = " + filePath); } @@ -159,7 +173,7 @@ } let fileName = "Status.Report.json" - let filePath = global.FILE_PATH_ROOT + "/Reports/" + owner.process; + let filePath = global.FILE_PATH_ROOT + "/Reports/" + owner.process + timePath; if (FULL_LOG === true) { logger.write("[INFO] save -> fileName = " + fileName); } if (FULL_LOG === true) { logger.write("[INFO] save -> filePath = " + filePath); }