Attach Detach new parts

This commit is contained in:
Luis Fernando Molina committed 2019-06-06 12:51:47 +02:00
1 parent 4330ef1e04
commit 984221977b
3 files changed
+61 -1

No files matched your search

+16 -1
View File
@@ -182,6 +182,14 @@ function newStrategyPart () {
let compatibleType
let compatibleSubType
switch (thisObject.payload.node.type) {
case 'Parameters':
compatibleType = 'Trading System'
compatibleSubType = undefined
break
case 'Base Assets':
compatibleType = 'Parameters'
compatibleSubType = undefined
break
case 'Strategy':
compatibleType = 'Trading System'
compatibleSubType = undefined
@@ -202,6 +210,10 @@ function newStrategyPart () {
compatibleType = 'Strategy'
compatibleSubType = undefined
break
case 'Position Size':
compatibleType = 'Trigger Stage'
compatibleSubType = undefined
break
case 'Take Position Event':
compatibleType = 'Trigger Stage'
compatibleSubType = undefined
@@ -231,7 +243,7 @@ function newStrategyPart () {
compatibleSubType = undefined
break
case 'Formula':
compatibleType = 'Phase'
compatibleType = 'Base Asset' + '.' + 'Position Size' + '.' + 'Phase'
compatibleSubType = undefined
break
case 'Next Phase Event':
@@ -264,10 +276,13 @@ function newStrategyPart () {
let nearbyNode = floatingObject.payload.node
if (compatibleType.indexOf(nearbyNode.type) >= 0) {
/* Discard objects with busy coonection ports */
if (thisObject.payload.node.type === 'Parameters' && nearbyNode.parameters !== undefined) { continue }
if (thisObject.payload.node.type === 'Base Asset' && nearbyNode.baseAsset !== undefined) { continue }
if (thisObject.payload.node.type === 'Trigger Stage' && nearbyNode.triggerStage !== undefined) { continue }
if (thisObject.payload.node.type === 'Open Stage' && nearbyNode.openStage !== undefined) { continue }
if (thisObject.payload.node.type === 'Manage Stage' && nearbyNode.manageStage !== undefined) { continue }
if (thisObject.payload.node.type === 'Close Stage' && nearbyNode.closeStage !== undefined) { continue }
if (thisObject.payload.node.type === 'Position Size' && nearbyNode.positionSize !== undefined) { continue }
if (thisObject.payload.node.type === 'Take Position Event' && nearbyNode.takePosition !== undefined) { continue }
if (thisObject.payload.node.type === 'Trigger Off Event' && nearbyNode.triggerOff !== undefined) { continue }
if (thisObject.payload.node.type === 'Trigger On Event' && nearbyNode.triggerOn !== undefined) { continue }
+9
View File
@@ -52,6 +52,12 @@ function newStrategyPartTitle () {
thisObject.allwaysVisible = true
break
}
case 'Parameters': {
break
}
case 'Base Asset': {
break
}
case 'Strategy': {
thisObject.allwaysVisible = true
break
@@ -68,6 +74,9 @@ function newStrategyPartTitle () {
case 'Close Stage': {
break
}
case 'Position Size': {
break
}
case 'Trigger On Event': {
break
}
@@ -11,6 +11,16 @@ function newAttachDetach () {
case 'Trading System': {
return
}
case 'Parameters': {
node.payload.parentNode.parameters = undefined
completeDetachment(node, rootNodes)
return
}
case 'Base Asset': {
node.payload.parentNode.baseAsset = undefined
completeDetachment(node, rootNodes)
return
}
case 'Strategy': {
let payload = node.payload
for (let i = 0; i < payload.parentNode.strategies.length; i++) {
@@ -42,6 +52,11 @@ function newAttachDetach () {
completeDetachment(node, rootNodes)
return
}
case 'Position Size': {
node.payload.parentNode.positionSize = undefined
completeDetachment(node, rootNodes)
return
}
case 'Trigger On Event': {
node.payload.parentNode.triggerOn = undefined
completeDetachment(node, rootNodes)
@@ -134,6 +149,20 @@ function newAttachDetach () {
function attachNode (node, attachToNode, rootNodes) {
switch (node.type) {
case 'Parameters': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.parameters = node
completeAttachment(node, rootNodes)
}
break
case 'Base Asset': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.baseAsset = node
completeAttachment(node, rootNodes)
}
break
case 'Strategy': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
@@ -169,6 +198,13 @@ function newAttachDetach () {
completeAttachment(node, rootNodes)
}
break
case 'Position Size': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.positionSize = node
completeAttachment(node, rootNodes)
}
break
case 'Initial Definition': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode