diff --git a/Canvas.js b/Canvas.js index 9da5ed793..fcc1c23b6 100644 --- a/Canvas.js +++ b/Canvas.js @@ -37,7 +37,7 @@ function newCanvas () { panelsSpace: undefined, cockpitSpace: undefined, bottomSpace: undefined, - strategySpace: undefined, + designerSpace: undefined, animation: undefined, initialize: initialize, finalize: finalize @@ -47,6 +47,7 @@ function newCanvas () { let splashScreen let lastContainerMouseOver + return thisObject function finalize () { @@ -71,6 +72,9 @@ function newCanvas () { browserCanvas.removeEventListener('drop', onDragDrop, false) browserCanvas.removeEventListener('keydown', onKeyDown, false) + + splashScreen = undefined + lastContainerMouseOver = undefined } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) } } @@ -90,8 +94,8 @@ function newCanvas () { thisObject.topSpace = newTopSpace() await thisObject.topSpace.initialize() - thisObject.strategySpace = newStrategySpace() - await thisObject.strategySpace.initialize() + thisObject.designerSpace = newDesignerSpace() + await thisObject.designerSpace.initialize() thisObject.cockpitSpace = newCockpitSpace() thisObject.cockpitSpace.initialize() @@ -118,13 +122,17 @@ function newCanvas () { animation.initialize() thisObject.animation = animation + /* Low Level Infraestructure First */ + animation.addCallBackFunction('System Event Handler Physics', systemEventHandler.physics) + /* Spcaces Physics */ animation.addCallBackFunction('Floating Space Physics', thisObject.floatingSpace.physics) animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics) animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics) - animation.addCallBackFunction('Strategy Space Physics', thisObject.strategySpace.physics) + animation.addCallBackFunction('Strategy Space Physics', thisObject.designerSpace.physics) animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics) + /* Spcaces Drawing */ animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) animation.addCallBackFunction('Chart Space Background', thisObject.chartSpace.drawBackground) animation.addCallBackFunction('Chart Space Draw', thisObject.chartSpace.draw) @@ -132,7 +140,7 @@ function newCanvas () { animation.addCallBackFunction('ViewPort Animate', viewPort.animate) animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw) animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) - animation.addCallBackFunction('Strategy Space Draw', thisObject.strategySpace.draw) + animation.addCallBackFunction('Strategy Space Draw', thisObject.designerSpace.draw) animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw) animation.start() } catch (err) { @@ -186,20 +194,27 @@ function newCanvas () { } function onKeyDown (event) { - let nodeOnFocus = canvas.strategySpace.workspace.getNodeThatIsOnFocus() + let nodeOnFocus = canvas.designerSpace.workspace.getNodeThatIsOnFocus() if (nodeOnFocus !== undefined) { if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) { if (nodeOnFocus.payload.uiObject.codeEditor.visible === true) { return } } - if (nodeOnFocus.payload.uiObject.partTitle !== undefined) { - if (nodeOnFocus.payload.uiObject.partTitle.editMode === true) { + if (nodeOnFocus.payload.uiObject.uiObjectTitle !== undefined) { + if (nodeOnFocus.payload.uiObject.uiObjectTitle.editMode === true) { return } } } + if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true && event.shiftKey === true && event.keyCode === 123) { // Dev Tool when used with F12 + if (nodeOnFocus !== undefined) { + console.log(nodeOnFocus) + return + } + } + if (event.altKey === true && event.code === 'ArrowUp') { thisObject.cockpitSpace.toTop() return @@ -231,22 +246,34 @@ function newCanvas () { } if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowLeft') { - canvas.floatingSpace.oneScreenLeft() + let displaceVector = canvas.floatingSpace.oneScreenLeft() + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() return } if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowRight') { - canvas.floatingSpace.oneScreenRight() + let displaceVector = canvas.floatingSpace.oneScreenRight() + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() return } if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowUp') { - canvas.floatingSpace.oneScreenUp() + let displaceVector = canvas.floatingSpace.oneScreenUp() + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() return } if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowDown') { - canvas.floatingSpace.oneScreenDown() + let displaceVector = canvas.floatingSpace.oneScreenDown() + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() return } @@ -257,12 +284,12 @@ function newCanvas () { } } - if ((event.ctrlKey === true || event.metaKey === true)) { + if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true) { if (event.keyCode >= 65 && event.keyCode <= 90) { /* From here we prevent the default behaviour */ event.preventDefault() - let nodeUsingThisKey = canvas.strategySpace.workspace.getNodeByShortcutKey(event.key) + let nodeUsingThisKey = canvas.designerSpace.workspace.getNodeByShortcutKey(event.key) if (nodeOnFocus === undefined && nodeUsingThisKey !== undefined) { /* Then we displace the whole workspace to center it at the node using this key */ @@ -284,15 +311,15 @@ function newCanvas () { /* If there is not node using this key and a node in focus, we assign this key to this node */ if (nodeUsingThisKey === undefined && nodeOnFocus !== undefined) { nodeOnFocus.payload.uiObject.shortcutKey = event.key - nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + ' + event.key) + nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + event.key) } return } } - if (event.ctrlKey === true && nodeOnFocus !== undefined) { + if (event.ctrlKey === true && event.altKey === true && nodeOnFocus !== undefined) { if (nodeOnFocus.payload.uiObject.shortcutKey !== undefined && nodeOnFocus.payload.uiObject.shortcutKey !== '') { - nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + ' + nodeOnFocus.payload.uiObject.shortcutKey) + nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + nodeOnFocus.payload.uiObject.shortcutKey) } } } @@ -345,7 +372,7 @@ function newCanvas () { x: event.x, y: event.y } - thisObject.strategySpace.workspace.spawn(reader.result, mousePosition) + thisObject.designerSpace.workspace.spawn(reader.result, mousePosition) } } } catch (err) { @@ -368,7 +395,7 @@ function newCanvas () { /* We check if the mouse is over an element of the Strategy Space / */ - container = thisObject.strategySpace.getContainer(point) + container = thisObject.designerSpace.getContainer(point) if (container !== undefined && container.isDraggeable === true) { containerBeingDragged = container @@ -474,7 +501,7 @@ function newCanvas () { /* We check if the mouse is over an element of the Strategy Space / */ - container = thisObject.strategySpace.getContainer(point) + container = thisObject.designerSpace.getContainer(point) if (container !== undefined && container.isClickeable === true) { container.eventHandler.raiseEvent('onMouseClick', point) @@ -546,6 +573,7 @@ function newCanvas () { function onMouseMove (event) { try { + /* Processing the event */ let point = { x: event.pageX, y: event.pageY - CURRENT_TOP_MARGIN @@ -603,8 +631,8 @@ function newCanvas () { /* We check if the mouse is over an element of the Strategy Space / */ - if (thisObject.strategySpace !== undefined) { - container = thisObject.strategySpace.getContainer(point) + if (thisObject.designerSpace !== undefined) { + container = thisObject.designerSpace.getContainer(point) if (container !== undefined && container.detectMouseOver === true) { containerFound() @@ -773,11 +801,6 @@ function newCanvas () { function checkDrag (event) { try { if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { - let point = { - x: event.pageX, - y: event.pageY - CURRENT_TOP_MARGIN - } - browserCanvas.style.cursor = 'grabbing' thisObject.eventHandler.raiseEvent('Dragging', undefined) diff --git a/Dashboard.js b/Dashboard.js index f6d435b22..5e0d85852 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -106,7 +106,7 @@ function newDashboard () { function setBrowserEvents () { window.onbeforeunload = onBrowserClosed function onBrowserClosed () { - canvas.strategySpace.workspace.stopAllRunningTasks() + canvas.designerSpace.workspace.stopAllRunningTasks() } } } diff --git a/StrategySpace/StrategizerGateway.js b/DesignerSpace/StrategizerGateway.js similarity index 96% rename from StrategySpace/StrategizerGateway.js rename to DesignerSpace/StrategizerGateway.js index bcf8644bb..2b626447f 100644 --- a/StrategySpace/StrategizerGateway.js +++ b/DesignerSpace/StrategizerGateway.js @@ -1,95 +1,95 @@ - -function newStrategizerGateway () { - const MODULE_NAME = 'Strategizer Gateway' - const logger = newWebDebugLog() - logger.fileName = MODULE_NAME - - let thisObject = { - idAtStrategizer: undefined, - strategizerData: undefined, - container: undefined, - loadFromStrategyzer: loadFromStrategyzer - } - - let colletionItems = [] - - thisObject.container = newContainer() - thisObject.container.name = MODULE_NAME - thisObject.container.initialize() - - thisObject.container.frame.width = 0 - thisObject.container.frame.height = 0 - - thisObject.container.frame.position.x = 0 - thisObject.container.frame.position.y = 0 - - thisObject.container.isDraggeable = false - thisObject.container.isClickeable = false - - let graphQLServer - - return thisObject - - async function loadFromStrategyzer () { - try { - const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY) - if (accessToken === null) { - logger.write('[ERROR] loadFromStrategyzer -> Can load from strategizer because the accessToken is missing.') - return - } - - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) - if (user === null) { - logger.write('[ERROR] saveToStrategyzer -> Can not load from strategizer because user is not logged in. ') - return - } - - user = JSON.parse(user) - - if (window.canvasApp.executingAt === 'Local') { - window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, 'Local File') - thisObject.strategizerData = JSON.parse('{"type":"Definition"}') - thisObject.idAtStrategizer = 'Local File' - return true - } else { - let fbSlug = 'simulator-bot-' + user.alias.replace('.', '') - - graphQLServer = await axios({ - url: window.canvasApp.graphQL.masterAppApiUrl, - method: 'post', - data: { - query: - ` - query($fbSlug: String!){ - strategizer_TradingSystemByFb(fbSlug: $fbSlug){ - id - fbSlug - data - } - } - `, - - variables: { - fbSlug: fbSlug - } - }, - headers: { - authorization: 'Bearer ' + accessToken - } - }) - - if (graphQLServer.data.errors) { - logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors)) - return false - } else { - thisObject.strategizerData = JSON.parse(JSON.stringify(graphQLServer.data.data.strategizer_TradingSystemByFb.data)) - thisObject.idAtStrategizer = graphQLServer.data.data.strategizer_TradingSystemByFb.id - window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer) - return true - } - } - } catch (err) { - logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack) - } + +function newStrategizerGateway () { + const MODULE_NAME = 'Strategizer Gateway' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + idAtStrategizer: undefined, + strategizerData: undefined, + container: undefined, + loadFromStrategyzer: loadFromStrategyzer } -} + + let colletionItems = [] + + thisObject.container = newContainer() + thisObject.container.name = MODULE_NAME + thisObject.container.initialize() + + thisObject.container.frame.width = 0 + thisObject.container.frame.height = 0 + + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 + + thisObject.container.isDraggeable = false + thisObject.container.isClickeable = false + + let graphQLServer + + return thisObject + + async function loadFromStrategyzer () { + try { + const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY) + if (accessToken === null) { + logger.write('[ERROR] loadFromStrategyzer -> Can load from strategizer because the accessToken is missing.') + return + } + + let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) + if (user === null) { + logger.write('[ERROR] saveToStrategyzer -> Can not load from strategizer because user is not logged in. ') + return + } + + user = JSON.parse(user) + + if (window.canvasApp.executingAt === 'Local') { + window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, 'Local File') + thisObject.strategizerData = JSON.parse('{"type":"Definition"}') + thisObject.idAtStrategizer = 'Local File' + return true + } else { + let fbSlug = 'simulator-bot-' + user.alias.replace('.', '') + + graphQLServer = await axios({ + url: window.canvasApp.graphQL.masterAppApiUrl, + method: 'post', + data: { + query: + ` + query($fbSlug: String!){ + strategizer_TradingSystemByFb(fbSlug: $fbSlug){ + id + fbSlug + data + } + } + `, + + variables: { + fbSlug: fbSlug + } + }, + headers: { + authorization: 'Bearer ' + accessToken + } + }) + + if (graphQLServer.data.errors) { + logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors)) + return false + } else { + thisObject.strategizerData = JSON.parse(JSON.stringify(graphQLServer.data.data.strategizer_TradingSystemByFb.data)) + thisObject.idAtStrategizer = graphQLServer.data.data.strategizer_TradingSystemByFb.id + window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer) + return true + } + } + } catch (err) { + logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack) + } + } +} diff --git a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js similarity index 66% rename from StrategySpace/Workspace/FunctionLibraries/AttachDetach.js rename to DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index 43a73a8b5..768153f6a 100644 --- a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -1,18 +1,212 @@ -function newAttachDetach () { +function newChainAttachDetach () { thisObject = { - detachNode: detachNode, - attachNode: attachNode + chainDetachNode: chainDetachNode, + chainAttachNode: chainAttachNode } return thisObject - function detachNode (node, rootNodes) { + function chainDetachNode (node, rootNodes) { switch (node.type) { case 'Definition': { return } case 'Network': { - node.payload.parentNode.network = undefined + return + } + case 'Team': { + return + } + case 'Sensor Bot': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.sensorBots.length; i++) { + let sensorBot = payload.parentNode.sensorBots[i] + if (sensorBot.id === node.id) { + payload.parentNode.sensorBots.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Indicator Bot': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.indicatorBots.length; i++) { + let indicatorBot = payload.parentNode.indicatorBots[i] + if (indicatorBot.id === node.id) { + payload.parentNode.indicatorBots.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Trading Bot': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.tradingBots.length; i++) { + let tradingBot = payload.parentNode.tradingBots[i] + if (tradingBot.id === node.id) { + payload.parentNode.tradingBots.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Process Definition': { + 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 'Process Output': { + node.payload.parentNode.processOutput = undefined + completeDetachment(node, rootNodes) + return + } + case 'Process Dependencies': { + node.payload.parentNode.processDependencies = undefined + completeDetachment(node, rootNodes) + return + } + case 'Status Report': { + node.payload.parentNode.statusReport = undefined + completeDetachment(node, rootNodes) + return + } + case 'Execution Started Event': { + node.payload.parentNode.executionStartedEvent = undefined + completeDetachment(node, rootNodes) + return + } + case 'Execution Finished Event': { + node.payload.parentNode.executionFinishedEvent = undefined + completeDetachment(node, rootNodes) + return + } + case 'Calculations Procedure': { + node.payload.parentNode.calculations = undefined + completeDetachment(node, rootNodes) + return + } + case 'Data Building Procedure': { + node.payload.parentNode.dataBuilding = undefined + completeDetachment(node, rootNodes) + return + } + case 'Procedure Initialization': { + node.payload.parentNode.initialization = undefined + completeDetachment(node, rootNodes) + return + } + case 'Procedure Loop': { + node.payload.parentNode.loop = undefined + completeDetachment(node, rootNodes) + return + } + case 'Output Dataset': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.outputDatasets.length; i++) { + let outputDataset = payload.parentNode.outputDatasets[i] + if (outputDataset.id === node.id) { + payload.parentNode.outputDatasets.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Status Dependency': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.statusDependencies.length; i++) { + let statusDependency = payload.parentNode.statusDependencies[i] + if (statusDependency.id === node.id) { + payload.parentNode.statusDependencies.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Data Dependency': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.dataDependencies.length; i++) { + let dataDependency = payload.parentNode.dataDependencies[i] + if (dataDependency.id === node.id) { + payload.parentNode.dataDependencies.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Product Definition': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.products.length; i++) { + let product = payload.parentNode.products[i] + if (product.id === node.id) { + payload.parentNode.products.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Record Definition': { + node.payload.parentNode.record = undefined + completeDetachment(node, rootNodes) + return + } + case 'Record Property': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.properties.length; i++) { + let property = payload.parentNode.properties[i] + if (property.id === node.id) { + payload.parentNode.properties.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Dataset Definition': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.datasets.length; i++) { + let dataset = payload.parentNode.datasets[i] + if (dataset.id === node.id) { + payload.parentNode.datasets.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Plotter': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.plotters.length; i++) { + let plotter = payload.parentNode.plotters[i] + if (plotter.id === node.id) { + payload.parentNode.plotters.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Plotter Module': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.modules.length; i++) { + let module = payload.parentNode.modules[i] + if (module.id === node.id) { + payload.parentNode.modules.splice(i, 1) + } + } + completeDetachment(node, rootNodes) + return + } + case 'Plotter Panel': { + let payload = node.payload + for (let i = 0; i < payload.parentNode.panels.length; i++) { + let panel = payload.parentNode.panels[i] + if (panel.id === node.id) { + payload.parentNode.panels.splice(i, 1) + } + } completeDetachment(node, rootNodes) return } @@ -135,17 +329,17 @@ function newAttachDetach () { completeDetachment(node, rootNodes) return } - case 'Sensor': { + case 'Sensor Bot Instance': { node.payload.parentNode.bot = undefined completeDetachment(node, rootNodes) return } - case 'Indicator': { + case 'Indicator Bot Instance': { node.payload.parentNode.bot = undefined completeDetachment(node, rootNodes) return } - case 'Trading Engine': { + case 'Trading Bot Instance': { node.payload.parentNode.bot = undefined completeDetachment(node, rootNodes) return @@ -170,7 +364,7 @@ function newAttachDetach () { completeDetachment(node, rootNodes) return } - case 'Process': { + case 'Process Instance': { let payload = node.payload for (let i = 0; i < payload.parentNode.processes.length; i++) { let process = payload.parentNode.processes[i] @@ -358,12 +552,166 @@ function newAttachDetach () { } } - function attachNode (node, attachToNode, rootNodes) { + function chainAttachNode (node, attachToNode, rootNodes) { switch (node.type) { - case 'Network': { + case 'Sensor Bot': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode - node.payload.parentNode.network = node + node.payload.parentNode.sensorBots.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Indicator Bot': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.indicatorBots.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Trading Bot': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.tradingBots.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Process Definition': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.processes.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Process Output': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.processOutput = node + completeAttachment(node, rootNodes) + } + break + case 'Process Dependencies': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.processDependencies = node + completeAttachment(node, rootNodes) + } + break + case 'Status Report': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.statusReport = node + completeAttachment(node, rootNodes) + } + break + case 'Execution Started Event': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.executionStartedEvent = node + completeAttachment(node, rootNodes) + } + break + case 'Execution Finished Event': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.executionFinishedEvent = node + completeAttachment(node, rootNodes) + } + break + case 'Calculations Procedure': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.calculations = node + completeAttachment(node, rootNodes) + } + break + case 'Data Building Procedure': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.dataBuilding = node + completeAttachment(node, rootNodes) + } + break + case 'Procedure Initialization': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.initialization = node + completeAttachment(node, rootNodes) + } + break + case 'Procedure Loop': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.loop = node + completeAttachment(node, rootNodes) + } + break + case 'Output Dataset': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.outputDatasets.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Status Dependency': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.statusDependencies.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Data Dependency': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.dataDependencies.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Product Definition': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.products.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Record Definition': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.record = node + completeAttachment(node, rootNodes) + } + break + case 'Record Property': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.properties.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Dataset Definition': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.datasets.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Plotter': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.plotters.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Plotter Module': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.modules.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Plotter Panel': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.panels.push(node) completeAttachment(node, rootNodes) } break @@ -423,28 +771,28 @@ function newAttachDetach () { completeAttachment(node, rootNodes) } break - case 'Sensor': { + case 'Sensor Bot Instance': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode node.payload.parentNode.bot = node completeAttachment(node, rootNodes) } break - case 'Indicator': { + case 'Indicator Bot Instance': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode node.payload.parentNode.bot = node completeAttachment(node, rootNodes) } break - case 'Trading Engine': { + case 'Trading Bot Instance': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode node.payload.parentNode.bot = node completeAttachment(node, rootNodes) } break - case 'Process': { + case 'Process Instance': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode node.payload.parentNode.processes.push(node) diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js similarity index 62% rename from StrategySpace/Workspace/FunctionLibraries/NodeChildren.js rename to DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js index 2a2ff97c3..f96277c64 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js @@ -14,6 +14,78 @@ function newNodeChildren () { case 'Network': { return countChildrenNetwork(parentNode, childNode) } + case 'Team': { + return countChildrenTeam(parentNode, childNode) + } + case 'Sensor Bot': { + return countChildrenSensorBot(parentNode, childNode) + } + case 'Indicator Bot': { + return countChildrenIndicatorBot(parentNode, childNode) + } + case 'Trading Bot': { + return countChildrenTradingBot(parentNode, childNode) + } + case 'Process Definition': { + return countChildrenProcessDefinition(parentNode, childNode) + } + case 'Process Output': { + return countChildrenProcessOutput(parentNode, childNode) + } + case 'Process Dependencies': { + return countChildrenProcessDependencies(parentNode, childNode) + } + case 'Status Rerport': { + return countChildrenStatusRerport(parentNode, childNode) + } + case 'Execution Started Event': { + return countChildrenExecutionStartedEvent(parentNode, childNode) + } + case 'Execution Finished Event': { + return countChildrenExecutionFinishedEvent(parentNode, childNode) + } + case 'Calculations Procedure': { + return countChildrenCalculationsProcedure(parentNode, childNode) + } + case 'Data Building Procedure': { + return countChildrenDataBuildingProcedure(parentNode, childNode) + } + case 'Procedure Initialization': { + return countChildrenProcedureInitialization(parentNode, childNode) + } + case 'Procedure Loop': { + return countChildrenProcedureLoop(parentNode, childNode) + } + case 'Output Dataset': { + return countChildrenOutputDataset(parentNode, childNode) + } + case 'Status Dependency': { + return countChildrenStatusDependency(parentNode, childNode) + } + case 'Data Dependency': { + return countChildrenDataDependency(parentNode, childNode) + } + case 'Product Definition': { + return countChildrenProductDefinition(parentNode, childNode) + } + case 'Record Definition': { + return countChildrenRecordDefinition(parentNode, childNode) + } + case 'Record Property': { + return countChildrenRecordProperty(parentNode, childNode) + } + case 'Dataset Definition': { + return countChildrenDatasetDefinition(parentNode, childNode) + } + case 'Plotter': { + return countChildrenPlotter(parentNode, childNode) + } + case 'Plotter Module': { + return countChildrenPlotterModule(parentNode, childNode) + } + case 'Plotter Panel': { + return countChildrenPlotterPanel(parentNode, childNode) + } case 'Network Node': { return countChildrenNetworkNode(parentNode, childNode) } @@ -38,17 +110,17 @@ function newNodeChildren () { case 'Task': { return countChildrenTask(parentNode, childNode) } - case 'Sensor': { - return countChildrenSensor(parentNode, childNode) + case 'Sensor Bot Instance': { + return countChildrenSensorBotInstance(parentNode, childNode) } - case 'Indicator': { - return countChildrenIndicator(parentNode, childNode) + case 'Indicator Bot Instance': { + return countChildrenIndicatorBotInstance(parentNode, childNode) } - case 'Trading Engine': { - return countChildrenTradingEngine(parentNode, childNode) + case 'Trading Bot Instance': { + return countChildrenTradingBotInstance(parentNode, childNode) } - case 'Process': { - return countChildrenProcess(parentNode, childNode) + case 'Process Instance': { + return countChildrenProcessInstance(parentNode, childNode) } case 'Backtesting Session': { return countBacktestingSession(parentNode, childNode) @@ -181,12 +253,6 @@ function newNodeChildren () { response.childIndex = response.childrenCount } } - if (parentNode.network !== undefined) { - response.childrenCount++ - if (parentNode.network.id === childNode.id) { - response.childIndex = response.childrenCount - } - } return response } @@ -207,6 +273,456 @@ function newNodeChildren () { return response } + function countChildrenTeam (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.sensorBots !== undefined) { + for (let i = 0; i < parentNode.sensorBots.length; i++) { + let child = parentNode.sensorBots[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + if (parentNode.indicatorBots !== undefined) { + for (let i = 0; i < parentNode.indicatorBots.length; i++) { + let child = parentNode.indicatorBots[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + if (parentNode.tradingBots !== undefined) { + for (let i = 0; i < parentNode.tradingBots.length; i++) { + let child = parentNode.tradingBots[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + if (parentNode.plotters !== undefined) { + for (let i = 0; i < parentNode.plotters.length; i++) { + let child = parentNode.plotters[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenSensorBot (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.processes !== 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 + } + } + } + if (parentNode.products !== undefined) { + for (let i = 0; i < parentNode.products.length; i++) { + let child = parentNode.products[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenIndicatorBot (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.processes !== 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 + } + } + } + if (parentNode.products !== undefined) { + for (let i = 0; i < parentNode.products.length; i++) { + let child = parentNode.products[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenTradingBot (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.processes !== 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 + } + } + } + if (parentNode.products !== undefined) { + for (let i = 0; i < parentNode.products.length; i++) { + let child = parentNode.products[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenProcessDefinition (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.processOutput !== undefined) { + response.childrenCount++ + if (parentNode.processOutput.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.processDependencies !== undefined) { + response.childrenCount++ + if (parentNode.processDependencies.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.statusReport !== undefined) { + response.childrenCount++ + if (parentNode.statusReport.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.executionStartedEvent !== undefined) { + response.childrenCount++ + if (parentNode.executionStartedEvent.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.executionFinishedEvent !== undefined) { + response.childrenCount++ + if (parentNode.executionFinishedEvent.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenProcessOutput (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.outputDatasets !== undefined) { + for (let i = 0; i < parentNode.outputDatasets.length; i++) { + let child = parentNode.outputDatasets[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenProcessDependencies (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.statusDependencies !== undefined) { + for (let i = 0; i < parentNode.statusDependencies.length; i++) { + let child = parentNode.statusDependencies[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + if (parentNode.dataDependencies !== undefined) { + for (let i = 0; i < parentNode.dataDependencies.length; i++) { + let child = parentNode.dataDependencies[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenStatusRerport (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenExecutionStartedEvent (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenExecutionFinishedEvent (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenCalculationsProcedure (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.initialization !== undefined) { + response.childrenCount++ + if (parentNode.initialization.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.loop !== undefined) { + response.childrenCount++ + if (parentNode.loop.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenDataBuildingProcedure (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.initialization !== undefined) { + response.childrenCount++ + if (parentNode.initialization.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.loop !== undefined) { + response.childrenCount++ + if (parentNode.loop.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenProcedureInitialization (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 countChildrenProcedureLoop (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 countChildrenOutputDataset (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenStatusDependency (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenDataDependency (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenProductDefinition (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.record !== undefined) { + response.childrenCount++ + if (parentNode.record.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + + if (parentNode.datasets !== undefined) { + for (let i = 0; i < parentNode.datasets.length; i++) { + let child = parentNode.datasets[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + + if (parentNode.calculations !== undefined) { + response.childrenCount++ + if (parentNode.calculations.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.dataBuilding !== undefined) { + response.childrenCount++ + if (parentNode.dataBuilding.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenRecordDefinition (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + + if (parentNode.properties !== undefined) { + for (let i = 0; i < parentNode.properties.length; i++) { + let child = parentNode.properties[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenRecordProperty (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 countChildrenDatasetDefinition (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + + function countChildrenPlotter (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.modules !== undefined) { + for (let i = 0; i < parentNode.modules.length; i++) { + let child = parentNode.modules[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenPlotterModule (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.code !== undefined) { + response.childrenCount++ + if (parentNode.code.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.panels !== undefined) { + for (let i = 0; i < parentNode.panels.length; i++) { + let child = parentNode.panels[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + return response + } + + function countChildrenPlotterPanel (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 countChildrenNetworkNode (parentNode, childNode) { let response = { childrenCount: 0, @@ -324,7 +840,7 @@ function newNodeChildren () { return response } - function countChildrenSensor (parentNode, childNode) { + function countChildrenSensorBotInstance (parentNode, childNode) { let response = { childrenCount: 0, childIndex: undefined @@ -340,7 +856,7 @@ function newNodeChildren () { return response } - function countChildrenIndicator (parentNode, childNode) { + function countChildrenIndicatorBotInstance (parentNode, childNode) { let response = { childrenCount: 0, childIndex: undefined @@ -356,7 +872,7 @@ function newNodeChildren () { return response } - function countChildrenTradingEngine (parentNode, childNode) { + function countChildrenTradingBotInstance (parentNode, childNode) { let response = { childrenCount: 0, childIndex: undefined @@ -372,7 +888,7 @@ function newNodeChildren () { return response } - function countChildrenProcess (parentNode, childNode) { + function countChildrenProcessInstance (parentNode, childNode) { let response = { childrenCount: 0, childIndex: undefined diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js similarity index 59% rename from StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js rename to DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js index 66597b412..1435c1a90 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -3,6 +3,29 @@ function newNodeDeleter () { deleteDefinition: deleteDefinition, deleteNetwork: deleteNetwork, deleteNetworkNode: deleteNetworkNode, + deleteTeam: deleteTeam, + deleteSensorBot: deleteSensorBot, + deleteIndicatorBot: deleteIndicatorBot, + deleteTradingBot: deleteTradingBot, + deleteProcessDefinition: deleteProcessDefinition, + deleteStatusReport: deleteStatusReport, + deleteExecutionStartedEvent: deleteExecutionStartedEvent, + deleteExecutionFinishedEvent: deleteExecutionFinishedEvent, + deleteCalculationsProcedure: deleteCalculationsProcedure, + deleteDataBuildingProcedure: deleteDataBuildingProcedure, + deleteProcedureInitialization: deleteProcedureInitialization, + deleteProcessDependencies: deleteProcessDependencies, + deleteProcedureLoop: deleteProcedureLoop, + deleteOutputDataset: deleteOutputDataset, + deleteStatusDependency: deleteStatusDependency, + deleteDataDependency: deleteDataDependency, + deleteProductDefinition: deleteProductDefinition, + deleteRecordDefinition: deleteRecordDefinition, + deleteRecordProperty: deleteRecordProperty, + deleteDatasetDefinition: deleteDatasetDefinition, + deletePlotter: deletePlotter, + deletePlotterModule: deletePlotterModule, + deletePlotterPanel: deletePlotterPanel, deleteSocialBots: deleteSocialBots, deleteSocialBot: deleteSocialBot, deleteAnnouncement: deleteAnnouncement, @@ -10,10 +33,10 @@ function newNodeDeleter () { deleteLayer: deleteLayer, deleteTaskManager: deleteTaskManager, deleteTask: deleteTask, - deleteSensor: deleteBot, - deleteIndicator: deleteBot, - deleteTradingEngine: deleteBot, - deleteProcess: deleteProcess, + deleteSensorBotInstance: deleteBotInstance, + deleteIndicatorBotInstance: deleteBotInstance, + deleteTradingBotInstance: deleteBotInstance, + deleteProcessInstance: deleteProcessInstance, deletePersonalData: deletePersonalData, deleteExchangeAccount: deleteExchangeAccount, deleteExchangeAccountAsset: deleteExchangeAccountAsset, @@ -51,8 +74,8 @@ function newNodeDeleter () { return thisObject - function destroyPart (node) { - canvas.floatingSpace.strategyPartConstructor.destroyStrategyPart(node.payload) + function destroyUiObject (node) { + canvas.floatingSpace.uiObjectConstructor.destroyUiObject(node.payload) } function deleteWorkspace (node, rootNodes) { @@ -73,6 +96,102 @@ function newNodeDeleter () { deleteNetworkNode(rootNode, rootNodes) break } + case 'Team': { + deleteTeam(rootNode, rootNodes) + break + } + case 'Sensor Bot': { + deleteSensorBot(rootNode, rootNodes) + break + } + case 'Indicator Bot': { + deleteIndicatorBot(rootNode, rootNodes) + break + } + case 'Trading Bot': { + deleteTradingBot(rootNode, rootNodes) + break + } + case 'Process Definition': { + deleteProcessDefinition(rootNode, rootNodes) + break + } + case 'Process Output': { + deleteProcessOutput(rootNode, rootNodes) + break + } + case 'Process Dependencies': { + deleteProcessDependencies(rootNode, rootNodes) + break + } + case 'Status Report': { + deleteStatusReport(rootNode, rootNodes) + break + } + case 'Execution Started Event': { + deleteExecutionStartedEvent(rootNode, rootNodes) + break + } + case 'Execution Finished Event': { + deleteExecutionFinishedEvent(rootNode, rootNodes) + break + } + case 'Calculations Procedure': { + deleteCalculationsProcedure(rootNode, rootNodes) + break + } + case 'Data Building Procedure': { + deleteDataBuildingProcedure(rootNode, rootNodes) + break + } + case 'Procedure Initialization': { + deleteProcedureInitialization(rootNode, rootNodes) + break + } + case 'Procedure Loop': { + deleteProcedureLoop(rootNode, rootNodes) + break + } + case 'Output Dataset': { + deleteOutputDataset(rootNode, rootNodes) + break + } + case 'Status Dependency': { + deleteStatusDependency(rootNode, rootNodes) + break + } + case 'Data Dependency': { + deleteDataDependency(rootNode, rootNodes) + break + } + case 'Product Definition': { + deleteProductDefinition(rootNode, rootNodes) + break + } + case 'Record Definition': { + deleteRecordDefinition(rootNode, rootNodes) + break + } + case 'Record Property': { + deleteRecordProperty(rootNode, rootNodes) + break + } + case 'Dataset Definition': { + deleteDatasetDefinition(rootNode, rootNodes) + break + } + case 'Plotter': { + deletePlotter(rootNode, rootNodes) + break + } + case 'Plotter Module': { + deletePlotterModule(rootNode, rootNodes) + break + } + case 'Plotter Panel': { + deletePlotterPanel(rootNode, rootNodes) + break + } case 'Social Bots': { deleteSocialBots(rootNode, rootNodes) break @@ -101,20 +220,20 @@ function newNodeDeleter () { deleteTask(rootNode, rootNodes) break } - case 'Sensor': { - deleteBot(rootNode, rootNodes) + case 'Sensor Bot Instance': { + deleteBotInstance(rootNode, rootNodes) break } - case 'Indicator': { - deleteBot(rootNode, rootNodes) + case 'Indicator Bot Instance': { + deleteBotInstance(rootNode, rootNodes) break } - case 'Trading Engine': { - deleteBot(rootNode, rootNodes) + case 'Trading Bot Instance': { + deleteBotInstance(rootNode, rootNodes) break } - case 'Process': { - deleteProcess(rootNode, rootNodes) + case 'Process Instance': { + deleteProcessInstance(rootNode, rootNodes) break } case 'Personal Data': { @@ -266,47 +385,31 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } - function deleteDefinition (node, rootNodes, forced) { + function deleteDefinition (node, rootNodes) { let payload = node.payload - if (forced !== true) { - /* Can not delete if it is the last one */ - let counter = 0 - for (let i = 0; i < rootNodes.length; i++) { - let rootNode = rootNodes[i] - if (rootNode.type === node.type) { - counter++ - } - } - if (counter <= 1) { return } - } - if (node.tradingSystem !== undefined) { deleteTradingSystem(node.tradingSystem, rootNodes) } if (node.personalData !== undefined) { deletePersonalData(node.personalData, rootNodes) } - if (node.network !== undefined) { - deleteNetwork(node.network, rootNodes) + for (let i = 0; i < node.referenceChildren.length; i++) { + let child = node.referenceChildren[i] + child.payload.referenceParent = undefined } - completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } - function deleteNetwork (node, rootNodes, forced) { + function deleteNetwork (node, rootNodes) { let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.network = undefined - } - if (node.networkNodes !== undefined) { while (node.networkNodes.length > 0) { deleteNetworkNode(node.networkNodes[0], rootNodes) @@ -314,11 +417,11 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } - function deleteNetworkNode (node, rootNodes, forced) { + function deleteNetworkNode (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { @@ -337,7 +440,518 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) + cleanNode(node) + } + + function deleteTeam (node, rootNodes) { + let payload = node.payload + + if (node.sensorBots !== undefined) { + while (node.sensorBots.length > 0) { + deleteSensorBot(node.sensorBots[0], rootNodes) + } + } + + if (node.indicatorBots !== undefined) { + while (node.indicatorBots.length > 0) { + deleteIndicatorBot(node.indicatorBots[0], rootNodes) + } + } + + if (node.tradingBots !== undefined) { + while (node.tradingBots.length > 0) { + deleteTradingBot(node.tradingBots[0], rootNodes) + } + } + + if (node.plotters !== undefined) { + while (node.plotters.length > 0) { + deletePlotter(node.plotters[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteSensorBot (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.sensorBots.length; j++) { + let sensorBot = payload.parentNode.sensorBots[j] + if (sensorBot.id === node.id) { + payload.parentNode.sensorBots.splice(j, 1) + } + } + } + + if (node.processes !== undefined) { + while (node.processes.length > 0) { + deleteProcessDefinition(node.processes[0], rootNodes) + } + } + + if (node.products !== undefined) { + while (node.products.length > 0) { + deleteProductDefinition(node.products[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteIndicatorBot (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.indicatorBots.length; j++) { + let indicatorBot = payload.parentNode.indicatorBots[j] + if (indicatorBot.id === node.id) { + payload.parentNode.indicatorBots.splice(j, 1) + } + } + } + + if (node.processes !== undefined) { + while (node.processes.length > 0) { + deleteProcessDefinition(node.processes[0], rootNodes) + } + } + + if (node.products !== undefined) { + while (node.products.length > 0) { + deleteProductDefinition(node.products[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteTradingBot (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.tradingBots.length; j++) { + let tradingBot = payload.parentNode.tradingBots[j] + if (tradingBot.id === node.id) { + payload.parentNode.tradingBots.splice(j, 1) + } + } + } + + if (node.processes !== undefined) { + while (node.processes.length > 0) { + deleteProcessDefinition(node.processes[0], rootNodes) + } + } + + if (node.products !== undefined) { + while (node.products.length > 0) { + deleteProductDefinition(node.products[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcessDefinition (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.processes.length; j++) { + let process = payload.parentNode.processes[j] + if (process.id === node.id) { + payload.parentNode.processes.splice(j, 1) + } + } + } + + if (node.processOutput !== undefined) { + deleteProcessOutput(node.processOutput, rootNodes) + } + + if (node.processDependencies !== undefined) { + deleteProcessDependencies(node.processDependencies, rootNodes) + } + + if (node.statusReport !== undefined) { + deleteStatusReport(node.statusReport, rootNodes) + } + + if (node.executionStartedEvent !== undefined) { + deleteExecutionStartedEvent(node.executionStartedEvent, rootNodes) + } + + if (node.executionFinishedEvent !== undefined) { + deleteExecutionFinishedEvent(node.executionFinishedEvent, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcessOutput (node, rootNodes) { + let payload = node.payload + + if (node.outputDatasets !== undefined) { + while (node.outputDatasets.length > 0) { + deleteOutputDataset(node.outputDatasets[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcessDependencies (node, rootNodes) { + let payload = node.payload + + if (node.statusDependencies !== undefined) { + while (node.statusDependencies.length > 0) { + deleteStatusDependency(node.statusDependencies[0], rootNodes) + } + } + + if (node.dataDependencies !== undefined) { + while (node.dataDependencies.length > 0) { + deleteDataDependency(node.dataDependencies[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteStatusReport (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.statusReport = undefined + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteExecutionStartedEvent (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.executionStartedEvent = undefined + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteExecutionFinishedEvent (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.executionFinishedEvent = undefined + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteCalculationsProcedure (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.calculations = undefined + } + + if (node.initialization !== undefined) { + deleteProcedureInitialization(node.initialization, rootNodes) + } + + if (node.loop !== undefined) { + deleteProcedureLoop(node.loop, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteDataBuildingProcedure (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.dataBuilding = undefined + } + + if (node.initialization !== undefined) { + deleteProcedureInitialization(node.initialization, rootNodes) + } + + if (node.loop !== undefined) { + deleteProcedureLoop(node.loop, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcedureInitialization (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.initialization = undefined + } + + if (node.code !== undefined) { + deleteParameters(node.code, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcedureLoop (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.loop = undefined + } + + if (node.code !== undefined) { + deleteCode(node.code, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteOutputDataset (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.outputDatasets.length; j++) { + let outputDataset = payload.parentNode.outputDatasets[j] + if (outputDataset.id === node.id) { + payload.parentNode.outputDatasets.splice(j, 1) + } + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteStatusDependency (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.statusDependencies.length; j++) { + let statusDependency = payload.parentNode.statusDependencies[j] + if (statusDependency.id === node.id) { + payload.parentNode.statusDependencies.splice(j, 1) + } + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteDataDependency (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.dataDependencies.length; j++) { + let dataDependency = payload.parentNode.dataDependencies[j] + if (dataDependency.id === node.id) { + payload.parentNode.dataDependencies.splice(j, 1) + } + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProductDefinition (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.products.length; j++) { + let product = payload.parentNode.products[j] + if (product.id === node.id) { + payload.parentNode.products.splice(j, 1) + } + } + } + + if (node.record !== undefined) { + deleteRecordDefinition(node.record, rootNodes) + } + + if (node.datasets !== undefined) { + while (node.datasets.length > 0) { + deleteDatasetDefinition(node.datasets[0], rootNodes) + } + } + + if (node.calculations !== undefined) { + deleteCalculationsProcedure(node.calculations, rootNodes) + } + + if (node.dataBuilding !== undefined) { + deleteDataBuildingProcedure(node.dataBuilding, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteRecordDefinition (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + payload.parentNode.record = undefined + } + + if (node.properties !== undefined) { + while (node.properties.length > 0) { + deleteRecordProperty(node.properties[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteRecordProperty (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.properties.length; j++) { + let property = payload.parentNode.properties[j] + if (property.id === node.id) { + payload.parentNode.properties.splice(j, 1) + } + } + } + + if (node.formula !== undefined) { + deleteFormula(node.formula, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteDatasetDefinition (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.datasets.length; j++) { + let dataset = payload.parentNode.datasets[j] + if (dataset.id === node.id) { + payload.parentNode.datasets.splice(j, 1) + } + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deletePlotter (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.plotters.length; j++) { + let plotter = payload.parentNode.plotters[j] + if (plotter.id === node.id) { + payload.parentNode.plotters.splice(j, 1) + } + } + } + + if (node.modules !== undefined) { + while (node.modules.length > 0) { + deletePlotterModule(node.modules[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deletePlotterModule (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.modules.length; j++) { + let module = payload.parentNode.modules[j] + if (module.id === node.id) { + payload.parentNode.modules.splice(j, 1) + } + } + } + + if (node.code !== undefined) { + deleteCode(node.code, rootNodes) + } + + if (node.panels !== undefined) { + while (node.panels.length > 0) { + deletePlotterPanel(node.panels[0], rootNodes) + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deletePlotterPanel (node, rootNodes) { + let payload = node.payload + + if (payload.parentNode !== undefined) { + for (let j = 0; j < payload.parentNode.panels.length; j++) { + let panel = payload.parentNode.panels[j] + if (panel.id === node.id) { + payload.parentNode.panels.splice(j, 1) + } + } + } + + if (node.code !== undefined) { + deleteCode(node.code, rootNodes) + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) cleanNode(node) } @@ -352,7 +966,7 @@ function newNodeDeleter () { } } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -372,7 +986,7 @@ function newNodeDeleter () { } } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -390,7 +1004,7 @@ function newNodeDeleter () { deleteFormula(node.formula, rootNodes) } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -405,7 +1019,7 @@ function newNodeDeleter () { } } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -420,7 +1034,7 @@ function newNodeDeleter () { } } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -440,7 +1054,7 @@ function newNodeDeleter () { } } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -455,30 +1069,30 @@ function newNodeDeleter () { } } if (node.bot !== undefined) { - deleteBot(node.bot, rootNodes) + deleteBotInstance(node.bot, rootNodes) } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } - function deleteBot (node, rootNodes) { + function deleteBotInstance (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { payload.parentNode.bot = undefined } if (node.processes !== undefined) { while (node.processes.length > 0) { - deleteProcess(node.processes[0], rootNodes) + deleteProcessInstance(node.processes[0], rootNodes) } } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } - function deleteProcess (node, rootNodes) { + function deleteProcessInstance (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { for (let j = 0; j < payload.parentNode.processes.length; j++) { @@ -511,80 +1125,27 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } function deleteBacktestingSession (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.session = undefined - } - - if (node.parameters !== undefined) { - deleteParameters(node.parameters, rootNodes) - } - - if (node.layerManager !== undefined) { - deleteLayerManager(node.layerManager, rootNodes) - } - - if (node.socialBots !== undefined) { - deleteSocialBots(node.socialBots, rootNodes) - } - completeDeletion(node, rootNodes) - destroyPart(node) - cleanNode(node) + deleteSession(node, rootNodes) } function deleteLiveTradingSession (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.session = undefined - } - - if (node.parameters !== undefined) { - deleteParameters(node.parameters, rootNodes) - } - - if (node.layerManager !== undefined) { - deleteLayerManager(node.layerManager, rootNodes) - } - - if (node.socialBots !== undefined) { - deleteSocialBots(node.socialBots, rootNodes) - } - completeDeletion(node, rootNodes) - destroyPart(node) - cleanNode(node) + deleteSession(node, rootNodes) } function deleteFordwardTestingSession (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.session = undefined - } - - if (node.parameters !== undefined) { - deleteParameters(node.parameters, rootNodes) - } - - if (node.layerManager !== undefined) { - deleteLayerManager(node.layerManager, rootNodes) - } - - if (node.socialBots !== undefined) { - deleteSocialBots(node.socialBots, rootNodes) - } - completeDeletion(node, rootNodes) - destroyPart(node) - cleanNode(node) + deleteSession(node, rootNodes) } function deletePaperTradingSession (node, rootNodes) { + deleteSession(node, rootNodes) + } + + function deleteSession (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { @@ -602,8 +1163,18 @@ function newNodeDeleter () { if (node.socialBots !== undefined) { deleteSocialBots(node.socialBots, rootNodes) } + if (node.payload.referenceParent !== undefined) { + for (let i = 0; i < node.payload.referenceParent.referenceChildren.length; i++) { + let child = node.payload.referenceParent.referenceChildren[i] + if (child.id === node.id) { + node.payload.referenceParent.referenceChildren.splice(i, 1) + return + } + } + } + completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -621,7 +1192,7 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -647,7 +1218,7 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -663,7 +1234,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -684,7 +1255,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -706,7 +1277,7 @@ function newNodeDeleter () { } completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -735,7 +1306,7 @@ function newNodeDeleter () { if (node.key !== undefined) { deleteExchangeAccountKey(node.key, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -746,7 +1317,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -757,7 +1328,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -768,7 +1339,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -779,7 +1350,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -790,7 +1361,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -818,7 +1389,7 @@ function newNodeDeleter () { if (node.closeStage !== undefined) { deleteCloseStage(node.closeStage, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -838,7 +1409,7 @@ function newNodeDeleter () { if (node.takePosition !== undefined) { deleteEvent(node.takePosition, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -857,7 +1428,7 @@ function newNodeDeleter () { deleteOpenExecution(node.openExecution, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -874,7 +1445,7 @@ function newNodeDeleter () { if (node.takeProfit !== undefined) { deleteManagedItem(node.takeProfit, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -888,7 +1459,7 @@ function newNodeDeleter () { if (node.closeExecution !== undefined) { deleteCloseExecution(node.closeExecution, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -902,7 +1473,7 @@ function newNodeDeleter () { if (node.formula !== undefined) { deleteFormula(node.formula, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -916,7 +1487,7 @@ function newNodeDeleter () { if (node.formula !== undefined) { deleteFormula(node.formula, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -939,7 +1510,7 @@ function newNodeDeleter () { if (node.positionRate !== undefined) { deletePositionSize(node.positionRate, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -950,7 +1521,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -961,7 +1532,7 @@ function newNodeDeleter () { } else { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -1001,7 +1572,7 @@ function newNodeDeleter () { deleteAnnouncement(node.announcements[0], rootNodes) } } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -1024,11 +1595,11 @@ function newNodeDeleter () { if (node.phases !== undefined) { while (node.phases.length > 0) { - deletePhase(node.phases[0]) + deletePhase(node.phases[0], rootNodes) } } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -1063,7 +1634,7 @@ function newNodeDeleter () { deleteAnnouncement(node.announcements[0], rootNodes) } } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -1075,7 +1646,7 @@ function newNodeDeleter () { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -1094,7 +1665,7 @@ function newNodeDeleter () { situation.conditions = [] payload.parentNode.situations.splice(j, 1) - destroyPart(situation) + destroyUiObject(situation) cleanNode(situation) return } @@ -1103,13 +1674,13 @@ function newNodeDeleter () { if (node.conditions !== undefined) { while (node.conditions.length > 0) { let condition = node.conditions[0] - deleteCondition(condition) + deleteCondition(condition, rootNodes) } } node.conditions = [] completeDeletion(node, rootNodes) - destroyPart(node) + destroyUiObject(node) cleanNode(node) } } @@ -1129,7 +1700,7 @@ function newNodeDeleter () { if (node.code !== undefined) { deleteCode(node.code, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } @@ -1141,7 +1712,7 @@ function newNodeDeleter () { completeDeletion(node, rootNodes) } - destroyPart(node) + destroyUiObject(node) cleanNode(node) } diff --git a/StrategySpace/Workspace/FunctionLibraries/OnFocus.js b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js similarity index 66% rename from StrategySpace/Workspace/FunctionLibraries/OnFocus.js rename to DesignerSpace/Workspace/FunctionLibraries/OnFocus.js index 77fa1621a..d3633c3d7 100644 --- a/StrategySpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js @@ -546,7 +546,7 @@ function newOnFocus () { return } } - case 'Sensor': { + case 'Sensor Bot Instance': { let child for (let m = 0; m < node.processes.length; m++) { child = getNodeThatIsOnFocus(node.processes[m]) @@ -560,7 +560,7 @@ function newOnFocus () { return } } - case 'Indicator': { + case 'Indicator Bot Instance': { let child for (let m = 0; m < node.processes.length; m++) { child = getNodeThatIsOnFocus(node.processes[m]) @@ -574,7 +574,7 @@ function newOnFocus () { return } } - case 'Trading Engine': { + case 'Trading Bot Instance': { let child for (let m = 0; m < node.processes.length; m++) { child = getNodeThatIsOnFocus(node.processes[m]) @@ -588,7 +588,7 @@ function newOnFocus () { return } } - case 'Process': { + case 'Process Instance': { let child child = getNodeThatIsOnFocus(node.session) if (child !== undefined) { @@ -723,7 +723,359 @@ function newOnFocus () { if (child !== undefined) { return child } - child = getNodeThatIsOnFocus(node.network) + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Team': { + let child + + for (let m = 0; m < node.sensorBots.length; m++) { + child = getNodeThatIsOnFocus(node.sensorBots[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.indicatorBots.length; m++) { + child = getNodeThatIsOnFocus(node.indicatorBots[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.tradingBots.length; m++) { + child = getNodeThatIsOnFocus(node.tradingBots[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.plotters.length; m++) { + child = getNodeThatIsOnFocus(node.plotters[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Sensor Bot': { + let child + for (let m = 0; m < node.processes.length; m++) { + child = getNodeThatIsOnFocus(node.processes[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.products.length; m++) { + child = getNodeThatIsOnFocus(node.products[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Indicator Bot': { + let child + for (let m = 0; m < node.processes.length; m++) { + child = getNodeThatIsOnFocus(node.processes[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.products.length; m++) { + child = getNodeThatIsOnFocus(node.products[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Trading Bot': { + let child + for (let m = 0; m < node.processes.length; m++) { + child = getNodeThatIsOnFocus(node.processes[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.products.length; m++) { + child = getNodeThatIsOnFocus(node.products[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Process Definition': { + let child + child = getNodeThatIsOnFocus(node.processOutput) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.processDependencies) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.statusReport) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.executionStartedEvent) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.executionFinishedEvent) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Process Output': { + let child + for (let m = 0; m < node.outputDatasets.length; m++) { + child = getNodeThatIsOnFocus(node.outputDatasets[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Process Dependencies': { + let child + for (let m = 0; m < node.statusDependencies.length; m++) { + child = getNodeThatIsOnFocus(node.statusDependencies[m]) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.dataDependencies.length; m++) { + child = getNodeThatIsOnFocus(node.dataDependencies[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Status Report': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Execution Started Event': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Execution Finished Event': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Calculations Procedure': { + let child + child = getNodeThatIsOnFocus(node.initialization) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.loop) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Data Building Procedure': { + let child + child = getNodeThatIsOnFocus(node.initialization) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.loop) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Procedure Initialization': { + let child + child = getNodeThatIsOnFocus(node.code) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Procedure Loop': { + let child + child = getNodeThatIsOnFocus(node.code) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Output Dataset': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Status Dependency': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Data Dependency': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Product Definition': { + let child + child = getNodeThatIsOnFocus(node.record) + if (child !== undefined) { + return child + } + for (let m = 0; m < node.datasets.length; m++) { + child = getNodeThatIsOnFocus(node.datasets[m]) + if (child !== undefined) { + return child + } + } + child = getNodeThatIsOnFocus(node.calculations) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.dataBuilding) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Record Definition': { + let child + for (let m = 0; m < node.properties.length; m++) { + child = getNodeThatIsOnFocus(node.properties[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Record Property': { + let child + child = getNodeThatIsOnFocus(node.formula) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Dataset Definition': { + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Plotter': { + let child + for (let m = 0; m < node.modules.length; m++) { + child = getNodeThatIsOnFocus(node.modules[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Plotter Module': { + let child + child = getNodeThatIsOnFocus(node.code) + if (child !== undefined) { + return child + } + for (let m = 0; m < node.panels.length; m++) { + child = getNodeThatIsOnFocus(node.panels[m]) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Plotter Panel': { + let child + child = getNodeThatIsOnFocus(node.code) if (child !== undefined) { return child } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js new file mode 100644 index 000000000..2fdb0ae82 --- /dev/null +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -0,0 +1,1707 @@ +function newProtocolNode () { + thisObject = { + getProtocolNode: getProtocolNode + } + return thisObject + + function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) { + if (node === undefined) { return } + switch (node.type) { + case 'Code': + { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Condition': + { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Situation': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + conditions: [] + } + + for (let m = 0; m < node.conditions.length; m++) { + let condition = getProtocolNode(node.conditions[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (condition !== undefined) { + object.conditions.push(condition) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Formula': + { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Next Phase Event': + { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [], + announcements: [] + } + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (situation !== undefined) { + object.situations.push(situation) + } + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (announcement !== undefined) { + object.announcements.push(announcement) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Phase': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + announcements: [], + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + nextPhaseEvent: getProtocolNode(node.nextPhaseEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (announcement !== undefined) { + object.announcements.push(announcement) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Stop': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + phases: [] + } + + for (let m = 0; m < node.phases.length; m++) { + let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (phase !== undefined) { + object.phases.push(phase) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Take Profit': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + phases: [] + } + + for (let m = 0; m < node.phases.length; m++) { + let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (phase !== undefined) { + object.phases.push(phase) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Take Position Event': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [], + announcements: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (situation !== undefined) { + object.situations.push(situation) + } + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (announcement !== undefined) { + object.announcements.push(announcement) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Trigger On Event': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [], + announcements: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.situations.push(situation) + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (announcement !== undefined) { + object.announcements.push(announcement) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Trigger Off Event': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [], + announcements: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (situation !== undefined) { + object.situations.push(situation) + } + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (announcement !== undefined) { + object.announcements.push(announcement) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Initial Definition': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + positionSize: getProtocolNode(node.positionSize, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + positionRate: getProtocolNode(node.positionRate, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Open Execution': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Close Execution': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Position Size': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Position Rate': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Trigger Stage': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + triggerOn: getProtocolNode(node.triggerOn, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + triggerOff: getProtocolNode(node.triggerOff, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + takePosition: getProtocolNode(node.takePosition, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Open Stage': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + initialDefinition: getProtocolNode(node.initialDefinition, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + openExecution: getProtocolNode(node.openExecution, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Manage Stage': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Close Stage': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + closeExecution: getProtocolNode(node.closeExecution, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Strategy': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + triggerStage: getProtocolNode(node.triggerStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + openStage: getProtocolNode(node.openStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + manageStage: getProtocolNode(node.manageStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + closeStage: getProtocolNode(node.closeStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Base Asset': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Time Range': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Time Period': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Slippage': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Fee Structure': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Parameters': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + baseAsset: getProtocolNode(node.baseAsset, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + timeRange: getProtocolNode(node.timeRange, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + timePeriod: getProtocolNode(node.timePeriod, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + slippage: getProtocolNode(node.slippage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + feeStructure: getProtocolNode(node.feeStructure, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + key: getProtocolNode(node.key, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Trading System': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + strategies: [], + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + + for (let m = 0; m < node.strategies.length; m++) { + let strategy = getProtocolNode(node.strategies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (strategy !== undefined) { + object.strategies.push(strategy) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Personal Data': { + if (removePersonalData === true) { return } + let object = { + type: node.type, + subType: node.subType, + name: node.name, + exchangeAccounts: [] + } + + for (let m = 0; m < node.exchangeAccounts.length; m++) { + let exchangeAccount = getProtocolNode(node.exchangeAccounts[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (exchangeAccount !== undefined) { + object.exchangeAccounts.push(exchangeAccount) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Exchange Account': { + if (removePersonalData === true) { return } + let object = { + type: node.type, + subType: node.subType, + name: node.name, + assets: [], + keys: [] + } + + for (let m = 0; m < node.assets.length; m++) { + let asset = getProtocolNode(node.assets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (asset !== undefined) { + object.assets.push(asset) + } + } + for (let m = 0; m < node.keys.length; m++) { + let key = getProtocolNode(node.keys[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (key !== undefined) { + object.keys.push(key) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Exchange Account Asset': { + if (removePersonalData === true) { return } + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Exchange Account Key': { + if (removePersonalData === true) { return } + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Social Bots': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + bots: [] + } + + for (let m = 0; m < node.bots.length; m++) { + let bot = getProtocolNode(node.bots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (bot !== undefined) { + object.bots.push(bot) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Telegram Bot': { + if (removePersonalData === true) { return } + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + announcements: [] + } + + for (let m = 0; m < node.announcements.length; m++) { + let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (announcement !== undefined) { + object.announcements.push(announcement) + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Announcement': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Layer Manager': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + layers: [] + } + + for (let m = 0; m < node.layers.length; m++) { + let layer = getProtocolNode(node.layers[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (layer !== undefined) { + object.layers.push(layer) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Layer': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Task Manager': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + tasks: [] + } + + for (let m = 0; m < node.tasks.length; m++) { + let task = getProtocolNode(node.tasks[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (task !== undefined) { + object.tasks.push(task) + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Task': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + bot: getProtocolNode(node.bot, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Sensor Bot Instance': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + processes: [] + } + + for (let m = 0; m < node.processes.length; m++) { + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (process !== undefined) { + object.processes.push(process) + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Indicator Bot Instance': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + processes: [] + } + + for (let m = 0; m < node.processes.length; m++) { + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (process !== undefined) { + object.processes.push(process) + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Trading Bot Instance': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + processes: [] + } + + for (let m = 0; m < node.processes.length; m++) { + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (process !== undefined) { + object.processes.push(process) + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Process Instance': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + session: getProtocolNode(node.session, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Backtesting Session': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(object.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Live Trading Session': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Fordward Testing Session': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(object.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Paper Trading Session': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Network Node': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + taskManagers: [] + } + if (node.taskManagers !== undefined) { + for (let m = 0; m < node.taskManagers.length; m++) { + let taskManager = getProtocolNode(node.taskManagers[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (taskManager !== undefined) { + object.taskManagers.push(taskManager) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Network': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + networkNodes: [] + } + if (node.networkNodes !== undefined) { + for (let m = 0; m < node.networkNodes.length; m++) { + let networkNode = getProtocolNode(node.networkNodes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (networkNode !== undefined) { + object.networkNodes.push(networkNode) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Definition': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + tradingSystem: getProtocolNode(node.tradingSystem, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + personalData: getProtocolNode(node.personalData, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Team': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + sensorBots: [], + indicatorBots: [], + tradingBots: [], + plotters: [] + } + if (followAncestors) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + + if (excludeChildren !== true) { + if (node.sensorBots !== undefined) { + for (let m = 0; m < node.sensorBots.length; m++) { + let sensorBot = getProtocolNode(node.sensorBots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (sensorBot !== undefined) { + object.sensorBots.push(sensorBot) + } + } + } + if (node.indicatorBots !== undefined) { + for (let m = 0; m < node.indicatorBots.length; m++) { + let indicatorBot = getProtocolNode(node.indicatorBots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (indicatorBot !== undefined) { + object.indicatorBots.push(indicatorBot) + } + } + } + if (node.tradingBots !== undefined) { + for (let m = 0; m < node.tradingBots.length; m++) { + let tradingBot = getProtocolNode(node.tradingBots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (tradingBot !== undefined) { + object.tradingBots.push(tradingBot) + } + } + } + if (node.plotters !== undefined) { + for (let m = 0; m < node.plotters.length; m++) { + let plotter = getProtocolNode(node.plotters[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (plotter !== undefined) { + object.plotters.push(plotter) + } + } + } + } + + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Sensor Bot': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + processes: [], + products: [] + } + if (followAncestors) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (excludeChildren !== true) { + if (node.processes !== undefined) { + for (let m = 0; m < node.processes.length; m++) { + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (process !== undefined) { + object.processes.push(process) + } + } + } + if (node.products !== undefined) { + for (let m = 0; m < node.products.length; m++) { + let product = getProtocolNode(node.products[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (product !== undefined) { + object.products.push(product) + } + } + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Indicator Bot': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + processes: [], + products: [] + } + if (followAncestors) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (excludeChildren !== true) { + /* Children are added only when not following ancestors */ + if (node.processes !== undefined) { + for (let m = 0; m < node.processes.length; m++) { + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (process !== undefined) { + object.processes.push(process) + } + } + } + if (node.products !== undefined) { + for (let m = 0; m < node.products.length; m++) { + let product = getProtocolNode(node.products[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (product !== undefined) { + object.products.push(product) + } + } + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Trading Bot': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + processes: [], + products: [] + } + if (followAncestors) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (excludeChildren !== true) { + /* Children are added only when not following ancestors */ + if (node.processes !== undefined) { + for (let m = 0; m < node.processes.length; m++) { + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (process !== undefined) { + object.processes.push(process) + } + } + } + if (node.products !== undefined) { + for (let m = 0; m < node.products.length; m++) { + let product = getProtocolNode(node.products[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (product !== undefined) { + object.products.push(product) + } + } + } + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Process Definition': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followAncestors) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (excludeChildren !== true) { + object.processOutput = getProtocolNode(node.processOutput, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.processDependencies = getProtocolNode(node.processDependencies, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.statusReport = getProtocolNode(node.statusReport, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.executionStartedEvent = getProtocolNode(node.executionStartedEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.executionFinishedEvent = getProtocolNode(node.executionFinishedEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + + if (includeParent) { + followAncestors = true + excludeChildren = true + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Process Output': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + outputDatasets: [] + } + if (node.outputDatasets !== undefined) { + for (let m = 0; m < node.outputDatasets.length; m++) { + let outputDataset = getProtocolNode(node.outputDatasets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (outputDataset !== undefined) { + object.outputDatasets.push(outputDataset) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Process Dependencies': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + statusDependencies: [], + dataDependencies: [] + } + if (node.statusDependencies !== undefined) { + for (let m = 0; m < node.statusDependencies.length; m++) { + let statusDependency = getProtocolNode(node.statusDependencies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (statusDependency !== undefined) { + object.statusDependencies.push(statusDependency) + } + } + } + if (node.dataDependencies !== undefined) { + for (let m = 0; m < node.dataDependencies.length; m++) { + let dataDependency = getProtocolNode(node.dataDependencies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (dataDependency !== undefined) { + object.dataDependencies.push(dataDependency) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Status Report': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeParent) { + followAncestors = true + excludeChildren = true + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Execution Started Event': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Execution Finished Event': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (includeParent) { + object.parentNode = { + type: node.payload.parentNode.type, + subType: node.payload.parentNode.subType, + name: node.payload.parentNode.name, + id: node.payload.parentNode.id, + code: JSON.parse(node.payload.parentNode.code) + } + } + return object + } + case 'Calculations Procedure': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + initialization: getProtocolNode(node.initialization, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + loop: getProtocolNode(node.loop, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Data Building Procedure': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + initialization: getProtocolNode(node.initialization, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + loop: getProtocolNode(node.loop, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Procedure Initialization': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Procedure Loop': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Output Dataset': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Status Dependency': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (includeIds) { + object.id = node.id + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Data Dependency': { + let object = { + type: node.type, + subType: node.subType, + name: node.name + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + if (followReferenceParent) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + return object + } + case 'Product Definition': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + datasets: [] + } + if (excludeChildren !== true) { + if (excludeType !== 'Dataset Definition') { + if (node.datasets !== undefined) { + for (let m = 0; m < node.datasets.length; m++) { + let dataset = getProtocolNode(node.datasets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (dataset !== undefined) { + object.datasets.push(dataset) + } + } + } + } + object.record = getProtocolNode(node.record, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.calculations = getProtocolNode(node.calculations, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.dataBuilding = getProtocolNode(node.dataBuilding, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (followAncestors) { + excludeChildren = true + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Record Definition': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + properties: [] + } + if (node.properties !== undefined) { + for (let m = 0; m < node.properties.length; m++) { + let property = getProtocolNode(node.properties[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (property !== undefined) { + object.properties.push(property) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Record Property': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Dataset Definition': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + if (parseCode) { + object.code = JSON.parse(node.code) + } + if (includeParent) { + followAncestors = true + excludeType = 'Dataset Definition' + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Plotter': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + modules: [] + } + if (node.modules !== undefined) { + for (let m = 0; m < node.modules.length; m++) { + let module = getProtocolNode(node.modules[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (module !== undefined) { + object.modules.push(module) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Plotter Module': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), + panels: [] + } + if (node.panels !== undefined) { + for (let m = 0; m < node.panels.length; m++) { + let panel = getProtocolNode(node.panels[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + if (panel !== undefined) { + object.panels.push(panel) + } + } + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Plotter Panel': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + + } + } + + function getSavedPayload (node, includeReferences) { + let savedPayload = { + position: { + x: node.payload.position.x, + y: node.payload.position.y + }, + targetPosition: { + x: node.payload.targetPosition.x, + y: node.payload.targetPosition.y + }, + floatingObject: { + isPinned: node.payload.floatingObject.isPinned, + isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), + isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), + isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) + }, + uiObject: { + isRunning: node.payload.uiObject.isRunning, + shortcutKey: node.payload.uiObject.shortcutKey + } + } + + if (includeReferences) { + /* For the ones that have reference children, we include them. */ + if (node.referenceChildren !== undefined) { + let referenceChildren = [] + for (let i = 0; i < node.referenceChildren.length; i++) { + let child = node.referenceChildren[i] + if (child !== undefined) { + let referencedChild = { + type: child.type, + subType: child.subType, + name: child.name, + id: child.id + } + referenceChildren.push(referencedChild) + } + } + savedPayload.referenceChildren = referenceChildren + } + + /* Next for the ones that have a reference parent, we include it */ + if (node.payload.referenceParent !== undefined) { + savedPayload.referenceParent = { + type: node.payload.referenceParent.type, + subType: node.payload.referenceParent.subType, + name: node.payload.referenceParent.name, + id: node.payload.referenceParent.id + } + } + } + return savedPayload + } +} diff --git a/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js new file mode 100644 index 000000000..0b5099aff --- /dev/null +++ b/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js @@ -0,0 +1,106 @@ +function newReferenceAttachDetach () { + thisObject = { + referenceDetachNode: referenceDetachNode, + referenceAttachNode: referenceAttachNode + } + + return thisObject + + function referenceDetachNode (node) { + switch (node.type) { + case 'Backtesting Session': { + completeDetachment(node) + return + } + case 'Live Trading Session': { + completeDetachment(node) + return + } + case 'Fordward Testing Session': { + completeDetachment(node) + return + } + case 'Paper Trading Session': { + completeDetachment(node) + return + } + case 'Output Dataset': { + completeDetachment(node) + return + } + case 'Data Dependency': { + completeDetachment(node) + return + } + case 'Status Dependency': { + completeDetachment(node) + return + } + case 'Execution Started Event': { + completeDetachment(node) + return + } + case 'Process Instance': { + completeDetachment(node) + return + } + } + } + + function referenceAttachNode (node, attachToNode, rootNodes) { + switch (node.type) { + case 'Backtesting Session': { + completeAttachment(node, attachToNode) + } + break + case 'Live Trading Session': { + completeAttachment(node, attachToNode) + } + break + case 'Fordward Testing Session': { + completeAttachment(node, attachToNode) + } + break + case 'Paper Trading Session': { + completeAttachment(node, attachToNode) + } + break + case 'Output Dataset': { + completeAttachment(node, attachToNode) + } + break + case 'Data Dependency': { + completeAttachment(node, attachToNode) + } + break + case 'Status Dependency': { + completeAttachment(node, attachToNode) + } + break + case 'Execution Started Event': { + completeAttachment(node, attachToNode) + } + break + case 'Process Instance': { + completeAttachment(node, attachToNode) + } + break + } + } + + function completeAttachment (node, attachToNode) { + node.payload.referenceParent = attachToNode + attachToNode.referenceChildren.push(node) + } + + function completeDetachment (node) { + for (let i = 0; i < node.payload.referenceParent.referenceChildren.length; i++) { + let child = node.payload.referenceParent.referenceChildren[i] + if (child.id === node.id) { + node.payload.referenceParent.referenceChildren.splice(i, 1) + return + } + } + node.payload.referenceParent = undefined + } +} diff --git a/StrategySpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js similarity index 79% rename from StrategySpace/Workspace/FunctionLibraries/SessionFunctions.js rename to DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index b1df94730..453fe61e7 100644 --- a/StrategySpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -9,11 +9,19 @@ function newSessionFunctions () { 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) { + node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.') callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return } if (node.payload.parentNode.payload.uiObject.isRunning !== true) { + node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be running to be able to run.') + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + + if (node.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Parent Process Instance need to reference a Process Definition.') callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return } @@ -22,8 +30,7 @@ function newSessionFunctions () { let key = node.name + '-' + node.type + '-' + node.id - let thisNodeDefinition = getDefinition(node) - if (thisNodeDefinition === undefined) { return } + let thisNodeDefinition = node.payload.referenceParent /* Raise event to run the session */ let event = { @@ -34,18 +41,6 @@ function newSessionFunctions () { 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')) diff --git a/StrategySpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js similarity index 66% rename from StrategySpace/Workspace/FunctionLibraries/ShortcutKeys.js rename to DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js index ce6e6b4f5..874f93f29 100644 --- a/StrategySpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -547,7 +547,7 @@ function newShortcutKeys () { return } } - case 'Sensor': { + case 'Sensor Bot Instance': { let child for (let m = 0; m < node.processes.length; m++) { child = getNodeByShortcutKey(node.processes[m], searchingKey) @@ -561,7 +561,7 @@ function newShortcutKeys () { return } } - case 'Indicator': { + case 'Indicator Bot Instance': { let child for (let m = 0; m < node.processes.length; m++) { child = getNodeByShortcutKey(node.processes[m], searchingKey) @@ -575,7 +575,7 @@ function newShortcutKeys () { return } } - case 'Trading Engine': { + case 'Trading Bot Instance': { let child for (let m = 0; m < node.processes.length; m++) { child = getNodeByShortcutKey(node.processes[m], searchingKey) @@ -589,7 +589,7 @@ function newShortcutKeys () { return } } - case 'Process': { + case 'Process Instance': { let child child = getNodeByShortcutKey(node.session, searchingKey) if (child !== undefined) { @@ -708,7 +708,123 @@ function newShortcutKeys () { if (child !== undefined) { return child } - child = getNodeByShortcutKey(node.network, searchingKey) + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Team': { + let child + for (let m = 0; m < node.sensorBots.length; m++) { + child = getNodeByShortcutKey(node.sensorBots[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.indicatorBots.length; m++) { + child = getNodeByShortcutKey(node.indicatorBots[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.tradingBots.length; m++) { + child = getNodeByShortcutKey(node.tradingBots[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.plotters.length; m++) { + child = getNodeByShortcutKey(node.plotters[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Sensor Bot': { + let child + for (let m = 0; m < node.processes.length; m++) { + child = getNodeByShortcutKey(node.processes[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.products.length; m++) { + child = getNodeByShortcutKey(node.products[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Indicator Bot': { + let child + for (let m = 0; m < node.processes.length; m++) { + child = getNodeByShortcutKey(node.processes[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.products.length; m++) { + child = getNodeByShortcutKey(node.products[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Trading Bot': { + let child + for (let m = 0; m < node.processes.length; m++) { + child = getNodeByShortcutKey(node.processes[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.products.length; m++) { + child = getNodeByShortcutKey(node.products[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Process Definition': { + let child + child = getNodeByShortcutKey(node.processOutput, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.processDependencies, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.statusReport, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.executionStartedEvent, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.executionFinishedEvent, searchingKey) if (child !== undefined) { return child } @@ -718,6 +834,235 @@ function newShortcutKeys () { return } } + case 'Process Output': { + let child + for (let m = 0; m < node.outputDatasets.length; m++) { + child = getNodeByShortcutKey(node.outputDatasets[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Process Dependencies': { + let child + for (let m = 0; m < node.statusDependencies.length; m++) { + child = getNodeByShortcutKey(node.statusDependencies[m], searchingKey) + if (child !== undefined) { + return child + } + } + for (let m = 0; m < node.dataDependencies.length; m++) { + child = getNodeByShortcutKey(node.dataDependencies[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Status Report': { + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Execution Finished Procedure': { + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Calculations Procedure': { + let child + child = getNodeByShortcutKey(node.initialization, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.loop, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Data Building Procedure': { + let child + child = getNodeByShortcutKey(node.initialization, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.loop, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Procedure Initialization': { + let child + child = getNodeByShortcutKey(node.code, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Procedure Loop': { + let child + child = getNodeByShortcutKey(node.code, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Output Dataset': { + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Status Dependency': { + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Data Dependency': { + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Product Definition': { + let child + child = getNodeByShortcutKey(node.record, searchingKey) + if (child !== undefined) { + return child + } + for (let m = 0; m < node.datasets.length; m++) { + child = getNodeByShortcutKey(node.datasets[m], searchingKey) + if (child !== undefined) { + return child + } + } + child = getNodeByShortcutKey(node.calculations, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.dataBuilding, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Record Definition': { + let child + for (let m = 0; m < node.properties.length; m++) { + child = getNodeByShortcutKey(node.properties[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Record Property': { + let child + child = getNodeByShortcutKey(node.formula, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Dataset Definition': { + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Plotter': { + let child + for (let m = 0; m < node.modules.length; m++) { + child = getNodeByShortcutKey(node.modules[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Plotter Module': { + let child + child = getNodeByShortcutKey(node.code, searchingKey) + if (child !== undefined) { + return child + } + for (let m = 0; m < node.panels.length; m++) { + child = getNodeByShortcutKey(node.panels[m], searchingKey) + if (child !== undefined) { + return child + } + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Plotter Panel': { + let child + child = getNodeByShortcutKey(node.code, searchingKey) + if (child !== undefined) { + return child + } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + } } } diff --git a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js similarity index 84% rename from StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js rename to DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index 4d8f9bf83..aec7aebc4 100644 --- a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -24,13 +24,19 @@ function newTaskFunctions () { 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. + definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, true, true)) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager. } + + if (node.payload.parentNode === undefined) { + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + systemEventHandler.raiseEvent('Task Server', 'Debug Task Started', event) + return + } + + node.payload.uiObject.run(callBackFunction) systemEventHandler.raiseEvent('Task Manager', 'Run Task', event) } diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js new file mode 100644 index 000000000..dc713be6f --- /dev/null +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -0,0 +1,2124 @@ +function newUiObjectsFromNodes () { + thisObject = { + recreateWorkspace: recreateWorkspace, + createUiObjectFromNode: createUiObjectFromNode, + addTeam: addTeam, + addSensorBot: addSensorBot, + addIndicatorBot: addIndicatorBot, + addTradingBot: addTradingBot, + addProcessDefinition: addProcessDefinition, + addMissingProcessDefinitionItems: addMissingProcessDefinitionItems, + addMissingProductDefinitionItems: addMissingProductDefinitionItems, + addProcessOutput: addProcessOutput, + addProcessDependencies: addProcessDependencies, + addStatusReport: addStatusReport, + addExecutionStartedEvent: addExecutionStartedEvent, + addExecutionFinishedEvent: addExecutionFinishedEvent, + addCalculationsProcedure: addCalculationsProcedure, + addDataBuildingProcedure: addDataBuildingProcedure, + addProcedureInitialization: addProcedureInitialization, + addProcedureLoop: addProcedureLoop, + addOutputDataset: addOutputDataset, + addStatusDependency: addStatusDependency, + addDataDependency: addDataDependency, + addProductDefinition: addProductDefinition, + addRecordDefinition: addRecordDefinition, + addRecordProperty: addRecordProperty, + addDatasetDefinition: addDatasetDefinition, + addPlotter: addPlotter, + addPlotterModule: addPlotterModule, + addPlotterPanel: addPlotterPanel, + addDefinition: addDefinition, + addNetwork: addNetwork, + addNetworkNode: addNetworkNode, + addSocialBots: addSocialBots, + addTelegramBot: addTelegramBot, + addAnnouncement: addAnnouncement, + addLayerManager: addLayerManager, + addLayer: addLayer, + addTaskManager: addTaskManager, + addTask: addTask, + addSensorBotInstance: addSensorBotInstance, + addIndicatorBotInstance: addIndicatorBotInstance, + addTradingBotInstance: addTradingBotInstance, + addProcessInstance: addProcessInstance, + addBacktestingSession: addBacktestingSession, + addLiveTradingSession: addLiveTradingSession, + addFordwardTestingSession: addFordwardTestingSession, + addPaperTradingSession: addPaperTradingSession, + addTradingSystem: addTradingSystem, + addPersonalData: addPersonalData, + addExchangeAccount: addExchangeAccount, + addExchangeAccountAsset: addExchangeAccountAsset, + addExchangeAccountKey: addExchangeAccountKey, + addStrategy: addStrategy, + addParameters: addParameters, + addMissingParameters: addMissingParameters, + addMissingStages: addMissingStages, + addMissingEvents: addMissingEvents, + addMissingItems: addMissingItems, + addInitialDefinition: addInitialDefinition, + addOpenExecution: addOpenExecution, + addCloseExecution: addCloseExecution, + addPhase: addPhase, + addFormula: addFormula, + addNextPhaseEvent: addNextPhaseEvent, + addSituation: addSituation, + addCondition: addCondition, + addCode: addCode + } + + let mapOfReferenceParents + let mapOfReferenceChildren + + return thisObject + + function recreateWorkspace (node) { + mapOfReferenceParents = new Map() + mapOfReferenceChildren = new Map() + let workspace = node + createUiObject('Workspace', workspace.name, workspace, undefined, undefined, 'Workspace') + if (node.rootNodes !== undefined) { + for (let i = 0; i < node.rootNodes.length; i++) { + let rootNode = node.rootNodes[i] + createUiObjectFromNode(rootNode, undefined, undefined) + } + } + /* We reconstruct here the reference relationships. */ + for (const [key, childNode] of mapOfReferenceChildren) { + childNode.payload.referenceParent = mapOfReferenceParents.get(childNode.savedPayload.referenceParent.id) + childNode.savedPayload = undefined + } + for (const [key, parentNode] of mapOfReferenceParents) { + if (parentNode.referenceChildren === undefined) { + parentNode.referenceChildren = [] + } + for (let i = 0; i < parentNode.savedPayload.referenceChildren.length; i++) { + let savedChild = parentNode.savedPayload.referenceChildren[i] + if (savedChild.id !== undefined) { + let referenceChild = mapOfReferenceChildren.get(savedChild.id) + parentNode.referenceChildren.push(referenceChild) + } + } + parentNode.savedPayload = undefined + } + mapOfReferenceChildren = undefined + mapOfReferenceParents = undefined + + return + } + + function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { + switch (node.type) { + case 'Code': + { + createUiObject('Code', node.name, node, parentNode, chainParent, 'Code', positionOffset) + return + } + case 'Condition': + { + createUiObject('Condition', node.name, node, parentNode, chainParent, 'Condition', positionOffset) + if (node.code !== undefined) { + createUiObjectFromNode(node.code, node, node, positionOffset) + } + return + } + case 'Situation': { + let situation = node + createUiObject('Situation', situation.name, situation, parentNode, chainParent, 'Situation', positionOffset) + for (let m = 0; m < node.conditions.length; m++) { + let condition = node.conditions[m] + createUiObjectFromNode(condition, situation, situation, positionOffset) + } + return + } + case 'Formula': + { + createUiObject('Formula', node.name, node, parentNode, chainParent, 'Formula', positionOffset) + return + } + case 'Next Phase Event': + { + createUiObject('Next Phase Event', node.name, node, parentNode, chainParent, 'Next Phase Event', positionOffset) + for (let m = 0; m < node.situations.length; m++) { + let situation = node.situations[m] + createUiObjectFromNode(situation, node, node, positionOffset) + } + if (node.announcements === undefined) { + node.announcements = [] + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = node.announcements[m] + createUiObjectFromNode(announcement, node, node, positionOffset) + } + return + } + case 'Phase': { + let phase = node + createUiObject('Phase', phase.name, phase, parentNode, chainParent, phase.subType, positionOffset) + + if (node.formula !== undefined) { + createUiObjectFromNode(node.formula, phase, phase, positionOffset) + } + if (node.nextPhaseEvent !== undefined) { + createUiObjectFromNode(node.nextPhaseEvent, phase, phase, positionOffset) + } + if (node.announcements === undefined) { + node.announcements = [] + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = node.announcements[m] + createUiObjectFromNode(announcement, node, node, positionOffset) + } + return + } + case 'Stop': { + let lastPhase + let stop = node + createUiObject('Stop', stop.name, stop, parentNode, chainParent, 'Stop', positionOffset) + for (let m = 0; m < node.phases.length; m++) { + let phase = node.phases[m] + let thisChainParent + if (m === 0) { + thisChainParent = node + } else { + thisChainParent = lastPhase + } + lastPhase = phase + createUiObjectFromNode(phase, stop, thisChainParent, positionOffset) + } + return + } + case 'Take Profit': { + let lastPhase + let takeProfit = node + createUiObject('Take Profit', takeProfit.name, takeProfit, parentNode, chainParent, 'Take Profit', positionOffset) + for (let m = 0; m < node.phases.length; m++) { + let phase = node.phases[m] + let thisChainParent + if (m === 0) { + thisChainParent = node + } else { + thisChainParent = lastPhase + } + lastPhase = phase + createUiObjectFromNode(phase, takeProfit, thisChainParent, positionOffset) + } + return + } + case 'Open Execution': + { + createUiObject('Open Execution', node.name, node, parentNode, chainParent, 'Open Execution', positionOffset) + return + } + case 'Close Execution': + { + createUiObject('Close Execution', node.name, node, parentNode, chainParent, 'Close Execution', positionOffset) + return + } + case 'Initial Definition': { + createUiObject('Initial Definition', node.name, node, parentNode, chainParent, 'Initial Definition', positionOffset) + + if (node.stopLoss !== undefined) { + createUiObjectFromNode(node.stopLoss, node, node, positionOffset) + } + if (node.takeProfit !== undefined) { + createUiObjectFromNode(node.takeProfit, node, node, positionOffset) + } + if (node.positionSize !== undefined) { + createUiObjectFromNode(node.positionSize, node, node, positionOffset) + } + if (node.positionRate !== undefined) { + createUiObjectFromNode(node.positionRate, node, node, positionOffset) + } + return + } + case 'Take Position Event': { + let event = node + createUiObject('Take Position Event', event.name, event, parentNode, chainParent, 'Take Position Event', positionOffset) + for (let m = 0; m < node.situations.length; m++) { + let situation = node.situations[m] + createUiObjectFromNode(situation, event, event, positionOffset) + } + if (node.announcements === undefined) { + node.announcements = [] + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = node.announcements[m] + createUiObjectFromNode(announcement, node, node, positionOffset) + } + return + } + case 'Trigger On Event': { + let event = node + createUiObject('Trigger On Event', event.name, event, parentNode, chainParent, 'Trigger On Event', positionOffset) + for (let m = 0; m < node.situations.length; m++) { + let situation = node.situations[m] + createUiObjectFromNode(situation, event, event, positionOffset) + } + if (node.announcements === undefined) { + node.announcements = [] + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = node.announcements[m] + createUiObjectFromNode(announcement, node, node, positionOffset) + } + return + } + case 'Trigger Off Event': { + let event = node + createUiObject('Trigger Off Event', event.name, event, parentNode, chainParent, 'Trigger Off Event', positionOffset) + for (let m = 0; m < node.situations.length; m++) { + let situation = node.situations[m] + createUiObjectFromNode(situation, event, event, positionOffset) + } + if (node.announcements === undefined) { + node.announcements = [] + } + for (let m = 0; m < node.announcements.length; m++) { + let announcement = node.announcements[m] + createUiObjectFromNode(announcement, node, node, positionOffset) + } + return + } + case 'Position Size': { + createUiObject('Position Size', node.name, node, parentNode, chainParent, 'Position Size', positionOffset) + if (node.formula !== undefined) { + createUiObjectFromNode(node.formula, node, node, positionOffset) + } + return + } + case 'Position Rate': { + createUiObject('Position Rate', node.name, node, parentNode, chainParent, 'Position Rate', positionOffset) + if (node.formula !== undefined) { + createUiObjectFromNode(node.formula, node, node, positionOffset) + } + return + } + case 'Trigger Stage': { + let stage = node + createUiObject('Trigger Stage', stage.name, stage, parentNode, chainParent, 'Trigger Stage', positionOffset) + + if (node.triggerOn !== undefined) { + createUiObjectFromNode(node.triggerOn, stage, stage, positionOffset) + } + if (node.triggerOff !== undefined) { + createUiObjectFromNode(node.triggerOff, stage, stage, positionOffset) + } + if (node.takePosition !== undefined) { + createUiObjectFromNode(node.takePosition, stage, stage, positionOffset) + } + return + } + case 'Open Stage': { + let stage = node + createUiObject('Open Stage', stage.name, stage, parentNode, chainParent, 'Open Stage', positionOffset) + + if (node.initialDefinition !== undefined) { + createUiObjectFromNode(node.initialDefinition, stage, stage, positionOffset) + } + if (node.openExecution !== undefined) { + createUiObjectFromNode(node.openExecution, stage, stage, positionOffset) + } + return + } + case 'Manage Stage': { + let stage = node + createUiObject('Manage Stage', stage.name, stage, parentNode, chainParent, 'Manage Stage', positionOffset) + + if (node.stopLoss !== undefined) { + createUiObjectFromNode(node.stopLoss, stage, stage, positionOffset) + } + if (node.takeProfit !== undefined) { + createUiObjectFromNode(node.takeProfit, stage, stage, positionOffset) + } + return + } + case 'Close Stage': { + let stage = node + createUiObject('Close Stage', stage.name, stage, parentNode, chainParent, 'Close Stage', positionOffset) + + if (node.closeExecution !== undefined) { + createUiObjectFromNode(node.closeExecution, stage, stage, positionOffset) + } + return + } + case 'Strategy': { + let strategy = node + createUiObject('Strategy', strategy.name, strategy, parentNode, chainParent, 'Strategy', positionOffset) + if (node.triggerStage !== undefined) { + createUiObjectFromNode(node.triggerStage, strategy, strategy, positionOffset) + } + if (node.openStage !== undefined) { + createUiObjectFromNode(node.openStage, strategy, strategy, positionOffset) + } + if (node.manageStage !== undefined) { + createUiObjectFromNode(node.manageStage, strategy, strategy, positionOffset) + } + if (node.closeStage !== undefined) { + createUiObjectFromNode(node.closeStage, strategy, strategy, positionOffset) + } + return + } + case 'Base Asset': { + createUiObject('Base Asset', node.name, node, parentNode, chainParent, 'Base Asset', positionOffset) + return + } + case 'Time Range': { + createUiObject('Time Range', node.name, node, parentNode, chainParent, 'Time Range', positionOffset) + return + } + case 'Time Period': { + createUiObject('Time Period', node.name, node, parentNode, chainParent, 'Time Period', positionOffset) + return + } + case 'Slippage': { + createUiObject('Slippage', node.name, node, parentNode, chainParent, 'Slippage', positionOffset) + return + } + case 'Fee Structure': { + createUiObject('Fee Structure', node.name, node, parentNode, chainParent, 'Fee Structure', positionOffset) + return + } + case 'Parameters': { + createUiObject('Parameters', node.name, node, parentNode, chainParent, 'Parameters', positionOffset) + if (node.baseAsset !== undefined) { + createUiObjectFromNode(node.baseAsset, node, node, positionOffset) + } + if (node.timeRange !== undefined) { + createUiObjectFromNode(node.timeRange, node, node, positionOffset) + } + if (node.timePeriod !== undefined) { + createUiObjectFromNode(node.timePeriod, node, node, positionOffset) + } + if (node.slippage !== undefined) { + createUiObjectFromNode(node.slippage, node, node, positionOffset) + } + if (node.feeStructure !== undefined) { + createUiObjectFromNode(node.feeStructure, node, node, positionOffset) + } + if (node.key !== undefined) { + createUiObjectFromNode(node.key, node, node, positionOffset) + } + return + } + case 'Trading System': { + let tradingSystem = node + createUiObject('Trading System', tradingSystem.name, tradingSystem, parentNode, chainParent, 'Trading System', positionOffset) + for (let m = 0; m < node.strategies.length; m++) { + let strategy = node.strategies[m] + createUiObjectFromNode(strategy, tradingSystem, tradingSystem, positionOffset) + } + if (node.parameters !== undefined) { + createUiObjectFromNode(node.parameters, node, node, positionOffset) + } + return + } + case 'Personal Data': { + createUiObject('Personal Data', node.name, node, parentNode, chainParent, 'Personal Data', positionOffset) + for (let m = 0; m < node.exchangeAccounts.length; m++) { + let exchangeAccount = node.exchangeAccounts[m] + createUiObjectFromNode(exchangeAccount, node, node, positionOffset) + } + return + } + case 'Exchange Account': { + createUiObject('Exchange Account', node.name, node, parentNode, chainParent, 'Exchange Account', positionOffset) + for (let m = 0; m < node.assets.length; m++) { + let asset = node.assets[m] + createUiObjectFromNode(asset, node, node, positionOffset) + } + for (let m = 0; m < node.keys.length; m++) { + let key = node.keys[m] + createUiObjectFromNode(key, node, node, positionOffset) + } + return + } + case 'Exchange Account Asset': { + createUiObject('Exchange Account Asset', node.name, node, parentNode, chainParent, 'Exchange Account Asset', positionOffset) + return + } + case 'Exchange Account Key': { + createUiObject('Exchange Account Key', node.name, node, parentNode, chainParent, 'Exchange Account Key', positionOffset) + return + } + case 'Definition': { + let referenceChildren + if (mapOfReferenceParents !== undefined) { + if (node.savedPayload.referenceChildren !== undefined) { + referenceChildren = [] + mapOfReferenceParents.set(node.id, node) + referenceChildren = node.savedPayload.referenceChildren + } + } + createUiObject('Definition', node.name, node, parentNode, chainParent, 'Definition', positionOffset) + if (node.tradingSystem !== undefined) { + createUiObjectFromNode(node.tradingSystem, node, node, positionOffset) + } + if (node.personalData !== undefined) { + createUiObjectFromNode(node.personalData, node, node, positionOffset) + } + if (node.referenceChildren === undefined) { + node.referenceChildren = [] + } + if (referenceChildren !== undefined) { + node.savedPayload = { + referenceChildren: referenceChildren + } + } + return + } + case 'Network': { + createUiObject('Network', node.name, node, parentNode, chainParent, 'Network', positionOffset) + if (node.networkNodes !== undefined) { + for (let m = 0; m < node.networkNodes.length; m++) { + let networkNode = node.networkNodes[m] + createUiObjectFromNode(networkNode, node, node, positionOffset) + } + } + return + } + case 'Network Node': { + createUiObject('Network Node', node.name, node, parentNode, chainParent, 'Network Node', positionOffset) + if (node.taskManagers !== undefined) { + for (let m = 0; m < node.taskManagers.length; m++) { + let taskManager = node.taskManagers[m] + createUiObjectFromNode(taskManager, node, node, positionOffset) + } + } + return + } + case 'Social Bots': { + createUiObject('Social Bots', node.name, node, parentNode, chainParent, 'Social Bots', positionOffset) + for (let m = 0; m < node.bots.length; m++) { + let bot = node.bots[m] + createUiObjectFromNode(bot, node, node, positionOffset) + } + return + } + case 'Telegram Bot': { + createUiObject('Telegram Bot', node.name, node, parentNode, chainParent, 'Telegram Bot', positionOffset) + for (let m = 0; m < node.announcements.length; m++) { + let announcement = node.announcements[m] + createUiObjectFromNode(announcement, node, node, positionOffset) + } + return + } + case 'Announcement': { + createUiObject('Announcement', node.name, node, parentNode, chainParent, 'Announcement', positionOffset) + if (node.formula !== undefined) { + createUiObjectFromNode(node.formula, node, node, positionOffset) + } + return + } + case 'Layer Manager': { + createUiObject('Layer Manager', node.name, node, parentNode, chainParent, 'Layer Manager', positionOffset) + for (let m = 0; m < node.layers.length; m++) { + let layer = node.layers[m] + createUiObjectFromNode(layer, node, node, positionOffset) + } + return + } + case 'Layer': { + createUiObject('Layer', node.name, node, parentNode, chainParent, 'Layer', positionOffset) + return + } + case 'Task Manager': { + createUiObject('Task Manager', node.name, node, parentNode, chainParent, 'Task Manager', positionOffset) + for (let m = 0; m < node.tasks.length; m++) { + let task = node.tasks[m] + createUiObjectFromNode(task, node, node, positionOffset) + } + return + } + case 'Task': { + createUiObject('Task', node.name, node, parentNode, chainParent, 'Task', positionOffset) + if (node.bot !== undefined) { + createUiObjectFromNode(node.bot, node, node, positionOffset) + } + return + } + case 'Sensor Bot Instance': { + createUiObject('Sensor Bot Instance', node.name, node, parentNode, chainParent, 'Sensor Bot Instance', positionOffset) + for (let m = 0; m < node.processes.length; m++) { + let process = node.processes[m] + createUiObjectFromNode(process, node, node, positionOffset) + } + return + } + case 'Indicator Bot Instance': { + createUiObject('Indicator Bot Instance', node.name, node, parentNode, chainParent, 'Indicator Bot Instance', positionOffset) + for (let m = 0; m < node.processes.length; m++) { + let process = node.processes[m] + createUiObjectFromNode(process, node, node, positionOffset) + } + return + } + case 'Trading Bot Instance': { + createUiObject('Trading Bot Instance', node.name, node, parentNode, chainParent, 'Trading Bot Instance', positionOffset) + for (let m = 0; m < node.processes.length; m++) { + let process = node.processes[m] + createUiObjectFromNode(process, node, node, positionOffset) + } + return + } + case 'Process Instance': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + if (parentNode !== undefined) { + switch (parentNode.type) { + case 'Sensor Bot Instance': { + node.subType = 'Sensor Process Instance' + break + } + case 'Indicator Bot Instance': { + node.subType = 'Indicator Process Instance' + break + } + case 'Trading Bot Instance': { + node.subType = 'Trading Process Instance' + break + } + } + } + createUiObject('Process Instance', node.name, node, parentNode, chainParent, 'Process Instance', positionOffset) + if (node.session !== undefined) { + createUiObjectFromNode(node.session, node, node, positionOffset) + } + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Backtesting Session': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject('Backtesting Session', node.name, node, parentNode, chainParent, 'Backtesting Session', positionOffset) + if (node.parameters !== undefined) { + createUiObjectFromNode(node.parameters, node, node, positionOffset) + } + if (node.layerManager !== undefined) { + createUiObjectFromNode(node.layerManager, node, node, positionOffset) + } + if (node.socialBots !== undefined) { + createUiObjectFromNode(node.socialBots, node, node, positionOffset) + } + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Live Trading Session': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject('Live Trading Session', node.name, node, parentNode, chainParent, 'Live Trading Session', positionOffset) + if (node.parameters !== undefined) { + createUiObjectFromNode(node.parameters, node, node, positionOffset) + } + if (node.layerManager !== undefined) { + createUiObjectFromNode(node.layerManager, node, node, positionOffset) + } + if (node.socialBots !== undefined) { + createUiObjectFromNode(node.socialBots, node, node, positionOffset) + } + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Fordward Testing Session': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject('Fordward Testing Session', node.name, node, parentNode, chainParent, 'Fordward Testing Session', positionOffset) + if (node.parameters !== undefined) { + createUiObjectFromNode(node.parameters, node, node, positionOffset) + } + if (node.layerManager !== undefined) { + createUiObjectFromNode(node.layerManager, node, node, positionOffset) + } + if (node.socialBots !== undefined) { + createUiObjectFromNode(node.socialBots, node, node, positionOffset) + } + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Paper Trading Session': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject('Paper Trading Session', node.name, node, parentNode, chainParent, 'Paper Trading Session', positionOffset) + if (node.parameters !== undefined) { + createUiObjectFromNode(node.parameters, node, node, positionOffset) + } + if (node.layerManager !== undefined) { + createUiObjectFromNode(node.layerManager, node, node, positionOffset) + } + if (node.socialBots !== undefined) { + createUiObjectFromNode(node.socialBots, node, node, positionOffset) + } + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + + case 'Team': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.sensorBots.length; m++) { + let sensorBot = node.sensorBots[m] + createUiObjectFromNode(sensorBot, node, node, positionOffset) + } + for (let m = 0; m < node.indicatorBots.length; m++) { + let indicatorBot = node.indicatorBots[m] + createUiObjectFromNode(indicatorBot, node, node, positionOffset) + } + for (let m = 0; m < node.tradingBots.length; m++) { + let tradingBot = node.tradingBots[m] + createUiObjectFromNode(tradingBot, node, node, positionOffset) + } + for (let m = 0; m < node.plotters.length; m++) { + let plotter = node.plotters[m] + createUiObjectFromNode(plotter, node, node, positionOffset) + } + return + } + case 'Sensor Bot': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.processes.length; m++) { + let process = node.processes[m] + createUiObjectFromNode(process, node, node, positionOffset) + } + for (let m = 0; m < node.products.length; m++) { + let product = node.products[m] + createUiObjectFromNode(product, node, node, positionOffset) + } + return + } + case 'Indicator Bot': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.processes.length; m++) { + let process = node.processes[m] + createUiObjectFromNode(process, node, node, positionOffset) + } + for (let m = 0; m < node.products.length; m++) { + let product = node.products[m] + createUiObjectFromNode(product, node, node, positionOffset) + } + return + } + case 'Trading Bot': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.processes.length; m++) { + let process = node.processes[m] + createUiObjectFromNode(process, node, node, positionOffset) + } + for (let m = 0; m < node.products.length; m++) { + let product = node.products[m] + createUiObjectFromNode(product, node, node, positionOffset) + } + return + } + case 'Process Definition': { + let referenceChildren + if (mapOfReferenceParents !== undefined) { + if (node.savedPayload.referenceChildren !== undefined) { + referenceChildren = [] + mapOfReferenceParents.set(node.id, node) + referenceChildren = node.savedPayload.referenceChildren + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.processOutput !== undefined) { + createUiObjectFromNode(node.processOutput, node, node, positionOffset) + } + if (node.processDependencies !== undefined) { + createUiObjectFromNode(node.processDependencies, node, node, positionOffset) + } + if (node.statusReport !== undefined) { + createUiObjectFromNode(node.statusReport, node, node, positionOffset) + } + if (node.executionStartedEvent !== undefined) { + createUiObjectFromNode(node.executionStartedEvent, node, node, positionOffset) + } + if (node.executionFinishedEvent !== undefined) { + createUiObjectFromNode(node.executionFinishedEvent, node, node, positionOffset) + } + if (referenceChildren !== undefined) { + node.savedPayload = { + referenceChildren: referenceChildren + } + } + return + } + case 'Process Output': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.outputDatasets.length; m++) { + let outputDataset = node.outputDatasets[m] + createUiObjectFromNode(outputDataset, node, node, positionOffset) + } + return + } + case 'Process Dependencies': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.statusDependencies.length; m++) { + let statusDependency = node.statusDependencies[m] + createUiObjectFromNode(statusDependency, node, node, positionOffset) + } + for (let m = 0; m < node.dataDependencies.length; m++) { + let dataDependency = node.dataDependencies[m] + createUiObjectFromNode(dataDependency, node, node, positionOffset) + } + return + } + case 'Status Report': { + let referenceChildren + if (mapOfReferenceParents !== undefined) { + if (node.savedPayload.referenceChildren !== undefined) { + referenceChildren = [] + mapOfReferenceParents.set(node.id, node) + referenceChildren = node.savedPayload.referenceChildren + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceChildren !== undefined) { + node.savedPayload = { + referenceChildren: referenceChildren + } + } + return + } + case 'Execution Started Event': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Execution Finished Event': { + let referenceChildren + if (mapOfReferenceParents !== undefined) { + if (node.savedPayload.referenceChildren !== undefined) { + referenceChildren = [] + mapOfReferenceParents.set(node.id, node) + referenceChildren = node.savedPayload.referenceChildren + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceChildren !== undefined) { + node.savedPayload = { + referenceChildren: referenceChildren + } + } + return + } + case 'Calculations Procedure': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.initialization !== undefined) { + createUiObjectFromNode(node.initialization, node, node, positionOffset) + } + if (node.loop !== undefined) { + createUiObjectFromNode(node.loop, node, node, positionOffset) + } + return + } + case 'Data Building Procedure': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.initialization !== undefined) { + createUiObjectFromNode(node.initialization, node, node, positionOffset) + } + if (node.loop !== undefined) { + createUiObjectFromNode(node.loop, node, node, positionOffset) + } + return + } + case 'Procedure Initialization': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.code !== undefined) { + createUiObjectFromNode(node.code, node, node, positionOffset) + } + return + } + case 'Procedure Loop': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.code !== undefined) { + createUiObjectFromNode(node.code, node, node, positionOffset) + } + return + } + case 'Output Dataset': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Status Dependency': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Data Dependency': { + let referenceParent + if (mapOfReferenceChildren !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { + if (node.savedPayload.referenceParent.id !== undefined) { + mapOfReferenceChildren.set(node.id, node) + referenceParent = node.savedPayload.referenceParent + } + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceParent !== undefined) { + node.savedPayload = { + referenceParent: referenceParent + } + } + return + } + case 'Product Definition': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.record !== undefined) { + createUiObjectFromNode(node.record, node, node, positionOffset) + } + for (let m = 0; m < node.datasets.length; m++) { + let dataset = node.datasets[m] + createUiObjectFromNode(dataset, node, node, positionOffset) + } + if (node.calculations !== undefined) { + createUiObjectFromNode(node.calculations, node, node, positionOffset) + } + if (node.dataBuilding !== undefined) { + createUiObjectFromNode(node.dataBuilding, node, node, positionOffset) + } + return + } + case 'Record Definition': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.properties.length; m++) { + let property = node.properties[m] + createUiObjectFromNode(property, node, node, positionOffset) + } + return + } + case 'Record Property': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.formula !== undefined) { + createUiObjectFromNode(node.formula, node, node, positionOffset) + } + return + } + case 'Dataset Definition': { + let referenceChildren + if (mapOfReferenceParents !== undefined) { + if (node.savedPayload.referenceChildren !== undefined) { + referenceChildren = [] + mapOfReferenceParents.set(node.id, node) + referenceChildren = node.savedPayload.referenceChildren + } + } + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (referenceChildren !== undefined) { + node.savedPayload = { + referenceChildren: referenceChildren + } + } + return + } + case 'Plotter': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + for (let m = 0; m < node.modules.length; m++) { + let module = node.modules[m] + createUiObjectFromNode(module, node, node, positionOffset) + } + return + } + case 'Plotter Module': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.code !== undefined) { + createUiObjectFromNode(node.code, node, node, positionOffset) + } + for (let m = 0; m < node.panels.length; m++) { + let panel = node.panels[m] + createUiObjectFromNode(panel, node, node, positionOffset) + } + return + } + case 'Plotter Panel': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + if (node.code !== undefined) { + createUiObjectFromNode(node.code, node, node, positionOffset) + } + return + } + } + } + + function addTeam (node) { + let team = { + name: 'New Team', + type: 'Team', + code: '{}', + sensorBots: [], + indicatorBots: [], + tradingBots: [], + plotters: [] + } + node.rootNodes.push(team) + createUiObject(team.type, team.name, team, undefined, undefined) + return team + } + + function addSensorBot (node) { + let object = { + type: 'Sensor Bot', + name: 'New Sensor Bot', + code: '{}', + processes: [], + products: [] + } + if (node.sensorBots === undefined) { + node.sensorBots = [] + } + node.sensorBots.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addIndicatorBot (node) { + let object = { + type: 'Indicator Bot', + name: 'New Indicator Bot', + code: '{}', + processes: [], + products: [] + } + if (node.indicatorBots === undefined) { + node.indicatorBots = [] + } + node.indicatorBots.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addTradingBot (node) { + let object = { + type: 'Trading Bot', + name: 'New Trading Bot', + code: '{}', + processes: [], + products: [] + } + if (node.tradingBots === undefined) { + node.tradingBots = [] + } + node.tradingBots.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addProcessDefinition (node) { + let object = { + type: 'Process Definition', + name: 'New Process Definition', + code: '{}', + referenceChildren: [] + } + if (node.processes === undefined) { + node.processes = [] + } + node.processes.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addMissingProcessDefinitionItems (node) { + addProcessOutput(node) + addProcessDependencies(node) + addStatusReport(node) + addExecutionStartedEvent(node) + addExecutionFinishedEvent(node) + } + + function addMissingProductDefinitionItems (node) { + addCalculationsProcedure(node) + addDataBuildingProcedure(node) + } + + function addProcessOutput (node) { + if (node.processOutput === undefined) { + node.processOutput = { + type: 'Process Output', + name: 'New Process Output', + outputDatasets: [] + } + createUiObject(node.processOutput.type, node.processOutput.name, node.processOutput, node, node) + } + return node.processOutput + } + + function addProcessDependencies (node) { + if (node.processDependencies === undefined) { + node.processDependencies = { + type: 'Process Dependencies', + name: 'New Process Dependencies', + statusDependencies: [], + dataDependencies: [] + } + createUiObject(node.processDependencies.type, node.processDependencies.name, node.processDependencies, node, node) + } + return node.processDependencies + } + + function addStatusReport (node) { + if (node.statusReport === undefined) { + node.statusReport = { + type: 'Status Report', + name: 'New Status Report', + referenceChildren: [] + } + createUiObject(node.statusReport.type, node.statusReport.name, node.statusReport, node, node) + } + return node.statusReport + } + + function addExecutionStartedEvent (node) { + if (node.executionStartedEvent === undefined) { + node.executionStartedEvent = { + type: 'Execution Started Event', + name: 'New Execution Started Event' + } + createUiObject(node.executionStartedEvent.type, node.executionStartedEvent.name, node.executionStartedEvent, node, node) + } + return node.executionStartedEvent + } + + function addExecutionFinishedEvent (node) { + if (node.executionFinishedEvent === undefined) { + node.executionFinishedEvent = { + type: 'Execution Finished Event', + name: 'New Execution Finished Event', + referenceChildren: [] + } + createUiObject(node.executionFinishedEvent.type, node.executionFinishedEvent.name, node.executionFinishedEvent, node, node) + } + return node.executionFinishedEvent + } + + function addCalculationsProcedure (node) { + if (node.calculations === undefined) { + node.calculations = { + type: 'Calculations Procedure', + name: 'New Calculations Procedure' + } + createUiObject(node.calculations.type, node.calculations.name, node.calculations, node, node) + } + return node.calculations + } + + function addDataBuildingProcedure (node) { + if (node.dataBuilding === undefined) { + node.dataBuilding = { + type: 'Data Building Procedure', + name: 'New Data Building Procedure' + } + createUiObject(node.dataBuilding.type, node.dataBuilding.name, node.dataBuilding, node, node) + } + return node.dataBuilding + } + + function addProcedureInitialization (node) { + if (node.initialization === undefined) { + node.initialization = { + type: 'Procedure Initialization', + name: 'New Procedure Initialization' + } + createUiObject(node.initialization.type, node.initialization.name, node.initialization, node, node) + } + return node.initialization + } + + function addProcedureLoop (node) { + if (node.loop === undefined) { + node.loop = { + type: 'Procedure Loop', + name: 'New Procedure Loop' + } + createUiObject(node.loop.type, node.loop.name, node.loop, node, node) + } + return node.loop + } + + function addOutputDataset (node) { + let object = { + type: 'Output Dataset', + name: 'New Output Dataset' + } + if (node.outputDatasets === undefined) { + node.outputDatasets = [] + } + node.outputDatasets.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addStatusDependency (node) { + let object = { + type: 'Status Dependency', + name: 'New Status Dependency', + code: '{"mainUtility": "Self Reference|Market Starting Point|Market Ending Point"}' + } + if (node.statusDependencies === undefined) { + node.statusDependencies = [] + } + node.statusDependencies.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addDataDependency (node) { + let object = { + type: 'Data Dependency', + name: 'New Data Dependency' + } + if (node.dataDependencies === undefined) { + node.dataDependencies = [] + } + node.dataDependencies.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addProductDefinition (node) { + let object = { + type: 'Product Definition', + name: 'New Product Definition', + code: '{}', + datasets: [] + } + if (node.products === undefined) { + node.products = [] + } + node.products.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addRecordDefinition (node) { + if (node.record === undefined) { + node.record = { + type: 'Record Definition', + name: 'New Record Definition', + properties: [] + } + createUiObject(node.record.type, node.record.name, node.record, node, node) + } + return node.record + } + + function addRecordProperty (node) { + let object = { + type: 'Record Property', + name: 'New Record Property', + code: '{}' + } + if (node.properties === undefined) { + node.properties = [] + } + node.properties.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addDatasetDefinition (node) { + let object = { + type: 'Dataset Definition', + name: 'New Dataset Definition', + code: '{}', + referenceChildren: [] + } + if (node.datasets === undefined) { + node.datasets = [] + } + node.datasets.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addPlotter (node) { + let object = { + type: 'Plotter', + name: 'New Plotter', + modules: [] + } + if (node.plotters === undefined) { + node.plotters = [] + } + node.plotters.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addPlotterModule (node) { + let object = { + type: 'Plotter Module', + name: 'New Plotter Module', + panels: [] + } + if (node.modules === undefined) { + node.modules = [] + } + node.modules.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addPlotterPanel (node) { + let object = { + type: 'Plotter Panel', + name: 'New Plotter Panel' + } + if (node.panels === undefined) { + node.panels = [] + } + node.panels.push(object) + createUiObject(object.type, object.name, object, node, node) + + return object + } + + function addNetwork (node) { + let network = { + name: 'Superalgos' + } + node.rootNodes.push(network) + createUiObject('Network', network.name, network, node, undefined, 'Network') + + return network + } + + function addNetworkNode (node) { + let networkNode = { + name: 'New Network Node' + } + if (node.networkNodes === undefined) { + node.networkNodes = [] + } + node.networkNodes.push(networkNode) + createUiObject('Network Node', networkNode.name, networkNode, node, node, 'Network Node') + + return networkNode + } + + function addSocialBots (node) { + if (node.socialBots === undefined) { + node.socialBots = { + name: 'New Social Bots', + bots: [] + } + createUiObject('Social Bots', node.socialBots.name, node.socialBots, node, node, 'Social Bots') + } + + return node.socialBots + } + + function addTelegramBot (node) { + let bot = { + name: 'New Telegram Bot', + code: '{ \n\"botToken\": \"Paste here the bot token obtained from Telegram Bot Father\",\n\"chatId\": Write here the chat or group id where the announcements are going to be sent to, as it is a number with no quotes please.\n}', + announcements: [] + } + node.bots.push(bot) + createUiObject('Telegram Bot', bot.name, bot, node, node, 'Telegram Bot') + + return bot + } + + function addAnnouncement (node) { + let announcement = { + name: 'Announcement via ' + node.type, + code: '{ \n\"text\": \"Write here what you want to announce.\",\n\"botType\": \"' + node.type + '\",\n\"botId\": \"' + node.id + '\"\n}' + } + node.announcements.push(announcement) + createUiObject('Announcement', announcement.name, announcement, node, node, 'Announcement') + + return announcement + } + + function addLayerManager (node) { + if (node.layerManager === undefined) { + node.layerManager = { + name: 'New Layer Manager', + layers: [] + } + createUiObject('Layer Manager', node.layerManager.name, node.layerManager, node, node, 'Layer Manager') + } + + return node.layerManager + } + + function addLayer (node) { + let layer = { + name: 'New Layer', + code: '{}' + } + node.layers.push(layer) + createUiObject('Layer', layer.name, layer, node, node, 'Layer') + + return layer + } + + function addTaskManager (node) { + let taskManager = { + name: 'New Task Manager', + tasks: [] + } + if (node.taskManagers === undefined) { + node.taskManagers = [] + } + node.taskManagers.push(taskManager) + createUiObject('Task Manager', taskManager.name, taskManager, node, node, 'Task Manager') + + return taskManager + } + + function addTask (node) { + let task = { + name: 'New Task' + } + node.tasks.push(task) + createUiObject('Task', task.name, task, node, node, 'Task') + + return task + } + + function addSensorBotInstance (node) { + if (node.bot === undefined) { + node.bot = { + processes: [], + code: '{}' + } + createUiObject('Sensor Bot Instance', '', node.bot, node, node) + } + return node.bot + } + + function addIndicatorBotInstance (node) { + if (node.bot === undefined) { + node.bot = { + processes: [], + code: '{}' + } + createUiObject('Indicator Bot Instance', '', node.bot, node, node) + } + return node.bot + } + + function addTradingBotInstance (node) { + if (node.bot === undefined) { + node.bot = { + processes: [], + code: '{}' + } + createUiObject('Trading Bot Instance', '', node.bot, node, node) + } + return node.bot + } + + function addProcessInstance (node) { + let process = { + name: 'New Process Instance', + code: '{}' + } + + switch (node.type) { + case 'Sensor Bot Instance': { + process.subType = 'Sensor Process Instance' + process.name = 'Sensor Process Instance' + break + } + case 'Indicator Bot Instance': { + process.subType = 'Indicator Process Instance' + process.name = 'Indicator Process Instance' + break + } + case 'Trading Bot Instance': { + process.subType = 'Trading Process Instance' + process.name = 'Trading Process Instance' + break + } + } + node.processes.push(process) + createUiObject('Process Instance', process.name, process, node, node, 'Process Instance') + + return process + } + + function addBacktestingSession (node) { + if (node.session === undefined) { + node.session = { + name: 'New Backtesting Session', + code: '{}' + } + createUiObject('Backtesting Session', '', node.session, node, node) + } + + return node.session + } + + function addLiveTradingSession (node) { + if (node.session === undefined) { + node.session = { + name: 'New Live Trading Session', + code: '{}' + } + createUiObject('Live Trading Session', '', node.session, node, node) + } + + return node.session + } + + function addFordwardTestingSession (node) { + if (node.session === undefined) { + node.session = { + name: 'New Fordward Testing Session', + code: '{}' + } + createUiObject('Fordward Testing Session', '', node.session, node, node) + } + + return node.session + } + + function addPaperTradingSession (node) { + if (node.session === undefined) { + node.session = { + name: 'New Paper Trading Session', + code: '{}' + } + createUiObject('Paper Trading Session', '', node.session, node, node) + } + + return node.session + } + + function addDefinition (node) { + let definition = { + name: 'New Definition', + referenceChildren: [] + } + node.rootNodes.push(definition) + createUiObject('Definition', definition.name, definition, node, undefined, 'Definition') + + return definition + } + + function addTradingSystem (node) { + if (node.tradingSystem === undefined) { + node.tradingSystem = { + strategies: [] + } + createUiObject('Trading System', '', node.tradingSystem, node, node) + } + return node.tradingSystem + } + + function addPersonalData (node) { + if (node.personalData === undefined) { + node.personalData = { + exchangeAccounts: [] + } + createUiObject('Personal Data', '', node.personalData, node, node) + } + + return node.personalData + } + + function addExchangeAccount (parentNode) { + let personalData = parentNode + let exchangeAccount = { + name: 'New Account', + assets: [], + keys: [] + } + personalData.exchangeAccounts.push(exchangeAccount) + createUiObject('Exchange Account', exchangeAccount.name, exchangeAccount, personalData, personalData, 'Exchange Account') + + return exchangeAccount + } + + function addExchangeAccountAsset (parentNode) { + let exchangeAccount = parentNode + let asset = { + name: 'New Asset' + } + exchangeAccount.assets.push(asset) + createUiObject('Exchange Account Asset', asset.name, asset, exchangeAccount, exchangeAccount, 'Account Asset') + + return asset + } + + function addExchangeAccountKey (parentNode) { + let exchangeAccount = parentNode + let key = { + name: 'New Key', + code: 'Paste your exchange API secret key here and the put the key name as this key object title. Secret keys are filtered out and NOT exported when using the SHARE menu option on any object at your workspace. Secret keys ARE downloaded when using the download button.' + } + exchangeAccount.keys.push(key) + createUiObject('Exchange Account Key', key.name, key, exchangeAccount, exchangeAccount, 'Account Key') + + return key + } + + function addStrategy (parentNode) { + let strategyParent = parentNode + let strategy = { + name: 'New Strategy', + active: true, + triggerStage: { + triggerOn: { + situations: [] + }, + triggerOff: { + situations: [] + }, + takePosition: { + situations: [] + }, + positionSize: { + formula: { + code: DEFAULT_FORMULA_TEXT + } + } + }, + openStage: { + initialDefinition: { + stopLoss: { + phases: [], + maxPhases: 1 + }, + takeProfit: { + phases: [], + maxPhases: 1 + } + } + }, + manageStage: { + stopLoss: { + phases: [] + }, + takeProfit: { + phases: [] + } + }, + closeStage: { + } + } + + strategyParent.strategies.push(strategy) + createUiObject('Strategy', strategy.name, strategy, strategyParent, strategyParent, 'Strategy') + createUiObject('Trigger Stage', '', strategy.triggerStage, strategy, strategy, 'Trigger Stage') + createUiObject('Open Stage', '', strategy.openStage, strategy, strategy, 'Open Stage') + createUiObject('Manage Stage', '', strategy.manageStage, strategy, strategy, 'Manage Stage') + createUiObject('Close Stage', '', strategy.closeStage, strategy, strategy, 'Close Stage') + createUiObject('Trigger On Event', '', strategy.triggerStage.triggerOn, strategy.triggerStage, strategy.triggerStage) + createUiObject('Trigger Off Event', '', strategy.triggerStage.triggerOff, strategy.triggerStage, strategy.triggerStage) + createUiObject('Take Position Event', '', strategy.triggerStage.takePosition, strategy.triggerStage, strategy.triggerStage) + createUiObject('Initial Definition', '', strategy.openStage.initialDefinition, strategy.openStage, strategy.openStage) + createUiObject('Position Size', '', strategy.openStage.initialDefinition.positionSize, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) + createUiObject('Position Rate', '', strategy.openStage.initialDefinition.positionRate, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) + createUiObject('Stop', '', strategy.manageStage.stopLoss, strategy.manageStage, strategy.manageStage) + createUiObject('Take Profit', '', strategy.manageStage.takeProfit, strategy.manageStage, strategy.manageStage) + createUiObject('Stop', 'Initial Stop', strategy.openStage.initialDefinition.stopLoss, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) + createUiObject('Take Profit', 'Initial Take Profit', strategy.openStage.initialDefinition.takeProfit, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) + createUiObject('Formula', '', strategy.triggerStage.positionSize.formula, strategy.triggerStage.positionSize, strategy.triggerStage.positionSize) + + return strategy + } + + function addParameters (node) { + if (node.parameters === undefined) { + node.parameters = { + name: 'Parameters' + } + createUiObject('Parameters', '', node.parameters, node, node) + addMissingParameters(node.parameters) + } + + return node.parameters + } + + function addMissingParameters (node) { + if (node.baseAsset === undefined) { + node.baseAsset = { + name: 'Base Asset', + code: DEFAULT_CONFIG_TEXT + } + createUiObject('Base Asset', '', node.baseAsset, node, node) + } + if (node.timeRange === undefined) { + node.timeRange = { + name: 'Time Range', + code: DEFAULT_CONFIG_TEXT + } + createUiObject('Time Range', '', node.timeRange, node, node) + } + if (node.timePeriod === undefined) { + node.timePeriod = { + name: 'Time Period', + code: DEFAULT_CONFIG_TEXT + } + createUiObject('Time Period', '', node.timePeriod, node, node) + } + if (node.slippage === undefined) { + node.slippage = { + name: 'Slippage', + code: DEFAULT_CONFIG_TEXT + } + createUiObject('Slippage', '', node.slippage, node, node) + } + if (node.feeStructure === undefined) { + node.feeStructure = { + name: 'Fee Structure', + code: DEFAULT_CONFIG_TEXT + } + createUiObject('Fee Structure', '', node.feeStructure, node, node) + } + } + + function addMissingStages (node) { + if (node.triggerStage === undefined) { + node.triggerStage = { + triggerOn: { + situations: [] + }, + triggerOff: { + situations: [] + }, + takePosition: { + situations: [] + }, + positionSize: { + formula: { + code: DEFAULT_FORMULA_TEXT + } + } + } + createUiObject('Trigger Stage', '', node.triggerStage, node, node, 'Trigger Stage') + createUiObject('Trigger On Event', '', node.triggerStage.triggerOn, node.triggerStage, node.triggerStage) + createUiObject('Trigger Off Event', '', node.triggerStage.triggerOff, node.triggerStage, node.triggerStage) + createUiObject('Take Position Event', '', node.triggerStage.takePosition, node.triggerStage, node.triggerStage) + createUiObject('Formula', '', node.triggerStage.positionSize.formula, node.triggerStage.positionSize, node.triggerStage.positionSize) + } + if (node.openStage === undefined) { + node.openStage = { + initialDefinition: { + stopLoss: { + phases: [], + maxPhases: 1 + }, + takeProfit: { + phases: [], + maxPhases: 1 + } + } + } + createUiObject('Open Stage', '', node.openStage, node, node, 'Open Stage') + createUiObject('Initial Definition', '', node.openStage.initialDefinition, node.openStage, node.openStage) + createUiObject('Stop', 'Initial Stop', node.openStage.initialDefinition.stopLoss, node.openStage.initialDefinition, node.openStage.initialDefinition) + createUiObject('Take Profit', 'Initial Take Profit', node.openStage.initialDefinition.takeProfit, node.openStage.initialDefinition, node.openStage.initialDefinition) + createUiObject('Position Size', 'Position Size', node.openStage.initialDefinition.positionSize, node.openStage.initialDefinition, node.openStage.initialDefinition) + createUiObject('Position Rate', 'Position Rate', node.openStage.initialDefinition.positionRate, node.openStage.initialDefinition, node.openStage.initialDefinition) + } + if (node.manageStage === undefined) { + node.manageStage = { + stopLoss: { + phases: [] + }, + takeProfit: { + phases: [] + } + } + createUiObject('Manage Stage', '', node.manageStage, node, node, 'Manage Stage') + createUiObject('Stop', '', node.manageStage.stopLoss, node.manageStage, node.manageStage) + createUiObject('Take Profit', '', node.manageStage.takeProfit, node.manageStage, node.manageStage) + } + if (node.closeStage === undefined) { + node.closeStage = { + } + createUiObject('Close Stage', '', node.closeStage, node, node, 'Close Stage') + } + } + + function addMissingEvents (node) { + if (node.triggerOn === undefined) { + node.triggerOn = { + situations: [], + announcements: [] + } + createUiObject('Trigger On Event', '', node.triggerOn, node, node) + } + if (node.triggerOff === undefined) { + node.triggerOff = { + situations: [], + announcements: [] + } + createUiObject('Trigger Off Event', '', node.triggerOff, node, node) + } + if (node.takePosition === undefined) { + node.takePosition = { + situations: [], + announcements: [] + } + createUiObject('Take Position Event', '', node.takePosition, node, node) + } + } + + function addMissingItems (node) { + if (node.type === 'Initial Definition') { + if (node.stopLoss === undefined) { + node.stopLoss = { + phases: [], + maxPhases: 1 + } + createUiObject('Stop', 'Initial Stop', node.stopLoss, node, node) + } + if (node.takeProfit === undefined) { + node.takeProfit = { + phases: [], + maxPhases: 1 + } + createUiObject('Take Profit', 'Initial Take Profit', node.takeProfit, node, node) + } + if (node.positionSize === undefined) { + node.positionSize = { + name: 'Position Size', + formula: { + code: DEFAULT_FORMULA_TEXT + } + } + createUiObject('Position Size', '', node.positionSize, node, node) + createUiObject('Formula', '', node.positionSize.formula, node.positionSize, node.positionSize) + } + if (node.positionRate === undefined) { + node.positionRate = { + name: 'Position Rate', + formula: { + code: DEFAULT_FORMULA_TEXT + } + } + createUiObject('Position Rate', '', node.positionRate, node, node) + createUiObject('Formula', '', node.positionRate.formula, node.positionRate, node.positionRate) + } + } else { + if (node.stopLoss === undefined) { + node.stopLoss = { + phases: [] + } + createUiObject('Stop', '', node.stopLoss, node, node) + } + if (node.takeProfit === undefined) { + node.takeProfit = { + phases: [] + } + createUiObject('Take Profit', '', node.takeProfit, node, node) + } + } + } + + function addInitialDefinition (node) { + if (node.initialDefinition === undefined) { + node.initialDefinition = { + stopLoss: { + phases: [], + maxPhases: 1 + }, + takeProfit: { + phases: [], + maxPhases: 1 + } + } + createUiObject('Initial Definition', '', node.initialDefinition, node, node) + createUiObject('Stop', 'Initial Stop', node.initialDefinition.stopLoss, node.initialDefinition, node.initialDefinition) + createUiObject('Take Profit', 'Initial Take Profit', node.initialDefinition.takeProfit, node.initialDefinition, node.initialDefinition) + createUiObject('Position Size', '', node.initialDefinition.positionSize, node.initialDefinition, node.initialDefinition) + createUiObject('Formula', '', node.initialDefinition.positionSize.formula, node.initialDefinition.positionSize, node.initialDefinition.positionSize) + createUiObject('Position Rate', '', node.initialDefinition.positionRate, node.initialDefinition, node.initialDefinition) + createUiObject('Formula', '', node.initialDefinition.positionRate.formula, node.initialDefinition.positionRate, node.initialDefinition.positionRate) + } + + return node.initialDefinition + } + + function addOpenExecution (node) { + if (node.openExecution === undefined) { + node.openExecution = {} + createUiObject('Open Execution', '', node.openExecution, node, node) + } + + return node.openExecution + } + + function addCloseExecution (node) { + if (node.closeExecution === undefined) { + node.closeExecution = {} + createUiObject('Close Execution', '', node.closeExecution, node, node) + } + + return node.closeExecution + } + + function addFormula (node) { + if (node.formula === undefined) { + node.formula = { + code: DEFAULT_FORMULA_TEXT + } + createUiObject('Formula', '', node.formula, node, node) + } + + return node.formula + } + + function addNextPhaseEvent (node) { + if (node.nextPhaseEvent === undefined) { + node.nextPhaseEvent = { + situations: [], + announcements: [] + } + createUiObject('Next Phase Event', '', node.nextPhaseEvent, node, node) + } + + return node.nextPhaseEvent + } + + function addCode (node) { + if (node.code === undefined) { + node.code = { + code: DEFAULT_CODE_TEXT + } + createUiObject('Code', '', node.code, node, node) + } + + return node.code + } + + function addPhase (parentNode) { + if (parentNode.maxPhases !== undefined) { + if (parentNode.phases.length >= parentNode.maxPhases) { + return + } + } + let phaseParent = parentNode + let m = phaseParent.phases.length + + if (phaseParent.payload.parentNode !== undefined) { + if (phaseParent.payload.parentNode.type === 'Initial Definition' && m > 0) { return } + } + + let phase = { + name: 'New Phase', + announcements: [], + formula: { + code: DEFAULT_FORMULA_TEXT + }, + nextPhaseEvent: { + situations: [] + } + } + phaseParent.phases.push(phase) + let phaseChainParent + if (m > 0) { + phaseChainParent = phaseParent.phases[m - 1] + } else { + phaseChainParent = phaseParent + } + createUiObject('Phase', phase.name, phase, phaseParent, phaseChainParent, 'Phase') + createUiObject('Formula', '', phase.formula, phase, phase, 'Formula') + createUiObject('Next Phase Event', '', phase.nextPhaseEvent, phase, phase) + + return phase + } + + function addSituation (parentNode) { + let m = parentNode.situations.length + let situation = { + name: 'New Situation', + conditions: [] + } + parentNode.situations.push(situation) + createUiObject('Situation', situation.name, situation, parentNode, parentNode, 'Situation') + + return situation + } + + function addCondition (parentNode) { + let situation = parentNode + let m = situation.conditions.length + let condition = { + name: 'New Condition', + code: { + code: DEFAULT_CODE_TEXT + } + } + situation.conditions.push(condition) + createUiObject('Condition', condition.name, condition, situation, situation, 'Condition') + createUiObject('Code', '', condition.code, condition, condition, 'Code') + + return condition + } + + function createUiObject (uiObjectType, name, node, parentNode, chainParent, title, positionOffset) { + let payload = {} + + if (name === '' || name === undefined) { name = 'My ' + uiObjectType } + if (node.savedPayload !== undefined) { + /* If there is a position offset, we apply it here. */ + if (positionOffset !== undefined) { + node.savedPayload.targetPosition.x = node.savedPayload.targetPosition.x + positionOffset.x + node.savedPayload.targetPosition.y = node.savedPayload.targetPosition.y + positionOffset.y + node.savedPayload.position.x = node.savedPayload.position.x + positionOffset.x + node.savedPayload.position.y = node.savedPayload.position.y + positionOffset.y + } + + payload.targetPosition = { + x: node.savedPayload.targetPosition.x, + y: node.savedPayload.targetPosition.y + } + + node.savedPayload.targetPosition = undefined + + if (payload.targetPosition.x === null) { payload.targetPosition.x = spawnPosition.x } + if (payload.targetPosition.y === null) { payload.targetPosition.y = spawnPosition.y } + } else { + if (chainParent === undefined) { + payload.targetPosition = { + x: spawnPosition.x, + y: spawnPosition.y + } + if (uiObjectType === 'Workspace' || uiObjectType === 'Trading System') { + payload.position = { + x: spawnPosition.x, + y: spawnPosition.y + } + } + } else { + payload.targetPosition = { + x: chainParent.payload.position.x, + y: chainParent.payload.position.y + } + } + } + + if (title !== undefined) { + payload.subTitle = title + } else { + payload.subTitle = uiObjectType + } + + payload.visible = true + payload.title = name + payload.node = node + payload.parentNode = parentNode + payload.chainParent = chainParent + payload.onMenuItemClick = canvas.designerSpace.workspace.onMenuItemClick + + if (node.id === undefined) { + node.id = newUniqueId() + } + node.payload = payload + node.type = uiObjectType + canvas.floatingSpace.uiObjectConstructor.createUiObject(payload) + } +} diff --git a/StrategySpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js similarity index 51% rename from StrategySpace/Workspace/Workspace.js rename to DesignerSpace/Workspace/Workspace.js index b39b051c3..9ddfc5263 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -13,13 +13,15 @@ function newWorkspace () { nodeChildren: undefined, getNodeThatIsOnFocus: getNodeThatIsOnFocus, getNodeByShortcutKey: getNodeByShortcutKey, - getAllTradingEngines: getAllTradingEngines, + getAllTradingBotInstances: getAllTradingBotInstances, stopAllRunningTasks: stopAllRunningTasks, onMenuItemClick: onMenuItemClick, physics: physics, spawn: spawn, - detachNode: detachNode, - attachNode: attachNode, + chainDetachNode: chainDetachNode, + chainAttachNode: chainAttachNode, + referenceDetachNode: referenceDetachNode, + referenceAttachNode: referenceAttachNode, initialize: initialize, finalize: finalize } @@ -44,9 +46,10 @@ function newWorkspace () { thisObject.workspaceNode = {} thisObject.workspaceNode.rootNodes = [] - let functionLibraryAttachDetach = newAttachDetach() + let functionLibraryReferenceAttachDetach = newReferenceAttachDetach() + let functionLibraryChainAttachDetach = newChainAttachDetach() let functionLibraryNodeDeleter = newNodeDeleter() - let functionLibraryPartsFromNodes = newPartsFromNodes() + let functionLibraryUiObjectsFromNodes = newUiObjectsFromNodes() let functionLibraryProtocolNode = newProtocolNode() let functionLibraryTaskFunctions = newTaskFunctions() let functionLibrarySessionFunctions = newSessionFunctions() @@ -78,16 +81,12 @@ function newWorkspace () { if (savedWorkspace === null || idAtStrategizer === null) { thisObject.workspaceNode.type = 'Workspace' thisObject.workspaceNode.name = 'My Workspace' - functionLibraryPartsFromNodes.createPartFromNode(thisObject.workspaceNode, undefined, undefined) + functionLibraryUiObjectsFromNodes.createUiObjectFromNode(thisObject.workspaceNode, undefined, undefined) spawnPosition.y = spawnPosition.y + 250 initializeLoadingFromStrategizer() } else { thisObject.workspaceNode = JSON.parse(savedWorkspace) - functionLibraryPartsFromNodes.createPartFromNode(thisObject.workspaceNode, undefined, undefined) - for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { - let rootNode = thisObject.workspaceNode.rootNodes[i] - functionLibraryPartsFromNodes.createPartFromNode(rootNode, undefined, undefined) - } + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) thisObject.enabled = true } } catch (err) { @@ -96,22 +95,30 @@ function newWorkspace () { } async function initializeLoadingFromStrategizer () { - let result = await canvas.strategySpace.strategizerGateway.loadFromStrategyzer() + let result = await canvas.designerSpace.strategizerGateway.loadFromStrategyzer() if (result === true) { - thisObject.definition = canvas.strategySpace.strategizerGateway.strategizerData + thisObject.definition = canvas.designerSpace.strategizerGateway.strategizerData thisObject.workspaceNode.rootNodes.push(thisObject.definition) - functionLibraryPartsFromNodes.createPartFromNode(thisObject.definition, undefined, undefined) + functionLibraryUiObjectsFromNodes.createUiObjectFromNode(thisObject.definition, undefined, undefined) thisObject.enabled = true } } - function detachNode (node) { - functionLibraryAttachDetach.detachNode(node, thisObject.workspaceNode.rootNodes) + function chainDetachNode (node) { + functionLibraryChainAttachDetach.chainDetachNode(node, thisObject.workspaceNode.rootNodes) } - function attachNode (node, attachToNode) { - functionLibraryAttachDetach.attachNode(node, attachToNode, thisObject.workspaceNode.rootNodes) + function chainAttachNode (node, attachToNode) { + functionLibraryChainAttachDetach.chainAttachNode(node, attachToNode, thisObject.workspaceNode.rootNodes) + } + + function referenceDetachNode (node) { + functionLibraryReferenceAttachDetach.referenceDetachNode(node) + } + + function referenceAttachNode (node, attachToNode) { + functionLibraryReferenceAttachDetach.referenceAttachNode(node, attachToNode, thisObject.workspaceNode.rootNodes) } function physics () { @@ -131,7 +138,7 @@ function newWorkspace () { let stringifyReadyNodes = [] for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true) + let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true) if (node) { stringifyReadyNodes.push(node) } @@ -148,16 +155,13 @@ function newWorkspace () { function stopAllRunningTasks () { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - if (rootNode.type === 'Definition') { - let definition = rootNode - if (definition.network !== undefined) { - if (definition.network.networkNodes !== undefined) { - for (let j = 0; j < definition.network.networkNodes.length; j++) { - let networkNode = definition.network.networkNodes[j] - for (let i = 0; i < networkNode.taskManagers.length; i++) { - let taskManager = networkNode.taskManagers[i] - taskManager.payload.uiObject.menu.internalClick('Stop All Tasks') - } + if (rootNode.type === 'Network') { + if (rootNode.networkNodes !== undefined) { + for (let j = 0; j < rootNode.networkNodes.length; j++) { + let networkNode = rootNode.networkNodes[j] + for (let i = 0; i < networkNode.taskManagers.length; i++) { + let taskManager = networkNode.taskManagers[i] + taskManager.payload.uiObject.menu.internalClick('Stop All Tasks') } } } @@ -165,23 +169,20 @@ function newWorkspace () { } } - function getAllTradingEngines () { - let tradingEngines = [] + function getAllTradingBotInstances () { + let tradingBotInstances = [] for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - if (rootNode.type === 'Definition') { - let definition = rootNode - if (definition.network !== undefined) { - if (definition.network.networkNodes !== undefined) { - for (let j = 0; j < definition.network.networkNodes.length; j++) { - let networkNode = definition.network.networkNodes[j] - for (let i = 0; i < networkNode.taskManagers.length; i++) { - let taskManager = networkNode.taskManagers[i] - for (k = 0; k < taskManager.tasks.length; k++) { - let task = taskManager.tasks[k] - if (task.bot.type === 'Trading Engine') { - tradingEngines.push(task.bot) - } + if (rootNode.type === 'Network') { + if (rootNode.networkNodes !== undefined) { + for (let j = 0; j < rootNode.networkNodes.length; j++) { + let networkNode = rootNode.networkNodes[j] + for (let i = 0; i < networkNode.taskManagers.length; i++) { + let taskManager = networkNode.taskManagers[i] + for (k = 0; k < taskManager.tasks.length; k++) { + let task = taskManager.tasks[k] + if (task.bot.type === 'Trading Bot Instance') { + tradingBotInstances.push(task.bot) } } } @@ -189,28 +190,24 @@ function newWorkspace () { } } } - return tradingEngines + return tradingBotInstances } function getNodeByShortcutKey (searchingKey) { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - if (rootNode.type === 'Definition') { - let definition = rootNode - let node = functionLibraryShortcutKeys.getNodeByShortcutKey(rootNode, searchingKey) - if (node !== undefined) { return node } - } + let definition = rootNode + let node = functionLibraryShortcutKeys.getNodeByShortcutKey(rootNode, searchingKey) + if (node !== undefined) { return node } } } function getNodeThatIsOnFocus () { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - if (rootNode.type === 'Definition') { - let definition = rootNode - let node = functionLibraryOnFocus.getNodeThatIsOnFocus(rootNode) - if (node !== undefined) { return node } - } + let definition = rootNode + let node = functionLibraryOnFocus.getNodeThatIsOnFocus(rootNode) + if (node !== undefined) { return node } } } @@ -226,16 +223,40 @@ function newWorkspace () { stopAllRunningTasks() functionLibraryNodeDeleter.deleteWorkspace(thisObject.workspaceNode, thisObject.workspaceNode.rootNodes) thisObject.workspaceNode = droppedNode - functionLibraryPartsFromNodes.createPartFromNode(thisObject.workspaceNode, undefined, undefined) - for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { - let rootNode = thisObject.workspaceNode.rootNodes[i] - functionLibraryPartsFromNodes.createPartFromNode(rootNode, undefined, undefined) - } + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) + return } else { - let rootNode = functionLibraryProtocolNode.getProtocolNode(droppedNode) - thisObject.workspaceNode.rootNodes.push(rootNode) - functionLibraryPartsFromNodes.createPartFromNode(rootNode, undefined, undefined) + if ( + droppedNode.type === 'Definition' || + droppedNode.type === 'Network' || + droppedNode.type === 'Team' + ) { + /* We will only respect the state of each object on these structures, if the structure does not yet exist inside the workspace */ + let alreadyExists = false + for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { + let rootNode = thisObject.workspaceNode.rootNodes[i] + if (droppedNode.id === rootNode.id) { + alreadyExists = true + } + } + if (alreadyExists === false) { + /* It does not exist, so we recreeate it respecting the inner state of each object. */ + let positionOffset = { + x: spawnPosition.x - droppedNode.savedPayload.targetPosition.x, + y: spawnPosition.y - droppedNode.savedPayload.targetPosition.y + } + + thisObject.workspaceNode.rootNodes.push(droppedNode) + functionLibraryUiObjectsFromNodes.createUiObjectFromNode(droppedNode, undefined, undefined, positionOffset) + return + } + } } + + /* This is the default behaviour, which consists of cleaning all nodes that are not supported and then creating the UIObjects that remains on the data structure. */ + let rootNode = functionLibraryProtocolNode.getProtocolNode(droppedNode) + thisObject.workspaceNode.rootNodes.push(rootNode) + functionLibraryUiObjectsFromNodes.createUiObjectFromNode(rootNode, undefined, undefined) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] spawn -> err = ' + err.stack) } } @@ -262,7 +283,17 @@ function newWorkspace () { break case 'Share': { - let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true)) + let text + if ( + payload.node.type === 'Definition' || + payload.node.type === 'Network' || + payload.node.type === 'Team' + ) { + text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true, false, true, true, true)) + } else { + text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true)) + } + let nodeName = payload.node.name if (nodeName === undefined) { nodeName = '' @@ -276,7 +307,17 @@ function newWorkspace () { break case 'Backup': { - let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false)) + let text + if ( + payload.node.type === 'Definition' || + payload.node.type === 'Network' || + payload.node.type === 'Team' + ) { + text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false, false, true, true, true)) + } else { + text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false)) + } + let nodeName = payload.node.name if (nodeName === undefined) { nodeName = '' @@ -320,194 +361,420 @@ function newWorkspace () { break case 'Add Definition': { - functionLibraryPartsFromNodes.addDefinition(payload.node) + functionLibraryUiObjectsFromNodes.addDefinition(payload.node) + } + break + case 'Add Team': + { + functionLibraryUiObjectsFromNodes.addTeam(payload.node) + } + break + case 'Add Sensor Bot': + { + functionLibraryUiObjectsFromNodes.addSensorBot(payload.node) + } + break + case 'Add Indicator Bot': + { + functionLibraryUiObjectsFromNodes.addIndicatorBot(payload.node) + } + break + case 'Add Trading Bot': + { + functionLibraryUiObjectsFromNodes.addTradingBot(payload.node) + } + break + case 'Add Process Definition': + { + functionLibraryUiObjectsFromNodes.addProcessDefinition(payload.node) + } + break + case 'Add Missing Process Definition Items': + { + functionLibraryUiObjectsFromNodes.addMissingProcessDefinitionItems(payload.node) + } + break + case 'Add Missing Product Definition Items': + { + functionLibraryUiObjectsFromNodes.addMissingProductDefinitionItems(payload.node) + } + break + case 'Add Process Output': + { + functionLibraryUiObjectsFromNodes.addProcessOutput(payload.node) + } + break + case 'Add Process Dependencies': + { + functionLibraryUiObjectsFromNodes.addProcessDependencies(payload.node) + } + break + case 'Add Status Report': + { + functionLibraryUiObjectsFromNodes.addStatusReport(payload.node) + } + break + case 'Add Execution Started Event': + { + functionLibraryUiObjectsFromNodes.addExecutionStartedEvent(payload.node) + } + break + case 'Add Execution Finished Event': + { + functionLibraryUiObjectsFromNodes.addExecutionFinishedEvent(payload.node) + } + break + case 'Add Calculations Procedure': + { + functionLibraryUiObjectsFromNodes.addCalculationsProcedure(payload.node) + } + break + case 'Add Data Building Procedure': + { + functionLibraryUiObjectsFromNodes.addDataBuildingProcedure(payload.node) + } + break + case 'Add Procedure Initialization': + { + functionLibraryUiObjectsFromNodes.addProcedureInitialization(payload.node) + } + break + case 'Add Procedure Loop': + { + functionLibraryUiObjectsFromNodes.addProcedureLoop(payload.node) + } + break + case 'Add Output Dataset': + { + functionLibraryUiObjectsFromNodes.addOutputDataset(payload.node) + } + break + case 'Add Status Dependency': + { + functionLibraryUiObjectsFromNodes.addStatusDependency(payload.node) + } + break + case 'Add Data Dependency': + { + functionLibraryUiObjectsFromNodes.addDataDependency(payload.node) + } + break + case 'Add Product Definition': + { + functionLibraryUiObjectsFromNodes.addProductDefinition(payload.node) + } + break + case 'Add Record Definition': + { + functionLibraryUiObjectsFromNodes.addRecordDefinition(payload.node) + } + break + case 'Add Record Property': + { + functionLibraryUiObjectsFromNodes.addRecordProperty(payload.node) + } + break + case 'Add Dataset Definition': + { + functionLibraryUiObjectsFromNodes.addDatasetDefinition(payload.node) + } + break + case 'Add Plotter': + { + functionLibraryUiObjectsFromNodes.addPlotter(payload.node) + } + break + case 'Add Plotter Module': + { + functionLibraryUiObjectsFromNodes.addPlotterModule(payload.node) + } + break + case 'Add Plotter Panel': + { + functionLibraryUiObjectsFromNodes.addPlotterPanel(payload.node) } break case 'Add Network': { - functionLibraryPartsFromNodes.addNetwork(payload.node) + functionLibraryUiObjectsFromNodes.addNetwork(payload.node) } break case 'Add Network Node': { - functionLibraryPartsFromNodes.addNetworkNode(payload.node) + functionLibraryUiObjectsFromNodes.addNetworkNode(payload.node) } break case 'Add Social Bots': { - functionLibraryPartsFromNodes.addSocialBots(payload.node) + functionLibraryUiObjectsFromNodes.addSocialBots(payload.node) } break case 'Add Telegram Bot': { - functionLibraryPartsFromNodes.addTelegramBot(payload.node) + functionLibraryUiObjectsFromNodes.addTelegramBot(payload.node) } break case 'Add Announcement': { - functionLibraryPartsFromNodes.addAnnouncement(payload.node) + functionLibraryUiObjectsFromNodes.addAnnouncement(payload.node) } break case 'Add Layer Manager': { - functionLibraryPartsFromNodes.addLayerManager(payload.node) + functionLibraryUiObjectsFromNodes.addLayerManager(payload.node) } break case 'Add Layer': { - functionLibraryPartsFromNodes.addLayer(payload.node) + functionLibraryUiObjectsFromNodes.addLayer(payload.node) } break case 'Add Task Manager': { - functionLibraryPartsFromNodes.addTaskManager(payload.node) + functionLibraryUiObjectsFromNodes.addTaskManager(payload.node) } break case 'Add Task': { - functionLibraryPartsFromNodes.addTask(payload.node) + functionLibraryUiObjectsFromNodes.addTask(payload.node) } break - case 'Add Sensor': + case 'Add Sensor Bot Instance': { - functionLibraryPartsFromNodes.addSensor(payload.node) + functionLibraryUiObjectsFromNodes.addSensorBotInstance(payload.node) } break - case 'Add Indicator': + case 'Add Indicator Bot Instance': { - functionLibraryPartsFromNodes.addIndicator(payload.node) + functionLibraryUiObjectsFromNodes.addIndicatorBotInstance(payload.node) } break - case 'Add Trading Engine': + case 'Add Trading Bot Instance': { - functionLibraryPartsFromNodes.addTradingEngine(payload.node) + functionLibraryUiObjectsFromNodes.addTradingBotInstance(payload.node) } break - case 'Add Process': + case 'Add Process Instance': { - functionLibraryPartsFromNodes.addProcess(payload.node) + functionLibraryUiObjectsFromNodes.addProcessInstance(payload.node) } break case 'Add Backtesting Session': { - functionLibraryPartsFromNodes.addBacktestingSession(payload.node) + functionLibraryUiObjectsFromNodes.addBacktestingSession(payload.node) } break case 'Add Live Trading Session': { - functionLibraryPartsFromNodes.addLiveTradingSession(payload.node) + functionLibraryUiObjectsFromNodes.addLiveTradingSession(payload.node) } break case 'Add Fordward Testing Session': { - functionLibraryPartsFromNodes.addFordwardTestingSession(payload.node) + functionLibraryUiObjectsFromNodes.addFordwardTestingSession(payload.node) } break case 'Add Paper Trading Session': { - functionLibraryPartsFromNodes.addPaperTradingSession(payload.node) + functionLibraryUiObjectsFromNodes.addPaperTradingSession(payload.node) } break case 'Add Strategy': { - functionLibraryPartsFromNodes.addStrategy(payload.node) + functionLibraryUiObjectsFromNodes.addStrategy(payload.node) } break case 'Add Parameters': { - functionLibraryPartsFromNodes.addParameters(payload.node) + functionLibraryUiObjectsFromNodes.addParameters(payload.node) } break case 'Add Missing Parameters': { - functionLibraryPartsFromNodes.addMissingParameters(payload.node) + functionLibraryUiObjectsFromNodes.addMissingParameters(payload.node) } break case 'Add Missing Stages': { - functionLibraryPartsFromNodes.addMissingStages(payload.node) + functionLibraryUiObjectsFromNodes.addMissingStages(payload.node) } break case 'Add Missing Events': { - functionLibraryPartsFromNodes.addMissingEvents(payload.node) + functionLibraryUiObjectsFromNodes.addMissingEvents(payload.node) } break case 'Add Missing Items': { - functionLibraryPartsFromNodes.addMissingItems(payload.node) + functionLibraryUiObjectsFromNodes.addMissingItems(payload.node) } break case 'Add Initial Definition': { - functionLibraryPartsFromNodes.addInitialDefinition(payload.node) + functionLibraryUiObjectsFromNodes.addInitialDefinition(payload.node) } break case 'Add Open Execution': { - functionLibraryPartsFromNodes.addOpenExecution(payload.node) + functionLibraryUiObjectsFromNodes.addOpenExecution(payload.node) } break case 'Add Close Execution': { - functionLibraryPartsFromNodes.addCloseExecution(payload.node) + functionLibraryUiObjectsFromNodes.addCloseExecution(payload.node) } break case 'Add Phase': { - functionLibraryPartsFromNodes.addPhase(payload.node) + functionLibraryUiObjectsFromNodes.addPhase(payload.node) } break case 'Add Formula': { - functionLibraryPartsFromNodes.addFormula(payload.node) + functionLibraryUiObjectsFromNodes.addFormula(payload.node) } break case 'Add Next Phase Event': { - functionLibraryPartsFromNodes.addNextPhaseEvent(payload.node) + functionLibraryUiObjectsFromNodes.addNextPhaseEvent(payload.node) } break case 'Add Situation': { - functionLibraryPartsFromNodes.addSituation(payload.node) + functionLibraryUiObjectsFromNodes.addSituation(payload.node) } break case 'Add Condition': { - functionLibraryPartsFromNodes.addCondition(payload.node) + functionLibraryUiObjectsFromNodes.addCondition(payload.node) } break case 'Add Code': { - functionLibraryPartsFromNodes.addCode(payload.node) + functionLibraryUiObjectsFromNodes.addCode(payload.node) } break case 'Add Exchange Account': { - functionLibraryPartsFromNodes.addExchangeAccount(payload.node) + functionLibraryUiObjectsFromNodes.addExchangeAccount(payload.node) } break case 'Add Exchange Account Asset': { - functionLibraryPartsFromNodes.addExchangeAccountAsset(payload.node) + functionLibraryUiObjectsFromNodes.addExchangeAccountAsset(payload.node) } break case 'Add Exchange Account Key': { - functionLibraryPartsFromNodes.addExchangeAccountKey(payload.node) + functionLibraryUiObjectsFromNodes.addExchangeAccountKey(payload.node) } break case 'Add Trading System': { - functionLibraryPartsFromNodes.addTradingSystem(payload.node) + functionLibraryUiObjectsFromNodes.addTradingSystem(payload.node) } break case 'Add Personal Data': { - functionLibraryPartsFromNodes.addPersonalData(payload.node) + functionLibraryUiObjectsFromNodes.addPersonalData(payload.node) } break + case 'Delete Team': { + functionLibraryNodeDeleter.deleteTeam(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Sensor Bot': { + functionLibraryNodeDeleter.deleteSensorBot(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Indicator Bot': { + functionLibraryNodeDeleter.deleteIndicatorBot(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Trading Bot': { + functionLibraryNodeDeleter.deleteTradingBot(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Process Definition': { + functionLibraryNodeDeleter.deleteProcessDefinition(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Process Output': { + functionLibraryNodeDeleter.deleteProcessOutput(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Process Dependencies': { + functionLibraryNodeDeleter.deleteProcessDependencies(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Status Report': { + functionLibraryNodeDeleter.deleteStatusReport(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Execution Started Event': { + functionLibraryNodeDeleter.deleteExecutionStartedEvent(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Execution Finished Event': { + functionLibraryNodeDeleter.deleteExecutionFinishedEvent(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Calculations Procedure': { + functionLibraryNodeDeleter.deleteCalculationsProcedure(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Data Building Procedure': { + functionLibraryNodeDeleter.deleteDataBuildingProcedure(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Procedure Initialization': { + functionLibraryNodeDeleter.deleteProcedureInitialization(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Procedure Loop': { + functionLibraryNodeDeleter.deleteProcedureLoop(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Output Dataset': { + functionLibraryNodeDeleter.deleteOutputDataset(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Status Dependency': { + functionLibraryNodeDeleter.deleteStatusDependency(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Data Dependency': { + functionLibraryNodeDeleter.deleteDataDependency(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Product Definition': { + functionLibraryNodeDeleter.deleteProductDefinition(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Record Definition': { + functionLibraryNodeDeleter.deleteRecordDefinition(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Record Property': { + functionLibraryNodeDeleter.deleteRecordProperty(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Dataset Definition': { + functionLibraryNodeDeleter.deleteDatasetDefinition(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Plotter': { + functionLibraryNodeDeleter.deletePlotter(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Plotter Module': { + functionLibraryNodeDeleter.deletePlotterModule(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Plotter Panel': { + functionLibraryNodeDeleter.deletePlotterPanel(payload.node, thisObject.workspaceNode.rootNodes) + break + } case 'Delete Network': { functionLibraryNodeDeleter.deleteNetwork(payload.node, thisObject.workspaceNode.rootNodes) break @@ -544,20 +811,20 @@ function newWorkspace () { functionLibraryNodeDeleter.deleteTask(payload.node, thisObject.workspaceNode.rootNodes) break } - case 'Delete Sensor': { - functionLibraryNodeDeleter.deleteSensor(payload.node, thisObject.workspaceNode.rootNodes) + case 'Delete Sensor Bot Instance': { + functionLibraryNodeDeleter.deleteSensorBotInstance(payload.node, thisObject.workspaceNode.rootNodes) break } - case 'Delete Indicator': { - functionLibraryNodeDeleter.deleteIndicator(payload.node, thisObject.workspaceNode.rootNodes) + case 'Delete Indicator Bot Instance': { + functionLibraryNodeDeleter.deleteIndicatorBotInstance(payload.node, thisObject.workspaceNode.rootNodes) break } - case 'Delete Trading Engine': { - functionLibraryNodeDeleter.deleteTradingEngine(payload.node, thisObject.workspaceNode.rootNodes) + case 'Delete Trading Bot Instance': { + functionLibraryNodeDeleter.deleteTradingBotInstance(payload.node, thisObject.workspaceNode.rootNodes) break } - case 'Delete Process': { - functionLibraryNodeDeleter.deleteProcess(payload.node, thisObject.workspaceNode.rootNodes) + case 'Delete Process Instance': { + functionLibraryNodeDeleter.deleteProcessInstance(payload.node, thisObject.workspaceNode.rootNodes) break } case 'Delete Backtesting Session': { diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index 4b4676921..c8ef434f8 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -72,7 +72,7 @@ function newCircularMenu () { menuItem.currentRadius = menuItemInitialValue.currentRadius menuItem.angle = menuItemInitialValue.angle menuItem.currentStatus = menuItemInitialValue.currentStatus - menuItem.relatedStrategyPart = menuItemInitialValue.relatedStrategyPart + menuItem.relatedUiObject = menuItemInitialValue.relatedUiObject menuItem.dontShowAtFullscreen = menuItemInitialValue.dontShowAtFullscreen menuItem.askConfirmation = menuItemInitialValue.askConfirmation menuItem.confirmationLabel = menuItemInitialValue.confirmationLabel diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 38bd97bd6..2ce83ed0a 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -33,7 +33,7 @@ function newCircularMenuItem () { angle: undefined, container: undefined, payload: undefined, - relatedStrategyPart: undefined, + relatedUiObject: undefined, dontShowAtFullscreen: undefined, internalClick: internalClick, physics: physics, @@ -105,7 +105,7 @@ function newCircularMenuItem () { selfMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) if (thisObject.type === 'Icon & Text') { - thisObject.container.frame.width = 150 + thisObject.container.frame.width = 185 } else { thisObject.container.frame.width = 50 } @@ -167,15 +167,15 @@ function newCircularMenuItem () { temporaryStatus === STATUS_SECONDARY_WORK_FAILED ) && thisObject.secondaryAction !== undefined ) { - thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon) - thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon) + thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.secondaryIcon) + thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.secondaryIcon) } else { - if (thisObject.relatedStrategyPart !== undefined) { - thisObject.iconOn = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart) - thisObject.iconOff = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart) + if (thisObject.relatedUiObject !== undefined) { + thisObject.iconOn = canvas.designerSpace.iconByUiObjectType.get(thisObject.relatedUiObject) + thisObject.iconOff = canvas.designerSpace.iconByUiObjectType.get(thisObject.relatedUiObject) } else { - thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.iconPathOn) - thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.iconPathOff) + thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.iconPathOn) + thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.iconPathOff) } } @@ -328,7 +328,8 @@ function newCircularMenuItem () { container: thisObject.container, borderColor: UI_COLOR.DARK, backgroundColor: backgroundColorToUse, - castShadow: false + castShadow: false, + xOffset: 40 } if (isMouseOver === true) { @@ -374,7 +375,7 @@ function newCircularMenuItem () { if (thisObject.currentRadius >= thisObject.targetRadius) { labelPoint = { - x: menuPosition.x + thisObject.currentRadius + 10, + x: menuPosition.x + thisObject.currentRadius + 20, y: menuPosition.y + fontSize * FONT_ASPECT_RATIO } @@ -386,3 +387,4 @@ function newCircularMenuItem () { } } } + diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 613441a30..1fb58ce00 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -28,7 +28,8 @@ function newCircularProgressBar () { return thisObject function finalize () { - systemEventHandler.stopListening('Jason-Heartbeat-Period', eventSubscriptionHeartbeat) + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + systemEventHandler.stopListening(key, eventSubscriptionHeartbeat) thisObject.container = undefined thisObject.payload = undefined diff --git a/FloatingSpace/CodeEditor.js b/FloatingSpace/CodeEditor.js index c552a55e7..1ed862964 100644 --- a/FloatingSpace/CodeEditor.js +++ b/FloatingSpace/CodeEditor.js @@ -128,8 +128,8 @@ function newCodeEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 + thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * 2 + thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 let textAreaPosition = { x: 0 - thisObject.container.frame.width / 2, @@ -161,7 +161,7 @@ function newCodeEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius + let radius = thisObject.container.frame.radius * 2 if (radius > 0.5) { browserCanvasContext.beginPath() diff --git a/FloatingSpace/FloatingLayer.js b/FloatingSpace/FloatingLayer.js index 22c78cd52..c0c6a7f92 100644 --- a/FloatingSpace/FloatingLayer.js +++ b/FloatingSpace/FloatingLayer.js @@ -10,7 +10,7 @@ 2. Notes: Notes are a rectangular area where some text is posted. It has a subject and a body. - 3. Strategy Parts: These are small balls that represent parts of an strategy. + 3. UI Objects: These are small balls that represent parts of an strategy. */ function newFloatingLayer () { @@ -203,7 +203,7 @@ function newFloatingLayer () { for (let i = 0; i < invisibleFloatingObjects.length; i++) { let floatingObject = invisibleFloatingObjects[i] - if (floatingObject.isFrozen === false) { + if (floatingObject.isFrozen === false && floatingObject.isParentCollapsed === false) { visibleFloatingObjects.push(floatingObject) invisibleFloatingObjects.splice(i, 1) // Delete item from array. return // Only one at the time. @@ -215,7 +215,7 @@ function newFloatingLayer () { for (let i = 0; i < visibleFloatingObjects.length; i++) { let floatingObject = visibleFloatingObjects[i] - if (floatingObject.isFrozen === true) { + if (floatingObject.isFrozen === true || floatingObject.isParentCollapsed === true) { invisibleFloatingObjects.push(floatingObject) visibleFloatingObjects.splice(i, 1) // Delete item from array. return // Only one at the time. @@ -293,7 +293,7 @@ function newFloatingLayer () { break } - case 'Strategy Part': { + case 'UI Object': { payload.targetPosition = floatingObject.payload.targetPosition payload.visible = floatingObject.payload.visible break @@ -563,7 +563,7 @@ function newFloatingLayer () { payload.targetPosition = floatingObject2.payload.notes[floatingObject2.payloadNoteIndex].position break } - case 'Strategy Part': { + case 'UI Object': { payload.targetPosition = floatingObject2.payload.targetPosition break } diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index ac7d40296..65a6672d5 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -186,7 +186,7 @@ function newFloatingObject () { function frozenPhysics () { if (thisObject.frozenManually === false) { let parent = thisObject.payload.chainParent - if (parent !== undefined) { + if (parent !== undefined && parent.payload !== undefined) { thisObject.isFrozen = parent.payload.floatingObject.isFrozen } } @@ -208,7 +208,7 @@ function newFloatingObject () { let parent = thisObject.payload.chainParent if (parent !== undefined) { let distanceToChainParent = Math.sqrt(Math.pow(parent.payload.position.x - thisObject.container.frame.position.x, 2) + Math.pow(parent.payload.position.y - thisObject.container.frame.position.y, 2)) // ... we calculate the distance ... - let parentChildren = canvas.strategySpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node) + let parentChildren = canvas.designerSpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node) let axisCount = parentChildren.childrenCount let axisIndex = parentChildren.childIndex let baseAngle = 0 diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/UiObject.js similarity index 60% rename from FloatingSpace/StrategyPart.js rename to FloatingSpace/UiObject.js index 295a5e5eb..1f77f9847 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/UiObject.js @@ -1,6 +1,6 @@ -function newStrategyPart () { - const MODULE_NAME = 'Strategy Part' +function newUiObject () { + const MODULE_NAME = 'UI Object' const ERROR_LOG = true const logger = newWebDebugLog() @@ -15,15 +15,17 @@ function newStrategyPart () { container: undefined, payload: undefined, codeEditor: undefined, - partTitle: undefined, + uiObjectTitle: undefined, circularProgressBar: undefined, isExecuting: undefined, isRunning: undefined, shortcutKey: undefined, run: run, stop: stop, - getReadyToAttach: getReadyToAttach, - showAvailabilityToAttach: showAvailabilityToAttach, + getReadyToChainAttach: getReadyToChainAttach, + showAvailabilityToChainAttach: showAvailabilityToChainAttach, + getReadyToReferenceAttach: getReadyToReferenceAttach, + showAvailabilityToReferenceAttach: showAvailabilityToReferenceAttach, highlight: highlight, setErrorMessage: setErrorMessage, setValue: setValue, @@ -63,19 +65,27 @@ function newStrategyPart () { let hasValue let valueCounter = 0 - let previousDistance + let previousDistanceToChainParent + let readyToChainAttachDisplayCounter = 5 + let readyToChainAttachDisplayIncrement = 0.1 + let readyToChainAttachCounter = 0 + let isReadyToChainAttach + let availableToChainAttachCounter = 0 + let isAvailableToChainAttach + let isChainAttaching = false + let chainAttachToNode - let readyToAttachDisplayCounter = 5 - let readyToAttachDisplayIncrement = 0.1 + let previousDistanceToReferenceParent + let readyToReferenceAttachDisplayCounter = 5 + let readyToReferenceAttachDisplayIncrement = 0.1 + let readyToReferenceAttachCounter = 0 + let isReadyToReferenceAttach + let availableToReferenceAttachCounter = 0 + let isAvailableToReferenceAttach + let isReferenceAttaching = false + let referenceAttachToNode - let readyToAttachCounter = 0 - let isReadyToAttach - let availableToAttachCounter = 0 - let isAvailableToAttach - - let isAttaching = false let isDragging = false - let attachToNode let errorMessage = '' let currentValue = 0 @@ -95,8 +105,8 @@ function newStrategyPart () { thisObject.payload = undefined thisObject.menu.finalize() thisObject.menu = undefined - thisObject.partTitle.finalize() - thisObject.partTitle = undefined + thisObject.uiObjectTitle.finalize() + thisObject.uiObjectTitle = undefined thisObject.fitFunction = undefined thisObject.isVisibleFunction = undefined @@ -106,7 +116,8 @@ function newStrategyPart () { } icon = undefined - attachToNode = undefined + chainAttachToNode = undefined + referenceAttachToNode = undefined } function initialize (payload, menuItemsInitialValues) { @@ -118,14 +129,14 @@ function newStrategyPart () { thisObject.menu.initialize(menuItemsInitialValues, thisObject.payload) thisObject.menu.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true) -/* Initialize Part Title */ +/* Initialize UI Object Title */ - thisObject.partTitle = newStrategyPartTitle() - thisObject.partTitle.isVisibleFunction = thisObject.isVisibleFunction - thisObject.partTitle.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true) - thisObject.partTitle.initialize(thisObject.payload) + thisObject.uiObjectTitle = newUiObjectTitle() + thisObject.uiObjectTitle.isVisibleFunction = thisObject.isVisibleFunction + thisObject.uiObjectTitle.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true) + thisObject.uiObjectTitle.initialize(thisObject.payload) -/* Load Part Image */ +/* Load UI Object Image */ iconPhysics() @@ -145,7 +156,7 @@ function newStrategyPart () { if (container !== undefined) { return container } } - container = thisObject.partTitle.getContainer(point) + container = thisObject.uiObjectTitle.getContainer(point) if (container !== undefined) { return container } container = thisObject.menu.getContainer(point) @@ -161,7 +172,7 @@ function newStrategyPart () { function physics () { thisObject.menu.physics() - thisObject.partTitle.physics() + thisObject.uiObjectTitle.physics() if (thisObject.codeEditor !== undefined) { thisObject.codeEditor.physics() @@ -183,12 +194,14 @@ function newStrategyPart () { highlightPhisycs() errorMessagePhisycs() valuePhisycs() - detachingPhysics() - attachingPhysics() + chainDetachingPhysics() + chainAttachingPhysics() + referenceDetachingPhysics() + referenceAttachingPhysics() } - function attachingPhysics () { - attacchingCounters() + function chainAttachingPhysics () { + chainAttacchingCounters() if (thisObject.isOnFocus !== true) { return } if (isDragging !== true) { return } @@ -199,6 +212,98 @@ function newStrategyPart () { let compatibleType let compatibleSubType switch (thisObject.payload.node.type) { + case 'Sensor Bot': + compatibleType = '->' + 'Team' + '->' + compatibleSubType = undefined + break + case 'Indicator Bot': + compatibleType = '->' + 'Team' + '->' + compatibleSubType = undefined + break + case 'Trading Bot': + compatibleType = '->' + 'Team' + '->' + compatibleSubType = undefined + break + case 'Process Definition': + compatibleType = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' + compatibleSubType = undefined + break + case 'Process Output': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + case 'Process Dependencies': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + case 'Status Report': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + case 'Execution Started Event': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + case 'Execution Finished Event': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + case 'Calculations Procedure': + compatibleType = '->' + 'Product Definition' + '->' + compatibleSubType = undefined + break + case 'Data Building Procedure': + compatibleType = '->' + 'Product Definition' + '->' + compatibleSubType = undefined + break + case 'Procedure Initialization': + compatibleType = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' + compatibleSubType = undefined + break + case 'Procedure Loop': + compatibleType = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' + compatibleSubType = undefined + break + case 'Output Dataset': + compatibleType = '->' + 'Process Output' + '->' + compatibleSubType = undefined + break + case 'Status Dependency': + compatibleType = '->' + 'Process Dependencies' + '->' + compatibleSubType = undefined + break + case 'Data Dependency': + compatibleType = '->' + 'Process Dependencies' + '->' + compatibleSubType = undefined + break + case 'Product Definition': + compatibleType = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' + compatibleSubType = undefined + break + case 'Record Definition': + compatibleType = '->' + 'Product Definition' + '->' + compatibleSubType = undefined + break + case 'Record Property': + compatibleType = '->' + 'Record Definition' + '->' + compatibleSubType = undefined + break + case 'Dataset Definition': + compatibleType = '->' + 'Product Definition' + '->' + compatibleSubType = undefined + break + case 'Plotter': + compatibleType = '->' + 'Team' + '->' + compatibleSubType = undefined + break + case 'Plotter Module': + compatibleType = '->' + 'Plotter' + '->' + compatibleSubType = undefined + break + case 'Plotter Panel': + compatibleType = '->' + 'Plotter Module' + '->' + compatibleSubType = undefined + break case 'Trading System': compatibleType = '->' + 'Definition' + '->' compatibleSubType = undefined @@ -207,10 +312,6 @@ function newStrategyPart () { compatibleType = '->' + 'Definition' + '->' compatibleSubType = undefined break - case 'Network': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined - break case 'Network Node': compatibleType = '->' + 'Network' + '->' compatibleSubType = undefined @@ -229,23 +330,23 @@ function newStrategyPart () { break case 'Parameters': compatibleType = '->' + 'Trading System' + '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubType = '->' + 'Trading Engine Process' + '->' + compatibleSubType = '->' + 'Trading Process Instance' + '->' break case 'Backtesting Session': - compatibleType = '->' + 'Process' + '->' - compatibleSubType = '->' + 'Trading Engine Process' + '->' + compatibleType = '->' + 'Process Instance' + '->' + compatibleSubType = '->' + 'Trading Process Instance' + '->' break case 'Live Trading Session': - compatibleType = '->' + 'Process' + '->' - compatibleSubType = '->' + 'Trading Engine Process' + '->' + compatibleType = '->' + 'Process Instance' + '->' + compatibleSubType = '->' + 'Trading Process Instance' + '->' break case 'Paper Trading Session': - compatibleType = '->' + 'Process' + '->' - compatibleSubType = '->' + 'Trading Engine Process' + '->' + compatibleType = '->' + 'Process Instance' + '->' + compatibleSubType = '->' + 'Trading Process Instance' + '->' break case 'Fordward Testing Session': - compatibleType = '->' + 'Process' + '->' - compatibleSubType = '->' + 'Trading Engine Process' + '->' + compatibleType = '->' + 'Process Instance' + '->' + compatibleSubType = '->' + 'Trading Process Instance' + '->' break case 'Base Asset': compatibleType = '->' + 'Parameters' + '->' @@ -295,30 +396,30 @@ function newStrategyPart () { compatibleType = '->' + 'Task Manager' + '->' compatibleSubType = undefined break - case 'Sensor': + case 'Sensor Bot Instance': compatibleType = '->' + 'Task' + '->' compatibleSubType = undefined break - case 'Indicator': + case 'Indicator Bot Instance': compatibleType = '->' + 'Task' + '->' compatibleSubType = undefined break - case 'Trading Engine': + case 'Trading Bot Instance': compatibleType = '->' + 'Task' + '->' compatibleSubType = undefined break - case 'Process': + case 'Process Instance': switch (thisObject.payload.node.subType) { - case 'Sensor Process': { - compatibleType = '->' + 'Sensor' + '->' + case 'Sensor Process Instance': { + compatibleType = '->' + 'Sensor Bot Instance' + '->' break } - case 'Indicator Process': { - compatibleType = '->' + 'Indicator' + '->' + case 'Indicator Process Instance': { + compatibleType = '->' + 'Indicator Bot Instance' + '->' break } - case 'Trading Engine Process': { - compatibleType = '->' + 'Trading Engine' + '->' + case 'Trading Process Instance': { + compatibleType = '->' + 'Trading Bot Instance' + '->' break } } @@ -389,7 +490,7 @@ function newStrategyPart () { compatibleSubType = undefined break case 'Formula': - compatibleType = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + '->' + 'Announcement' + '->' + compatibleType = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + '->' + 'Announcement' + '->' + 'Record Property' + '->' compatibleSubType = undefined break case 'Next Phase Event': @@ -405,15 +506,15 @@ function newStrategyPart () { compatibleSubType = undefined break case 'Code': - compatibleType = '->' + 'Condition' + '->' + compatibleType = '->' + 'Condition' + '->' + 'Procedure Initialization' + '->' + 'Procedure Loop' + '->' + 'Plotter Module' + '->' + 'Plotter Panel' + '->' compatibleSubType = undefined break default: return } let foundCompatible = false - attachToNode = undefined - isAttaching = false + chainAttachToNode = undefined + isChainAttaching = false for (let i = 0; i < nearbyFloatingObjects.length; i++) { let nearby = nearbyFloatingObjects[i] @@ -422,11 +523,19 @@ function newStrategyPart () { let nearbyNode = floatingObject.payload.node if (compatibleType.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Discard objects with busy coonection ports */ + if (thisObject.payload.node.type === 'Status Report' && nearbyNode.statusReport !== undefined) { continue } + if (thisObject.payload.node.type === 'Execution Started Event' && nearbyNode.executionStartedEvent !== undefined) { continue } + if (thisObject.payload.node.type === 'Execution Finished Event' && nearbyNode.executionFinishedEvent !== undefined) { continue } + if (thisObject.payload.node.type === 'Calculations Procedure' && nearbyNode.calculations !== undefined) { continue } + if (thisObject.payload.node.type === 'Data Building Procedure' && nearbyNode.dataBuilding !== undefined) { continue } + if (thisObject.payload.node.type === 'Procedure Initialization' && nearbyNode.initialization !== undefined) { continue } + if (thisObject.payload.node.type === 'Procedure Loop' && nearbyNode.loop !== undefined) { continue } + if (thisObject.payload.node.type === 'Record Definition' && nearbyNode.record !== undefined) { continue } if (thisObject.payload.node.type === 'Task' && nearbyNode.task !== undefined) { continue } - if (thisObject.payload.node.type === 'Sensor' && nearbyNode.bot !== undefined) { continue } - if (thisObject.payload.node.type === 'Indicator' && nearbyNode.bot !== undefined) { continue } - if (thisObject.payload.node.type === 'Trading Engine' && nearbyNode.bot !== undefined) { continue } - if (thisObject.payload.node.type === 'Process' && nearbyNode.process !== undefined) { continue } + if (thisObject.payload.node.type === 'Sensor Bot Instance' && nearbyNode.bot !== undefined) { continue } + if (thisObject.payload.node.type === 'Indicator Bot Instance' && nearbyNode.bot !== undefined) { continue } + if (thisObject.payload.node.type === 'Trading Bot Instance' && nearbyNode.bot !== undefined) { continue } + if (thisObject.payload.node.type === 'Process Instance' && nearbyNode.process !== undefined) { continue } if (thisObject.payload.node.type === 'Trading System' && nearbyNode.tradingSystem !== undefined) { continue } if (thisObject.payload.node.type === 'Personal Data' && nearbyNode.personalData !== undefined) { continue } if (thisObject.payload.node.type === 'Parameters' && nearbyNode.parameters !== undefined) { continue } @@ -481,65 +590,65 @@ function newStrategyPart () { } if (foundCompatible === false) { if (distance < thisObject.container.frame.radius * 1.5 + floatingObject.container.frame.radius * 1.5) { - nearbyNode.payload.uiObject.getReadyToAttach() - isAttaching = true - attachToNode = nearbyNode + nearbyNode.payload.uiObject.getReadyToChainAttach() + isChainAttaching = true + chainAttachToNode = nearbyNode foundCompatible = true } } - nearbyNode.payload.uiObject.showAvailabilityToAttach() + nearbyNode.payload.uiObject.showAvailabilityToChainAttach() } } } - function attacchingCounters () { - if (readyToAttachDisplayCounter > 15) { - readyToAttachDisplayIncrement = -0.25 + function chainAttacchingCounters () { + if (readyToChainAttachDisplayCounter > 15) { + readyToChainAttachDisplayIncrement = -0.25 } - if (readyToAttachDisplayCounter < 5) { - readyToAttachDisplayIncrement = 0.25 + if (readyToChainAttachDisplayCounter < 5) { + readyToChainAttachDisplayIncrement = 0.25 } - readyToAttachDisplayCounter = readyToAttachDisplayCounter + readyToAttachDisplayIncrement + readyToChainAttachDisplayCounter = readyToChainAttachDisplayCounter + readyToChainAttachDisplayIncrement - readyToAttachCounter-- - if (readyToAttachCounter <= 0) { - readyToAttachCounter = 0 - isReadyToAttach = false + readyToChainAttachCounter-- + if (readyToChainAttachCounter <= 0) { + readyToChainAttachCounter = 0 + isReadyToChainAttach = false } else { - isReadyToAttach = true + isReadyToChainAttach = true } - availableToAttachCounter-- - if (availableToAttachCounter <= 0) { - availableToAttachCounter = 0 - isAvailableToAttach = false + availableToChainAttachCounter-- + if (availableToChainAttachCounter <= 0) { + availableToChainAttachCounter = 0 + isAvailableToChainAttach = false } else { - isAvailableToAttach = true + isAvailableToChainAttach = true } } - function getReadyToAttach () { - readyToAttachCounter = 10 + function getReadyToChainAttach () { + readyToChainAttachCounter = 10 } - function showAvailabilityToAttach () { - availableToAttachCounter = 10 + function showAvailabilityToChainAttach () { + availableToChainAttachCounter = 10 } - function detachingPhysics () { + function chainDetachingPhysics () { if (isDragging !== true) { return } if (thisObject.payload.floatingObject.isFrozen === true) { return } if (rightDragging === false) { return } let distanceToChainParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.targetPosition.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.targetPosition.y, 2)) - let ratio = distanceToChainParent / previousDistance - if (previousDistance === 0) { - previousDistance = distanceToChainParent + let ratio = distanceToChainParent / previousDistanceToChainParent + if (previousDistanceToChainParent === 0) { + previousDistanceToChainParent = distanceToChainParent return } - previousDistance = distanceToChainParent + previousDistanceToChainParent = distanceToChainParent if (thisObject.isOnFocus !== true) { return } if (thisObject.payload.chainParent === undefined) { return } @@ -547,9 +656,152 @@ function newStrategyPart () { let THRESHOLD = 1.15 - if (previousDistance !== undefined) { + if (previousDistanceToChainParent !== undefined) { if (ratio > THRESHOLD) { - canvas.strategySpace.workspace.detachNode(thisObject.payload.node) + canvas.designerSpace.workspace.chainDetachNode(thisObject.payload.node) + } + } + } + + function referenceAttachingPhysics () { + referenceAttacchingCounters() + + if (thisObject.isOnFocus !== true) { return } + if (isDragging !== true) { return } + if (rightDragging !== true) { return } + if (thisObject.payload.referenceParent !== undefined) { return } + + let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects + let compatibleType + let compatibleSubType + switch (thisObject.payload.node.type) { + case 'Backtesting Session': + compatibleType = '->' + 'Definition' + '->' + compatibleSubType = undefined + break + case 'Live Trading Session': + compatibleType = '->' + 'Definition' + '->' + compatibleSubType = undefined + break + case 'Paper Trading Session': + compatibleType = '->' + 'Definition' + '->' + compatibleSubType = undefined + break + case 'Fordward Testing Session': + compatibleType = '->' + 'Definition' + '->' + compatibleSubType = undefined + break + case 'Output Dataset': + compatibleType = '->' + 'Dataset Definition' + '->' + compatibleSubType = undefined + break + case 'Data Dependency': + compatibleType = '->' + 'Dataset Definition' + '->' + compatibleSubType = undefined + break + case 'Status Dependency': + compatibleType = '->' + 'Status Report' + '->' + compatibleSubType = undefined + break + case 'Execution Started Event': + compatibleType = '->' + 'Execution Finished Event' + '->' + compatibleSubType = undefined + break + case 'Process Instance': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + default: + return + } + let foundCompatible = false + referenceAttachToNode = undefined + isReferenceAttaching = false + + for (let i = 0; i < nearbyFloatingObjects.length; i++) { + let nearby = nearbyFloatingObjects[i] + let distance = nearby[0] + let floatingObject = nearby[1] + let nearbyNode = floatingObject.payload.node + if (compatibleType.indexOf('->' + nearbyNode.type + '->') >= 0) { + /* Here we check if the subtypes are compatible. */ + if (nearbyNode.subType !== undefined && compatibleSubType !== undefined) { + if (compatibleSubType.indexOf('->' + nearbyNode.subType + '->') < 0) { + continue + } + } + + if (foundCompatible === false) { + if (distance < thisObject.container.frame.radius * 1.5 + floatingObject.container.frame.radius * 1.5) { + nearbyNode.payload.uiObject.getReadyToReferenceAttach() + isReferenceAttaching = true + referenceAttachToNode = nearbyNode + foundCompatible = true + } + } + nearbyNode.payload.uiObject.showAvailabilityToReferenceAttach() + } + } + } + + function referenceAttacchingCounters () { + if (readyToReferenceAttachDisplayCounter > 15) { + readyToReferenceAttachDisplayIncrement = -0.25 + } + + if (readyToReferenceAttachDisplayCounter < 5) { + readyToReferenceAttachDisplayIncrement = 0.25 + } + + readyToReferenceAttachDisplayCounter = readyToReferenceAttachDisplayCounter + readyToReferenceAttachDisplayIncrement + + readyToReferenceAttachCounter-- + if (readyToReferenceAttachCounter <= 0) { + readyToReferenceAttachCounter = 0 + isReadyToReferenceAttach = false + } else { + isReadyToReferenceAttach = true + } + + availableToReferenceAttachCounter-- + if (availableToReferenceAttachCounter <= 0) { + availableToReferenceAttachCounter = 0 + isAvailableToReferenceAttach = false + } else { + isAvailableToReferenceAttach = true + } + } + + function getReadyToReferenceAttach () { + readyToReferenceAttachCounter = 10 + } + + function showAvailabilityToReferenceAttach () { + availableToReferenceAttachCounter = 10 + } + + function referenceDetachingPhysics () { + if (isDragging !== true) { return } + if (thisObject.payload.floatingObject.isFrozen === true) { return } + if (rightDragging === false) { return } + if (thisObject.payload.referenceParent === undefined) { return } + + let distanceToReferenceParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.referenceParent.payload.position.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.referenceParent.payload.position.y, 2)) + let ratio = distanceToReferenceParent / previousDistanceToReferenceParent + if (previousDistanceToReferenceParent === 0) { + previousDistanceToReferenceParent = distanceToReferenceParent + return + } + previousDistanceToReferenceParent = distanceToReferenceParent + + if (thisObject.isOnFocus !== true) { return } + if (thisObject.payload.referenceParent === undefined) { return } + + let THRESHOLD = 1.15 + + if (previousDistanceToReferenceParent !== undefined) { + if (ratio > THRESHOLD) { + canvas.designerSpace.workspace.referenceDetachNode(thisObject.payload.node) } } } @@ -658,8 +910,8 @@ function newStrategyPart () { } function iconPhysics () { - icon = canvas.strategySpace.iconByPartType.get(thisObject.payload.node.type) - executingIcon = canvas.strategySpace.iconCollection.get('attractive') + icon = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + executingIcon = canvas.designerSpace.iconCollection.get('attractive') } function onFocus () { @@ -674,11 +926,11 @@ function newStrategyPart () { } function onDisplace (event) { - thisObject.partTitle.exitEditMode() + thisObject.uiObjectTitle.exitEditMode() } function onDragStarted (event) { - thisObject.partTitle.exitEditMode() + thisObject.uiObjectTitle.exitEditMode() if (thisObject.codeEditor !== undefined) { thisObject.codeEditor.deactivate() } @@ -688,20 +940,29 @@ function newStrategyPart () { } else { rightDragging = false } + + previousDistanceToReferenceParent = undefined + previousDistanceToChainParent = undefined } function onDragFinished (event) { - if (isAttaching === true) { - canvas.strategySpace.workspace.attachNode(thisObject.payload.node, attachToNode) - attachToNode = undefined - isAttaching = false + if (isChainAttaching === true) { + canvas.designerSpace.workspace.chainAttachNode(thisObject.payload.node, chainAttachToNode) + chainAttachToNode = undefined + isChainAttaching = false + } + if (isReferenceAttaching === true) { + canvas.designerSpace.workspace.referenceAttachNode(thisObject.payload.node, referenceAttachToNode) + referenceAttachToNode = undefined + isReferenceAttaching = false } isDragging = false } function drawBackground () { if (thisObject.isOnFocus === false) { - drawConnectingLine() + drawReferenceLine() + drawChainLine() if (isDragging === false && thisObject.isOnFocus === true) { thisObject.menu.drawBackground() @@ -717,7 +978,7 @@ function newStrategyPart () { if (thisObject.isOnFocus === false) { drawValue() drawText() - thisObject.partTitle.draw() + thisObject.uiObjectTitle.draw() } } @@ -736,7 +997,8 @@ function newStrategyPart () { function drawOnFocus () { if (thisObject.isOnFocus === true) { - drawConnectingLine() + drawReferenceLine() + drawChainLine() if (thisObject.codeEditor !== undefined) { thisObject.codeEditor.drawBackground() @@ -762,11 +1024,11 @@ function newStrategyPart () { drawErrorMessage() drawValue() drawText() - thisObject.partTitle.draw() + thisObject.uiObjectTitle.draw() } } - function drawConnectingLine () { + function drawChainLine () { if (thisObject.payload.chainParent === undefined) { return } let targetPoint = { @@ -797,7 +1059,16 @@ function newStrategyPart () { browserCanvasContext.moveTo(position.x, position.y) browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' - browserCanvasContext.setLineDash([3, 4]) + browserCanvasContext.setLineDash([3, 47]) + browserCanvasContext.lineWidth = 4 + browserCanvasContext.stroke() + browserCanvasContext.setLineDash([0, 0]) + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(position.x, position.y) + browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) + browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' + browserCanvasContext.setLineDash([1, 9]) browserCanvasContext.lineWidth = 2 browserCanvasContext.stroke() browserCanvasContext.setLineDash([0, 0]) @@ -816,6 +1087,60 @@ function newStrategyPart () { } } + function drawReferenceLine () { + if (thisObject.payload.referenceParent === undefined) { return } + if (thisObject.payload.referenceParent.payload.floatingObject.isParentCollapsed === true) { return } + + let targetPoint = { + x: thisObject.payload.referenceParent.payload.position.x, + y: thisObject.payload.referenceParent.payload.position.y + } + + let position = { + x: 0, + y: 0 + } + + targetPoint = canvas.floatingSpace.container.frame.frameThisPoint(targetPoint) + position = thisObject.container.frame.frameThisPoint(position) + + let LINE_STYLE = UI_COLOR.GREY + + if (thisObject.container.frame.radius > 1) { + /* Target Line */ + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(position.x, position.y) + browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) + browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' + browserCanvasContext.setLineDash([1, 9]) + browserCanvasContext.lineWidth = 1 + browserCanvasContext.stroke() + browserCanvasContext.setLineDash([0, 0]) + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(position.x, position.y) + browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) + browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' + browserCanvasContext.setLineDash([1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 0, 100]) + browserCanvasContext.lineWidth = 4 + browserCanvasContext.stroke() + browserCanvasContext.setLineDash([0, 0]) + } + + if (thisObject.container.frame.radius > 0.5) { + /* Target Spot */ + + let radius = 1 + + browserCanvasContext.beginPath() + browserCanvasContext.arc(targetPoint.x, targetPoint.y, radius, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + browserCanvasContext.fill() + } + } + function drawText () { /* Text Follows */ let position = { @@ -1034,18 +1359,24 @@ function newStrategyPart () { browserCanvasContext.fill() - if (thisObject.payload.node.type === 'Definition') { + if (thisObject.payload.node.type === 'Definition' || thisObject.payload.node.type === 'Network' || thisObject.payload.node.type === 'Team') { VISIBLE_RADIUS = thisObject.container.frame.radius * 2 let OPACITY = 1 browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' - browserCanvasContext.lineWidth = 10 - browserCanvasContext.setLineDash([4, 20]) + browserCanvasContext.setLineDash([4, 16]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([20, 20]) browserCanvasContext.stroke() } @@ -1090,33 +1421,103 @@ function newStrategyPart () { browserCanvasContext.stroke() } - if (isReadyToAttach === true) { - VISIBLE_RADIUS = thisObject.container.frame.radius * 2 + readyToAttachDisplayCounter * 2 - let OPACITY = readyToAttachCounter / 10 + if (isReadyToChainAttach === true) { + VISIBLE_RADIUS = thisObject.container.frame.radius * 2.5 + readyToChainAttachDisplayCounter - readyToChainAttachDisplayCounter / 2 + let OPACITY = readyToChainAttachCounter / 10 browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', ' + OPACITY + ')' - browserCanvasContext.lineWidth = 10 - browserCanvasContext.setLineDash([readyToAttachDisplayCounter, readyToAttachDisplayCounter * 2]) + browserCanvasContext.setLineDash([10, 90]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 5 + browserCanvasContext.setLineDash([5, 45]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([2, 8]) browserCanvasContext.stroke() } - if (isAvailableToAttach === true && isReadyToAttach === false) { - VISIBLE_RADIUS = thisObject.container.frame.radius * 1.5 - let OPACITY = availableToAttachCounter / 10 + if (isAvailableToChainAttach === true && isReadyToChainAttach === false) { + VISIBLE_RADIUS = thisObject.container.frame.radius * 2.5 + let OPACITY = availableToChainAttachCounter / 10 browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TURQUOISE + ', ' + OPACITY + ')' - browserCanvasContext.lineWidth = 10 - browserCanvasContext.setLineDash([8, 20]) + browserCanvasContext.setLineDash([8, 32]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TURQUOISE + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 2 + browserCanvasContext.setLineDash([3, 5]) + browserCanvasContext.stroke() + } + + if (isReadyToReferenceAttach === true) { + VISIBLE_RADIUS = thisObject.container.frame.radius * 2.5 + readyToReferenceAttachDisplayCounter - readyToReferenceAttachDisplayCounter / 2 + let OPACITY = readyToReferenceAttachCounter / 10 + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 10 + browserCanvasContext.setLineDash([10, 90]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 5 + browserCanvasContext.setLineDash([5, 45]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([2, 8]) + browserCanvasContext.stroke() + } + + if (isAvailableToReferenceAttach === true && isReadyToReferenceAttach === false) { + VISIBLE_RADIUS = thisObject.container.frame.radius * 2.5 + let OPACITY = availableToReferenceAttachCounter / 10 + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 10 + browserCanvasContext.setLineDash([8, 32]) + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 2 + browserCanvasContext.setLineDash([3, 5]) browserCanvasContext.stroke() } } diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/UiObjectConstructor.js similarity index 62% rename from FloatingSpace/StrategyPartConstructor.js rename to FloatingSpace/UiObjectConstructor.js index a47d7728f..538d29438 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -1,13 +1,13 @@ -function newStrategyPartConstructor () { - const MODULE_NAME = 'Strategy Part Constructor' +function newUiObjectConstructor () { + const MODULE_NAME = 'UI Object Constructor' const ERROR_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME let thisObject = { - createStrategyPart: createStrategyPart, - destroyStrategyPart: destroyStrategyPart, + createUiObject: createUiObject, + destroyUiObject: destroyUiObject, initialize: initialize, finalize: finalize } @@ -27,11 +27,11 @@ function newStrategyPartConstructor () { floatingLayer = pFloatingLayer } - function createStrategyPart (payload) { + function createUiObject (payload) { let floatingObject = newFloatingObject() floatingObject.fitFunction = canvas.floatingSpace.fitIntoVisibleArea floatingObject.container.connectToParent(canvas.floatingSpace.container, false, false, false, false, false, false, false, false) - floatingObject.initialize('Strategy Part', payload) + floatingObject.initialize('UI Object', payload) payload.floatingObject = floatingObject if (payload.node.savedPayload !== undefined) { @@ -59,13 +59,13 @@ function newStrategyPartConstructor () { } } - let strategyPart = newStrategyPart() - payload.uiObject = strategyPart - strategyPart.fitFunction = canvas.floatingSpace.fitIntoVisibleArea - strategyPart.isVisibleFunction = canvas.floatingSpace.isThisPointVisible - let menuItemsInitialValues = getMenuItemsInitialValues(strategyPart, floatingObject, payload) - strategyPart.initialize(payload, menuItemsInitialValues) - strategyPart.container.connectToParent(floatingObject.container, false, false, true, true, false, false, true, true, true, true, true) + let uiObject = newUiObject() + payload.uiObject = uiObject + uiObject.fitFunction = canvas.floatingSpace.fitIntoVisibleArea + uiObject.isVisibleFunction = canvas.floatingSpace.isThisPointVisible + let menuItemsInitialValues = getMenuItemsInitialValues(uiObject, floatingObject, payload) + uiObject.initialize(payload, menuItemsInitialValues) + uiObject.container.connectToParent(floatingObject.container, false, false, true, true, false, false, true, true, true, true, true) setFloatingObjectBasicProperties(floatingObject, payload) @@ -162,7 +162,7 @@ function newStrategyPartConstructor () { ) } - function getMenuItemsInitialValues (strategyPart, floatingObject, payload) { + function getMenuItemsInitialValues (uiObject, floatingObject, payload) { let menuItemsInitialValues = [] switch (payload.node.type) { case 'Workspace': { @@ -200,12 +200,34 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Definition', visible: true, - relatedStrategyPart: 'Definition', + relatedUiObject: 'Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + }, + { + action: 'Add Network', + actionFunction: payload.onMenuItemClick, + label: 'Add Network', + visible: true, + relatedUiObject: 'Network', rawRadius: 8, targetRadius: 0, currentRadius: 0, angle: -10 }, + { + action: 'Add Team', + actionFunction: payload.onMenuItemClick, + label: 'Add Team', + visible: true, + relatedUiObject: 'Team', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 10 + }, { action: 'Share Workspace', actionFunction: payload.onMenuItemClick, @@ -216,7 +238,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 10 + angle: 30 }] break } @@ -230,11 +252,11 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Trading System', visible: true, - relatedStrategyPart: 'Trading System', + relatedUiObject: 'Trading System', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -40 + angle: -30 } ) menuItemsInitialValues.push( @@ -243,7 +265,86 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Personal Data', visible: true, - relatedStrategyPart: 'Personal Data', + relatedUiObject: 'Personal Data', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -10 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Definition', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Definition', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 10 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } + case 'Team': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Team', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Bot', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -75, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Sensor Bot', + actionFunction: payload.onMenuItemClick, + label: 'Add Sensor Bot', + visible: true, + relatedUiObject: 'Sensor Bot', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Indicator Bot', + actionFunction: payload.onMenuItemClick, + label: 'Add Indicator Bot', + visible: true, + relatedUiObject: 'Indicator Bot', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -252,24 +353,116 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Add Network', + action: 'Add Trading Bot', actionFunction: payload.onMenuItemClick, - label: 'Add Network', + label: 'Add Trading Bot', visible: true, - relatedStrategyPart: 'Network', + relatedUiObject: 'Trading Bot', rawRadius: 8, targetRadius: 0, currentRadius: 0, angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Plotter', + actionFunction: payload.onMenuItemClick, + label: 'Add Plotter', + visible: true, + relatedUiObject: 'Plotter', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 } ) menuItemsInitialValues.push( { - action: 'Delete Definition', + action: 'Delete Team', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Definition', + label: 'Delete Team', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 40 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 75 + } + ) + break + } + case 'Sensor Bot': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Bot', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Bot', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -45, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Process Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Process Definition', + visible: true, + relatedUiObject: 'Process Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Product Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Product Definition', + visible: true, + relatedUiObject: 'Product Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Sensor Bot', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Sensor Bot', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -279,6 +472,606 @@ function newStrategyPartConstructor () { angle: 20 } ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 45 + } + ) + break + } + case 'Indicator Bot': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Bot', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Bot', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -45, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Process Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Process Definition', + visible: true, + relatedUiObject: 'Process Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Product Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Product Definition', + visible: true, + relatedUiObject: 'Product Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Indicator Bot', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Indicator Bot', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 45 + } + ) + break + } + case 'Trading Bot': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Bot', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Bot', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -45, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Process Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Process Definition', + visible: true, + relatedUiObject: 'Process Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Product Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Product Definition', + visible: true, + relatedUiObject: 'Product Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Trading Bot', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Trading Bot', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 45 + } + ) + break + } + case 'Process Definition': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Process', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Process', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -60, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Missing Process Definition Items', + actionFunction: payload.onMenuItemClick, + label: 'Add Missing Items', + visible: true, + relatedUiObject: 'Calculations Procedure', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process Definition', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process Definition', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 60 + } + ) + break + } + case 'Process Output': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Output Dataset', + actionFunction: payload.onMenuItemClick, + label: 'Add Output Dataset', + visible: true, + relatedUiObject: 'Output Dataset', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process Output', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process Output', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } + case 'Process Dependencies': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Status Dependency', + actionFunction: payload.onMenuItemClick, + label: 'Add Status Dependency', + visible: true, + relatedUiObject: 'Status Dependency', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -60 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Data Dependency', + actionFunction: payload.onMenuItemClick, + label: 'Add Data Dependency', + visible: true, + relatedUiObject: 'Data Dependency', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process Dependencies', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process Dependencies', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 60 + } + ) + break + } + case 'Status Report': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Status Report', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Status Report', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 15 + } + ) + break + } + case 'Execution Started Event': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Execution Started Event', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Event', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 15 + } + ) + break + } + case 'Execution Finished Event': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Execution Finished Event', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Event', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 15 + } + ) + break + } + case 'Calculations Procedure': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Procedure Initialization', + actionFunction: payload.onMenuItemClick, + label: 'Add Procedure Initialization', + visible: true, + relatedUiObject: 'Procedure Initialization', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -45 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Procedure Loop', + actionFunction: payload.onMenuItemClick, + label: 'Add Procedure Loop', + visible: true, + relatedUiObject: 'Procedure Loop', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Calculations Procedure', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Procedure', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 15 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 45 + } + ) + break + } + case 'Data Building Procedure': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Procedure Initialization', + actionFunction: payload.onMenuItemClick, + label: 'Add Procedure Initialization', + visible: true, + relatedUiObject: 'Procedure Initialization', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -45 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Procedure Loop', + actionFunction: payload.onMenuItemClick, + label: 'Add Procedure Loop', + visible: true, + relatedUiObject: 'Procedure Loop', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Data Building Procedure', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Procedure', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 15 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 45 + } + ) + break + } + case 'Procedure Initialization': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Code', + actionFunction: payload.onMenuItemClick, + label: 'Add Code', + visible: true, + relatedUiObject: 'Code', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Procedure Initialization', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Initialization', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) menuItemsInitialValues.push( { action: 'Share', @@ -295,6 +1088,586 @@ function newStrategyPartConstructor () { ) break } + case 'Procedure Loop': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Code', + actionFunction: payload.onMenuItemClick, + label: 'Add Code', + visible: true, + relatedUiObject: 'Code', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Procedure Loop', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Procedure Loop', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 40 + } + ) + break + } + case 'Output Dataset': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Output Dataset', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Output Dataset', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + break + } + case 'Status Dependency': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Status Dependency', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Status Dependency', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Status Dependency', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Status Dependency', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 40 + } + ) + break + } + case 'Data Dependency': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Delete Data Dependency', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Data Dependency', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + break + } + case 'Product Definition': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Product', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Product', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -60, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Record Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Record Definition', + visible: true, + relatedUiObject: 'Record Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Dataset Definition', + actionFunction: payload.onMenuItemClick, + label: 'Add Dataset Definition', + visible: true, + relatedUiObject: 'Dataset Definition', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -10 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Missing Product Definition Items', + actionFunction: payload.onMenuItemClick, + label: 'Add Missing Items', + visible: true, + relatedUiObject: 'Calculations Procedure', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 10 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Product Definition', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Product Definition', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 60 + } + ) + break + } + case 'Record Definition': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Record Property', + actionFunction: payload.onMenuItemClick, + label: 'Add Record Property', + visible: true, + relatedUiObject: 'Record Property', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Record Definition', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Record Definition', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } + case 'Record Property': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Property', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Property', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -45, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Add Formula', + actionFunction: payload.onMenuItemClick, + label: 'Add Formula', + visible: true, + relatedUiObject: 'Formula', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Record Property', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Record Property', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 15 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 45 + } + ) + break + } + case 'Dataset Definition': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Definition', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Definition', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Dataset Definition', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Dataset', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } + case 'Plotter': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Plotter Module', + actionFunction: payload.onMenuItemClick, + label: 'Add Plotter Module', + visible: true, + relatedUiObject: 'Plotter Module', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Plotter', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Plotter', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + break + } + case 'Plotter Module': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Code', + actionFunction: payload.onMenuItemClick, + label: 'Add Code', + visible: true, + relatedUiObject: 'Code', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Plotter Panel', + actionFunction: payload.onMenuItemClick, + label: 'Add Plotter Panel', + visible: true, + relatedUiObject: 'Plotter Panel', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -10 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Plotter Module', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Plotter Module', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 10 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } + case 'Plotter Panel': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Code', + actionFunction: payload.onMenuItemClick, + label: 'Add Code', + visible: true, + relatedUiObject: 'Code', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Plotter Panel', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Plotter Panel', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } case 'Network': { addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( @@ -303,7 +1676,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Network Node', visible: true, - relatedStrategyPart: 'Network Node', + relatedUiObject: 'Network Node', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -350,7 +1723,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Task Manager', visible: true, - relatedStrategyPart: 'Task Manager', + relatedUiObject: 'Task Manager', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -397,7 +1770,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Telegram Bot', visible: true, - relatedStrategyPart: 'Telegram Bot', + relatedUiObject: 'Telegram Bot', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -437,10 +1810,10 @@ function newStrategyPartConstructor () { break } case 'Telegram Bot': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { @@ -448,7 +1821,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Announcement', visible: true, - relatedStrategyPart: 'Announcement', + relatedUiObject: 'Announcement', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -458,7 +1831,7 @@ function newStrategyPartConstructor () { menuItemsInitialValues.push( { action: 'Edit Telegram Bot', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Telegram Bot', visible: true, iconPathOn: 'html', @@ -503,10 +1876,10 @@ function newStrategyPartConstructor () { break } case 'Announcement': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { @@ -514,7 +1887,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Formula', visible: true, - relatedStrategyPart: 'Formula', + relatedUiObject: 'Formula', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -525,7 +1898,7 @@ function newStrategyPartConstructor () { menuItemsInitialValues.push( { action: 'Edit Announcement', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Announcement', visible: true, iconPathOn: 'html', @@ -577,7 +1950,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Layer', visible: true, - relatedStrategyPart: 'Layer', + relatedUiObject: 'Layer', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -617,15 +1990,15 @@ function newStrategyPartConstructor () { break } case 'Layer': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Layer', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Layer', visible: true, iconPathOn: 'html', @@ -705,7 +2078,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Task', visible: true, - relatedStrategyPart: 'Task Manager', + relatedUiObject: 'Task Manager', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -771,11 +2144,11 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Add Sensor', + action: 'Add Sensor Bot Instance', actionFunction: payload.onMenuItemClick, - label: 'Add Sensor', + label: 'Add Sensor Bot Instance', visible: true, - relatedStrategyPart: 'Sensor', + relatedUiObject: 'Sensor Bot Instance', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -784,11 +2157,11 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Add Indicator', + action: 'Add Indicator Bot Instance', actionFunction: payload.onMenuItemClick, - label: 'Add Indicator', + label: 'Add Indicator Bot Instance', visible: true, - relatedStrategyPart: 'Indicator', + relatedUiObject: 'Indicator Bot Instance', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -797,11 +2170,11 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Add Trading Engine', + action: 'Add Trading Bot Instance', actionFunction: payload.onMenuItemClick, - label: 'Add Trading Engine', + label: 'Add Trading Bot Instance', visible: true, - relatedStrategyPart: 'Trading Engine', + relatedUiObject: 'Trading Bot Instance', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -840,48 +2213,48 @@ function newStrategyPartConstructor () { ) break } - case 'Sensor': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + case 'Sensor Bot Instance': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { - action: 'Add Process', - actionFunction: payload.onMenuItemClick, - label: 'Add Process', - visible: true, - relatedStrategyPart: 'Process', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45 - } - ) - menuItemsInitialValues.push( - { - action: 'Edit Sensor', - actionFunction: strategyPart.codeEditor.activate, - label: 'Edit Sensor', + action: 'Edit Sensor Bot Instance', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Sensor Bot Instance', visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -15, + angle: -45, dontShowAtFullscreen: true } ) menuItemsInitialValues.push( { - action: 'Delete Sensor', + action: 'Add Process Instance', + actionFunction: payload.onMenuItemClick, + label: 'Add Process Instance', + visible: true, + relatedUiObject: 'Process Instance', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Sensor Bot Instance', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Sensor', + label: 'Delete Sensor Bot Instance', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -907,48 +2280,48 @@ function newStrategyPartConstructor () { ) break } - case 'Indicator': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + case 'Indicator Bot Instance': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { - action: 'Add Process', - actionFunction: payload.onMenuItemClick, - label: 'Add Process', - visible: true, - relatedStrategyPart: 'Process', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45 - } - ) - menuItemsInitialValues.push( - { - action: 'Edit Indicator', - actionFunction: strategyPart.codeEditor.activate, - label: 'Edit Indicator', + action: 'Edit Indicator Bot Instance', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Indicator Bot Instance', visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -15, + angle: -45, dontShowAtFullscreen: true } ) menuItemsInitialValues.push( { - action: 'Delete Indicator', + action: 'Add Process Instance', + actionFunction: payload.onMenuItemClick, + label: 'Add Process Instance', + visible: true, + relatedUiObject: 'Process Instance', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Indicator Bot Instance', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Indicator', + label: 'Delete Indicator Bot Instance', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -974,48 +2347,48 @@ function newStrategyPartConstructor () { ) break } - case 'Trading Engine': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + case 'Trading Bot Instance': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { - action: 'Add Process', - actionFunction: payload.onMenuItemClick, - label: 'Add Process', - visible: true, - relatedStrategyPart: 'Process', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45 - } - ) - menuItemsInitialValues.push( - { - action: 'Edit Trading Engine', - actionFunction: strategyPart.codeEditor.activate, - label: 'Edit Trading Engine', + action: 'Edit Trading Bot Instance', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Trading Bot Instance', visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -15, + angle: -45, dontShowAtFullscreen: true } ) menuItemsInitialValues.push( { - action: 'Delete Trading Engine', + action: 'Add Process Instance', + actionFunction: payload.onMenuItemClick, + label: 'Add Process Instance', + visible: true, + relatedUiObject: 'Process Instance', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -15 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Trading Bot Instance', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Trading Engine', + label: 'Delete Trading Bot Instance', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -1041,23 +2414,23 @@ function newStrategyPartConstructor () { ) break } - case 'Process': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + case 'Process Instance': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) switch (payload.node.subType) { - case 'Trading Engine Process': { + case 'Trading Process Instance': { menuItemsInitialValues.push( { action: 'Add Backtesting Session', actionFunction: payload.onMenuItemClick, label: 'Add Backtesting', visible: true, - relatedStrategyPart: 'Backtesting Session', + relatedUiObject: 'Backtesting Session', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1070,7 +2443,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Live Trading', visible: true, - relatedStrategyPart: 'Live Trading Session', + relatedUiObject: 'Live Trading Session', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1083,7 +2456,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Fordward Testing', visible: true, - relatedStrategyPart: 'Fordward Testing Session', + relatedUiObject: 'Fordward Testing Session', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1096,7 +2469,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Paper Trading', visible: true, - relatedStrategyPart: 'Paper Trading Session', + relatedUiObject: 'Paper Trading Session', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1105,9 +2478,9 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Edit Process', - actionFunction: strategyPart.codeEditor.activate, - label: 'Edit Process', + action: 'Edit Process Instance', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Process Instance', visible: true, iconPathOn: 'html', iconPathOff: 'html', @@ -1120,11 +2493,11 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Delete Process', + action: 'Delete Process Instance', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Process', + label: 'Delete Process Instance', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -1153,9 +2526,9 @@ function newStrategyPartConstructor () { default: { menuItemsInitialValues.push( { - action: 'Edit Process', - actionFunction: strategyPart.codeEditor.activate, - label: 'Edit Process', + action: 'Edit Process Instance', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Process Instance', visible: true, iconPathOn: 'html', iconPathOff: 'html', @@ -1168,11 +2541,11 @@ function newStrategyPartConstructor () { ) menuItemsInitialValues.push( { - action: 'Delete Process', + action: 'Delete Process Instance', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Process', + label: 'Delete Process Instance', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -1202,10 +2575,10 @@ function newStrategyPartConstructor () { break } case 'Backtesting Session': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( @@ -1237,7 +2610,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Layer Manager', visible: true, - relatedStrategyPart: 'Layer Manager', + relatedUiObject: 'Layer Manager', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1250,7 +2623,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Parameters', visible: true, - relatedStrategyPart: 'Parameters', + relatedUiObject: 'Parameters', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1263,7 +2636,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Social Bots', visible: true, - relatedStrategyPart: 'Social Bots', + relatedUiObject: 'Social Bots', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1273,7 +2646,7 @@ function newStrategyPartConstructor () { menuItemsInitialValues.push( { action: 'Edit Session', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Session', visible: true, iconPathOn: 'html', @@ -1318,10 +2691,10 @@ function newStrategyPartConstructor () { break } case 'Live Trading Session': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( @@ -1353,7 +2726,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Layer Manager', visible: true, - relatedStrategyPart: 'Layer Manager', + relatedUiObject: 'Layer Manager', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1366,7 +2739,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Parameters', visible: true, - relatedStrategyPart: 'Parameters', + relatedUiObject: 'Parameters', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1379,7 +2752,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Social Bots', visible: true, - relatedStrategyPart: 'Social Bots', + relatedUiObject: 'Social Bots', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1389,7 +2762,7 @@ function newStrategyPartConstructor () { menuItemsInitialValues.push( { action: 'Edit Session', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Session', visible: true, iconPathOn: 'html', @@ -1434,10 +2807,10 @@ function newStrategyPartConstructor () { break } case 'Fordward Testing Session': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( @@ -1469,7 +2842,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Layer Manager', visible: true, - relatedStrategyPart: 'Layer Manager', + relatedUiObject: 'Layer Manager', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1482,7 +2855,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Parameters', visible: true, - relatedStrategyPart: 'Parameters', + relatedUiObject: 'Parameters', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1495,7 +2868,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Social Bots', visible: true, - relatedStrategyPart: 'Social Bots', + relatedUiObject: 'Social Bots', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1505,7 +2878,7 @@ function newStrategyPartConstructor () { menuItemsInitialValues.push( { action: 'Edit Session', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Session', visible: true, iconPathOn: 'html', @@ -1550,10 +2923,10 @@ function newStrategyPartConstructor () { break } case 'Paper Trading Session': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( @@ -1585,7 +2958,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Layer Manager', visible: true, - relatedStrategyPart: 'Layer Manager', + relatedUiObject: 'Layer Manager', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1598,7 +2971,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Parameters', visible: true, - relatedStrategyPart: 'Parameters', + relatedUiObject: 'Parameters', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1611,7 +2984,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Social Bots', visible: true, - relatedStrategyPart: 'Social Bots', + relatedUiObject: 'Social Bots', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1621,7 +2994,7 @@ function newStrategyPartConstructor () { menuItemsInitialValues.push( { action: 'Edit Session', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Session', visible: true, iconPathOn: 'html', @@ -1673,7 +3046,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Exchange Account', visible: true, - relatedStrategyPart: 'Exchange Account', + relatedUiObject: 'Exchange Account', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1706,7 +3079,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Asset', visible: true, - relatedStrategyPart: 'Exchange Account Asset', + relatedUiObject: 'Exchange Account Asset', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1719,7 +3092,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Key', visible: true, - relatedStrategyPart: 'Exchange Account Key', + relatedUiObject: 'Exchange Account Key', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1765,16 +3138,16 @@ function newStrategyPartConstructor () { break } case 'Exchange Account Key': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Key Value', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Key Value', visible: true, iconPathOn: 'html', @@ -1812,7 +3185,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Strategy', visible: true, - relatedStrategyPart: 'Strategy', + relatedUiObject: 'Strategy', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1825,7 +3198,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Parameters', visible: true, - relatedStrategyPart: 'Parameters', + relatedUiObject: 'Parameters', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1872,7 +3245,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Missing Params', visible: true, - relatedStrategyPart: 'Parameters', + relatedUiObject: 'Parameters', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -1912,16 +3285,16 @@ function newStrategyPartConstructor () { break } case 'Base Asset': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Base Asset', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Base Asset', visible: true, iconPathOn: 'settings', @@ -1965,16 +3338,16 @@ function newStrategyPartConstructor () { break } case 'Time Range': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Time Range', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Time Range', visible: true, iconPathOn: 'settings', @@ -2018,16 +3391,16 @@ function newStrategyPartConstructor () { break } case 'Time Period': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Time Period', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Time Period', visible: true, iconPathOn: 'settings', @@ -2071,16 +3444,16 @@ function newStrategyPartConstructor () { break } case 'Slippage': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Slippage', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Slippage', visible: true, iconPathOn: 'settings', @@ -2124,16 +3497,16 @@ function newStrategyPartConstructor () { break } case 'Fee Structure': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Fee Structure', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Fee Structure', visible: true, iconPathOn: 'settings', @@ -2184,7 +3557,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Missing Stages', visible: true, - relatedStrategyPart: 'Strategy', + relatedUiObject: 'Strategy', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2231,7 +3604,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Missing Events', visible: true, - relatedStrategyPart: 'Trigger Stage', + relatedUiObject: 'Trigger Stage', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2278,7 +3651,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Initial Definition', visible: true, - relatedStrategyPart: 'Initial Definition', + relatedUiObject: 'Initial Definition', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2291,7 +3664,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Open Execution', visible: true, - relatedStrategyPart: 'Open Execution', + relatedUiObject: 'Open Execution', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2338,7 +3711,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Missing Items', visible: true, - relatedStrategyPart: 'Manage Stage', + relatedUiObject: 'Manage Stage', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2385,7 +3758,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Close Execution', visible: true, - relatedStrategyPart: 'Close Execution', + relatedUiObject: 'Close Execution', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2432,7 +3805,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Formula', visible: true, - relatedStrategyPart: 'Formula', + relatedUiObject: 'Formula', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2479,7 +3852,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Formula', visible: true, - relatedStrategyPart: 'Formula', + relatedUiObject: 'Formula', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2526,7 +3899,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Situation', visible: true, - relatedStrategyPart: 'Situation', + relatedUiObject: 'Situation', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2573,7 +3946,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Situation', visible: true, - relatedStrategyPart: 'Situation', + relatedUiObject: 'Situation', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2620,7 +3993,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Situation', visible: true, - relatedStrategyPart: 'Situation', + relatedUiObject: 'Situation', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2667,7 +4040,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Missing Items', visible: true, - relatedStrategyPart: 'Initial Definition', + relatedUiObject: 'Initial Definition', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2782,7 +4155,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Phase', visible: true, - relatedStrategyPart: 'Phase', + relatedUiObject: 'Phase', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2829,7 +4202,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Phase', visible: true, - relatedStrategyPart: 'Phase', + relatedUiObject: 'Phase', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2876,7 +4249,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Formula', visible: true, - relatedStrategyPart: 'Formula', + relatedUiObject: 'Formula', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2889,7 +4262,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Next Phase Event', visible: true, - relatedStrategyPart: 'Next Phase Event', + relatedUiObject: 'Next Phase Event', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -2929,16 +4302,16 @@ function newStrategyPartConstructor () { break } case 'Formula': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Formula', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Formula', visible: true, iconPathOn: 'html', @@ -2990,7 +4363,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Situation', visible: true, - relatedStrategyPart: 'Situation', + relatedUiObject: 'Situation', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -3037,7 +4410,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Condition', visible: true, - relatedStrategyPart: 'Condition', + relatedUiObject: 'Condition', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -3084,7 +4457,7 @@ function newStrategyPartConstructor () { actionFunction: payload.onMenuItemClick, label: 'Add Code', visible: true, - relatedStrategyPart: 'Code', + relatedUiObject: 'Code', rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -3124,16 +4497,16 @@ function newStrategyPartConstructor () { break } case 'Code': { - strategyPart.codeEditor = newCodeEditor() - strategyPart.codeEditor.isVisibleFunction = strategyPart.isVisibleFunction - strategyPart.codeEditor.initialize() - strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { action: 'Edit Code', - actionFunction: strategyPart.codeEditor.activate, + actionFunction: uiObject.codeEditor.activate, label: 'Edit Code', visible: true, iconPathOn: 'html', @@ -3178,7 +4551,7 @@ function newStrategyPartConstructor () { break } default: { - if (ERROR_LOG === true) { logger.write('[ERROR] getMenuItemsInitialValues -> Part Type not Recognized -> type = ' + payload.node.type) } + if (ERROR_LOG === true) { logger.write('[ERROR] getMenuItemsInitialValues -> UI Object Type not Recognized -> type = ' + payload.node.type) } } } @@ -3198,6 +4571,102 @@ function newStrategyPartConstructor () { level_0() break } + case 'Team': { + level_0() + break + } + case 'Sensor Bot': { + level_1() + break + } + case 'Indicator Bot': { + level_1() + break + } + case 'Trading Bot': { + level_1() + break + } + case 'Process Definition': { + level_2() + break + } + case 'Process Output': { + level_3() + break + } + case 'Process Dependencies': { + level_3() + break + } + case 'Status Report': { + level_3() + break + } + case 'Execution Started Event': { + level_3() + break + } + case 'Execution Finished Event': { + level_3() + break + } + case 'Calculations Procedure': { + level_3() + break + } + case 'Data Building Procedure': { + level_3() + break + } + case 'Procedure Initialization': { + level_4() + break + } + case 'Procedure Loop': { + level_4() + break + } + case 'Output Dataset': { + level_3() + break + } + case 'Status Dependency': { + level_3() + break + } + case 'Data Dependency': { + level_3() + break + } + case 'Product Definition': { + level_2() + break + } + case 'Record Definition': { + level_3() + break + } + case 'Record Property': { + level_4() + break + } + case 'Dataset Definition': { + level_3() + break + } + case 'Plotter': { + level_1() + break + } + case 'Plotter Module': { + level_2() + break + } + case 'Plotter Panel': { + level_3() + break + } case 'Network': { level_1() break @@ -3234,19 +4703,19 @@ function newStrategyPartConstructor () { level_3() break } - case 'Sensor': { + case 'Sensor Bot Instance': { level_3() break } - case 'Indicator': { + case 'Indicator Bot Instance': { level_3() break } - case 'Trading Engine': { + case 'Trading Bot Instance': { level_3() break } - case 'Process': { + case 'Process Instance': { level_2() break } @@ -3395,7 +4864,7 @@ function newStrategyPartConstructor () { break } default: { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Part Type not Recognized -> type = ' + payload.node.type) } + if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> UI Object Type not Recognized -> type = ' + payload.node.type) } return } } @@ -3502,7 +4971,7 @@ function newStrategyPartConstructor () { floatingObject.labelStrokeStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' } - function destroyStrategyPart (payload) { + function destroyUiObject (payload) { floatingLayer.removeFloatingObject(payload.floatingObject.handle) payload.floatingObject.finalize() diff --git a/FloatingSpace/StrategyPartTitle.js b/FloatingSpace/UiObjectTitle.js similarity index 81% rename from FloatingSpace/StrategyPartTitle.js rename to FloatingSpace/UiObjectTitle.js index c397723a3..25143c9a2 100644 --- a/FloatingSpace/StrategyPartTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -1,6 +1,6 @@ -function newStrategyPartTitle () { - const MODULE_NAME = 'Strategy Part Title' +function newUiObjectTitle () { + const MODULE_NAME = 'UI Object Title' const ERROR_LOG = true const logger = newWebDebugLog() @@ -52,50 +52,70 @@ function newStrategyPartTitle () { thisObject.allwaysVisible = true break } - case 'Network': { + case 'Team': { thisObject.allwaysVisible = true break } - case 'Network Node': { + case 'Sensor Bot': { + thisObject.allwaysVisible = true break } - case 'Social Bots': { + case 'Indicator Bot': { + thisObject.allwaysVisible = true break } - case 'Telegram Bot': { + case 'Trading Bot': { + thisObject.allwaysVisible = true + break + } + case 'Process Definition': { + thisObject.allwaysVisible = true + break + } + case 'Product Definition': { + thisObject.allwaysVisible = true + break + } + case 'Dataset Definition': { + thisObject.allwaysVisible = true + break + } + case 'Record Property': { + thisObject.allwaysVisible = true + break + } + case 'Plotter': { + thisObject.allwaysVisible = true + break + } + case 'Plotter Module': { + thisObject.allwaysVisible = true + break + } + case 'Plotter Panel': { + thisObject.allwaysVisible = true + break + } + case 'Network': { + thisObject.allwaysVisible = true break } case 'Announcement': { thisObject.allwaysVisible = true break } - case 'Layer Manager': { - break - } case 'Layer': { thisObject.allwaysVisible = true break } - case 'Task Manager': { - break - } - case 'Task': { - break - } - case 'Sensor': { + case 'Sensor Bot Instance': { thisObject.allwaysVisible = true break } - case 'Indicator': { + case 'Indicator Bot Instance': { thisObject.allwaysVisible = true break } - case 'Trading Engine': { - break - } - case 'Process': { - break - } case 'Backtesting Session': { thisObject.allwaysVisible = true break @@ -112,18 +132,6 @@ function newStrategyPartTitle () { thisObject.allwaysVisible = true break } - case 'Personal Data': { - break - } - case 'Exchange Account': { - break - } - case 'Exchange Account Asset': { - break - } - case 'Exchange Account Key': { - break - } case 'Workspace': { thisObject.allwaysVisible = true break @@ -132,90 +140,12 @@ function newStrategyPartTitle () { thisObject.allwaysVisible = true break } - case 'Parameters': { - break - } - case 'Base Asset': { - break - } - case 'Time Range': { - break - } - case 'Time Period': { - break - } - case 'Slippage': { - break - } - case 'Fee Structure': { - break - } case 'Strategy': { thisObject.allwaysVisible = true break } - case 'Trigger Stage': { - break - } - case 'Open Stage': { - break - } - case 'Manage Stage': { - break - } - case 'Close Stage': { - break - } - case 'Position Size': { - break - } - case 'Position Rate': { - break - } - case 'Trigger On Event': { - break - } - case 'Trigger Off Event': { - break - } - case 'Take Position Event': { - break - } - case 'Initial Definition': { - break - } - case 'Open Execution': { - break - } - case 'Close Execution': { - break - } - case 'Stop': { - break - } - case 'Take Profit': { - break - } - case 'Phase': { - break - } - case 'Formula': { - break - } - case 'Next Phase Event': { - break - } - case 'Situation': { - break - } - case 'Condition': { - break - } - case 'Code': { - break - } default: { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Part Type not Recognized -> type = ' + payload.node.type) } + thisObject.allwaysVisible = false } } diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 3d6e61160..32f500524 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -71,7 +71,7 @@ function newProductsPanel () { for (let j = 0; j < devTeam.bots.length; j++) { let bot = devTeam.bots[j] - if (bot.type !== 'Indicator') { continue } + if (bot.type !== 'Indicator Bot Instance') { continue } if (bot.products !== undefined) { for (let k = 0; k < bot.products.length; k++) { @@ -271,65 +271,69 @@ function newProductsPanel () { calculateVisbleProductCards() function synchronizeLayersAndProductCards () { - /* We will look into the ecosystem to know which Trading Engine bots are defined there. */ + /* We will look into the ecosystem to know which Trading bots are defined there. */ let ecosystem = JSON.parse(window.localStorage.getItem('ecosystem')) if (ecosystem === null || ecosystem === undefined) { ecosystem = getUserEcosystem() } /* Then we get an Array of all instances of this bot placed at Definitions on the Workspace. */ - let tradingEngineInstances = canvas.strategySpace.workspace.getAllTradingEngines() + let tradingBotInstances = canvas.designerSpace.workspace.getAllTradingBotInstances() /* Here we will go through all the instances of trading engines and see their layers, to see if we can find a matching layer. */ - for (let n = 0; n < tradingEngineInstances.length; n++) { - let tradingEngine = tradingEngineInstances[n] + for (let n = 0; n < tradingBotInstances.length; n++) { + let tradingBotInstance = tradingBotInstances[n] let code - try { - code = JSON.parse(tradingEngine.code) - } catch (err) { - // if we can not parse this, then we ignore this trading engine. - } - if (code !== undefined) { + let instanceBot + let instanceTeam + + for (let m = 0; m < tradingBotInstance.processes.length; m++) { + let process = tradingBotInstance.processes[m] + try { + code = JSON.parse(process.payload.referenceParent.payload.parentNode.code) + instanceBot = code.codeName + code = JSON.parse(process.payload.referenceParent.payload.parentNode.payload.parentNode.code) + instanceTeam = code.codeName + } catch (err) { + continue + } for (let i = 0; i < ecosystem.devTeams.length; i++) { let devTeam = ecosystem.devTeams[i] for (let j = 0; j < devTeam.bots.length; j++) { let bot = devTeam.bots[j] - if (bot.type !== 'Trading Engine') { continue } + if (bot.type !== 'Trading Bot Instance') { continue } - if (devTeam.codeName === code.team && bot.codeName === code.bot) { - /* We found an instance of the same Trading Engine we are currently looking at. + if (devTeam.codeName === instanceTeam && bot.codeName === instanceBot) { + /* We found an instance of the same Trading we are currently looking at. Next thing to do is to see its layers to see if we can match it with the current product. */ - for (let m = 0; m < tradingEngine.processes.length; m++) { - let process = tradingEngine.processes[m] - if (process.session !== undefined) { - if (process.session.layerManager !== undefined) { - let layerManager = process.session.layerManager + if (process.session !== undefined) { + if (process.session.layerManager !== undefined) { + let layerManager = process.session.layerManager - if (bot.products !== undefined) { - for (let k = 0; k < bot.products.length; k++) { - let product = bot.products[k] + if (bot.products !== undefined) { + for (let k = 0; k < bot.products.length; k++) { + let product = bot.products[k] - for (let p = 0; p < layerManager.layers.length; p++) { - let layer = layerManager.layers[p] - let layerCode - try { - layerCode = JSON.parse(layer.code) - } catch (err) { + for (let p = 0; p < layerManager.layers.length; p++) { + let layer = layerManager.layers[p] + let layerCode + try { + layerCode = JSON.parse(layer.code) + } catch (err) { // if we can not parse this, then we ignore this trading engine. - } + } - if (product.codeName === layerCode.product) { + if (product.codeName === layerCode.product) { /* We have a layer that is matching the current product */ - let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id - let cardFound = removeFromLocalProductCards(cardCode) - if (cardFound !== true) { - productCard = addProductCard(devTeam, bot, product, process.session) - onProductCardStatusChanged(productCard) - } + let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id + let cardFound = removeFromLocalProductCards(cardCode) + if (cardFound !== true) { + productCard = addProductCard(devTeam, bot, product, process.session) + onProductCardStatusChanged(productCard) } } } diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index dbf34cfef..453d5e779 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -45,7 +45,7 @@ thisObject.container.frame.position.x = 0 let INITIAL_POSITION - if (canvas.strategySpace.workspace.enabled === true) { + if (canvas.designerSpace.workspace.enabled === true) { let localStorage = window.localStorage.getItem(MODULE_NAME) if (localStorage !== null) { storage = JSON.parse(localStorage) @@ -100,7 +100,7 @@ thisObject.status = 'MIDDLE' - if (canvas.strategySpace.workspace.enabled === true) { + if (canvas.designerSpace.workspace.enabled === true) { thisObject.container.isDraggeable = true } else { thisObject.container.isDraggeable = false @@ -109,10 +109,10 @@ if (thisObject.container.frame.position.y > browserCanvas.height * 99.5 / 100 - COCKPIT_SPACE_HEIGHT) { thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT thisObject.status = 'BOTTOM' - canvas.strategySpace.makeInvisible() + canvas.designerSpace.makeInvisible() canvas.floatingSpace.makeInvisible() } else { - canvas.strategySpace.makeVisible() + canvas.designerSpace.makeVisible() canvas.floatingSpace.makeVisible() } @@ -184,7 +184,7 @@ browserCanvasContext.closePath() browserCanvasContext.fill() - if (canvas.strategySpace.workspace.enabled === true) { + if (canvas.designerSpace.workspace.enabled === true) { arrow() } } diff --git a/Spaces/StrategySpace.js b/Spaces/DesignerSpace.js similarity index 71% rename from Spaces/StrategySpace.js rename to Spaces/DesignerSpace.js index 608dd3e75..be4207f31 100644 --- a/Spaces/StrategySpace.js +++ b/Spaces/DesignerSpace.js @@ -1,12 +1,12 @@ -function newStrategySpace () { +function newDesignerSpace () { const MODULE_NAME = 'Strategy Space' let thisObject = { sidePanel: undefined, strategizerGateway: undefined, container: undefined, iconCollection: undefined, - iconByPartType: undefined, + iconByUiObjectType: undefined, workspace: undefined, physics: physics, draw: draw, @@ -23,13 +23,13 @@ function newStrategySpace () { container.isDraggeable = false thisObject.iconCollection = new Map() - thisObject.iconByPartType = new Map() + thisObject.iconByUiObjectType = new Map() return thisObject async function initialize () { loadIconCollection() - buildIconByPartTypeMap() + buildIconByUiObjectTypeMap() thisObject.strategizerGateway = newStrategizerGateway() @@ -37,22 +37,22 @@ function newStrategySpace () { thisObject.workspace.initialize() } - function buildIconByPartTypeMap () { + function buildIconByUiObjectTypeMap () { const relationshipArray = [ ['Definition', 'text'], ['Network', 'network'], ['Network Node', 'network-node'], - ['Social Bots', 'support'], + ['Social Bots', 'social-bot'], ['Telegram Bot', 'paper-plane'], ['Announcement', 'promotion'], ['Layer Manager', 'layer-manager'], ['Layer', 'attractive'], ['Task Manager', 'task'], ['Task', 'timeline'], - ['Sensor', 'bot-sensor'], - ['Indicator', 'bot-indicator'], - ['Trading Engine', 'trading-engine'], - ['Process', 'process'], + ['Sensor Bot Instance', 'bot-sensor'], + ['Indicator Bot Instance', 'bot-indicator'], + ['Trading Bot Instance', 'bot-trading'], + ['Process Instance', 'process'], ['Backtesting Session', 'session-backtesting'], ['Live Trading Session', 'session-live-trading'], ['Fordward Testing Session', 'session-forward-testing'], @@ -89,13 +89,37 @@ function newStrategySpace () { ['Next Phase Event', 'pantone'], ['Situation', 'pyramid'], ['Condition', 'testing'], - ['Code', 'html'] + ['Code', 'html'], + ['Team', 'team'], + ['Sensor Bot', 'bot-sensor'], + ['Indicator Bot', 'bot-indicator'], + ['Trading Bot', 'bot-trading'], + ['Process Definition', 'process-definition'], + ['Process Output', 'process-output'], + ['Process Dependencies', 'process-dependencies'], + ['Status Report', 'status-report'], + ['Execution Started Event', 'execution-started-event'], + ['Execution Finished Event', 'execution-finished-event'], + ['Calculations Procedure', 'calculations-procedure'], + ['Data Building Procedure', 'data-building-procedure'], + ['Procedure Initialization', 'procedure-initialization'], + ['Procedure Loop', 'procedure-loop'], + ['Output Dataset', 'output-dataset'], + ['Status Dependency', 'status-dependency'], + ['Data Dependency', 'data-dependency'], + ['Product Definition', 'product-definition'], + ['Record Definition', 'record-definition'], + ['Record Property', 'record-property'], + ['Dataset Definition', 'dataset-definition'], + ['Plotter', 'plotter'], + ['Plotter Module', 'plotter-module'], + ['Plotter Panel', 'plotter-panel'] ] for (let i = 0; i < relationshipArray.length; i++) { let record = relationshipArray[i] let icon = thisObject.iconCollection.get(record[1]) - thisObject.iconByPartType.set(record[0], icon) + thisObject.iconByUiObjectType.set(record[0], icon) } } @@ -178,12 +202,34 @@ function newStrategySpace () { 'session-forward-testing', 'network', 'network-node', - 'trading-engine', + 'bot-trading', 'layer-manager', 'process', 'bot-indicator', 'bot-sensor', - 'time-period' + 'time-period', + 'team', + 'procedure-loop', + 'calculations-procedure', + 'data-building-procedure', + 'procedure-initialization', + 'process-definition', + 'output-dataset', + 'data-dependency', + 'product-definition', + 'plotter-module', + 'status-dependency', + 'record-property', + 'record-definition', + 'plotter', + 'plotter-panel', + 'dataset-definition', + 'status-report', + 'execution-finished-event', + 'process-dependencies', + 'process-output', + 'social-bot', + 'execution-started-event' ] for (let i = 0; i < iconsNames.length; i++) { diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 348c8307a..da3c213d6 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -10,7 +10,7 @@ function newFloatingSpace () { let thisObject = { floatingLayer: undefined, // This is the array of floatingObjects being displayed profileBalls: undefined, - strategyPartConstructor: undefined, + uiObjectConstructor: undefined, noteSets: undefined, container: undefined, oneScreenUp: oneScreenUp, @@ -53,7 +53,7 @@ function newFloatingSpace () { function finalize () { thisObject.floatingLayer.finalize() thisObject.profileBalls.finalize() - thisObject.strategyPartConstructor.finalize() + thisObject.uiObjectConstructor.finalize() thisObject.noteSets.finalize() } @@ -67,8 +67,8 @@ function newFloatingSpace () { thisObject.noteSets = newNoteSets() thisObject.noteSets.initialize(thisObject.floatingLayer) - thisObject.strategyPartConstructor = newStrategyPartConstructor() - thisObject.strategyPartConstructor.initialize(thisObject.floatingLayer) + thisObject.uiObjectConstructor = newUiObjectConstructor() + thisObject.uiObjectConstructor.initialize(thisObject.floatingLayer) thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } @@ -107,6 +107,7 @@ function newFloatingSpace () { } thisObject.container.displace(displaceVector) + return displaceVector } function oneScreenDown () { @@ -116,6 +117,7 @@ function newFloatingSpace () { } thisObject.container.displace(displaceVector) + return displaceVector } function oneScreenLeft () { @@ -125,6 +127,7 @@ function newFloatingSpace () { } thisObject.container.displace(displaceVector) + return displaceVector } function oneScreenRight () { @@ -134,6 +137,7 @@ function newFloatingSpace () { } thisObject.container.displace(displaceVector) + return displaceVector } function positionAtNode (node) { @@ -223,4 +227,3 @@ function newFloatingSpace () { browserCanvasContext.fill() } } - diff --git a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js deleted file mode 100644 index 3498dddc0..000000000 --- a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js +++ /dev/null @@ -1,1303 +0,0 @@ -function newPartsFromNodes () { - thisObject = { - createPartFromNode: createPartFromNode, - addDefinition: addDefinition, - addNetwork: addNetwork, - addNetworkNode: addNetworkNode, - addSocialBots: addSocialBots, - addTelegramBot: addTelegramBot, - addAnnouncement: addAnnouncement, - addLayerManager: addLayerManager, - addLayer: addLayer, - addTaskManager: addTaskManager, - addTask: addTask, - addSensor: addSensor, - addIndicator: addIndicator, - addTradingEngine: addTradingEngine, - addProcess: addProcess, - addBacktestingSession: addBacktestingSession, - addLiveTradingSession: addLiveTradingSession, - addFordwardTestingSession: addFordwardTestingSession, - addPaperTradingSession: addPaperTradingSession, - addTradingSystem: addTradingSystem, - addPersonalData: addPersonalData, - addExchangeAccount: addExchangeAccount, - addExchangeAccountAsset: addExchangeAccountAsset, - addExchangeAccountKey: addExchangeAccountKey, - addStrategy: addStrategy, - addParameters: addParameters, - addMissingParameters: addMissingParameters, - addMissingStages: addMissingStages, - addMissingEvents: addMissingEvents, - addMissingItems: addMissingItems, - addInitialDefinition: addInitialDefinition, - addOpenExecution: addOpenExecution, - addCloseExecution: addCloseExecution, - addPhase: addPhase, - addFormula: addFormula, - addNextPhaseEvent: addNextPhaseEvent, - addSituation: addSituation, - addCondition: addCondition, - addCode: addCode - } - - return thisObject - - function createPartFromNode (node, parentNode, chainParent) { - switch (node.type) { - case 'Code': - { - createPart('Code', node.name, node, parentNode, chainParent, 'Code') - return - } - case 'Condition': - { - createPart('Condition', node.name, node, parentNode, chainParent, 'Condition') - if (node.code !== undefined) { - createPartFromNode(node.code, node, node) - } - return - } - case 'Situation': { - let situation = node - createPart('Situation', situation.name, situation, parentNode, chainParent, 'Situation') - for (let m = 0; m < node.conditions.length; m++) { - let condition = node.conditions[m] - createPartFromNode(condition, situation, situation) - } - return - } - case 'Formula': - { - createPart('Formula', node.name, node, parentNode, chainParent, 'Formula') - return - } - case 'Next Phase Event': - { - createPart('Next Phase Event', node.name, node, parentNode, chainParent, 'Next Phase Event') - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createPartFromNode(situation, node, node) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createPartFromNode(announcement, node, node) - } - return - } - case 'Phase': { - let phase = node - createPart('Phase', phase.name, phase, parentNode, chainParent, phase.subType) - - if (node.formula !== undefined) { - createPartFromNode(node.formula, phase, phase) - } - if (node.nextPhaseEvent !== undefined) { - createPartFromNode(node.nextPhaseEvent, phase, phase) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createPartFromNode(announcement, node, node) - } - return - } - case 'Stop': { - let lastPhase - let stop = node - createPart('Stop', stop.name, stop, parentNode, chainParent, 'Stop') - for (let m = 0; m < node.phases.length; m++) { - let phase = node.phases[m] - let thisChainParent - if (m === 0) { - thisChainParent = node - } else { - thisChainParent = lastPhase - } - lastPhase = phase - createPartFromNode(phase, stop, thisChainParent) - } - return - } - case 'Take Profit': { - let lastPhase - let takeProfit = node - createPart('Take Profit', takeProfit.name, takeProfit, parentNode, chainParent, 'Take Profit') - for (let m = 0; m < node.phases.length; m++) { - let phase = node.phases[m] - let thisChainParent - if (m === 0) { - thisChainParent = node - } else { - thisChainParent = lastPhase - } - lastPhase = phase - createPartFromNode(phase, takeProfit, thisChainParent) - } - return - } - case 'Open Execution': - { - createPart('Open Execution', node.name, node, parentNode, chainParent, 'Open Execution') - return - } - case 'Close Execution': - { - createPart('Close Execution', node.name, node, parentNode, chainParent, 'Close Execution') - return - } - case 'Initial Definition': { - createPart('Initial Definition', node.name, node, parentNode, chainParent, 'Initial Definition') - - if (node.stopLoss !== undefined) { - createPartFromNode(node.stopLoss, node, node) - } - if (node.takeProfit !== undefined) { - createPartFromNode(node.takeProfit, node, node) - } - if (node.positionSize !== undefined) { - createPartFromNode(node.positionSize, node, node) - } - if (node.positionRate !== undefined) { - createPartFromNode(node.positionRate, node, node) - } - return - } - case 'Take Position Event': { - let event = node - createPart('Take Position Event', event.name, event, parentNode, chainParent, 'Take Position Event') - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createPartFromNode(situation, event, event) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createPartFromNode(announcement, node, node) - } - return - } - case 'Trigger On Event': { - let event = node - createPart('Trigger On Event', event.name, event, parentNode, chainParent, 'Trigger On Event') - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createPartFromNode(situation, event, event) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createPartFromNode(announcement, node, node) - } - return - } - case 'Trigger Off Event': { - let event = node - createPart('Trigger Off Event', event.name, event, parentNode, chainParent, 'Trigger Off Event') - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createPartFromNode(situation, event, event) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createPartFromNode(announcement, node, node) - } - return - } - case 'Position Size': { - createPart('Position Size', node.name, node, parentNode, chainParent, 'Position Size') - if (node.formula !== undefined) { - createPartFromNode(node.formula, node, node) - } - return - } - case 'Position Rate': { - createPart('Position Rate', node.name, node, parentNode, chainParent, 'Position Rate') - if (node.formula !== undefined) { - createPartFromNode(node.formula, node, node) - } - return - } - case 'Trigger Stage': { - let stage = node - createPart('Trigger Stage', stage.name, stage, parentNode, chainParent, 'Trigger Stage') - - if (node.triggerOn !== undefined) { - createPartFromNode(node.triggerOn, stage, stage) - } - if (node.triggerOff !== undefined) { - createPartFromNode(node.triggerOff, stage, stage) - } - if (node.takePosition !== undefined) { - createPartFromNode(node.takePosition, stage, stage) - } - return - } - case 'Open Stage': { - let stage = node - createPart('Open Stage', stage.name, stage, parentNode, chainParent, 'Open Stage') - - if (node.initialDefinition !== undefined) { - createPartFromNode(node.initialDefinition, stage, stage) - } - if (node.openExecution !== undefined) { - createPartFromNode(node.openExecution, stage, stage) - } - return - } - case 'Manage Stage': { - let stage = node - createPart('Manage Stage', stage.name, stage, parentNode, chainParent, 'Manage Stage') - - if (node.stopLoss !== undefined) { - createPartFromNode(node.stopLoss, stage, stage) - } - if (node.takeProfit !== undefined) { - createPartFromNode(node.takeProfit, stage, stage) - } - return - } - case 'Close Stage': { - let stage = node - createPart('Close Stage', stage.name, stage, parentNode, chainParent, 'Close Stage') - - if (node.closeExecution !== undefined) { - createPartFromNode(node.closeExecution, stage, stage) - } - return - } - case 'Strategy': { - let strategy = node - createPart('Strategy', strategy.name, strategy, parentNode, chainParent, 'Strategy') - if (node.triggerStage !== undefined) { - createPartFromNode(node.triggerStage, strategy, strategy) - } - if (node.openStage !== undefined) { - createPartFromNode(node.openStage, strategy, strategy) - } - if (node.manageStage !== undefined) { - createPartFromNode(node.manageStage, strategy, strategy) - } - if (node.closeStage !== undefined) { - createPartFromNode(node.closeStage, strategy, strategy) - } - return - } - case 'Base Asset': { - createPart('Base Asset', node.name, node, parentNode, chainParent, 'Base Asset') - return - } - case 'Time Range': { - createPart('Time Range', node.name, node, parentNode, chainParent, 'Time Range') - return - } - case 'Time Period': { - createPart('Time Period', node.name, node, parentNode, chainParent, 'Time Period') - return - } - case 'Slippage': { - createPart('Slippage', node.name, node, parentNode, chainParent, 'Slippage') - return - } - case 'Fee Structure': { - createPart('Fee Structure', node.name, node, parentNode, chainParent, 'Fee Structure') - return - } - case 'Parameters': { - createPart('Parameters', node.name, node, parentNode, chainParent, 'Parameters') - if (node.baseAsset !== undefined) { - createPartFromNode(node.baseAsset, node, node) - } - if (node.timeRange !== undefined) { - createPartFromNode(node.timeRange, node, node) - } - if (node.timePeriod !== undefined) { - createPartFromNode(node.timePeriod, node, node) - } - if (node.slippage !== undefined) { - createPartFromNode(node.slippage, node, node) - } - if (node.feeStructure !== undefined) { - createPartFromNode(node.feeStructure, node, node) - } - if (node.key !== undefined) { - createPartFromNode(node.key, node, node) - } - return - } - case 'Trading System': { - let tradingSystem = node - createPart('Trading System', tradingSystem.name, tradingSystem, parentNode, chainParent, 'Trading System') - for (let m = 0; m < node.strategies.length; m++) { - let strategy = node.strategies[m] - createPartFromNode(strategy, tradingSystem, tradingSystem) - } - if (node.parameters !== undefined) { - createPartFromNode(node.parameters, node, node) - } - return - } - case 'Workspace': { - let workspace = node - createPart('Workspace', workspace.name, workspace, parentNode, chainParent, 'Workspace') - return - } - case 'Personal Data': { - createPart('Personal Data', node.name, node, parentNode, chainParent, 'Personal Data') - for (let m = 0; m < node.exchangeAccounts.length; m++) { - let exchangeAccount = node.exchangeAccounts[m] - createPartFromNode(exchangeAccount, node, node) - } - return - } - case 'Exchange Account': { - createPart('Exchange Account', node.name, node, parentNode, chainParent, 'Exchange Account') - for (let m = 0; m < node.assets.length; m++) { - let asset = node.assets[m] - createPartFromNode(asset, node, node) - } - for (let m = 0; m < node.keys.length; m++) { - let key = node.keys[m] - createPartFromNode(key, node, node) - } - return - } - case 'Exchange Account Asset': { - createPart('Exchange Account Asset', node.name, node, parentNode, chainParent, 'Exchange Account Asset') - return - } - case 'Exchange Account Key': { - createPart('Exchange Account Key', node.name, node, parentNode, chainParent, 'Exchange Account Key') - return - } - case 'Definition': { - createPart('Definition', node.name, node, parentNode, chainParent, 'Definition') - if (node.tradingSystem !== undefined) { - createPartFromNode(node.tradingSystem, node, node) - } - if (node.personalData !== undefined) { - createPartFromNode(node.personalData, node, node) - } - if (node.network !== undefined) { - createPartFromNode(node.network, node, node) - } - return - } - case 'Network': { - createPart('Network', node.name, node, parentNode, chainParent, 'Network') - if (node.networkNodes !== undefined) { - for (let m = 0; m < node.networkNodes.length; m++) { - let networkNode = node.networkNodes[m] - createPartFromNode(networkNode, node, node) - } - } - return - } - case 'Network Node': { - createPart('Network Node', node.name, node, parentNode, chainParent, 'Network Node') - if (node.taskManagers !== undefined) { - for (let m = 0; m < node.taskManagers.length; m++) { - let taskManager = node.taskManagers[m] - createPartFromNode(taskManager, node, node) - } - } - return - } - case 'Social Bots': { - createPart('Social Bots', node.name, node, parentNode, chainParent, 'Social Bots') - for (let m = 0; m < node.bots.length; m++) { - let bot = node.bots[m] - createPartFromNode(bot, node, node) - } - return - } - case 'Telegram Bot': { - createPart('Telegram Bot', node.name, node, parentNode, chainParent, 'Telegram Bot') - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createPartFromNode(announcement, node, node) - } - return - } - case 'Announcement': { - createPart('Announcement', node.name, node, parentNode, chainParent, 'Announcement') - if (node.formula !== undefined) { - createPartFromNode(node.formula, node, node) - } - return - } - case 'Layer Manager': { - createPart('Layer Manager', node.name, node, parentNode, chainParent, 'Layer Manager') - for (let m = 0; m < node.layers.length; m++) { - let layer = node.layers[m] - createPartFromNode(layer, node, node) - } - return - } - case 'Layer': { - createPart('Layer', node.name, node, parentNode, chainParent, 'Layer') - return - } - case 'Task Manager': { - createPart('Task Manager', node.name, node, parentNode, chainParent, 'Task Manager') - for (let m = 0; m < node.tasks.length; m++) { - let task = node.tasks[m] - createPartFromNode(task, node, node) - } - return - } - case 'Task': { - createPart('Task', node.name, node, parentNode, chainParent, 'Task') - if (node.bot !== undefined) { - createPartFromNode(node.bot, node, node) - } - return - } - case 'Sensor': { - createPart('Sensor', node.name, node, parentNode, chainParent, 'Sensor') - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createPartFromNode(process, node, node) - } - return - } - case 'Indicator': { - createPart('Indicator', node.name, node, parentNode, chainParent, 'Indicator') - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createPartFromNode(process, node, node) - } - return - } - case 'Trading Engine': { - createPart('Trading Engine', node.name, node, parentNode, chainParent, 'Trading Engine') - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createPartFromNode(process, node, node) - } - return - } - case 'Process': { - if (parentNode !== undefined) { - switch (parentNode.type) { - case 'Sensor': { - node.subType = 'Sensor Process' - break - } - case 'Indicator': { - node.subType = 'Indicator Process' - break - } - case 'Trading Engine': { - node.subType = 'Trading Engine Process' - break - } - } - } - createPart('Process', node.name, node, parentNode, chainParent, 'Process') - if (node.session !== undefined) { - createPartFromNode(node.session, node, node) - } - return - } - case 'Backtesting Session': { - createPart('Backtesting Session', node.name, node, parentNode, chainParent, 'Backtesting Session') - if (node.parameters !== undefined) { - createPartFromNode(node.parameters, node, node) - } - if (node.layerManager !== undefined) { - createPartFromNode(node.layerManager, node, node) - } - if (node.socialBots !== undefined) { - createPartFromNode(node.socialBots, node, node) - } - return - } - case 'Live Trading Session': { - createPart('Live Trading Session', node.name, node, parentNode, chainParent, 'Live Trading Session') - if (node.parameters !== undefined) { - createPartFromNode(node.parameters, node, node) - } - if (node.layerManager !== undefined) { - createPartFromNode(node.layerManager, node, node) - } - if (node.socialBots !== undefined) { - createPartFromNode(node.socialBots, node, node) - } - return - } - case 'Fordward Testing Session': { - createPart('Fordward Testing Session', node.name, node, parentNode, chainParent, 'Fordward Testing Session') - if (node.parameters !== undefined) { - createPartFromNode(node.parameters, node, node) - } - if (node.layerManager !== undefined) { - createPartFromNode(node.layerManager, node, node) - } - if (node.socialBots !== undefined) { - createPartFromNode(node.socialBots, node, node) - } - return - } - case 'Paper Trading Session': { - createPart('Paper Trading Session', node.name, node, parentNode, chainParent, 'Paper Trading Session') - if (node.parameters !== undefined) { - createPartFromNode(node.parameters, node, node) - } - if (node.layerManager !== undefined) { - createPartFromNode(node.layerManager, node, node) - } - if (node.socialBots !== undefined) { - createPartFromNode(node.socialBots, node, node) - } - return - } - } - } - - function addNetwork (node) { - if (node.network === undefined) { - node.network = { - name: 'Superalgos' - } - createPart('Network', node.network.name, node.network, node, node, 'Network') - } - - return node.network - } - - function addNetworkNode (node) { - let networkNode = { - name: 'New Network Node' - } - if (node.networkNodes === undefined) { - node.networkNodes = [] - } - node.networkNodes.push(networkNode) - createPart('Network Node', networkNode.name, networkNode, node, node, 'Network Node') - - return networkNode - } - - function addSocialBots (node) { - if (node.socialBots === undefined) { - node.socialBots = { - name: 'New Social Bots', - bots: [] - } - createPart('Social Bots', node.socialBots.name, node.socialBots, node, node, 'Social Bots') - } - - return node.socialBots - } - - function addTelegramBot (node) { - let bot = { - name: 'New Telegram Bot', - code: '{ \n\"botToken\": \"Paste here the bot token obtained from Telegram Bot Father\",\n\"chatId\": Write here the chat or group id where the announcements are going to be sent to, as it is a number with no quotes please.\n}', - announcements: [] - } - node.bots.push(bot) - createPart('Telegram Bot', bot.name, bot, node, node, 'Telegram Bot') - - return bot - } - - function addAnnouncement (node) { - let announcement = { - name: 'Announcement via ' + node.type, - code: '{ \n\"text\": \"Write here what you want to announce.\",\n\"botType\": \"' + node.type + '\",\n\"botId\": \"' + node.id + '\"\n}' - } - node.announcements.push(announcement) - createPart('Announcement', announcement.name, announcement, node, node, 'Announcement') - - return announcement - } - - function addLayerManager (node) { - if (node.layerManager === undefined) { - node.layerManager = { - name: 'New Layer Manager', - layers: [] - } - createPart('Layer Manager', node.layerManager.name, node.layerManager, node, node, 'Layer Manager') - } - - return node.layerManager - } - - function addLayer (node) { - let layer = { - name: 'New Layer', - code: '{}' - } - node.layers.push(layer) - createPart('Layer', layer.name, layer, node, node, 'Layer') - - return layer - } - - function addTaskManager (node) { - let taskManager = { - name: 'New Task Manager', - tasks: [] - } - if (node.taskManagers === undefined) { - node.taskManagers = [] - } - node.taskManagers.push(taskManager) - createPart('Task Manager', taskManager.name, taskManager, node, node, 'Task Manager') - - return taskManager - } - - function addTask (node) { - let task = { - name: 'New Task' - } - node.tasks.push(task) - createPart('Task', task.name, task, node, node, 'Task') - - return task - } - - function addSensor (node) { - if (node.bot === undefined) { - node.bot = { - processes: [], - code: '{}' - } - createPart('Sensor', '', node.bot, node, node) - } - return node.bot - } - - function addIndicator (node) { - if (node.bot === undefined) { - node.bot = { - processes: [], - code: '{}' - } - createPart('Indicator', '', node.bot, node, node) - } - return node.bot - } - - function addTradingEngine (node) { - if (node.bot === undefined) { - node.bot = { - processes: [], - code: '{}' - } - createPart('Trading Engine', '', node.bot, node, node) - } - return node.bot - } - - function addProcess (node) { - let process = { - name: 'New Process', - code: '{}' - } - - switch (node.type) { - case 'Sensor': { - process.subType = 'Sensor Process' - process.name = 'Sensor Process' - break - } - case 'Indicator': { - process.subType = 'Indicator Process' - process.name = 'Indicator Process' - break - } - case 'Trading Engine': { - process.subType = 'Trading Engine Process' - process.name = 'Trading Engine Process' - break - } - } - node.processes.push(process) - createPart('Process', process.name, process, node, node, 'Process') - - return process - } - - function addBacktestingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Backtesting Session', - code: '{}' - } - createPart('Backtesting Session', '', node.session, node, node) - } - - return node.session - } - - function addLiveTradingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Live Trading Session', - code: '{}' - } - createPart('Live Trading Session', '', node.session, node, node) - } - - return node.session - } - - function addFordwardTestingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Fordward Testing Session', - code: '{}' - } - createPart('Fordward Testing Session', '', node.session, node, node) - } - - return node.session - } - - function addPaperTradingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Paper Trading Session', - code: '{}' - } - createPart('Paper Trading Session', '', node.session, node, node) - } - - return node.session - } - - function addDefinition (node) { - let definition = { - name: 'New Definition' - } - node.rootNodes.push(definition) - createPart('Definition', definition.name, definition, node, undefined, 'Definition') - - return definition - } - - function addTradingSystem (node) { - if (node.tradingSystem === undefined) { - node.tradingSystem = { - strategies: [] - } - createPart('Trading System', '', node.tradingSystem, node, node) - } - return node.tradingSystem - } - - function addPersonalData (node) { - if (node.personalData === undefined) { - node.personalData = { - exchangeAccounts: [] - } - createPart('Personal Data', '', node.personalData, node, node) - } - - return node.personalData - } - - function addExchangeAccount (parentNode) { - let personalData = parentNode - let exchangeAccount = { - name: 'New Account', - assets: [], - keys: [] - } - personalData.exchangeAccounts.push(exchangeAccount) - createPart('Exchange Account', exchangeAccount.name, exchangeAccount, personalData, personalData, 'Exchange Account') - - return exchangeAccount - } - - function addExchangeAccountAsset (parentNode) { - let exchangeAccount = parentNode - let asset = { - name: 'New Asset' - } - exchangeAccount.assets.push(asset) - createPart('Exchange Account Asset', asset.name, asset, exchangeAccount, exchangeAccount, 'Account Asset') - - return asset - } - - function addExchangeAccountKey (parentNode) { - let exchangeAccount = parentNode - let key = { - name: 'New Key', - code: 'Paste your exchange API secret key here and the put the key name as this key object title. Secret keys are filtered out and NOT exported when using the SHARE menu option on any object at your workspace. Secret keys ARE downloaded when using the download button.' - } - exchangeAccount.keys.push(key) - createPart('Exchange Account Key', key.name, key, exchangeAccount, exchangeAccount, 'Account Key') - - return key - } - - function addStrategy (parentNode) { - let strategyParent = parentNode - let strategy = { - name: 'New Strategy', - active: true, - triggerStage: { - triggerOn: { - situations: [] - }, - triggerOff: { - situations: [] - }, - takePosition: { - situations: [] - }, - positionSize: { - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - }, - openStage: { - initialDefinition: { - stopLoss: { - phases: [], - maxPhases: 1 - }, - takeProfit: { - phases: [], - maxPhases: 1 - } - } - }, - manageStage: { - stopLoss: { - phases: [] - }, - takeProfit: { - phases: [] - } - }, - closeStage: { - } - } - - strategyParent.strategies.push(strategy) - createPart('Strategy', strategy.name, strategy, strategyParent, strategyParent, 'Strategy') - createPart('Trigger Stage', '', strategy.triggerStage, strategy, strategy, 'Trigger Stage') - createPart('Open Stage', '', strategy.openStage, strategy, strategy, 'Open Stage') - createPart('Manage Stage', '', strategy.manageStage, strategy, strategy, 'Manage Stage') - createPart('Close Stage', '', strategy.closeStage, strategy, strategy, 'Close Stage') - createPart('Trigger On Event', '', strategy.triggerStage.triggerOn, strategy.triggerStage, strategy.triggerStage) - createPart('Trigger Off Event', '', strategy.triggerStage.triggerOff, strategy.triggerStage, strategy.triggerStage) - createPart('Take Position Event', '', strategy.triggerStage.takePosition, strategy.triggerStage, strategy.triggerStage) - createPart('Initial Definition', '', strategy.openStage.initialDefinition, strategy.openStage, strategy.openStage) - createPart('Position Size', '', strategy.openStage.initialDefinition.positionSize, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createPart('Position Rate', '', strategy.openStage.initialDefinition.positionRate, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createPart('Stop', '', strategy.manageStage.stopLoss, strategy.manageStage, strategy.manageStage) - createPart('Take Profit', '', strategy.manageStage.takeProfit, strategy.manageStage, strategy.manageStage) - createPart('Stop', 'Initial Stop', strategy.openStage.initialDefinition.stopLoss, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createPart('Take Profit', 'Initial Take Profit', strategy.openStage.initialDefinition.takeProfit, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createPart('Formula', '', strategy.triggerStage.positionSize.formula, strategy.triggerStage.positionSize, strategy.triggerStage.positionSize) - - return strategy - } - - function addParameters (node) { - if (node.parameters === undefined) { - node.parameters = { - name: 'Parameters' - } - createPart('Parameters', '', node.parameters, node, node) - addMissingParameters(node.parameters) - } - - return node.parameters - } - - function addMissingParameters (node) { - if (node.baseAsset === undefined) { - node.baseAsset = { - name: 'Base Asset', - code: DEFAULT_CONFIG_TEXT - } - createPart('Base Asset', '', node.baseAsset, node, node) - } - if (node.timeRange === undefined) { - node.timeRange = { - name: 'Time Range', - code: DEFAULT_CONFIG_TEXT - } - createPart('Time Range', '', node.timeRange, node, node) - } - if (node.timePeriod === undefined) { - node.timePeriod = { - name: 'Time Period', - code: DEFAULT_CONFIG_TEXT - } - createPart('Time Period', '', node.timePeriod, node, node) - } - if (node.slippage === undefined) { - node.slippage = { - name: 'Slippage', - code: DEFAULT_CONFIG_TEXT - } - createPart('Slippage', '', node.slippage, node, node) - } - if (node.feeStructure === undefined) { - node.feeStructure = { - name: 'Fee Structure', - code: DEFAULT_CONFIG_TEXT - } - createPart('Fee Structure', '', node.feeStructure, node, node) - } - } - - function addMissingStages (node) { - if (node.triggerStage === undefined) { - node.triggerStage = { - triggerOn: { - situations: [] - }, - triggerOff: { - situations: [] - }, - takePosition: { - situations: [] - }, - positionSize: { - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - } - createPart('Trigger Stage', '', node.triggerStage, node, node, 'Trigger Stage') - createPart('Trigger On Event', '', node.triggerStage.triggerOn, node.triggerStage, node.triggerStage) - createPart('Trigger Off Event', '', node.triggerStage.triggerOff, node.triggerStage, node.triggerStage) - createPart('Take Position Event', '', node.triggerStage.takePosition, node.triggerStage, node.triggerStage) - createPart('Formula', '', node.triggerStage.positionSize.formula, node.triggerStage.positionSize, node.triggerStage.positionSize) - } - if (node.openStage === undefined) { - node.openStage = { - initialDefinition: { - stopLoss: { - phases: [], - maxPhases: 1 - }, - takeProfit: { - phases: [], - maxPhases: 1 - } - } - } - createPart('Open Stage', '', node.openStage, node, node, 'Open Stage') - createPart('Initial Definition', '', node.openStage.initialDefinition, node.openStage, node.openStage) - createPart('Stop', 'Initial Stop', node.openStage.initialDefinition.stopLoss, node.openStage.initialDefinition, node.openStage.initialDefinition) - createPart('Take Profit', 'Initial Take Profit', node.openStage.initialDefinition.takeProfit, node.openStage.initialDefinition, node.openStage.initialDefinition) - createPart('Position Size', 'Position Size', node.openStage.initialDefinition.positionSize, node.openStage.initialDefinition, node.openStage.initialDefinition) - createPart('Position Rate', 'Position Rate', node.openStage.initialDefinition.positionRate, node.openStage.initialDefinition, node.openStage.initialDefinition) - } - if (node.manageStage === undefined) { - node.manageStage = { - stopLoss: { - phases: [] - }, - takeProfit: { - phases: [] - } - } - createPart('Manage Stage', '', node.manageStage, node, node, 'Manage Stage') - createPart('Stop', '', node.manageStage.stopLoss, node.manageStage, node.manageStage) - createPart('Take Profit', '', node.manageStage.takeProfit, node.manageStage, node.manageStage) - } - if (node.closeStage === undefined) { - node.closeStage = { - } - createPart('Close Stage', '', node.closeStage, node, node, 'Close Stage') - } - } - - function addMissingEvents (node) { - if (node.triggerOn === undefined) { - node.triggerOn = { - situations: [], - announcements: [] - } - createPart('Trigger On Event', '', node.triggerOn, node, node) - } - if (node.triggerOff === undefined) { - node.triggerOff = { - situations: [], - announcements: [] - } - createPart('Trigger Off Event', '', node.triggerOff, node, node) - } - if (node.takePosition === undefined) { - node.takePosition = { - situations: [], - announcements: [] - } - createPart('Take Position Event', '', node.takePosition, node, node) - } - } - - function addMissingItems (node) { - if (node.type === 'Initial Definition') { - if (node.stopLoss === undefined) { - node.stopLoss = { - phases: [], - maxPhases: 1 - } - createPart('Stop', 'Initial Stop', node.stopLoss, node, node) - } - if (node.takeProfit === undefined) { - node.takeProfit = { - phases: [], - maxPhases: 1 - } - createPart('Take Profit', 'Initial Take Profit', node.takeProfit, node, node) - } - if (node.positionSize === undefined) { - node.positionSize = { - name: 'Position Size', - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - createPart('Position Size', '', node.positionSize, node, node) - createPart('Formula', '', node.positionSize.formula, node.positionSize, node.positionSize) - } - if (node.positionRate === undefined) { - node.positionRate = { - name: 'Position Rate', - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - createPart('Position Rate', '', node.positionRate, node, node) - createPart('Formula', '', node.positionRate.formula, node.positionRate, node.positionRate) - } - } else { - if (node.stopLoss === undefined) { - node.stopLoss = { - phases: [] - } - createPart('Stop', '', node.stopLoss, node, node) - } - if (node.takeProfit === undefined) { - node.takeProfit = { - phases: [] - } - createPart('Take Profit', '', node.takeProfit, node, node) - } - } - } - - function addInitialDefinition (node) { - if (node.initialDefinition === undefined) { - node.initialDefinition = { - stopLoss: { - phases: [], - maxPhases: 1 - }, - takeProfit: { - phases: [], - maxPhases: 1 - } - } - createPart('Initial Definition', '', node.initialDefinition, node, node) - createPart('Stop', 'Initial Stop', node.initialDefinition.stopLoss, node.initialDefinition, node.initialDefinition) - createPart('Take Profit', 'Initial Take Profit', node.initialDefinition.takeProfit, node.initialDefinition, node.initialDefinition) - createPart('Position Size', '', node.initialDefinition.positionSize, node.initialDefinition, node.initialDefinition) - createPart('Formula', '', node.initialDefinition.positionSize.formula, node.initialDefinition.positionSize, node.initialDefinition.positionSize) - createPart('Position Rate', '', node.initialDefinition.positionRate, node.initialDefinition, node.initialDefinition) - createPart('Formula', '', node.initialDefinition.positionRate.formula, node.initialDefinition.positionRate, node.initialDefinition.positionRate) - } - - return node.initialDefinition - } - - function addOpenExecution (node) { - if (node.openExecution === undefined) { - node.openExecution = {} - createPart('Open Execution', '', node.openExecution, node, node) - } - - return node.openExecution - } - - function addCloseExecution (node) { - if (node.closeExecution === undefined) { - node.closeExecution = {} - createPart('Close Execution', '', node.closeExecution, node, node) - } - - return node.closeExecution - } - - function addFormula (node) { - if (node.formula === undefined) { - node.formula = { - code: DEFAULT_FORMULA_TEXT - } - createPart('Formula', '', node.formula, node, node) - } - - return node.formula - } - - function addNextPhaseEvent (node) { - if (node.nextPhaseEvent === undefined) { - node.nextPhaseEvent = { - situations: [], - announcements: [] - } - createPart('Next Phase Event', '', node.nextPhaseEvent, node, node) - } - - return node.nextPhaseEvent - } - - function addCode (node) { - if (node.code === undefined) { - node.code = { - code: DEFAULT_CODE_TEXT - } - createPart('Code', '', node.code, node, node) - } - - return node.code - } - - function addPhase (parentNode) { - if (parentNode.maxPhases !== undefined) { - if (parentNode.phases.length >= parentNode.maxPhases) { - return - } - } - let phaseParent = parentNode - let m = phaseParent.phases.length - - if (phaseParent.payload.parentNode !== undefined) { - if (phaseParent.payload.parentNode.type === 'Initial Definition' && m > 0) { return } - } - - let phase = { - name: 'New Phase', - announcements: [], - formula: { - code: DEFAULT_FORMULA_TEXT - }, - nextPhaseEvent: { - situations: [] - } - } - phaseParent.phases.push(phase) - let phaseChainParent - if (m > 0) { - phaseChainParent = phaseParent.phases[m - 1] - } else { - phaseChainParent = phaseParent - } - createPart('Phase', phase.name, phase, phaseParent, phaseChainParent, 'Phase') - createPart('Formula', '', phase.formula, phase, phase, 'Formula') - createPart('Next Phase Event', '', phase.nextPhaseEvent, phase, phase) - - return phase - } - - function addSituation (parentNode) { - let m = parentNode.situations.length - let situation = { - name: 'New Situation', - conditions: [] - } - parentNode.situations.push(situation) - createPart('Situation', situation.name, situation, parentNode, parentNode, 'Situation') - - return situation - } - - function addCondition (parentNode) { - let situation = parentNode - let m = situation.conditions.length - let condition = { - name: 'New Condition', - code: { - code: DEFAULT_CODE_TEXT - } - } - situation.conditions.push(condition) - createPart('Condition', condition.name, condition, situation, situation, 'Condition') - createPart('Code', '', condition.code, condition, condition, 'Code') - - return condition - } - - function createPart (partType, name, node, parentNode, chainParent, title) { - let payload = {} - - if (name === '' || name === undefined) { name = 'My ' + partType } - if (node.savedPayload !== undefined) { - payload.targetPosition = { - x: node.savedPayload.targetPosition.x, - y: node.savedPayload.targetPosition.y - } - node.savedPayload.targetPosition = undefined - - if (payload.targetPosition.x === null) { payload.targetPosition.x = spawnPosition.x } - if (payload.targetPosition.y === null) { payload.targetPosition.y = spawnPosition.y } - } else { - if (chainParent === undefined) { - payload.targetPosition = { - x: spawnPosition.x, - y: spawnPosition.y - } - if (partType === 'Workspace' || partType === 'Trading System') { - payload.position = { - x: spawnPosition.x, - y: spawnPosition.y - } - } - } else { - payload.targetPosition = { - x: chainParent.payload.position.x, - y: chainParent.payload.position.y - } - } - } - - if (title !== undefined) { - payload.subTitle = title - } else { - payload.subTitle = partType - } - - payload.visible = true - payload.title = name - payload.node = node - payload.parentNode = parentNode - payload.chainParent = chainParent - payload.onMenuItemClick = canvas.strategySpace.workspace.onMenuItemClick - - if (node.id === undefined) { - node.id = newUniqueId() - } - node.payload = payload - node.type = partType - canvas.floatingSpace.strategyPartConstructor.createStrategyPart(payload) - } -} diff --git a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js deleted file mode 100644 index 4d28635ed..000000000 --- a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js +++ /dev/null @@ -1,1048 +0,0 @@ -function newProtocolNode () { - thisObject = { - getProtocolNode: getProtocolNode - } - return thisObject - - function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload) { - if (node === undefined) { return } - switch (node.type) { - case 'Code': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Condition': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Situation': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - conditions: [] - } - - for (let m = 0; m < node.conditions.length; m++) { - let condition = getProtocolNode(node.conditions[m], removePersonalData, parseCode, includeIds, includePayload) - if (condition !== undefined) { - object.conditions.push(condition) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Formula': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Next Phase Event': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload) - if (situation !== undefined) { - object.situations.push(situation) - } - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Phase': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - announcements: [], - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload), - nextPhaseEvent: getProtocolNode(node.nextPhaseEvent, removePersonalData, parseCode, includeIds, includePayload) - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Stop': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - phases: [] - } - - for (let m = 0; m < node.phases.length; m++) { - let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds, includePayload) - if (phase !== undefined) { - object.phases.push(phase) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Take Profit': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - phases: [] - } - - for (let m = 0; m < node.phases.length; m++) { - let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds, includePayload) - if (phase !== undefined) { - object.phases.push(phase) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Take Position Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload) - if (situation !== undefined) { - object.situations.push(situation) - } - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Trigger On Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload) - object.situations.push(situation) - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Trigger Off Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload) - if (situation !== undefined) { - object.situations.push(situation) - } - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Initial Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds, includePayload), - takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds, includePayload), - positionSize: getProtocolNode(node.positionSize, removePersonalData, parseCode, includeIds, includePayload), - positionRate: getProtocolNode(node.positionRate, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Open Execution': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Close Execution': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Position Size': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Position Rate': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Trigger Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - triggerOn: getProtocolNode(node.triggerOn, removePersonalData, parseCode, includeIds, includePayload), - triggerOff: getProtocolNode(node.triggerOff, removePersonalData, parseCode, includeIds, includePayload), - takePosition: getProtocolNode(node.takePosition, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Open Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - initialDefinition: getProtocolNode(node.initialDefinition, removePersonalData, parseCode, includeIds, includePayload), - openExecution: getProtocolNode(node.openExecution, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Manage Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds, includePayload), - takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Close Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - closeExecution: getProtocolNode(node.closeExecution, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Strategy': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - triggerStage: getProtocolNode(node.triggerStage, removePersonalData, parseCode, includeIds, includePayload), - openStage: getProtocolNode(node.openStage, removePersonalData, parseCode, includeIds, includePayload), - manageStage: getProtocolNode(node.manageStage, removePersonalData, parseCode, includeIds, includePayload), - closeStage: getProtocolNode(node.closeStage, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Base Asset': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Time Range': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Time Period': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Slippage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Fee Structure': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Parameters': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - baseAsset: getProtocolNode(node.baseAsset, removePersonalData, parseCode, includeIds, includePayload), - timeRange: getProtocolNode(node.timeRange, removePersonalData, parseCode, includeIds, includePayload), - timePeriod: getProtocolNode(node.timePeriod, removePersonalData, parseCode, includeIds, includePayload), - slippage: getProtocolNode(node.slippage, removePersonalData, parseCode, includeIds, includePayload), - feeStructure: getProtocolNode(node.feeStructure, removePersonalData, parseCode, includeIds, includePayload), - key: getProtocolNode(node.key, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Trading System': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - strategies: [], - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload) - } - - for (let m = 0; m < node.strategies.length; m++) { - let strategy = getProtocolNode(node.strategies[m], removePersonalData, parseCode, includeIds, includePayload) - if (strategy !== undefined) { - object.strategies.push(strategy) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Personal Data': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - exchangeAccounts: [] - } - - for (let m = 0; m < node.exchangeAccounts.length; m++) { - let exchangeAccount = getProtocolNode(node.exchangeAccounts[m], removePersonalData, parseCode, includeIds, includePayload) - if (exchangeAccount !== undefined) { - object.exchangeAccounts.push(exchangeAccount) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Exchange Account': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - assets: [], - keys: [] - } - - for (let m = 0; m < node.assets.length; m++) { - let asset = getProtocolNode(node.assets[m], removePersonalData, parseCode, includeIds, includePayload) - if (asset !== undefined) { - object.assets.push(asset) - } - } - for (let m = 0; m < node.keys.length; m++) { - let key = getProtocolNode(node.keys[m], removePersonalData, parseCode, includeIds, includePayload) - if (key !== undefined) { - object.keys.push(key) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Exchange Account Asset': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Exchange Account Key': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Social Bots': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - bots: [] - } - - for (let m = 0; m < node.bots.length; m++) { - let bot = getProtocolNode(node.bots[m], removePersonalData, parseCode, includeIds, includePayload) - if (bot !== undefined) { - object.bots.push(bot) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Telegram Bot': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - announcements: [] - } - - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Announcement': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Layer Manager': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - layers: [] - } - - for (let m = 0; m < node.layers.length; m++) { - let layer = getProtocolNode(node.layers[m], removePersonalData, parseCode, includeIds, includePayload) - if (layer !== undefined) { - object.layers.push(layer) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Layer': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Task Manager': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - tasks: [] - } - - for (let m = 0; m < node.tasks.length; m++) { - let task = getProtocolNode(node.tasks[m], removePersonalData, parseCode, includeIds, includePayload) - if (task !== undefined) { - object.tasks.push(task) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Task': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - bot: getProtocolNode(node.bot, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Sensor': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [] - } - - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload) - if (process !== undefined) { - object.processes.push(process) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Indicator': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [] - } - - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload) - if (process !== undefined) { - object.processes.push(process) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Trading Engine': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [] - } - - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload) - if (process !== undefined) { - object.processes.push(process) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Process': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - session: getProtocolNode(node.session, removePersonalData, parseCode, includeIds, includePayload) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Backtesting Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload) - } - if (parseCode) { - object.code = JSON.parse(object.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Live Trading Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Fordward Testing Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload) - } - if (parseCode) { - object.code = JSON.parse(object.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Paper Trading Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Network Node': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - taskManagers: [] - } - if (node.taskManagers !== undefined) { - for (let m = 0; m < node.taskManagers.length; m++) { - let taskManager = getProtocolNode(node.taskManagers[m], removePersonalData, parseCode, includeIds, includePayload) - if (taskManager !== undefined) { - object.taskManagers.push(taskManager) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Network': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - networkNodes: [] - } - if (node.networkNodes !== undefined) { - for (let m = 0; m < node.networkNodes.length; m++) { - let networkNode = getProtocolNode(node.networkNodes[m], removePersonalData, parseCode, includeIds, includePayload) - if (networkNode !== undefined) { - object.networkNodes.push(networkNode) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - case 'Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - tradingSystem: getProtocolNode(node.tradingSystem, removePersonalData, parseCode, includeIds, includePayload), - personalData: getProtocolNode(node.personalData, removePersonalData, parseCode, includeIds, includePayload), - network: getProtocolNode(node.network, removePersonalData, parseCode, includeIds, includePayload) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node) - } - return object - } - } - } - - function getSavedPayload (node) { - if (node.payload === undefined) { - console.log(node) - } - let savedPayload = { - position: { - x: node.payload.position.x, - y: node.payload.position.y - }, - targetPosition: { - x: node.payload.targetPosition.x, - y: node.payload.targetPosition.y - }, - floatingObject: { - isPinned: node.payload.floatingObject.isPinned, - isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), - isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) - }, - uiObject: { - isRunning: node.payload.uiObject.isRunning, - shortcutKey: node.payload.uiObject.shortcutKey - } - } - return savedPayload - } -} diff --git a/SystemEventHandler.js b/SystemEventHandler.js index 740048d48..07618cbf8 100644 --- a/SystemEventHandler.js +++ b/SystemEventHandler.js @@ -4,6 +4,7 @@ function newSystemEventHandler () { const MODULE_NAME = 'System Event Handler' const ERROR_LOG = true + const INFO_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME @@ -12,6 +13,7 @@ function newSystemEventHandler () { let thisObject = { initialize: initialize, + physics: physics, createEventHandler: createEventHandler, deleteEventHandler: deleteEventHandler, listenToEvent: listenToEvent, @@ -95,6 +97,17 @@ function newSystemEventHandler () { sendCommand(eventCommand, responseCallBack) } + function physics () { + if (WEB_SOCKETS_CONNECTION !== undefined) { + if (WEB_SOCKETS_CONNECTION.readyState === 3) { // Connection closed. May happen after computer goes to sleep. + setuptWebSockets(onOpen) + function onOpen () { + if (INFO_LOG === true) { logger.write('[INFO] setuptWebSockets -> Found Web Sockets Connection Closed. Reconnected to WebSockets Server.') } + } + } + } + } + function setuptWebSockets (callBackFunction) { try { WEB_SOCKETS_CONNECTION = new WebSocket(WEB_SOCKETS_URL) @@ -105,7 +118,9 @@ function newSystemEventHandler () { console.log('WebSocket error:' + JSON.stringify(error)) } WEB_SOCKETS_CONNECTION.onopen = () => { - callBackFunction() + if (callBackFunction !== undefined) { + callBackFunction() + } } WEB_SOCKETS_CONNECTION.onmessage = e => { // console.log('Websoked Message Received: ' + e.data) diff --git a/Utilities/RoundedCornersBackground.js b/Utilities/RoundedCornersBackground.js index a940c81c8..557f1de72 100644 --- a/Utilities/RoundedCornersBackground.js +++ b/Utilities/RoundedCornersBackground.js @@ -1,6 +1,7 @@ function roundedCornersBackground (params) { + if (params.xOffset === undefined) { params.xOffset = 0 } borderPoint1 = { - x: params.cornerRadius, + x: params.cornerRadius + params.xOffset, y: params.cornerRadius } @@ -15,7 +16,7 @@ function roundedCornersBackground (params) { } borderPoint4 = { - x: params.cornerRadius, + x: params.cornerRadius + params.xOffset, y: params.container.frame.height - params.cornerRadius }