Next Phase Event Implemented
This commit is contained in:
1 parent
99f4227d6c
commit
03e628de53
10 files changed
+160
-34
No files matched your search
@@ -234,6 +234,10 @@ function newStrategyPart () {
|
||||
compatibleType = 'Phase'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Next Phase Event':
|
||||
compatibleType = 'Phase'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Situation':
|
||||
compatibleType = 'Phase' + '.' + 'Take Position Event' + '.' + 'Trigger On Event' + '.' + 'Trigger Off Event'
|
||||
compatibleSubType = undefined
|
||||
@@ -271,6 +275,7 @@ function newStrategyPart () {
|
||||
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 }
|
||||
if (thisObject.payload.node.type === 'Next Phase Event' && nearbyNode.nextPhaseEvent !== undefined) { continue }
|
||||
if (thisObject.payload.node.type === 'Code' && nearbyNode.code !== undefined) { continue }
|
||||
/* Discard Phases without partent */
|
||||
if (thisObject.payload.node.type === 'Phase' && nearbyNode.type === 'Phase' && nearbyNode.payload.parentNode === undefined) { continue }
|
||||
|
||||
@@ -752,8 +752,8 @@ function newStrategyPartConstructor () {
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Add Formula',
|
||||
visible: false,
|
||||
iconPathOn: 'pipette',
|
||||
iconPathOff: 'pipette',
|
||||
iconPathOn: 'schedule',
|
||||
iconPathOff: 'schedule',
|
||||
relatedStrategyPart: 'Formula',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
@@ -761,13 +761,13 @@ function newStrategyPartConstructor () {
|
||||
angle: -60
|
||||
},
|
||||
{
|
||||
action: 'Add Situation',
|
||||
action: 'Add Next Phase Event',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Add Situation',
|
||||
label: 'Add Next Phase Event',
|
||||
visible: false,
|
||||
iconPathOn: 'pyramid',
|
||||
iconPathOff: 'pyramid',
|
||||
relatedStrategyPart: 'Situation',
|
||||
iconPathOn: 'pipette',
|
||||
iconPathOff: 'pipette',
|
||||
relatedStrategyPart: 'Next Phase Event',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
@@ -859,6 +859,61 @@ function newStrategyPartConstructor () {
|
||||
}]
|
||||
break
|
||||
}
|
||||
case 'Next Phase Event': {
|
||||
menuItemsInitialValues = [
|
||||
{
|
||||
action: 'Pin / Unpin',
|
||||
actionFunction: floatingObject.pinToggle,
|
||||
actionStatus: floatingObject.getPinStatus,
|
||||
currentStatus: false,
|
||||
label: undefined,
|
||||
visible: false,
|
||||
iconPathOn: 'target',
|
||||
iconPathOff: 'security',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -135
|
||||
},
|
||||
{
|
||||
action: 'Add Situation',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Add Situation',
|
||||
visible: false,
|
||||
iconPathOn: 'pyramid',
|
||||
iconPathOff: 'pyramid',
|
||||
relatedStrategyPart: 'Situation',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -40
|
||||
},
|
||||
{
|
||||
action: 'Delete Event',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Delete This Event',
|
||||
visible: false,
|
||||
iconPathOn: 'trash',
|
||||
iconPathOff: 'trash',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 0
|
||||
},
|
||||
{
|
||||
action: 'Download',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Download',
|
||||
visible: false,
|
||||
iconPathOn: 'upload',
|
||||
iconPathOff: 'upload',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 40
|
||||
}]
|
||||
break
|
||||
}
|
||||
case 'Situation': {
|
||||
menuItemsInitialValues = [
|
||||
{
|
||||
@@ -1098,6 +1153,10 @@ function newStrategyPartConstructor () {
|
||||
level_5()
|
||||
break
|
||||
}
|
||||
case 'Next Phase Event': {
|
||||
level_5()
|
||||
break
|
||||
}
|
||||
case 'Situation': {
|
||||
level_5()
|
||||
break
|
||||
|
||||
@@ -92,6 +92,9 @@ function newStrategyPartTitle () {
|
||||
case 'Formula': {
|
||||
break
|
||||
}
|
||||
case 'Next Phase Event': {
|
||||
break
|
||||
}
|
||||
case 'Situation': {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ function newStrategySpace () {
|
||||
['Take Profit', 'competition'],
|
||||
['Phase', 'placeholder'],
|
||||
['Formula', 'pipette'],
|
||||
['Next Phase Event', 'schedule'],
|
||||
['Situation', 'pyramid'],
|
||||
['Condition', 'testing'],
|
||||
['Code', 'html']
|
||||
|
||||
@@ -77,6 +77,11 @@ function newAttachDetach () {
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Next Phase Event': {
|
||||
node.payload.parentNode.nextPhaseEvent = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Code': {
|
||||
node.payload.parentNode.code = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
@@ -213,6 +218,13 @@ function newAttachDetach () {
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Next Phase Event': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.nextPhaseEvent = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
switch (attachToNode.type) {
|
||||
case 'Stop': {
|
||||
|
||||
@@ -164,6 +164,10 @@ function newNodeDeleter () {
|
||||
payload.parentNode.takePosition = undefined
|
||||
break
|
||||
}
|
||||
case 'Next Phase Event': {
|
||||
payload.parentNode.nextPhaseEvent = undefined
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
completeDeletion(node, rootNodes)
|
||||
@@ -218,15 +222,13 @@ function newNodeDeleter () {
|
||||
completeDeletion(node, rootNodes)
|
||||
}
|
||||
|
||||
while (node.situations.length > 0) {
|
||||
let situation = node.situations[0]
|
||||
deleteSituation(situation)
|
||||
}
|
||||
node.situations = []
|
||||
|
||||
if (node.formula !== undefined) {
|
||||
deleteFormula(node.formula, rootNodes)
|
||||
}
|
||||
|
||||
if (node.nextPhaseEvent !== undefined) {
|
||||
deleteEvent(node.nextPhaseEvent, rootNodes)
|
||||
}
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ function newPartsFromNodes () {
|
||||
addInitialDefinition: addInitialDefinition,
|
||||
addPhase: addPhase,
|
||||
addFormula: addFormula,
|
||||
addNextPhaseEvent: addNextPhaseEvent,
|
||||
addSituation: addSituation,
|
||||
addCondition: addCondition,
|
||||
addCode: addCode
|
||||
@@ -44,16 +45,25 @@ function newPartsFromNodes () {
|
||||
createPart('Formula', node.name, node, parentNode, chainParent, 'Formula')
|
||||
return
|
||||
}
|
||||
case 'Next Phase Event':
|
||||
{
|
||||
createPart('Next Phase Event', node.name, node, parentNode, chainParent, 'Next Phase Event')
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
let situation = node.situations[m]
|
||||
createPartFromNode(situation, node, node)
|
||||
}
|
||||
return
|
||||
}
|
||||
case 'Phase': {
|
||||
let phase = node
|
||||
createPart('Phase', phase.name, phase, parentNode, chainParent, phase.subType)
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
let situation = node.situations[m]
|
||||
createPartFromNode(situation, phase, phase)
|
||||
}
|
||||
|
||||
if (node.formula !== undefined) {
|
||||
createPartFromNode(node.formula, phase, phase)
|
||||
}
|
||||
if (node.nextPhaseEvent !== undefined) {
|
||||
createPartFromNode(node.nextPhaseEvent, phase, phase)
|
||||
}
|
||||
return
|
||||
}
|
||||
case 'Stop': {
|
||||
@@ -330,6 +340,15 @@ function newPartsFromNodes () {
|
||||
}
|
||||
}
|
||||
|
||||
function addNextPhaseEvent (node) {
|
||||
if (node.nextPhaseEvent === undefined) {
|
||||
node.nextPhaseEvent = {
|
||||
situations: []
|
||||
}
|
||||
createPart('Next Phase Event', '', node.nextPhaseEvent, node, node)
|
||||
}
|
||||
}
|
||||
|
||||
function addCode (node) {
|
||||
if (node.code === undefined) {
|
||||
node.code = {}
|
||||
@@ -343,7 +362,7 @@ function newPartsFromNodes () {
|
||||
let phase = {
|
||||
name: 'New Phase',
|
||||
formula: {},
|
||||
situations: []
|
||||
nextPhaseEvent: {}
|
||||
}
|
||||
phaseParent.phases.push(phase)
|
||||
let phaseChainParent
|
||||
@@ -354,17 +373,17 @@ function newPartsFromNodes () {
|
||||
}
|
||||
createPart('Phase', phase.name, phase, phaseParent, phaseChainParent, 'Phase')
|
||||
createPart('Formula', '', phase.formula, phase, phase, 'Formula')
|
||||
createPart('Next Phase Event', '', phase.nextPhaseEvent, phase, phase)
|
||||
}
|
||||
|
||||
function addSituation (parentNode) {
|
||||
let phase = parentNode
|
||||
let m = phase.situations.length
|
||||
let m = parentNode.situations.length
|
||||
let situation = {
|
||||
name: 'New Situation',
|
||||
conditions: []
|
||||
}
|
||||
phase.situations.push(situation)
|
||||
createPart('Situation', situation.name, situation, phase, phase, 'Situation')
|
||||
parentNode.situations.push(situation)
|
||||
createPart('Situation', situation.name, situation, parentNode, parentNode, 'Situation')
|
||||
}
|
||||
|
||||
function addCondition (parentNode) {
|
||||
|
||||
@@ -51,18 +51,27 @@ function newProtocolNode () {
|
||||
}
|
||||
return formula
|
||||
}
|
||||
case 'Next Phase Event':
|
||||
{
|
||||
let event = {
|
||||
type: node.type,
|
||||
subType: node.subType,
|
||||
name: node.name,
|
||||
situations: []
|
||||
}
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
let situation = getProtocolNode(node.situations[m])
|
||||
node.situations.push(situation)
|
||||
}
|
||||
return event
|
||||
}
|
||||
case 'Phase': {
|
||||
let phase = {
|
||||
type: node.type,
|
||||
subType: node.subType,
|
||||
name: node.name,
|
||||
formula: getProtocolNode(node.formula),
|
||||
situations: []
|
||||
}
|
||||
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
let situation = getProtocolNode(node.situations[m])
|
||||
phase.situations.push(situation)
|
||||
nextPhaseEvent: getProtocolNode(node.nextPhaseEvent)
|
||||
}
|
||||
return phase
|
||||
}
|
||||
|
||||
@@ -59,6 +59,22 @@ function newWorkspaceNode () {
|
||||
}
|
||||
return formula
|
||||
}
|
||||
case 'Next Phase Event':
|
||||
{
|
||||
let event = {
|
||||
id: node.id,
|
||||
type: node.type,
|
||||
subType: node.subType,
|
||||
name: node.name,
|
||||
situations: [],
|
||||
savedPayload: getSavedPayload(node)
|
||||
}
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
let situation = getWorkspaceNode(node.situations[m])
|
||||
node.situations.push(situation)
|
||||
}
|
||||
return event
|
||||
}
|
||||
case 'Phase': {
|
||||
let phase = {
|
||||
id: node.id,
|
||||
@@ -66,14 +82,9 @@ function newWorkspaceNode () {
|
||||
subType: node.subType,
|
||||
name: node.name,
|
||||
formula: getWorkspaceNode(node.formula),
|
||||
situations: [],
|
||||
nextPhaseEvent: getWorkspaceNode(node.nextPhaseEvent),
|
||||
savedPayload: getSavedPayload(node)
|
||||
}
|
||||
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
let situation = getWorkspaceNode(node.situations[m])
|
||||
phase.situations.push(situation)
|
||||
}
|
||||
return phase
|
||||
}
|
||||
case 'Stop': {
|
||||
|
||||
@@ -189,6 +189,11 @@ function newWorkspace () {
|
||||
functionLibraryPartsFromNodes.addFormula(payload.node)
|
||||
}
|
||||
break
|
||||
case 'Add Next Phase Event':
|
||||
{
|
||||
functionLibraryPartsFromNodes.addNextPhaseEvent(payload.node)
|
||||
}
|
||||
break
|
||||
case 'Add Situation':
|
||||
{
|
||||
functionLibraryPartsFromNodes.addSituation(payload.node)
|
||||
|
||||
Reference in new issue
Block a user