From 2e98b587f69eaf1fb704fe9ac8070d7d0c8ee453 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 18:38:23 +0100 Subject: [PATCH] Refactoring --- Conditions.js | 14 +++++++------- SimulationExecution.js | 36 ++++++++++++++++++------------------ Strategies.js | 22 +++++++++++----------- Trades.js | 20 ++++++++++---------- TradingSimulation.js | 34 +++++++++++++++++----------------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/Conditions.js b/Conditions.js index ca66bc756..8f39f4f3a 100644 --- a/Conditions.js +++ b/Conditions.js @@ -35,7 +35,7 @@ container.initialize(); thisObject.container = container; - let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -312,8 +312,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -394,8 +394,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -449,7 +449,7 @@ try { - if (timeLineCoordinateSystem.maxValue > 0) { return; } // Already calculated. + if (coordinateSystem.maxValue > 0) { return; } // Already calculated. let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), @@ -462,7 +462,7 @@ }; - timeLineCoordinateSystem.initialize( + coordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, diff --git a/SimulationExecution.js b/SimulationExecution.js index 315e2ede8..12f9fcd1d 100644 --- a/SimulationExecution.js +++ b/SimulationExecution.js @@ -26,7 +26,7 @@ container.initialize(); thisObject.container = container; - let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -308,7 +308,7 @@ try { if (fileSequence === undefined) { return; } // We need the market file to be loaded to make the calculation. - if (timeLineCoordinateSystem.maxValue > 0) { return; } // Already calculated. + if (coordinateSystem.maxValue > 0) { return; } // Already calculated. let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), @@ -320,7 +320,7 @@ y: nextPorwerOf10(USDT_BTC_HTH) / 4 // TODO: This 4 is temporary }; - timeLineCoordinateSystem.initialize( + coordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, @@ -366,7 +366,7 @@ y: record.marketRate }; - point = timeLineCoordinateSystem.transformThisPoint(point); + point = coordinateSystem.transformThisPoint(point); point = transformThisPoint(point, thisObject.container); if (point.x < viewPort.visibleArea.bottomLeft.x || point.x > viewPort.visibleArea.bottomRight.x) { continue; } @@ -406,15 +406,15 @@ y: record.sellExecRate }; - point1 = timeLineCoordinateSystem.transformThisPoint(point1); + point1 = coordinateSystem.transformThisPoint(point1); point1 = transformThisPoint(point1, thisObject.container); point1 = viewPort.fitIntoVisibleArea(point1); - point2 = timeLineCoordinateSystem.transformThisPoint(point2); + point2 = coordinateSystem.transformThisPoint(point2); point2 = transformThisPoint(point2, thisObject.container); point2 = viewPort.fitIntoVisibleArea(point2); - point3 = timeLineCoordinateSystem.transformThisPoint(point3); + point3 = coordinateSystem.transformThisPoint(point3); point3 = transformThisPoint(point3, thisObject.container); point3 = viewPort.fitIntoVisibleArea(point3); @@ -476,15 +476,15 @@ y: record.buyExecRate }; - point1 = timeLineCoordinateSystem.transformThisPoint(point1); + point1 = coordinateSystem.transformThisPoint(point1); point1 = transformThisPoint(point1, thisObject.container); point1 = viewPort.fitIntoVisibleArea(point1); - point2 = timeLineCoordinateSystem.transformThisPoint(point2); + point2 = coordinateSystem.transformThisPoint(point2); point2 = transformThisPoint(point2, thisObject.container); point2 = viewPort.fitIntoVisibleArea(point2); - point3 = timeLineCoordinateSystem.transformThisPoint(point3); + point3 = coordinateSystem.transformThisPoint(point3); point3 = transformThisPoint(point3, thisObject.container); point3 = viewPort.fitIntoVisibleArea(point3); @@ -544,15 +544,15 @@ y: record.lastSellRate }; - point1 = timeLineCoordinateSystem.transformThisPoint(point1); + point1 = coordinateSystem.transformThisPoint(point1); point1 = transformThisPoint(point1, thisObject.container); point1 = viewPort.fitIntoVisibleArea(point1); - point2 = timeLineCoordinateSystem.transformThisPoint(point2); + point2 = coordinateSystem.transformThisPoint(point2); point2 = transformThisPoint(point2, thisObject.container); point2 = viewPort.fitIntoVisibleArea(point2); - point3 = timeLineCoordinateSystem.transformThisPoint(point3); + point3 = coordinateSystem.transformThisPoint(point3); point3 = transformThisPoint(point3, thisObject.container); point3 = viewPort.fitIntoVisibleArea(point3); @@ -613,15 +613,15 @@ y: record.lastBuyRate }; - point1 = timeLineCoordinateSystem.transformThisPoint(point1); + point1 = coordinateSystem.transformThisPoint(point1); point1 = transformThisPoint(point1, thisObject.container); point1 = viewPort.fitIntoVisibleArea(point1); - point2 = timeLineCoordinateSystem.transformThisPoint(point2); + point2 = coordinateSystem.transformThisPoint(point2); point2 = transformThisPoint(point2, thisObject.container); point2 = viewPort.fitIntoVisibleArea(point2); - point3 = timeLineCoordinateSystem.transformThisPoint(point3); + point3 = coordinateSystem.transformThisPoint(point3); point3 = transformThisPoint(point3, thisObject.container); point3 = viewPort.fitIntoVisibleArea(point3); @@ -731,11 +731,11 @@ y: line.y2 }; - point1 = timeLineCoordinateSystem.transformThisPoint(point1); + point1 = coordinateSystem.transformThisPoint(point1); point1 = transformThisPoint(point1, thisObject.container); point1 = viewPort.fitIntoVisibleArea(point1); - point2 = timeLineCoordinateSystem.transformThisPoint(point2); + point2 = coordinateSystem.transformThisPoint(point2); point2 = transformThisPoint(point2, thisObject.container); point2 = viewPort.fitIntoVisibleArea(point2); diff --git a/Strategies.js b/Strategies.js index b0fbb4f82..a84b3de64 100644 --- a/Strategies.js +++ b/Strategies.js @@ -35,7 +35,7 @@ container.initialize(); thisObject.container = container; - let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -317,8 +317,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -397,8 +397,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -450,7 +450,7 @@ try { - if (timeLineCoordinateSystem.maxValue > 0) { return; } // Already calculated. + if (coordinateSystem.maxValue > 0) { return; } // Already calculated. let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), @@ -463,7 +463,7 @@ }; - timeLineCoordinateSystem.initialize( + coordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, @@ -511,10 +511,10 @@ y: record.endRate }; - recordPoint1 = timeLineCoordinateSystem.transformThisPoint(recordPoint1); - recordPoint2 = timeLineCoordinateSystem.transformThisPoint(recordPoint2); - recordPoint3 = timeLineCoordinateSystem.transformThisPoint(recordPoint3); - recordPoint4 = timeLineCoordinateSystem.transformThisPoint(recordPoint4); + recordPoint1 = coordinateSystem.transformThisPoint(recordPoint1); + recordPoint2 = coordinateSystem.transformThisPoint(recordPoint2); + recordPoint3 = coordinateSystem.transformThisPoint(recordPoint3); + recordPoint4 = coordinateSystem.transformThisPoint(recordPoint4); recordPoint1 = transformThisPoint(recordPoint1, thisObject.container); recordPoint2 = transformThisPoint(recordPoint2, thisObject.container); diff --git a/Trades.js b/Trades.js index d059b5f28..8caedd9e2 100644 --- a/Trades.js +++ b/Trades.js @@ -35,7 +35,7 @@ container.initialize(); thisObject.container = container; - let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -310,8 +310,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -384,8 +384,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -431,7 +431,7 @@ try { - if (timeLineCoordinateSystem.maxValue > 0) { return; } // Already calculated. + if (coordinateSystem.maxValue > 0) { return; } // Already calculated. let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), @@ -444,7 +444,7 @@ }; - timeLineCoordinateSystem.initialize( + coordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, @@ -496,9 +496,9 @@ y: record.endRate }; - recordPoint1 = timeLineCoordinateSystem.transformThisPoint(recordPoint1); - recordPoint2 = timeLineCoordinateSystem.transformThisPoint(recordPoint2); - recordPoint3 = timeLineCoordinateSystem.transformThisPoint(recordPoint3); + recordPoint1 = coordinateSystem.transformThisPoint(recordPoint1); + recordPoint2 = coordinateSystem.transformThisPoint(recordPoint2); + recordPoint3 = coordinateSystem.transformThisPoint(recordPoint3); recordPoint1 = transformThisPoint(recordPoint1, thisObject.container); recordPoint2 = transformThisPoint(recordPoint2, thisObject.container); diff --git a/TradingSimulation.js b/TradingSimulation.js index 240f38874..7d5f3e964 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -34,7 +34,7 @@ container.initialize(); thisObject.container = container; - let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -298,8 +298,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -396,8 +396,8 @@ let daysOnSides = getSideDays(timeFrame); - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem); - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem); + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem); + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem); let dateDiff = rightDate.valueOf() - leftDate.valueOf(); @@ -471,7 +471,7 @@ try { - if (timeLineCoordinateSystem.maxValue > 0) { return; } // Already calculated. + if (coordinateSystem.maxValue > 0) { return; } // Already calculated. let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), @@ -483,7 +483,7 @@ y: nextPorwerOf10(USDT_BTC_HTH) / 4 // TODO: This 4 is temporary }; - timeLineCoordinateSystem.initialize( + coordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, @@ -602,16 +602,16 @@ recordPoint10.x = 0; } - recordPoint1 = timeLineCoordinateSystem.transformThisPoint(recordPoint1); - recordPoint2 = timeLineCoordinateSystem.transformThisPoint(recordPoint2); - recordPoint3 = timeLineCoordinateSystem.transformThisPoint(recordPoint3); - recordPoint4 = timeLineCoordinateSystem.transformThisPoint(recordPoint4); - recordPoint5 = timeLineCoordinateSystem.transformThisPoint(recordPoint5); - recordPoint6 = timeLineCoordinateSystem.transformThisPoint(recordPoint6); - recordPoint7 = timeLineCoordinateSystem.transformThisPoint(recordPoint7); - recordPoint8 = timeLineCoordinateSystem.transformThisPoint(recordPoint8); - recordPoint9 = timeLineCoordinateSystem.transformThisPoint(recordPoint9); - recordPoint10 = timeLineCoordinateSystem.transformThisPoint(recordPoint10); + recordPoint1 = coordinateSystem.transformThisPoint(recordPoint1); + recordPoint2 = coordinateSystem.transformThisPoint(recordPoint2); + recordPoint3 = coordinateSystem.transformThisPoint(recordPoint3); + recordPoint4 = coordinateSystem.transformThisPoint(recordPoint4); + recordPoint5 = coordinateSystem.transformThisPoint(recordPoint5); + recordPoint6 = coordinateSystem.transformThisPoint(recordPoint6); + recordPoint7 = coordinateSystem.transformThisPoint(recordPoint7); + recordPoint8 = coordinateSystem.transformThisPoint(recordPoint8); + recordPoint9 = coordinateSystem.transformThisPoint(recordPoint9); + recordPoint10 = coordinateSystem.transformThisPoint(recordPoint10); recordPoint1 = transformThisPoint(recordPoint1, thisObject.container); recordPoint2 = transformThisPoint(recordPoint2, thisObject.container);