diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 049de0b79..e801de72d 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -248,6 +248,14 @@ function newStrategyPart () { compatibleType = '->' + 'Open Stage' compatibleSubType = undefined break + case 'Open Execution': + compatibleType = '->' + 'Open Stage' + compatibleSubType = undefined + break + case 'Close Execution': + compatibleType = '->' + 'Close Stage' + compatibleSubType = undefined + break case 'Stop': compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' compatibleSubType = undefined @@ -306,6 +314,8 @@ function newStrategyPart () { if (thisObject.payload.node.type === 'Trigger Off Event' && nearbyNode.triggerOff !== undefined) { continue } if (thisObject.payload.node.type === 'Trigger On Event' && nearbyNode.triggerOn !== undefined) { continue } if (thisObject.payload.node.type === 'Initial Definition' && nearbyNode.initialDefinition !== undefined) { continue } + if (thisObject.payload.node.type === 'Open Execution' && nearbyNode.openExecution !== undefined) { continue } + if (thisObject.payload.node.type === 'Close Execution' && nearbyNode.closeExecution !== undefined) { continue } if (thisObject.payload.node.type === 'Stop' && nearbyNode.stopLoss !== undefined) { continue } if (thisObject.payload.node.type === 'Take Profit' && nearbyNode.takeProfit !== undefined) { continue } if (thisObject.payload.node.type === 'Formula' && nearbyNode.formula !== undefined) { continue } @@ -962,4 +972,3 @@ function newStrategyPart () { } } } - diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 91d34379f..16ee8683c 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -524,7 +524,21 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -40 + angle: -60 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Open Execution', + actionFunction: payload.onMenuItemClick, + label: 'Add Open Execution', + visible: false, + iconPathOn: 'target', + iconPathOff: 'trash', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 } ) menuItemsInitialValues.push( @@ -540,7 +554,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: 20 } ) menuItemsInitialValues.push( @@ -554,7 +568,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 40 + angle: 60 } ) break @@ -609,6 +623,20 @@ function newStrategyPartConstructor () { } case 'Close Stage': { addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Close Execution', + actionFunction: payload.onMenuItemClick, + label: 'Add Close Execution', + visible: false, + iconPathOn: 'target', + iconPathOff: 'trash', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) menuItemsInitialValues.push( { action: 'Delete Close Stage', @@ -622,7 +650,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: 0 } ) menuItemsInitialValues.push( @@ -636,7 +664,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 40 } ) break @@ -934,6 +962,74 @@ function newStrategyPartConstructor () { ) break } + case 'Open Execution': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Open Execution', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete This Definition', + visible: false, + iconPathOn: 'trash', + iconPathOff: 'trash', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + break + } + case 'Close Execution': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Close Execution', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete This Definition', + visible: false, + iconPathOn: 'trash', + iconPathOff: 'trash', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + break + } case 'Stop': { addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( @@ -1424,6 +1520,14 @@ function newStrategyPartConstructor () { level_3() break } + case 'Open Execution': { + level_3() + break + } + case 'Close Execution': { + level_3() + break + } case 'Stop': { level_3() break diff --git a/FloatingSpace/StrategyPartTitle.js b/FloatingSpace/StrategyPartTitle.js index 27d0652d9..9a5209bc4 100644 --- a/FloatingSpace/StrategyPartTitle.js +++ b/FloatingSpace/StrategyPartTitle.js @@ -96,6 +96,12 @@ function newStrategyPartTitle () { case 'Initial Definition': { break } + case 'Open Execution': { + break + } + case 'Close Execution': { + break + } case 'Stop': { break } diff --git a/Spaces/StrategySpace.js b/Spaces/StrategySpace.js index 848785951..39f67b6a4 100644 --- a/Spaces/StrategySpace.js +++ b/Spaces/StrategySpace.js @@ -54,6 +54,8 @@ function newStrategySpace () { ['Trigger Off Event', 'support'], ['Take Position Event', 'compass'], ['Initial Definition', 'task'], + ['Open Execution', 'piggy-bank'], + ['Close Execution', 'piggy-bank'], ['Stop', 'pixel'], ['Take Profit', 'competition'], ['Phase', 'placeholder'], diff --git a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js b/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js index b486bd0ea..5b25d4bb5 100644 --- a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js +++ b/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js @@ -82,6 +82,16 @@ function newAttachDetach () { completeDetachment(node, rootNodes) return } + case 'Open Execution': { + node.payload.parentNode.openExecution = undefined + completeDetachment(node, rootNodes) + return + } + case 'Close Execution': { + node.payload.parentNode.closeExecution = undefined + completeDetachment(node, rootNodes) + return + } case 'Stop': { node.payload.parentNode.stopLoss = undefined completeDetachment(node, rootNodes) @@ -224,6 +234,20 @@ function newAttachDetach () { completeAttachment(node, rootNodes) } break + case 'Open Execution': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.openExecution = node + completeAttachment(node, rootNodes) + } + break + case 'Close Execution': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.closeExecution = node + completeAttachment(node, rootNodes) + } + break case 'Trigger On Event': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js b/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js index 85d1664d9..1dadb8006 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js @@ -41,6 +41,12 @@ function newNodeChildren () { case 'Initial Definition': { return countChildrenInitialDefinition(parentNode, childNode) } + case 'Open Execution': { + return countChildrenOpenExecution(parentNode, childNode) + } + case 'Close Execution': { + return countChildrenCloseExecution(parentNode, childNode) + } case 'Next Phase Event': { return countChildrenEvent(parentNode, childNode) } @@ -291,6 +297,22 @@ function newNodeChildren () { return response } + function countChildrenOpenExecution (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenCloseExecution (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + function countChildrenEvent (parentNode, childNode) { let response = { childrenCount: 0, diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js index 51f9d84da..6169a5eae 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -12,6 +12,8 @@ function newNodeDeleter () { deletePositionSize: deletePositionSize, deletePositionRate: deletePositionRate, deleteInitialDefinition: deleteInitialDefinition, + deleteOpenExecution: deleteOpenExecution, + deleteCloseExecution: deleteCloseExecution, deleteEvent: deleteEvent, deleteManagedItem: deleteManagedItem, deletePhase: deletePhase, @@ -76,6 +78,14 @@ function newNodeDeleter () { deleteInitialDefinition(rootNode, rootNodes) break } + case 'Open Execution': { + deleteOpenExecution(rootNode, rootNodes) + break + } + case 'Close Execution': { + deleteCloseExecution(rootNode, rootNodes) + break + } case 'Event': { deleteEvent(rootNode, rootNodes) break @@ -232,6 +242,11 @@ function newNodeDeleter () { if (node.initialDefinition !== undefined) { deleteInitialDefinition(node.initialDefinition, rootNodes) } + + if (node.openExecution !== undefined) { + deleteOpenExecution(node.openExecution, rootNodes) + } + destroyPart(node) cleanNode(node) } @@ -260,6 +275,9 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } + if (node.closeExecution !== undefined) { + deleteCloseExecution(node.closeExecution, rootNodes) + } destroyPart(node) cleanNode(node) } @@ -315,6 +333,28 @@ function newNodeDeleter () { cleanNode(node) } + function deleteOpenExecution (node, rootNodes) { + let payload = node.payload + if (payload.parentNode !== undefined) { + payload.parentNode.openExecution = undefined + } else { + completeDeletion(node, rootNodes) + } + destroyPart(node) + cleanNode(node) + } + + function deleteCloseExecution (node, rootNodes) { + let payload = node.payload + if (payload.parentNode !== undefined) { + payload.parentNode.closeExecution = undefined + } else { + completeDeletion(node, rootNodes) + } + destroyPart(node) + cleanNode(node) + } + function deleteEvent (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { diff --git a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js index 9c5942813..73f429808 100644 --- a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js +++ b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js @@ -8,6 +8,8 @@ function newPartsFromNodes () { addMissingEvents: addMissingEvents, addMissingItems: addMissingItems, addInitialDefinition: addInitialDefinition, + addOpenExecution: addOpenExecution, + addCloseExecution: addCloseExecution, addPhase: addPhase, addFormula: addFormula, addNextPhaseEvent: addNextPhaseEvent, @@ -102,6 +104,16 @@ function newPartsFromNodes () { } return } + case 'Open Execution': + { + createPart('Open Execution', node.name, node, parentNode, chainParent, 'Open Execution') + return + } + case 'Close Execution': + { + createPart('Close Execution', node.name, node, parentNode, chainParent, 'Close Execution') + return + } case 'Initial Definition': { createPart('Initial Definition', node.name, node, parentNode, chainParent, 'Initial Definition') @@ -498,6 +510,20 @@ function newPartsFromNodes () { } } + function addOpenExecution (node) { + if (node.openExecution === undefined) { + node.openExecution = {} + createPart('Open Execution', '', node.openExecution, node, node) + } + } + + function addCloseExecution (node) { + if (node.closeExecution === undefined) { + node.closeExecution = {} + createPart('Open Execution', '', node.closeExecution, node, node) + } + } + function addFormula (node) { if (node.formula === undefined) { node.formula = { @@ -637,4 +663,3 @@ function newPartsFromNodes () { canvas.floatingSpace.strategyPartConstructor.createStrategyPart(payload) } } - diff --git a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js index 5e665b21d..9eb6d1377 100644 --- a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -157,6 +157,22 @@ function newProtocolNode () { } return object } + case 'Open Execution': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + return object + } + case 'Close Execution': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + return object + } case 'Position Size': { let object = { type: node.type, diff --git a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js index 05039cebc..eb75a7eb7 100644 --- a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js @@ -183,6 +183,26 @@ function newStringifyNode () { } return object } + case 'Open Execution': { + let object = { + id: node.id, + type: node.type, + subType: node.subType, + name: node.name, + savedPayload: getSavedPayload(node) + } + return object + } + case 'Close Execution': { + let object = { + id: node.id, + type: node.type, + subType: node.subType, + name: node.name, + savedPayload: getSavedPayload(node) + } + return object + } case 'Position Size': { let object = { id: node.id, diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index 661f96ce0..b10fd119e 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -222,6 +222,16 @@ function newWorkspace () { functionLibraryPartsFromNodes.addInitialDefinition(payload.node) } break + case 'Add Open Execution': + { + functionLibraryPartsFromNodes.addOpenExecution(payload.node) + } + break + case 'Add Close Execution': + { + functionLibraryPartsFromNodes.addCloseExecution(payload.node) + } + break case 'Add Phase': { functionLibraryPartsFromNodes.addPhase(payload.node)