Merge pull request #81 from AAMasters/develop

Tensors
This commit is contained in:
benme authored and GitHub committed 2019-07-03 10:37:42 -03:00
commit 0682d7ace7
9 files changed
+809 -41

No files matched your search

+2
View File
@@ -89,6 +89,8 @@ function newSpeedometer () {
let PROFIT_VALUE_ANGLE = CURRENT_VALUE_ANGLE
if (CURRENT_VALUE_ANGLE > INIT_VALUE_ANGLE) { CURRENT_VALUE_ANGLE = INIT_VALUE_ANGLE }
if (CURRENT_VALUE_ANGLE < MIN_VALUE_ANGLE) { CURRENT_VALUE_ANGLE = MIN_VALUE_ANGLE }
if (PROFIT_VALUE_ANGLE > BAR_END_ANGLE) { PROFIT_VALUE_ANGLE = BAR_END_ANGLE }
if (
thisObject.params.VALUE > 0 &&
+15 -10
View File
@@ -429,9 +429,10 @@ function newFloatingLayer () {
}
/* We add the force vector to the speed vector */
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x + forceVector.x
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y + forceVector.y
if (isNaN(forceVector.x) === false && isNaN(forceVector.y) === false) {
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x + forceVector.x
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y + forceVector.y
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] gravityForce -> err= ' + err.stack) }
@@ -490,9 +491,10 @@ function newFloatingLayer () {
}
/* We substract the force vector to the speed vector of the current floatingObject */
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
if (isNaN(forceVector.x) === false && isNaN(forceVector.y) === false) {
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
}
}
}
} catch (err) {
@@ -608,8 +610,10 @@ function newFloatingLayer () {
/* We substract the force vector to the speed vector of the current floatingObject */
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
if (isNaN(forceVector.x) === false && isNaN(forceVector.y) === false) {
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
}
}
}
} catch (err) {
@@ -732,10 +736,10 @@ function newFloatingLayer () {
pos2.x = pos2.x - minTD.x * (im2 / (im1 + im2))
pos2.y = pos2.y - minTD.y * (im2 / (im1 + im2))
if (floatingObject1.positionLocked === false) {
if (floatingObject1.positionLocked === false && isNaN(pos1.x) === false && isNaN(pos1.y) === false) {
floatingObject1.container.frame.position = pos1
}
if (floatingObject2.positionLocked === false) {
if (floatingObject2.positionLocked === false && isNaN(pos2.x) === false && isNaN(pos2.y) === false) {
floatingObject2.container.frame.position = pos2
}
} catch (err) {
@@ -743,3 +747,4 @@ function newFloatingLayer () {
}
}
}
+66 -3
View File
@@ -22,13 +22,16 @@ function newFloatingObject () {
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
isPinned: false,
isFrozen: false,
isTensed: false,
frozenManually: false,
getPinStatus: getPinStatus,
getFreezeStatus: getFreezeStatus,
getTensionStatus: getTensionStatus,
nearbyFloatingObjects: [],
setPosition: setPosition,
pinToggle: pinToggle,
freezeToggle: freezeToggle,
tensionToggle: tensionToggle,
physics: physics,
initializeMass: initializeMass,
initializeRadius: initializeRadius,
@@ -124,6 +127,10 @@ function newFloatingObject () {
return thisObject.isFrozen
}
function getTensionStatus () {
return thisObject.isTensed
}
function freezeToggle () {
if (thisObject.isFrozen !== true) {
thisObject.isFrozen = true
@@ -135,10 +142,22 @@ function newFloatingObject () {
return thisObject.isFrozen
}
function tensionToggle () {
if (thisObject.isTensed !== true) {
thisObject.isTensed = true
thisObject.tensedManually = true
} else {
thisObject.isTensed = false
thisObject.tensedManually = false
}
return thisObject.isTensed
}
function physics () {
thisObjectPhysics()
thisObject.payload.uiObject.physics()
frozenPhysics()
tensionPhysics()
}
function frozenPhysics () {
@@ -150,6 +169,49 @@ function newFloatingObject () {
}
}
function tensionPhysics () {
/* Tension Effect */
if (thisObject.isTensed === true) {
let parent = thisObject.payload.chainParent
if (parent !== undefined) {
let distanceToChainParent = Math.sqrt(Math.pow(parent.payload.position.x - thisObject.container.frame.position.x, 2) + Math.pow(parent.payload.position.y - thisObject.container.frame.position.y, 2)) // ... we calculate the distance ...
let parentChildren = canvas.strategySpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node)
let axisCount = parentChildren.childrenCount
let axisIndex = parentChildren.childIndex
let baseAngle = 0
if (axisIndex === undefined) {
axisCount = 1
axisIndex = axisCount
}
if (parent.payload.chainParent !== undefined && parent.payload.angle !== undefined) {
axisCount++
axisIndex++
baseAngle = parent.payload.angle + 180
}
let angleStep = 360 / axisCount
thisObject.payload.angle = baseAngle + (axisIndex - 1) * angleStep
if (thisObject.payload.angle >= 360) {
thisObject.payload.angle = thisObject.payload.angle - 360
}
newPosition = {
x: parent.payload.position.x + distanceToChainParent * Math.cos(toRadians(thisObject.payload.angle)),
y: parent.payload.position.y + distanceToChainParent * Math.sin(toRadians(thisObject.payload.angle))
}
if (isNaN(newPosition.x) === false) {
thisObject.container.frame.position.x = newPosition.x
}
if (isNaN(newPosition.y) === false) {
thisObject.container.frame.position.y = newPosition.y
}
}
}
}
function thisObjectPhysics () {
// The radius also have a target.
@@ -298,12 +360,12 @@ function newFloatingObject () {
}
function initializeCurrentPosition (arroundPoint) {
let position
let position = {}
if (thisObject.payload.position === undefined) {
position = {
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
x: Math.floor((Math.random() * (1000) - 500)) + arroundPoint.x,
y: Math.floor((Math.random() * (1000) - 500)) + arroundPoint.y
}
} else {
position = {
@@ -356,3 +418,4 @@ function newFloatingObject () {
function updateRadius () {
}
}
+4 -3
View File
@@ -592,11 +592,12 @@ function newStrategyPart () {
if (thisObject.container.frame.radius > 1) {
/* Target Line */
let LINE_STYLE
let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW
if (thisObject.payload.floatingObject.isTensed === true) {
LINE_STYLE = UI_COLOR.GOLDEN_ORANGE
}
if (thisObject.payload.floatingObject.isFrozen === true) {
LINE_STYLE = UI_COLOR.TURQUOISE
} else {
LINE_STYLE = UI_COLOR.TITANIUM_YELLOW
}
browserCanvasContext.beginPath()
+319 -18
View File
@@ -51,6 +51,9 @@ function newStrategyPartConstructor () {
if (payload.node.savedPayload.floatingObject.isFrozen === true) {
floatingObject.freezeToggle()
}
if (payload.node.savedPayload.floatingObject.isTensed === true) {
floatingObject.tensionToggle()
}
}
let strategyPart = newStrategyPart()
@@ -67,10 +70,11 @@ function newStrategyPartConstructor () {
canvas.strategySpace.workspace.tradingSystem = payload.node
}
}
payload.node.savedPayload = undefined
setFloatingObjectBasicProperties(floatingObject, payload)
payload.node.savedPayload = undefined
floatingLayer.addFloatingObject(floatingObject)
return
@@ -97,20 +101,6 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
actionStatus: floatingObject.getFreezeStatus,
currentStatus: true,
label: undefined,
visible: false,
iconPathOn: 'broken-link',
iconPathOff: 'targeting',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 135
},
{
action: 'Download Workspace',
actionFunction: payload.onMenuItemClick,
@@ -143,6 +133,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: true,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -254,6 +258,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -324,6 +342,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -395,6 +427,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -465,6 +511,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -548,6 +608,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -618,6 +692,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -688,6 +776,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -746,6 +848,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -817,6 +933,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -888,6 +1018,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -959,6 +1103,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1030,6 +1188,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1100,6 +1272,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1171,6 +1357,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1242,6 +1442,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1331,6 +1545,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1402,6 +1630,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1473,6 +1715,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1544,6 +1800,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1620,6 +1890,20 @@ function newStrategyPartConstructor () {
currentRadius: 0,
angle: -135
},
{
action: 'Tense / Untense',
actionFunction: floatingObject.tensionToggle,
actionStatus: floatingObject.getTensionStatus,
currentStatus: false,
label: undefined,
visible: false,
iconPathOn: 'compass',
iconPathOff: 'headphones',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 180
},
{
action: 'Freeze / Unfreeze',
actionFunction: floatingObject.freezeToggle,
@@ -1685,7 +1969,7 @@ function newStrategyPartConstructor () {
function setFloatingObjectBasicProperties (floatingObject, payload) {
const FRICTION = 0.95
const INITIAL_FRICTION = 0.99
const INITIAL_FRICTION = 0.97
switch (payload.node.type) {
case 'Workspace': {
@@ -1761,11 +2045,11 @@ function newStrategyPartConstructor () {
break
}
case 'Next Phase Event': {
level_5()
level_4()
break
}
case 'Situation': {
level_5()
level_4()
break
}
case 'Condition': {
@@ -1804,6 +2088,10 @@ function newStrategyPartConstructor () {
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
if (payload.node.savedPayload === undefined) {
floatingObject.tensionToggle()
}
}
function level_2 () {
@@ -1816,6 +2104,10 @@ function newStrategyPartConstructor () {
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.GREEN + ', 1)'
if (payload.node.savedPayload === undefined) {
floatingObject.tensionToggle()
}
}
function level_3 () {
@@ -1828,6 +2120,10 @@ function newStrategyPartConstructor () {
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 1)'
if (payload.node.savedPayload === undefined) {
floatingObject.tensionToggle()
}
}
function level_4 () {
@@ -1840,6 +2136,10 @@ function newStrategyPartConstructor () {
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', 1)'
if (payload.node.savedPayload === undefined) {
floatingObject.tensionToggle()
}
}
function level_5 () {
@@ -1878,3 +2178,4 @@ function newStrategyPartConstructor () {
payload.uiObject = undefined
}
}
@@ -0,0 +1,391 @@
function newNodeChildren () {
thisObject = {
childrenCount: childrenCount
}
return thisObject
function childrenCount (parentNode, childNode) {
switch (parentNode.type) {
case 'Trading System': {
return countChildrenTradingSystem(parentNode, childNode)
}
case 'Parameters': {
return countChildrenParameters(parentNode, childNode)
}
case 'Base Asset': {
return countChildrenBaseAsset(parentNode, childNode)
}
case 'Strategy': {
return countChildrenStrategy(parentNode, childNode)
}
case 'Trigger Stage': {
return countChildrenTriggerStage(parentNode, childNode)
}
case 'Open Stage': {
return countChildrenOpenStage(parentNode, childNode)
}
case 'Manage Stage': {
return countChildrenManageStage(parentNode, childNode)
}
case 'Close Stage': {
return countChildrenCloseStage(parentNode, childNode)
}
case 'Position Size': {
return countChildrenPositionSize(parentNode, childNode)
}
case 'Initial Definition': {
return countChildrenInitialDefinition(parentNode, childNode)
}
case 'Next Phase Event': {
return countChildrenEvent(parentNode, childNode)
}
case 'Trigger On Event': {
return countChildrenEvent(parentNode, childNode)
}
case 'Trigger Off Event': {
return countChildrenEvent(parentNode, childNode)
}
case 'Take Position Event': {
return countChildrenEvent(parentNode, childNode)
}
case 'Stop': {
return countChildrenStop(parentNode, childNode)
}
case 'Take Profit': {
return countChildrenTakeProfit(parentNode, childNode)
}
case 'Phase': {
return countChildrenPhase(parentNode, childNode)
}
case 'Formula': {
return countChildrenFormula(parentNode, childNode)
}
case 'Situation': {
return countChildrenSituation(parentNode, childNode)
}
case 'Condition': {
return countChildrenCondition(parentNode, childNode)
}
case 'Code': {
return countChildrenCode(parentNode, childNode)
}
default: {
console.log('WARNING this parentNode type is not listed at NodeChildren: ' + parentNode.type)
}
}
}
function countChildrenTradingSystem (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
for (let i = 0; i < parentNode.strategies.length; i++) {
let child = parentNode.strategies[i]
response.childrenCount++
if (child.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.parameters !== undefined) {
response.childrenCount++
if (parentNode.parameters.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenParameters (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.baseAsset !== undefined) {
response.childrenCount++
if (parentNode.baseAsset.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenBaseAsset (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.formula !== undefined) {
response.childrenCount++
if (parentNode.formula.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenStrategy (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.triggerStage !== undefined) {
response.childrenCount++
if (parentNode.triggerStage.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.openStage !== undefined) {
response.childrenCount++
if (parentNode.openStage.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.manageStage !== undefined) {
response.childrenCount++
if (parentNode.manageStage.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.closeStage !== undefined) {
response.childrenCount++
if (parentNode.closeStage.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenTriggerStage (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.triggerOn !== undefined) {
response.childrenCount++
if (parentNode.triggerOn.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.triggerOff !== undefined) {
response.childrenCount++
if (parentNode.triggerOff.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.takePosition !== undefined) {
response.childrenCount++
if (parentNode.takePosition.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.positionSize !== undefined) {
response.childrenCount++
if (parentNode.positionSize.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenOpenStage (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.initialDefinition !== undefined) {
response.childrenCount++
if (parentNode.initialDefinition.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenManageStage (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.stopLoss !== undefined) {
response.childrenCount++
if (parentNode.stopLoss.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.takeProfit !== undefined) {
response.childrenCount++
if (parentNode.takeProfit.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenCloseStage (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
return response
}
function countChildrenPositionSize (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.formula !== undefined) {
response.childrenCount++
if (parentNode.formula.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenInitialDefinition (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.stopLoss !== undefined) {
response.childrenCount++
if (parentNode.stopLoss.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.takeProfit !== undefined) {
response.childrenCount++
if (parentNode.takeProfit.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenEvent (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
for (let i = 0; i < parentNode.situations.length; i++) {
let child = parentNode.situations[i]
response.childrenCount++
if (child.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenStop (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
for (let i = 0; i < parentNode.phases.length; i++) {
let child = parentNode.phases[i]
if (child.id === childNode.id) {
if (childNode.payload.chainParent !== undefined) {
if (childNode.payload.chainParent.id === parentNode.id) {
response.childrenCount++
response.childIndex = response.childrenCount
}
}
}
}
return response
}
function countChildrenTakeProfit (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
for (let i = 0; i < parentNode.phases.length; i++) {
let child = parentNode.phases[i]
if (child.id === childNode.id) {
if (childNode.payload.chainParent !== undefined) {
if (childNode.payload.chainParent.id === parentNode.id) {
response.childrenCount++
response.childIndex = response.childrenCount
}
}
}
}
return response
}
function countChildrenPhase (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.formula !== undefined) {
response.childrenCount++
if (parentNode.formula.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
if (parentNode.nextPhaseEvent !== undefined) {
response.childrenCount++
if (parentNode.nextPhaseEvent.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenFormula (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
return response
}
function countChildrenSituation (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
for (let i = 0; i < parentNode.conditions.length; i++) {
let child = parentNode.conditions[i]
response.childrenCount++
if (child.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenCondition (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.code !== undefined) {
response.childrenCount++
if (parentNode.code.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countChildrenCode (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
return response
}
}
@@ -99,8 +99,10 @@ function newNodeDeleter () {
deleteCode(rootNode, rootNodes)
break
}
default:
default: {
console.log('WARNING this node type is not listed at NodeDeleter: ' + node.type)
}
}
}
@@ -310,7 +310,8 @@ function newStringifyNode () {
},
floatingObject: {
isPinned: node.payload.floatingObject.isPinned,
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually)
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually)
},
uiObject: {
isRunning: node.payload.uiObject.isRunning
+7 -5
View File
@@ -6,6 +6,7 @@ function newWorkspace () {
tradingSystem: undefined,
container: undefined,
enabled: false,
nodeChildren: undefined,
onMenuItemClick: onMenuItemClick,
getProtocolTradingSystem: getProtocolTradingSystem,
physics: physics,
@@ -36,11 +37,12 @@ function newWorkspace () {
let workspaceNode = {}
workspaceNode.rootNodes = []
functionLibraryAttachDetach = newAttachDetach()
functionLibraryNodeDeleter = newNodeDeleter()
functionLibraryPartsFromNodes = newPartsFromNodes()
functionLibraryProtocolNode = newProtocolNode()
functionLibraryWorkspaceNodes = newStringifyNode()
let functionLibraryAttachDetach = newAttachDetach()
let functionLibraryNodeDeleter = newNodeDeleter()
let functionLibraryPartsFromNodes = newPartsFromNodes()
let functionLibraryProtocolNode = newProtocolNode()
let functionLibraryWorkspaceNodes = newStringifyNode()
thisObject.nodeChildren = newNodeChildren()
return thisObject