From 69f48964af04616aa43d305e7d607ee0f83751c7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 13:03:56 +0200 Subject: [PATCH] Can Add new Strategies --- StrategySpace/Workspace.js | 115 +++++++++++-------------------------- 1 file changed, 35 insertions(+), 80 deletions(-) diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index 693d55112..03d21d91a 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -175,73 +175,7 @@ function newWorkspace () { } function destroyStrategyParts () { - let strategy = thisObject.tradingSystem - destroyPart(strategy) - destroyPart(strategy.entryPoint) - for (let k = 0; k < strategy.entryPoint.situations.length; k++) { - let situation = strategy.entryPoint.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - - destroyPart(strategy.exitPoint) - for (let k = 0; k < strategy.exitPoint.situations.length; k++) { - let situation = strategy.exitPoint.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - - destroyPart(strategy.sellPoint) - for (let k = 0; k < strategy.sellPoint.situations.length; k++) { - let situation = strategy.sellPoint.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - - destroyPart(strategy.stopLoss) - for (let p = 0; p < strategy.stopLoss.phases.length; p++) { - let phase = strategy.stopLoss.phases[p] - destroyPart(strategy.stopLoss) - - for (let k = 0; k < phase.situations.length; k++) { - let situation = phase.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - } - - destroyPart(strategy.buyOrder) - for (let p = 0; p < strategy.buyOrder.phases.length; p++) { - let phase = strategy.buyOrder.phases[p] - destroyPart(strategy.buyOrder) - - for (let k = 0; k < phase.situations.length; k++) { - let situation = phase.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - } } async function onMenuItemClick (payload, action) { @@ -253,20 +187,6 @@ function newWorkspace () { break } - case 'Open Settings': - break - case 'Delete Strategy': - - break - - case 'Reload Strategy': - - break - - case 'Save Strategy': - - break - case 'Edit Code': break @@ -283,6 +203,40 @@ function newWorkspace () { download(fileName, text) break + + case 'New Strategy': + { + let strategyParent = payload.node + + let strategy = { + name: 'New Strategy', + active: true, + entryPoint: { + situations: [] + }, + exitPoint: { + situations: [] + }, + sellPoint: { + situations: [] + }, + stopLoss: { + phases: [] + }, + buyOrder: { + phases: [] + } + } + + strategyParent.strategies.push(strategy) + createPart('Strategy', strategy.name, strategy, strategyParent, strategyParent, 'Strategy') + createPart('Strategy Entry Event', '', strategy.entryPoint, strategy, strategy) + createPart('Strategy Exit Event', '', strategy.exitPoint, strategy, strategy) + createPart('Trade Entry Event', '', strategy.sellPoint, strategy, strategy) + createPart('Stop', '', strategy.stopLoss, strategy, strategy) + createPart('Take Profit', '', strategy.buyOrder, strategy, strategy) + } + break case 'Add Phase': { let phaseParent = payload.node @@ -618,3 +572,4 @@ function newWorkspace () { } } } +