Designer Space Refactoring
This commit is contained in:
1 parent
d078d17881
commit
f13700287e
19 files changed
+128
-128
No files matched your search
@@ -0,0 +1,780 @@
|
||||
function newAttachDetach () {
|
||||
thisObject = {
|
||||
detachNode: detachNode,
|
||||
attachNode: attachNode
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function detachNode (node, rootNodes) {
|
||||
switch (node.type) {
|
||||
case 'Definition': {
|
||||
return
|
||||
}
|
||||
case 'Network': {
|
||||
node.payload.parentNode.network = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Network Node': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.networkNodes.length; i++) {
|
||||
let networkNode = payload.parentNode.networkNodes[i]
|
||||
if (networkNode.id === node.id) {
|
||||
payload.parentNode.networkNodes.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Personal Data': {
|
||||
node.payload.parentNode.personalData = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Exchange Account': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.exchangeAccounts.length; i++) {
|
||||
let strategy = payload.parentNode.exchangeAccounts[i]
|
||||
if (strategy.id === node.id) {
|
||||
payload.parentNode.exchangeAccounts.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Exchange Account Asset': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.assets.length; i++) {
|
||||
let asset = payload.parentNode.assets[i]
|
||||
if (asset.id === node.id) {
|
||||
payload.parentNode.assets.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Exchange Account Key': {
|
||||
let payload = node.payload
|
||||
if (payload.parentNode.keys !== undefined) {
|
||||
for (let i = 0; i < payload.parentNode.keys.length; i++) {
|
||||
let key = payload.parentNode.keys[i]
|
||||
if (key.id === node.id) {
|
||||
payload.parentNode.keys.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (payload.parentNode.key !== undefined) {
|
||||
payload.parentNode.key = undefined
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Social Bots': {
|
||||
node.payload.parentNode.socialBots = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Telegram Bot': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.bots.length; i++) {
|
||||
let bot = payload.parentNode.bots[i]
|
||||
if (bot.id === node.id) {
|
||||
payload.parentNode.bots.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Announcement': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.announcements.length; i++) {
|
||||
let announcement = payload.parentNode.announcements[i]
|
||||
if (announcement.id === node.id) {
|
||||
payload.parentNode.announcements.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Layer Manager': {
|
||||
node.payload.parentNode.layerManager = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Layer': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.layers.length; i++) {
|
||||
let layer = payload.parentNode.layers[i]
|
||||
if (layer.id === node.id) {
|
||||
payload.parentNode.layers.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Task Manager': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.taskManagers.length; i++) {
|
||||
let taskManager = payload.parentNode.taskManagers[i]
|
||||
if (taskManager.id === node.id) {
|
||||
payload.parentNode.taskManagers.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Task': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.tasks.length; i++) {
|
||||
let task = payload.parentNode.tasks[i]
|
||||
if (task.id === node.id) {
|
||||
payload.parentNode.tasks.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Sensor Bot Instance': {
|
||||
node.payload.parentNode.bot = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Indicator Bot Instance': {
|
||||
node.payload.parentNode.bot = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Trading Bot Instance': {
|
||||
node.payload.parentNode.bot = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Backtesting Session': {
|
||||
node.payload.parentNode.session = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Live Trading Session': {
|
||||
node.payload.parentNode.session = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Fordward Testing Session': {
|
||||
node.payload.parentNode.session = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Paper Trading Session': {
|
||||
node.payload.parentNode.session = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Process': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.processes.length; i++) {
|
||||
let process = payload.parentNode.processes[i]
|
||||
if (process.id === node.id) {
|
||||
payload.parentNode.processes.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Trading System': {
|
||||
node.payload.parentNode.tradingSystem = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Base Asset': {
|
||||
node.payload.parentNode.baseAsset = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Time Range': {
|
||||
node.payload.parentNode.timeRange = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Time Period': {
|
||||
node.payload.parentNode.timePeriod = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Slippage': {
|
||||
node.payload.parentNode.slippage = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Fee Structure': {
|
||||
node.payload.parentNode.feeStructure = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Parameters': {
|
||||
node.payload.parentNode.parameters = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Strategy': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.strategies.length; i++) {
|
||||
let strategy = payload.parentNode.strategies[i]
|
||||
if (strategy.id === node.id) {
|
||||
payload.parentNode.strategies.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Trigger Stage': {
|
||||
node.payload.parentNode.triggerStage = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Open Stage': {
|
||||
node.payload.parentNode.openStage = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Manage Stage': {
|
||||
node.payload.parentNode.manageStage = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Close Stage': {
|
||||
node.payload.parentNode.closeStage = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Position Size': {
|
||||
node.payload.parentNode.positionSize = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Position Rate': {
|
||||
node.payload.parentNode.positionRate = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Trigger On Event': {
|
||||
node.payload.parentNode.triggerOn = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Trigger Off Event': {
|
||||
node.payload.parentNode.triggerOff = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Take Position Event': {
|
||||
node.payload.parentNode.takePosition = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Initial Definition': {
|
||||
node.payload.parentNode.initialDefinition = undefined
|
||||
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)
|
||||
return
|
||||
}
|
||||
case 'Take Profit': {
|
||||
node.payload.parentNode.takeProfit = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Formula': {
|
||||
node.payload.parentNode.formula = undefined
|
||||
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)
|
||||
return
|
||||
}
|
||||
case 'Condition': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.conditions.length; i++) {
|
||||
let condition = payload.parentNode.conditions[i]
|
||||
if (condition.id === node.id) {
|
||||
payload.parentNode.conditions.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Situation': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.situations.length; i++) {
|
||||
let situation = payload.parentNode.situations[i]
|
||||
if (situation.id === node.id) {
|
||||
payload.parentNode.situations.splice(i, 1)
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Phase': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.phases.length; i++) {
|
||||
let phase = payload.parentNode.phases[i]
|
||||
if (phase.id === node.id) {
|
||||
if (i < payload.parentNode.phases.length - 1) {
|
||||
let nextPhase = payload.parentNode.phases[i + 1]
|
||||
if (i > 0) {
|
||||
let previousPhase = payload.parentNode.phases[i - 1]
|
||||
nextPhase.payload.chainParent = previousPhase
|
||||
} else {
|
||||
nextPhase.payload.chainParent = payload.parentNode
|
||||
}
|
||||
}
|
||||
payload.parentNode.phases.splice(i, 1)
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function attachNode (node, attachToNode, rootNodes) {
|
||||
switch (node.type) {
|
||||
case 'Network': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.network = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Network Node': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.networkNodes.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Social Bots': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.socialBots = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Telegram Bot': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.bots.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Announcement': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.announcements.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Layer Manager': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.layerManager = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Layer': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.layers.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Task Manager': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.taskManagers.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Task': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.tasks.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Sensor Bot Instance': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.bot = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Indicator Bot Instance': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.bot = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Trading Bot Instance': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.bot = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Process': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.processes.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Backtesting Session': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.session = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Live Trading Session': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.session = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Fordward Testing Session': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.session = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Paper Trading Session': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.session = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Personal Data': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.personalData = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Exchange Account': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.exchangeAccounts.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Exchange Account Asset': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.assets.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Exchange Account Key': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
if (node.payload.parentNode.keys !== undefined) {
|
||||
node.payload.parentNode.keys.push(node)
|
||||
} else {
|
||||
node.payload.parentNode.key = node
|
||||
}
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
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 'Time Range': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.timeRange = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Time Period': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.timePeriod = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Slippage': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.slippage = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Fee Structure': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.feeStructure = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Trading System': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.tradingSystem = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Strategy': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.strategies.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Trigger Stage': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.triggerStage = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Open Stage': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.openStage = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Manage Stage': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.manageStage = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Close Stage': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.closeStage = node
|
||||
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 'Position Rate': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.positionRate = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Initial Definition': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.initialDefinition = node
|
||||
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
|
||||
node.payload.parentNode.triggerOn = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Trigger Off Event': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.triggerOff = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Take Position Event': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.takePosition = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Stop': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.stopLoss = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Take Profit': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.takeProfit = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Formula': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.formula = node
|
||||
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': {
|
||||
if (attachToNode.maxPhases !== undefined) {
|
||||
if (attachToNode.phases.length >= attachToNode.maxPhases) {
|
||||
return
|
||||
}
|
||||
}
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Take Profit': {
|
||||
if (attachToNode.maxPhases !== undefined) {
|
||||
if (attachToNode.phases.length >= attachToNode.maxPhases) {
|
||||
return
|
||||
}
|
||||
}
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
node.payload.parentNode = attachToNode.payload.parentNode
|
||||
for (let i = 0; i < node.payload.parentNode.phases.length; i++) {
|
||||
let phase = node.payload.parentNode.phases[i]
|
||||
if (attachToNode.id === phase.id) {
|
||||
if (i === node.payload.parentNode.phases.length - 1) {
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
let nextPhase = node.payload.parentNode.phases[i + 1]
|
||||
nextPhase.payload.chainParent = node
|
||||
node.payload.parentNode.phases.splice(i + 1, 0, node)
|
||||
completeAttachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'Situation': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.situations.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Condition': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.conditions.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Code': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.code = node
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function completeDetachment (node, rootNodes) {
|
||||
node.payload.parentNode = undefined
|
||||
node.payload.chainParent = undefined
|
||||
rootNodes.push(node)
|
||||
}
|
||||
|
||||
function completeAttachment (node, rootNodes) {
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode.id === node.id) {
|
||||
rootNodes.splice(i, 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,977 @@
|
||||
function newNodeChildren () {
|
||||
thisObject = {
|
||||
childrenCount: childrenCount
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function childrenCount (parentNode, childNode) {
|
||||
switch (parentNode.type) {
|
||||
|
||||
case 'Definition': {
|
||||
return countChildrenDefinition(parentNode, childNode)
|
||||
}
|
||||
case 'Network': {
|
||||
return countChildrenNetwork(parentNode, childNode)
|
||||
}
|
||||
case 'Network Node': {
|
||||
return countChildrenNetworkNode(parentNode, childNode)
|
||||
}
|
||||
case 'Social Bots': {
|
||||
return countChildrenSocialBots(parentNode, childNode)
|
||||
}
|
||||
case 'Telegram Bot': {
|
||||
return countChildrenTelegramBot(parentNode, childNode)
|
||||
}
|
||||
case 'Announcement': {
|
||||
return countChildrenAnnouncement(parentNode, childNode)
|
||||
}
|
||||
case 'Layer Manager': {
|
||||
return countChildrenLayerManager(parentNode, childNode)
|
||||
}
|
||||
case 'Layer': {
|
||||
return countChildrenLayer(parentNode, childNode)
|
||||
}
|
||||
case 'Task Manager': {
|
||||
return countChildrenTaskManager(parentNode, childNode)
|
||||
}
|
||||
case 'Task': {
|
||||
return countChildrenTask(parentNode, childNode)
|
||||
}
|
||||
case 'Sensor Bot Instance': {
|
||||
return countChildrenSensorBotInstance(parentNode, childNode)
|
||||
}
|
||||
case 'Indicator Bot Instance': {
|
||||
return countChildrenIndicatorBotInstance(parentNode, childNode)
|
||||
}
|
||||
case 'Trading Bot Instance': {
|
||||
return countChildrenTradingBotInstance(parentNode, childNode)
|
||||
}
|
||||
case 'Process': {
|
||||
return countChildrenProcess(parentNode, childNode)
|
||||
}
|
||||
case 'Backtesting Session': {
|
||||
return countBacktestingSession(parentNode, childNode)
|
||||
}
|
||||
case 'Live Trading Session': {
|
||||
return countLiveTradingSession(parentNode, childNode)
|
||||
}
|
||||
case 'Fordward Testing Session': {
|
||||
return countFordwardTestingSession(parentNode, childNode)
|
||||
}
|
||||
case 'Paper Trading Session': {
|
||||
return countPaperTradingSession(parentNode, childNode)
|
||||
}
|
||||
case 'Personal Data': {
|
||||
return countChildrenPersonalData(parentNode, childNode)
|
||||
}
|
||||
case 'Exchange Account': {
|
||||
return countChildrenExchangeAccount(parentNode, childNode)
|
||||
}
|
||||
case 'Exchange Account Asset': {
|
||||
return countChildrenExchangeAccountAsset(parentNode, childNode)
|
||||
}
|
||||
case 'Exchange Account Key': {
|
||||
return countChildrenExchangeAccountKey(parentNode, childNode)
|
||||
}
|
||||
case 'Trading System': {
|
||||
return countChildrenTradingSystem(parentNode, childNode)
|
||||
}
|
||||
case 'Parameters': {
|
||||
return countChildrenParameters(parentNode, childNode)
|
||||
}
|
||||
case 'Base Asset': {
|
||||
return countChildrenBaseAsset(parentNode, childNode)
|
||||
}
|
||||
case 'Time Range': {
|
||||
return countChildrenTimeRange(parentNode, childNode)
|
||||
}
|
||||
case 'Time Period': {
|
||||
return countChildrenTimePeriod(parentNode, childNode)
|
||||
}
|
||||
case 'Slippage': {
|
||||
return countChildrenSlippage(parentNode, childNode)
|
||||
}
|
||||
case 'Fee Structure': {
|
||||
return countChildrenFeeStructure(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 'Position Rate': {
|
||||
return countChildrenPositionSize(parentNode, childNode)
|
||||
}
|
||||
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)
|
||||
}
|
||||
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 countChildrenDefinition (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.tradingSystem !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.tradingSystem.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.personalData !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.personalData.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.network !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.network.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenNetwork (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.networkNodes !== undefined) {
|
||||
for (let i = 0; i < parentNode.networkNodes.length; i++) {
|
||||
let child = parentNode.networkNodes[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenNetworkNode (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.taskManagers !== undefined) {
|
||||
for (let i = 0; i < parentNode.taskManagers.length; i++) {
|
||||
let child = parentNode.taskManagers[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenSocialBots (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.bots.length; i++) {
|
||||
let child = parentNode.bots[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTelegramBot (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.announcements.length; i++) {
|
||||
let child = parentNode.announcements[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenAnnouncement (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 countChildrenLayerManager (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.layers.length; i++) {
|
||||
let child = parentNode.layers[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenLayer (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTaskManager (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.tasks.length; i++) {
|
||||
let child = parentNode.tasks[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTask (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.bot !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.bot.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenSensorBotInstance (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.processes.length; i++) {
|
||||
let child = parentNode.processes[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenIndicatorBotInstance (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.processes.length; i++) {
|
||||
let child = parentNode.processes[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTradingBotInstance (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.processes.length; i++) {
|
||||
let child = parentNode.processes[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenProcess (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.session !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.session.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countBacktestingSession (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.parameters !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.parameters.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.layerManager !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.layerManager.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.socialBots !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.socialBots.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countLiveTradingSession (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.parameters !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.parameters.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.layerManager !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.layerManager.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.socialBots !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.socialBots.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countFordwardTestingSession (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.parameters !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.parameters.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.layerManager !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.layerManager.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.socialBots !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.socialBots.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countPaperTradingSession (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
if (parentNode.parameters !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.parameters.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.layerManager !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.layerManager.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.socialBots !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.socialBots.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenPersonalData (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.exchangeAccounts.length; i++) {
|
||||
let child = parentNode.exchangeAccounts[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenExchangeAccount (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.assets.length; i++) {
|
||||
let child = parentNode.assets[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < parentNode.keys.length; i++) {
|
||||
let child = parentNode.keys[i]
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenExchangeAccountAsset (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenExchangeAccountKey (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
if (parentNode.timeRange !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.timeRange.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.timePeriod !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.timePeriod.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.slippage !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.slippage.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.feeStructure !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.feeStructure.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
if (parentNode.key !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.key.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenBaseAsset (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTimeRange (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTimePeriod (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenSlippage (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenFeeStructure (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
if (parentNode.openExecution !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.openExecution.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
|
||||
}
|
||||
if (parentNode.closeExecution !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.closeExecution.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
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 countChildrenPositionRate (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.positionSize !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.positionSize.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
if (parentNode.positionRate !== undefined) {
|
||||
response.childrenCount++
|
||||
if (parentNode.positionRate.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
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,
|
||||
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
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < parentNode.announcements.length; i++) {
|
||||
let child = parentNode.announcements[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
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < parentNode.announcements.length; i++) {
|
||||
let child = parentNode.announcements[i]
|
||||
response.childrenCount++
|
||||
if (child.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
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,738 @@
|
||||
function newOnFocus () {
|
||||
thisObject = {
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getNodeThatIsOnFocus (node) {
|
||||
if (node === undefined) { return }
|
||||
switch (node.type) {
|
||||
case 'Code':
|
||||
{
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Condition':
|
||||
{
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.code)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Situation': {
|
||||
let child
|
||||
for (let m = 0; m < node.conditions.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.conditions[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Formula':
|
||||
{
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Next Phase Event':
|
||||
{
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.situations[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.announcements[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Phase': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.formula)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.nextPhaseEvent)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.announcements[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Stop': {
|
||||
let child
|
||||
for (let m = 0; m < node.phases.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.phases[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Take Profit': {
|
||||
let child
|
||||
for (let m = 0; m < node.phases.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.phases[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Take Position Event': {
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.situations[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.announcements[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trigger On Event': {
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.situations[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.announcements[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trigger Off Event': {
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.situations[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.announcements[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Initial Definition': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.stopLoss)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.takeProfit)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.positionSize)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.positionRate)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Open Execution': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Close Execution': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Position Size': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.formula)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Position Rate': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.formula)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trigger Stage': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.triggerOn)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.triggerOff)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.takePosition)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Open Stage': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.initialDefinition)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.openExecution)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Manage Stage': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.stopLoss)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.takeProfit)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Close Stage': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.closeExecution)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Strategy': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.triggerStage)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.openStage)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.manageStage)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.closeStage)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Base Asset': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Time Range': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Time Period': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Slippage': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Fee Structure': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Parameters': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.baseAsset)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.timeRange)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.timePeriod)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.slippage)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.feeStructure)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trading System': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.parameters)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
for (let m = 0; m < node.strategies.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.strategies[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Personal Data': {
|
||||
let child
|
||||
for (let m = 0; m < node.exchangeAccounts.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.exchangeAccounts[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Exchange Account': {
|
||||
let child
|
||||
for (let m = 0; m < node.assets.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.assets[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.keys.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.keys[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Exchange Account Asset': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Exchange Account Key': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Social Bots': {
|
||||
let child
|
||||
for (let m = 0; m < node.bots.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.bots[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Telegram Bot': {
|
||||
let child
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.announcements[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Announcement': {
|
||||
child = getNodeThatIsOnFocus(node.formula)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Layer Manager': {
|
||||
let child
|
||||
for (let m = 0; m < node.layers.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.layers[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Layer': {
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Task Manager': {
|
||||
let child
|
||||
for (let m = 0; m < node.tasks.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.tasks[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Task': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.bot)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Sensor Bot Instance': {
|
||||
let child
|
||||
for (let m = 0; m < node.processes.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.processes[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Indicator Bot Instance': {
|
||||
let child
|
||||
for (let m = 0; m < node.processes.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.processes[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trading Bot Instance': {
|
||||
let child
|
||||
for (let m = 0; m < node.processes.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.processes[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Process': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.session)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Backtesting Session': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.parameters)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.layerManager)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.socialBots)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Live Trading Session': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.parameters)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.layerManager)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.socialBots)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Fordward Testing Session': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.parameters)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.layerManager)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.socialBots)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Paper Trading Session': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.parameters)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.layerManager)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.socialBots)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Network Node': {
|
||||
let child
|
||||
for (let m = 0; m < node.taskManagers.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.taskManagers[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Network': {
|
||||
let child
|
||||
for (let m = 0; m < node.networkNodes.length; m++) {
|
||||
child = getNodeThatIsOnFocus(node.networkNodes[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Definition': {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node.tradingSystem)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.personalData)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeThatIsOnFocus(node.network)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,73 @@
|
||||
function newSessionFunctions () {
|
||||
thisObject = {
|
||||
runSession: runSession,
|
||||
stopSession: stopSession
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function runSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
/* We can not run a sessionif its parent process is not running. Less if it does not have a parent. */
|
||||
if (node.payload.parentNode === undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
if (node.payload.parentNode.payload.uiObject.isRunning !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
node.payload.uiObject.run(callBackFunction)
|
||||
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
|
||||
let thisNodeDefinition = getDefinition(node)
|
||||
if (thisNodeDefinition === undefined) { return }
|
||||
|
||||
/* Raise event to run the session */
|
||||
let event = {
|
||||
session: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true)),
|
||||
definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(thisNodeDefinition, false, true, true)),
|
||||
uiCurrentValues: getUICurrentValues()
|
||||
}
|
||||
|
||||
systemEventHandler.raiseEvent(key, 'Run Session', event)
|
||||
|
||||
function getDefinition (node) {
|
||||
if (node.type === 'Definition') {
|
||||
return node
|
||||
}
|
||||
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
return getDefinition(node.payload.parentNode)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
function getUICurrentValues () {
|
||||
let dateAtScreenCorner = new Date(window.localStorage.getItem('Date @ Screen Corner'))
|
||||
let currentTimePeriod = JSON.parse(window.localStorage.getItem('Current Time Period'))
|
||||
|
||||
let timePeriodsMasterArray = [marketFilesPeriods, dailyFilePeriods]
|
||||
let timePeriodArray = timePeriodsMasterArray[currentTimePeriod.filePeriodIndex]
|
||||
let timePeriod = timePeriodArray[currentTimePeriod.timePeriodIndex][1]
|
||||
|
||||
let uiCurrentValues = {
|
||||
initialDatetime: dateAtScreenCorner,
|
||||
timePeriod: timePeriod,
|
||||
timestamp: (new Date()).valueOf()
|
||||
}
|
||||
|
||||
return uiCurrentValues
|
||||
}
|
||||
}
|
||||
|
||||
function stopSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
systemEventHandler.raiseEvent(key, 'Stop Session')
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,723 @@
|
||||
function newShortcutKeys () {
|
||||
thisObject = {
|
||||
getNodeByShortcutKey: getNodeByShortcutKey
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getNodeByShortcutKey (node, searchingKey) {
|
||||
if (node === undefined) { return }
|
||||
switch (node.type) {
|
||||
case 'Code':
|
||||
{
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Condition':
|
||||
{
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.code, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Situation': {
|
||||
let child
|
||||
for (let m = 0; m < node.conditions.length; m++) {
|
||||
child = getNodeByShortcutKey(node.conditions[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Formula':
|
||||
{
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Next Phase Event':
|
||||
{
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeByShortcutKey(node.situations[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeByShortcutKey(node.announcements[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Phase': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.formula, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.nextPhaseEvent, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeByShortcutKey(node.announcements[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Stop': {
|
||||
let child
|
||||
for (let m = 0; m < node.phases.length; m++) {
|
||||
child = getNodeByShortcutKey(node.phases[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Take Profit': {
|
||||
let child
|
||||
for (let m = 0; m < node.phases.length; m++) {
|
||||
child = getNodeByShortcutKey(node.phases[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Take Position Event': {
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeByShortcutKey(node.situations[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeByShortcutKey(node.announcements[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trigger On Event': {
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeByShortcutKey(node.situations[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeByShortcutKey(node.announcements[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trigger Off Event': {
|
||||
let child
|
||||
for (let m = 0; m < node.situations.length; m++) {
|
||||
child = getNodeByShortcutKey(node.situations[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeByShortcutKey(node.announcements[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Initial Definition': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.stopLoss, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.takeProfit, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.positionSize, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.positionRate, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Open Execution': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Close Execution': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Position Size': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.formula, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Position Rate': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.formula, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trigger Stage': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.triggerOn, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.triggerOff, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.takePosition, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Open Stage': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.initialDefinition, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.openExecution, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Manage Stage': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.stopLoss, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.takeProfit, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Close Stage': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.closeExecution, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Strategy': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.triggerStage, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.openStage, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.manageStage, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.closeStage, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Base Asset': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Time Range': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Time Period': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Slippage': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Fee Structure': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Parameters': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.baseAsset, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.timeRange, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.timePeriod, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.slippage, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.feeStructure, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trading System': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.parameters, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
for (let m = 0; m < node.strategies.length; m++) {
|
||||
child = getNodeByShortcutKey(node.strategies[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Personal Data': {
|
||||
let child
|
||||
for (let m = 0; m < node.exchangeAccounts.length; m++) {
|
||||
child = getNodeByShortcutKey(node.exchangeAccounts[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Exchange Account': {
|
||||
let child
|
||||
for (let m = 0; m < node.assets.length; m++) {
|
||||
child = getNodeByShortcutKey(node.assets[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
for (let m = 0; m < node.keys.length; m++) {
|
||||
child = getNodeByShortcutKey(node.keys[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Exchange Account Asset': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Exchange Account Key': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Social Bots': {
|
||||
let child
|
||||
for (let m = 0; m < node.bots.length; m++) {
|
||||
child = getNodeByShortcutKey(node.bots[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Telegram Bot': {
|
||||
let child
|
||||
for (let m = 0; m < node.announcements.length; m++) {
|
||||
child = getNodeByShortcutKey(node.announcements[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Announcement': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.formula, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Layer Manager': {
|
||||
let child
|
||||
for (let m = 0; m < node.layers.length; m++) {
|
||||
child = getNodeByShortcutKey(node.layers[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Layer': {
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Task Manager': {
|
||||
let child
|
||||
for (let m = 0; m < node.tasks.length; m++) {
|
||||
child = getNodeByShortcutKey(node.tasks[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Task': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.bot, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Sensor Bot Instance': {
|
||||
let child
|
||||
for (let m = 0; m < node.processes.length; m++) {
|
||||
child = getNodeByShortcutKey(node.processes[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Indicator Bot Instance': {
|
||||
let child
|
||||
for (let m = 0; m < node.processes.length; m++) {
|
||||
child = getNodeByShortcutKey(node.processes[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Trading Bot Instance': {
|
||||
let child
|
||||
for (let m = 0; m < node.processes.length; m++) {
|
||||
child = getNodeByShortcutKey(node.processes[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Process': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.session, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Backtesting Session': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.parameters, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.layerManager, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Live Trading Session': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.parameters, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.layerManager, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Fordward Testing Session': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.parameters, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.layerManager, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Paper Trading Session': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.parameters, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.layerManager, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'Network Node': {
|
||||
let child
|
||||
for (let m = 0; m < node.taskManagers.length; m++) {
|
||||
child = getNodeByShortcutKey(node.taskManagers[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Network': {
|
||||
let child
|
||||
for (let m = 0; m < node.networkNodes.length; m++) {
|
||||
child = getNodeByShortcutKey(node.networkNodes[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
case 'Definition': {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node.tradingSystem, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.personalData, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
child = getNodeByShortcutKey(node.network, searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
function newTaskFunctions () {
|
||||
thisObject = {
|
||||
runTask: runTask,
|
||||
stopTask: stopTask,
|
||||
runAllTasks: runAllTasks,
|
||||
stopAllTasks: stopAllTasks
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function runTask (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
/* Check if it is possible to Run or not */
|
||||
if (node.bot === undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
if (node.bot.processes.length === 0) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
for (let i = 0; i < node.bot.processes.length; i++) {
|
||||
let process = node.bot.processes[i]
|
||||
process.payload.uiObject.run()
|
||||
}
|
||||
|
||||
node.payload.uiObject.run(callBackFunction)
|
||||
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name,
|
||||
definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true)) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager.
|
||||
}
|
||||
systemEventHandler.raiseEvent('Task Manager', 'Run Task', event)
|
||||
}
|
||||
|
||||
function stopTask (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name
|
||||
}
|
||||
systemEventHandler.raiseEvent('Task Manager', 'Stop Task', event)
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
|
||||
if (node.bot === undefined) { return }
|
||||
if (node.bot.processes.length === 0) { return }
|
||||
|
||||
for (let i = 0; i < node.bot.processes.length; i++) {
|
||||
let process = node.bot.processes[i]
|
||||
process.payload.uiObject.stop()
|
||||
}
|
||||
}
|
||||
|
||||
function runAllTasks (taskManager, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < taskManager.tasks.length; i++) {
|
||||
let node = taskManager.tasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Run Task')
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllTasks (taskManager, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < taskManager.tasks.length; i++) {
|
||||
let node = taskManager.tasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Stop Task')
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user