From d2bdd1f5df10ac5ace31aab1e66c647ea4d6abc1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 18 Oct 2019 09:42:34 +0200 Subject: [PATCH] Fordward Test finished --- Session.js | 32 ++++++++++++++++++++++++++++++++ server.js | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Session.js b/Session.js index cf857dcbe..6ff290bb4 100644 --- a/Session.js +++ b/Session.js @@ -136,6 +136,28 @@ bot.multiPeriodProcessDatetime = new Date(bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf()) bot.hasTheBotJustStarted = true + /* Reduce the balance */ + + let balancePercentage = 1 // This is the default value + try { + let code = JSON.parse(bot.SESSION.code) + + if (code.balancePercentage !== undefined) { + balancePercentage = code.balancePercentage + } + + } catch (err) { + parentLogger.write(MODULE_NAME, "[WARN] initialize -> startFordwardTesting -> Invalid value por balancePercentage. Using Default."); + } + + bot.VALUES_TO_USE.initialBalanceA = bot.VALUES_TO_USE.initialBalanceA * balancePercentage / 100 + bot.VALUES_TO_USE.initialBalanceB = bot.VALUES_TO_USE.initialBalanceB * balancePercentage / 100 + + bot.VALUES_TO_USE.minimumBalanceA = bot.VALUES_TO_USE.minimumBalanceA * balancePercentage / 100 + bot.VALUES_TO_USE.minimumBalanceB = bot.VALUES_TO_USE.minimumBalanceB * balancePercentage / 100 + + bot.VALUES_TO_USE.maximumBalanceA = bot.VALUES_TO_USE.maximumBalanceA * balancePercentage / 100 + bot.VALUES_TO_USE.maximumBalanceB = bot.VALUES_TO_USE.maximumBalanceB * balancePercentage / 100 } function startPaperTrading(message) { @@ -236,6 +258,16 @@ bot.VALUES_TO_USE.timeRange.finalDatetime = new Date((new Date()).valueOf() + ONE_YEAR_IN_MILISECONDS) break } + case 'Fordward Testing Session': { + bot.VALUES_TO_USE.timeRange.initialDatetime = new Date() + bot.VALUES_TO_USE.timeRange.finalDatetime = new Date((new Date()).valueOf() + ONE_YEAR_IN_MILISECONDS) + break + } + case 'Paper Trading Session': { + bot.VALUES_TO_USE.timeRange.initialDatetime = new Date() + bot.VALUES_TO_USE.timeRange.finalDatetime = new Date((new Date()).valueOf() + ONE_YEAR_IN_MILISECONDS) + break + } } let tradingSystem = bot.DEFINITION.tradingSystem diff --git a/server.js b/server.js index 184f140c5..06ed86a90 100644 --- a/server.js +++ b/server.js @@ -112,7 +112,7 @@ process.on('message', message => { There are some process that might no be able to end grafully, for example the ones schedulle to process information in a future day or month. In order to be sure that the process will be terminated, we schedulle one forced exit in 2 minutes from now. */ - console.log('[INFO] Task Server -> server -> process.on -> Executing order received from Task Manager to Stop this Task. Nodejs process will be exited in less than 1 minutes.') + console.log('[INFO] Task Server -> server -> process.on -> Executing order received from Task Manager to Stop this Task. Nodejs process will be exited in less than 1 minute.') setTimeout(global.EXIT_NODE_PROCESS, 60000); } });