From 62b5d5c9ea1a05922e211c9b84ff4395e6ce9043 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 2 Oct 2019 10:34:45 +0200 Subject: [PATCH] Time Period taken from Time Period Object --- TradingEngineProcessMainLoop.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/TradingEngineProcessMainLoop.js b/TradingEngineProcessMainLoop.js index ae56003d5..83798826a 100644 --- a/TradingEngineProcessMainLoop.js +++ b/TradingEngineProcessMainLoop.js @@ -107,7 +107,7 @@ processConfig.framework.startDate.resumeExecution = false; global.STOP_PROCESSING = false bot.hasTheBotJustStarted = true - setInitialBalance() + setValuesToUse() const ONE_YEAR_IN_MILISECONDS = 365 * 24 * 60 * 60 * 1000 /* If we can not get for any reason the initial date of the backtest, we will start at present time. */ @@ -182,21 +182,21 @@ bot.multiPeriodDailyProcessDatetime = processConfig.framework.startDate.fixedDate global.STOP_PROCESSING = false bot.hasTheBotJustStarted = true - setInitialBalance() + setValuesToUse() } function stopRequested() { global.STOP_PROCESSING = true } - function setInitialBalance() { + function setValuesToUse() { if (global.DEFINITION !== undefined) { - - /* Get the initial balance from the global.DEFINITION */ let tradingSystem = global.DEFINITION.tradingSystem if (tradingSystem) { if (tradingSystem.parameters !== undefined) { + + /* Decide which Initial Balance we are going to use. */ if (tradingSystem.parameters.baseAsset !== undefined) { let code try { @@ -233,6 +233,12 @@ } } + + /* Decide which Time Period we are going to use. If a TimePeriod is explicity defined we replace the one which was sent on simulation params.*/ + + if (tradingSystem.parameters.timePeriod !== undefined) { + global.DEFINITION.simulationParams.timePeriod = tradingSystem.parameters.timePeriod.code + } } } }