diff --git a/.vs/AACloudPlatform/v15/.suo b/.vs/AACloudPlatform/v15/.suo index 40fd77d6e..6b22e7c7e 100644 Binary files a/.vs/AACloudPlatform/v15/.suo and b/.vs/AACloudPlatform/v15/.suo differ diff --git a/Trading Bot Main Loop.js b/Trading Bot Main Loop.js index 3a2b05ead..7735c9399 100644 --- a/Trading Bot Main Loop.js +++ b/Trading Bot Main Loop.js @@ -324,6 +324,15 @@ if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> nextWaitTime = " + nextWaitTime); } + /* Here we check if we must stop the loop gracefully. */ + + if (shallWeStop() === true) { + + if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time! :-)"); } + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } + /* Trading 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) { @@ -339,6 +348,24 @@ break; } } + + function shallWeStop() { + + var fs = require('fs'); + let vmConfig; + + try { + + vmConfig = JSON.parse(fs.readFileSync('this.vm.config.json', 'utf8')); + return vmConfig.stopGrafully; + } + catch (err) { + const logText = "[ERROR] 'readConfig' - ERROR : " + err.message; + console.log(logText); + + return; + } + } } catch (err) { diff --git a/this.vm.config.json b/this.vm.config.json index 5d775bb42..4d1d36e09 100644 --- a/this.vm.config.json +++ b/this.vm.config.json @@ -1,5 +1,6 @@ { "bot": { "path": "../Bots/AAMasters/AAMariam-Trading-Bot" - } + }, + "stopGrafully": "false" } \ No newline at end of file