diff --git a/LowFrequencyTrading/TradingSimulation.js b/LowFrequencyTrading/TradingSimulation.js index 89255ae3f..fe81e4a1e 100644 --- a/LowFrequencyTrading/TradingSimulation.js +++ b/LowFrequencyTrading/TradingSimulation.js @@ -104,8 +104,9 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin */ for (let i = initialCandle; i < candles.length - 1; i++) { tradingEngine.current.episode.candle.index.value = i - if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Processing candle # ' + tradingEngine.current.episode.candle.index.value) } - let candle = candles[tradingEngine.current.episode.candle.index.value] // This is the current candle the Simulation is working at. + + /* This is the current candle the Simulation is working at. */ + let candle = candles[tradingEngine.current.episode.candle.index.value] if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Candle Begin @ ' + (new Date(candle.begin)).toLocaleString()) } if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Candle End @ ' + (new Date(candle.end)).toLocaleString()) } @@ -186,6 +187,10 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin tradingEpisodeModule.reset() tradingEngineModule.reset() + let infoMessage = 'Processing candle # ' + tradingEngine.current.episode.candle.index.value + ' @ the ' + tradingEngine.current.episode.cycle.value + ' cycle.' + if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> ' + infoMessage) } + tradingSystem.infos.push([tradingSystem.id, infoMessage]) + await tradingSystemModule.run() } diff --git a/LowFrequencyTrading/TradingSystem.js b/LowFrequencyTrading/TradingSystem.js index 5ee168a04..479ed7b66 100644 --- a/LowFrequencyTrading/TradingSystem.js +++ b/LowFrequencyTrading/TradingSystem.js @@ -87,6 +87,8 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM tradingSystem.highlights = undefined tradingSystem.errors = undefined + tradingSystem.warnings = undefined + tradingSystem.infos = undefined tradingSystem.values = undefined tradingSystem.status = undefined tradingSystem.progress = undefined @@ -106,6 +108,8 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM tradingSystem.highlights = [] tradingSystem.errors = [] + tradingSystem.warnings = [] + tradingSystem.infos = [] tradingSystem.values = [] tradingSystem.status = [] tradingSystem.progress = [] diff --git a/Session.js b/Session.js index 135b2cc68..7ad26a9b2 100644 --- a/Session.js +++ b/Session.js @@ -214,10 +214,19 @@ */ /* Initial Datetime */ - if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined || bot.SESSION.parameters.timeRange.config.allowStartingFromThePast !== true ) { - bot.SESSION.parameters.timeRange.config.initialDatetime = initialDefault + if (bot.SESSION.type === 'Backtesting Session') { + if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined ) { + bot.SESSION.parameters.timeRange.config.initialDatetime = initialDefault + } else { + bot.SESSION.parameters.timeRange.config.initialDatetime = (new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf() + } } else { - bot.SESSION.parameters.timeRange.config.initialDatetime = (new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf() + /* Non backtest session can start from the past only if explicitly configured that way */ + if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined || bot.SESSION.parameters.timeRange.config.allowStartingFromThePast !== true ) { + bot.SESSION.parameters.timeRange.config.initialDatetime = initialDefault + } else { + bot.SESSION.parameters.timeRange.config.initialDatetime = (new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf() + } } /* Final Datetime */