From ebd657f35e71df68adea71b3fa7442564916abf3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 25 Aug 2020 15:24:05 +0200 Subject: [PATCH] Update TradingSimulation.js --- LowFrequencyTrading/TradingSimulation.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/LowFrequencyTrading/TradingSimulation.js b/LowFrequencyTrading/TradingSimulation.js index 7937c46f5..eb70d24ac 100644 --- a/LowFrequencyTrading/TradingSimulation.js +++ b/LowFrequencyTrading/TradingSimulation.js @@ -148,6 +148,15 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin tradingEngineModule.setCurrentCycle('First') await runCycle() + /* + We check if we need to stop before appending the records so that the stop + reason is also propery recorded. Note also that we check this after the first + cycle, where orders have not been submitted to the exchange yet, but we + had the chance to check for the status of placed orders or even cancel + the ones that needed cancellation. + */ + checkIfWeNeedToStop() + /* Add new records to the process output */ tradingRecordsModule.appendRecords() @@ -163,12 +172,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin tradingEngineModule.setCurrentCycle('Second') await runCycle() - /* - We check if we need to stop before appending the records so that the stop - reason is also propery recorded. - */ - checkIfWeNeedToStop() - /* Add new records to the process output */ tradingRecordsModule.appendRecords()