From c7a2c383b6c888e7546b5dc6e74ba9ec2f994ca0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jul 2020 09:25:56 +0200 Subject: [PATCH] Update TradingRecords.js --- LowFrequencyTrading/TradingRecords.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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,