diff --git a/LowFrequencyTrading/TradingRecords.js b/LowFrequencyTrading/TradingRecords.js index ca81843e4..cb7ff4b0d 100644 --- a/LowFrequencyTrading/TradingRecords.js +++ b/LowFrequencyTrading/TradingRecords.js @@ -57,6 +57,17 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) { /* Clean the file from information of previous executions */ pruneOutputFile(product, outputDatasetArray) + /* Clean Open Records */ + if (product.config.saveAsObjects === true) { + for (let j = 0; j < product.record.properties.length; j++) { + let recordProperty = product.record.properties[j] + if (recordProperty.config.codeName === product.config.propertyNameThatDefinesObject) { + /* Remove Open Records */ + spliceOpenRecords(j, product, outputDatasetArray) + } + } + } + /* The product root can be a node or a node property of type array. */ @@ -99,9 +110,6 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) { if (recordProperty.config.codeName === product.config.propertyNameThatDefinesObject) { let propertyValue = record[j] - /* Remove Open Records */ - spliceOpenRecords(j, product, outputDatasetArray) - if (bot.processingDailyFiles) { /* When dealing with Daily Files, we need to avoid to write an open object at the last 'candle' of the day,