From 6c2a8abf93b49a247e0d29e7d78a36da5b1debb2 Mon Sep 17 00:00:00 2001 From: Ferrox85 <64791738+Ferrox85@users.noreply.github.com> Date: Fri, 24 Sep 2021 10:37:09 +0200 Subject: [PATCH] Update Snapshots.js Added periods and a minor bug fix if the the undefined values happen before save --- .../Trading-Bot/Low-Frequency-Trading/Snapshots.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js index 1af896627..4a2ed0b9a 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js @@ -314,7 +314,7 @@ exports.newFoundationsBotModulesSnapshots = function(processIndex) { let qouteProfit = ((quoteClose / quoteOpen * 100) - 100) let baseProfit = ((baseClose / baseOpen * 100) - 100) - let closeHeaders = ['Trade Number', 'Open Datetime', 'Close Datetime', 'Strategy Name', 'Trigger On Situation', 'Take Position Situation', 'Open Position in Base Asset', 'Close Position in Base Asset', 'Open Position in Quoted Asset', 'Close Position in Quoted Asset', 'Result In Base Asset', 'Result In Quoted Asset', 'ROI in Base Asset', '% P/L Base Asset', 'P/L Type Base Asset', 'ROI in Quoted Asset', '% P/L Quoted Asset', 'P/L Type Quoted Asset', 'Exit Type'] + let closeHeaders = ['Trade Number', 'Open Datetime', 'Close Datetime', 'Strategy Name', 'Trigger On Situation', 'Take Position Situation', 'Open Position in Base Asset', 'Close Position in Base Asset', 'Open Position in Quoted Asset', 'Close Position in Quoted Asset', 'Result In Base Asset', 'Result In Quoted Asset', 'ROI in Base Asset', '% P/L Base Asset', 'P/L Type Base Asset', 'ROI in Quoted Asset', '% P/L Quoted Asset', 'P/L Type Quoted Asset', 'Exit Type', '# Periods'] closeValues = [ tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.positions.value, // Position Number (new Date(openDatetime)).toISOString(), // Open Datetime @@ -335,7 +335,8 @@ exports.newFoundationsBotModulesSnapshots = function(processIndex) { tradingEngine.tradingCurrent.position.positionQuotedAsset.ROI.value, // ROI in Quoted Asset <- not sure this works as intended qouteProfit + '%', // % profit loss in quoted Asset qouteProfit === 0 ? 'Even' : (qouteProfit > 0 ? "Profit" : "Loss"), - tradingEngine.tradingCurrent.position.exitType.value // Exit Type + tradingEngine.tradingCurrent.position.exitType.value, // Exit Type + tradingEngine.tradingCurrent.position.positionCounters.periods.value // periods counter ] if (createCloseHeaders === true) { @@ -394,7 +395,7 @@ exports.newFoundationsBotModulesSnapshots = function(processIndex) { function parseRecord(record) { // if we have undefined values, we need to extract the previous stored values for this trade and append them to the new record for completion - if (record[record.length - 1] === undefined) { + if (record[record.length - 1] === undefined && contentArray.length > 0) { let rowToMutateArray = contentArray[contentArray.length - 1].split(',') // check if are for sure on the same tradenumber and merge the data and remove previous line incl separator