From ec46e9696c06aefa4bb632b8a4f2fe80461ba453 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 21 May 2020 22:58:48 +0200 Subject: [PATCH] Adding Records Correctly to all --- TradingBot.js | 30 +++--------------------------- TradingSimulation.js | 2 +- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/TradingBot.js b/TradingBot.js index 4efdb2a0e..051500fc0 100644 --- a/TradingBot.js +++ b/TradingBot.js @@ -216,6 +216,7 @@ exports.newTradingBot = function newTradingBot(bot, logger, UTILITIES, FILE_STOR } conditionsArray = JSON.parse(text) + conditionsArray = conditionsArray[1] // conditionsArray[0] = a snapshot of the trading system. readStrategiesFile() } catch (err) { logger.write(MODULE_NAME, '[ERROR] start -> readMarketFiles -> readConditionsFile -> onFileRead -> err = ' + err.stack) @@ -387,6 +388,7 @@ exports.newTradingBot = function newTradingBot(bot, logger, UTILITIES, FILE_STOR } conditionsArray = JSON.parse(text) + conditionsArray = conditionsArray[1] // conditionsArray[0] = a snapshot of the trading system. readStrategiesFile() } catch (err) { logger.write(MODULE_NAME, '[ERROR] start -> readDailyFiles -> readConditionsFile -> onFileRead -> err = ' + err.stack) @@ -564,34 +566,8 @@ exports.newTradingBot = function newTradingBot(bot, logger, UTILITIES, FILE_STOR try { if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] start -> writeMarketFiles -> writeConditionsFile -> Entering function.') } - let separator = '' - let fileRecordCounter = 0 + let fileContent = JSON.stringify(conditionsArray) - let fileContent = '' - - for (let i = 0; i < conditionsArray.length; i++) { - let record = conditionsArray[i] - - let conditions = '' - let conditionsSeparator = '' - - for (let j = 0; j < record.length - 3; j++) { - conditions = conditions + conditionsSeparator + record[j] - if (conditionsSeparator === '') { conditionsSeparator = ',' } - } - - conditions = conditions + conditionsSeparator + '[' + record[record.length - 3] + ']' // The last item contains an Array of condition values. - conditions = conditions + conditionsSeparator + '[' + record[record.length - 2] + ']' // The last item contains an Array of formulaErrors. - conditions = conditions + conditionsSeparator + '[' + record[record.length - 1] + ']' // The last item contains an Array of formulaValues. - - fileContent = fileContent + separator + '[' + conditions + ']' - - if (separator === '') { separator = ',' } - - fileRecordCounter++ - } - - fileContent = '[' + fileContent + ']' fileContent = '[' + JSON.stringify(tradingSystem) + ',' + fileContent + ']' let fileName = 'Data.json' diff --git a/TradingSimulation.js b/TradingSimulation.js index e1e2f4738..bf4258aec 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -2260,9 +2260,9 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT variable.current.position.end, variable.current.position.status, variable.current.position.stat.ROI, - variable.current.position.exitType, variable.current.position.beginRate, variable.current.position.endRate, + variable.current.position.exitType, '"' + variable.current.position.situationName + '"' ]