From 2fcd49ff13a3c46d0163cb2e98a0f9bb3a6cf1a3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 12 May 2019 14:07:41 +0200 Subject: [PATCH] Refactoring to Trading System --- FloatingSpace/StrategyPart.js | 6 +++--- FloatingSpace/StrategyPartConstructor.js | 2 +- FloatingSpace/StrategyPartTitle.js | 2 +- Spaces/BottomSpace.js | 2 +- Spaces/StrategySpace.js | 18 ++++++++--------- StrategySpace/StrategyCollectionItem.js | 3 +-- .../{InvestmentPlan.js => TradingSystem.js} | 20 +++++++++---------- ...Workspace.js => TradingSystemWorkspace.js} | 10 +++++----- 8 files changed, 31 insertions(+), 32 deletions(-) rename StrategySpace/{InvestmentPlan.js => TradingSystem.js} (95%) rename StrategySpace/{InvestmentPlanWorkspace.js => TradingSystemWorkspace.js} (94%) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 30569f65e..41cd9e751 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -72,11 +72,11 @@ function newStrategyPart () { let menuItemsInitialValues = [] switch (thisObject.payload.node.type) { - case 'Investment Plan': { + case 'Trading System': { imagePath = 'Images/icons/style-01/analysis.png' menuItemsInitialValues = [ { - action: 'Reload Investment Plan', + action: 'Reload Trading System', actionFunction: thisObject.payload.onMenuItemClick, label: 'Reload', visible: false, @@ -88,7 +88,7 @@ function newStrategyPart () { angle: -60 }, { - action: 'Save Investment Plan', + action: 'Save Trading System', actionFunction: thisObject.payload.onMenuItemClick, label: 'Save Changes', visible: false, diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index bc00726d8..662c806b2 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -46,7 +46,7 @@ function newStrategyPartConstructor () { const FRICTION = 0.97 switch (payload.node.type) { - case 'Investment Plan': { + case 'Trading System': { level_0() break } diff --git a/FloatingSpace/StrategyPartTitle.js b/FloatingSpace/StrategyPartTitle.js index 74553641d..8597bff14 100644 --- a/FloatingSpace/StrategyPartTitle.js +++ b/FloatingSpace/StrategyPartTitle.js @@ -48,7 +48,7 @@ function newStrategyPartTitle () { thisObject.payload = payload switch (payload.node.type) { - case 'Investment Plan': { + case 'Trading System': { break } case 'Strategy': { diff --git a/Spaces/BottomSpace.js b/Spaces/BottomSpace.js index acc7d5cde..5e6ae3b05 100644 --- a/Spaces/BottomSpace.js +++ b/Spaces/BottomSpace.js @@ -44,7 +44,7 @@ } function onMouseClick (event) { - // canvas.strategySpace.investmentPlanWorkspace.showUp() + // canvas.strategySpace.tradingSystemWorkspace.showUp() } function resize () { diff --git a/Spaces/StrategySpace.js b/Spaces/StrategySpace.js index d150059e9..0d4264972 100644 --- a/Spaces/StrategySpace.js +++ b/Spaces/StrategySpace.js @@ -3,7 +3,7 @@ function newStrategySpace () { const MODULE_NAME = 'Strategy Space' let thisObject = { sidePanel: undefined, - investmentPlanWorkspace: undefined, + tradingSystemWorkspace: undefined, container: undefined, draw: draw, getContainer: getContainer, @@ -24,16 +24,16 @@ function newStrategySpace () { // thisObject.sidePanel = newSidePanel() // thisObject.sidePanel.initialize() - thisObject.investmentPlanWorkspace = newInvestmentPlanWorkspace() - // thisObject.investmentPlanWorkspace.container.connectToParent(thisObject.sidePanel.container, true, true) - await thisObject.investmentPlanWorkspace.initialize() + thisObject.tradingSystemWorkspace = newTradingSystemWorkspace() + // thisObject.tradingSystemWorkspace.container.connectToParent(thisObject.sidePanel.container, true, true) + await thisObject.tradingSystemWorkspace.initialize() - // thisObject.sidePanel.areas.push(thisObject.investmentPlanWorkspace) + // thisObject.sidePanel.areas.push(thisObject.tradingSystemWorkspace) } function makeVisible () { - if (thisObject.investmentPlanWorkspace.isDeployed !== true) { - thisObject.investmentPlanWorkspace.deploydInvestmentPlan() + if (thisObject.tradingSystemWorkspace.isDeployed !== true) { + thisObject.tradingSystemWorkspace.deploydTradingSystem() } canvas.floatingSpace.makeVisible() visible = true @@ -46,8 +46,8 @@ function newStrategySpace () { function getContainer (point) { let container - if (thisObject.investmentPlanWorkspace !== undefined) { - container = thisObject.investmentPlanWorkspace.getContainer(point) + if (thisObject.tradingSystemWorkspace !== undefined) { + container = thisObject.tradingSystemWorkspace.getContainer(point) if (container !== undefined) { return container } } diff --git a/StrategySpace/StrategyCollectionItem.js b/StrategySpace/StrategyCollectionItem.js index 38dbef787..2b1b8c920 100644 --- a/StrategySpace/StrategyCollectionItem.js +++ b/StrategySpace/StrategyCollectionItem.js @@ -44,7 +44,7 @@ function newStrategyCollectionItem () { function onMouseClick (event) { if (status === 'off') { canvas.floatingSpace.makeVisible() - thisObject.strategy = newInvestmentPlan() + thisObject.strategy = newTradingSystem() thisObject.strategy.initialize(thisObject.strategySource) status = 'on' } else { @@ -175,4 +175,3 @@ function newStrategyCollectionItem () { browserCanvasContext.drawImage(thisObject.icon, point1.x - IMAGE_SIZE / 2, point1.y - IMAGE_SIZE / 2, IMAGE_SIZE, IMAGE_SIZE) } } - diff --git a/StrategySpace/InvestmentPlan.js b/StrategySpace/TradingSystem.js similarity index 95% rename from StrategySpace/InvestmentPlan.js rename to StrategySpace/TradingSystem.js index 0eefe04e2..c06e3912c 100644 --- a/StrategySpace/InvestmentPlan.js +++ b/StrategySpace/TradingSystem.js @@ -1,9 +1,9 @@ -function newInvestmentPlan () { - const MODULE_NAME = 'Investment Plan' +function newTradingSystem () { + const MODULE_NAME = 'Trading System' let thisObject = { - investmentPlan: undefined, + tradingSystem: undefined, container: undefined, getContainer: getContainer, initialize: initialize, @@ -29,7 +29,7 @@ function newInvestmentPlan () { } function initialize (strategies) { - thisObject.investmentPlan = { + thisObject.tradingSystem = { strategies: strategies } generateStrategyParts() @@ -80,13 +80,13 @@ function newInvestmentPlan () { function generateStrategyParts () { let lastPhase - let investmentPlan = thisObject.investmentPlan + let tradingSystem = thisObject.tradingSystem - createPart('Investment Plan', '', investmentPlan, undefined, undefined) + createPart('Trading System', '', tradingSystem, undefined, undefined) - for (m = 0; m < investmentPlan.strategies.length; m++) { - let strategy = investmentPlan.strategies[m] - createPart('Strategy', strategy.name, strategy, investmentPlan, investmentPlan) + for (m = 0; m < tradingSystem.strategies.length; m++) { + let strategy = tradingSystem.strategies[m] + createPart('Strategy', strategy.name, strategy, tradingSystem, tradingSystem) createPart('Strategy Entry Event', '', strategy.entryPoint, strategy, strategy) for (let k = 0; k < strategy.entryPoint.situations.length; k++) { @@ -171,7 +171,7 @@ function newInvestmentPlan () { } function destroyStrategyParts () { - let strategy = thisObject.investmentPlan + let strategy = thisObject.tradingSystem destroyPart(strategy) destroyPart(strategy.entryPoint) diff --git a/StrategySpace/InvestmentPlanWorkspace.js b/StrategySpace/TradingSystemWorkspace.js similarity index 94% rename from StrategySpace/InvestmentPlanWorkspace.js rename to StrategySpace/TradingSystemWorkspace.js index d2ceaa8b9..a8ee995e4 100644 --- a/StrategySpace/InvestmentPlanWorkspace.js +++ b/StrategySpace/TradingSystemWorkspace.js @@ -1,6 +1,6 @@ -function newInvestmentPlanWorkspace () { - const MODULE_NAME = 'Investment Plan Workspace' +function newTradingSystemWorkspace () { + const MODULE_NAME = 'Trading System Workspace' const ERROR_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME @@ -9,7 +9,7 @@ function newInvestmentPlanWorkspace () { isDeployed: false, strategies: undefined, container: undefined, - deploydInvestmentPlan: deploydInvestmentPlan, + deploydTradingSystem: deploydTradingSystem, draw: draw, getContainer: getContainer, initialize: initialize @@ -122,8 +122,8 @@ function newInvestmentPlanWorkspace () { } } - function deploydInvestmentPlan () { - thisObject.strategy = newInvestmentPlan() + function deploydTradingSystem () { + thisObject.strategy = newTradingSystem() thisObject.strategy.initialize(thisObject.strategies) thisObject.isDeployed = true }