From 07aedb0563ec01f978fad372317e287a86f499ee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 6 Mar 2019 18:05:13 +0100 Subject: [PATCH] See conditions dinamically --- TradingSimulation.js | 27 +++++++++++++++++++++------ TradingSimulationPanel.js | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/TradingSimulation.js b/TradingSimulation.js index 80493171d..f7b465f0c 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -426,7 +426,8 @@ strategyPhase: undefined, buyOrder: undefined, stopLossPhase: undefined, - buyOrderPhase: undefined + buyOrderPhase: undefined, + conditions: undefined }; record.begin = marketFile[i][0]; @@ -454,6 +455,11 @@ record.buyOrder = marketFile[i][22]; record.stopLossPhase = marketFile[i][23]; record.buyOrderPhase = marketFile[i][24]; + record.conditions = marketFile[i][25]; + + if (i === 0) { // The first record contains headers needed to be printed. + records.push(record); + } if (record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) { @@ -875,11 +881,6 @@ /* highlight the current record */ browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', 1)'; // Current record accroding to time - - let currentRecord = { - innerRecord: record - }; - thisObject.container.eventHandler.raiseEvent("Current Record Changed", currentRecord); } } @@ -1025,6 +1026,20 @@ } } + /* Send the current record to the panel */ + + if (datetime !== undefined) { + let dateValue = datetime.valueOf(); + if (dateValue >= record.begin && dateValue <= record.end) { + + let currentRecord = { + conditionsNames: records[0].conditions, + conditionsValues: record.conditions, + innerRecord: record + }; + thisObject.container.eventHandler.raiseEvent("Current Record Changed", currentRecord); + } + } /* This is how we write the text */ diff --git a/TradingSimulationPanel.js b/TradingSimulationPanel.js index 662405276..bbc814680 100644 --- a/TradingSimulationPanel.js +++ b/TradingSimulationPanel.js @@ -23,7 +23,7 @@ function newAAMastersPlottersTradingSimulationTradingSimulationTradingSimulation function initialize() { thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL; - thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.5; + thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 2; thisObject.container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 1; thisObject.container.frame.position.y = viewPort.visibleArea.topRight.y; @@ -166,7 +166,7 @@ function newAAMastersPlottersTradingSimulationTradingSimulationTradingSimulation let y = 0; - let increment = 0.03; + let increment = 0.025; y = y + increment; printLabel('Balance A', X_AXIS, frameTitleHeight + frameBodyHeight * y, '1'); @@ -248,6 +248,20 @@ function newAAMastersPlottersTradingSimulationTradingSimulationTradingSimulation y = y + increment; printLabel((currentRecord.innerRecord.anualizedRateOfReturn * 100).toFixed(2) + ' %', X_AXIS, frameTitleHeight + frameBodyHeight * y, '0.50'); + y = y + increment; + y = y + increment; + + for (let i = 0; i < currentRecord.conditionsNames.length; i++) { + y = y + increment; + let opacity; + if (currentRecord.conditionsValues[i] === 1) { + opacity = '1.00' + } else { + opacity = '0.50'; + } + printLabel(currentRecord.conditionsNames[i], X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity); + } + function printLabel(labelToPrint, x, y, opacity) { let labelPoint;