diff --git a/Canvas.js b/Canvas.js index 98358cc03..caffa0046 100644 --- a/Canvas.js +++ b/Canvas.js @@ -239,6 +239,11 @@ function newCanvas () { if (event.code === 'Period') { let nodeOnFocus = canvas.strategySpace.workspace.getNodeThatIsOnFocus() if (nodeOnFocus !== undefined) { + if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) { + if (nodeOnFocus.payload.uiObject.codeEditor.visible === true) { + return + } + } nodeOnFocus.payload.uiObject.setValue('Id: ' + nodeOnFocus.id) return } @@ -246,7 +251,6 @@ function newCanvas () { if (event.ctrlKey === true) { if (event.keyCode >= 65 && event.keyCode <= 90) { - event.preventDefault() let nodeOnFocus = canvas.strategySpace.workspace.getNodeThatIsOnFocus() let nodeUsingThisKey = canvas.strategySpace.workspace.getNodeByShortcutKey(event.key) @@ -255,6 +259,14 @@ function newCanvas () { nodeUsingThisKey = canvas.floatingSpace.positionAtNode(nodeUsingThisKey) return } + if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) { + if (nodeOnFocus.payload.uiObject.codeEditor.visible === true) { + return + } + } + + /* From here we prevent the default behaviour */ + event.preventDefault() /* If there is a node in focus, we try to assign the key to it. */ if (nodeUsingThisKey !== undefined) { diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 57186cfdf..b45e3151e 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -1022,6 +1022,11 @@ 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) + addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { @@ -1043,7 +1048,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -60 + angle: -70 } ) menuItemsInitialValues.push( @@ -1056,7 +1061,22 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Edit Session', + actionFunction: strategyPart.codeEditor.activate, + label: 'Edit Session', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0, + dontShowAtFullscreen: true } ) menuItemsInitialValues.push( @@ -1072,7 +1092,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 30 } ) menuItemsInitialValues.push( @@ -1086,12 +1106,17 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 60 + angle: 70 } ) 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) + addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { @@ -1113,7 +1138,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -60 + angle: -70 } ) menuItemsInitialValues.push( @@ -1126,9 +1151,24 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -30 } ) + menuItemsInitialValues.push( + { + action: 'Edit Session', + actionFunction: strategyPart.codeEditor.activate, + label: 'Edit Session', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0, + dontShowAtFullscreen: true + } + ) menuItemsInitialValues.push( { action: 'Delete Live Trading Session', @@ -1142,7 +1182,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 30 } ) menuItemsInitialValues.push( @@ -1156,12 +1196,17 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 60 + angle: 70 } ) 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) + addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { @@ -1183,7 +1228,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -60 + angle: -70 } ) menuItemsInitialValues.push( @@ -1196,9 +1241,24 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -30 } ) + menuItemsInitialValues.push( + { + action: 'Edit Session', + actionFunction: strategyPart.codeEditor.activate, + label: 'Edit Session', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0, + dontShowAtFullscreen: true + } + ) menuItemsInitialValues.push( { action: 'Delete Fordward Testing Session', @@ -1212,7 +1272,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 30 } ) menuItemsInitialValues.push( @@ -1226,12 +1286,17 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 60 + angle: 70 } ) 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) + addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { @@ -1253,7 +1318,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -60 + angle: -70 } ) menuItemsInitialValues.push( @@ -1266,9 +1331,24 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -30 } ) + menuItemsInitialValues.push( + { + action: 'Edit Session', + actionFunction: strategyPart.codeEditor.activate, + label: 'Edit Session', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0, + dontShowAtFullscreen: true + } + ) menuItemsInitialValues.push( { action: 'Delete Paper Trading Session', @@ -1282,7 +1362,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 30 } ) menuItemsInitialValues.push( @@ -1296,7 +1376,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 60 + angle: 70 } ) break diff --git a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js index 980432664..3d0ac7844 100644 --- a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js +++ b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js @@ -600,6 +600,7 @@ function newPartsFromNodes () { function addProcess (node) { let process = { + name: 'New Process', code: '{}' } @@ -629,7 +630,8 @@ function newPartsFromNodes () { function addBacktestingSession (node) { if (node.session === undefined) { node.session = { - name: 'New Backtesting Session' + name: 'New Backtesting Session', + code: '{}' } createPart('Backtesting Session', '', node.session, node, node) } @@ -640,7 +642,8 @@ function newPartsFromNodes () { function addLiveTradingSession (node) { if (node.session === undefined) { node.session = { - name: 'New Live Trading Session' + name: 'New Live Trading Session', + code: '{}' } createPart('Live Trading Session', '', node.session, node, node) } @@ -651,7 +654,8 @@ function newPartsFromNodes () { function addFordwardTestingSession (node) { if (node.session === undefined) { node.session = { - name: 'New Fordward Testing Session' + name: 'New Fordward Testing Session', + code: '{}' } createPart('Fordward Testing Session', '', node.session, node, node) } @@ -662,7 +666,8 @@ function newPartsFromNodes () { function addPaperTradingSession (node) { if (node.session === undefined) { node.session = { - name: 'New Paper Trading Session' + name: 'New Paper Trading Session', + code: '{}' } createPart('Paper Trading Session', '', node.session, node, node) } diff --git a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js index 4b52ac24c..184efe7c1 100644 --- a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -4,7 +4,7 @@ function newProtocolNode () { } return thisObject - function getProtocolNode (node, removePersonalData, parseJSONStrings, includeIds) { + function getProtocolNode (node, removePersonalData, parseCode, includeIds) { if (node === undefined) { return } switch (node.type) { case 'Code': @@ -26,7 +26,7 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - code: getProtocolNode(node.code, removePersonalData, parseJSONStrings, includeIds) + code: getProtocolNode(node.code, removePersonalData, parseCode, includeIds) } if (includeIds) { condition.id = node.id @@ -42,7 +42,7 @@ function newProtocolNode () { } for (let m = 0; m < node.conditions.length; m++) { - let condition = getProtocolNode(node.conditions[m], removePersonalData, parseJSONStrings, includeIds) + let condition = getProtocolNode(node.conditions[m], removePersonalData, parseCode, includeIds) situation.conditions.push(condition) } if (includeIds) { @@ -72,7 +72,7 @@ function newProtocolNode () { situations: [] } for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseJSONStrings, includeIds) + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds) event.situations.push(situation) } if (includeIds) { @@ -85,8 +85,8 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseJSONStrings, includeIds), - nextPhaseEvent: getProtocolNode(node.nextPhaseEvent, removePersonalData, parseJSONStrings, includeIds) + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds), + nextPhaseEvent: getProtocolNode(node.nextPhaseEvent, removePersonalData, parseCode, includeIds) } if (includeIds) { phase.id = node.id @@ -102,7 +102,7 @@ function newProtocolNode () { } for (let m = 0; m < node.phases.length; m++) { - let phase = getProtocolNode(node.phases[m], removePersonalData, parseJSONStrings, includeIds) + let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds) stop.phases.push(phase) } if (includeIds) { @@ -119,7 +119,7 @@ function newProtocolNode () { } for (let m = 0; m < node.phases.length; m++) { - let phase = getProtocolNode(node.phases[m], removePersonalData, parseJSONStrings, includeIds) + let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds) takeProfit.phases.push(phase) } if (includeIds) { @@ -136,7 +136,7 @@ function newProtocolNode () { } for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseJSONStrings, includeIds) + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds) event.situations.push(situation) } if (includeIds) { @@ -153,7 +153,7 @@ function newProtocolNode () { } for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseJSONStrings, includeIds) + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds) event.situations.push(situation) } if (includeIds) { @@ -170,7 +170,7 @@ function newProtocolNode () { } for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseJSONStrings, includeIds) + let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds) event.situations.push(situation) } if (includeIds) { @@ -183,10 +183,10 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseJSONStrings, includeIds), - takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseJSONStrings, includeIds), - positionSize: getProtocolNode(node.positionSize, removePersonalData, parseJSONStrings, includeIds), - positionRate: getProtocolNode(node.positionRate, removePersonalData, parseJSONStrings, includeIds) + stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds), + takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds), + positionSize: getProtocolNode(node.positionSize, removePersonalData, parseCode, includeIds), + positionRate: getProtocolNode(node.positionRate, removePersonalData, parseCode, includeIds) } if (includeIds) { object.id = node.id @@ -220,7 +220,7 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseJSONStrings, includeIds) + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds) } if (includeIds) { object.id = node.id @@ -232,7 +232,7 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseJSONStrings, includeIds) + formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds) } if (includeIds) { object.id = node.id @@ -244,9 +244,9 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - triggerOn: getProtocolNode(node.triggerOn, removePersonalData, parseJSONStrings, includeIds), - triggerOff: getProtocolNode(node.triggerOff, removePersonalData, parseJSONStrings, includeIds), - takePosition: getProtocolNode(node.takePosition, removePersonalData, parseJSONStrings, includeIds) + triggerOn: getProtocolNode(node.triggerOn, removePersonalData, parseCode, includeIds), + triggerOff: getProtocolNode(node.triggerOff, removePersonalData, parseCode, includeIds), + takePosition: getProtocolNode(node.takePosition, removePersonalData, parseCode, includeIds) } if (includeIds) { stage.id = node.id @@ -258,8 +258,8 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - initialDefinition: getProtocolNode(node.initialDefinition, removePersonalData, parseJSONStrings, includeIds), - openExecution: getProtocolNode(node.openExecution, removePersonalData, parseJSONStrings, includeIds) + initialDefinition: getProtocolNode(node.initialDefinition, removePersonalData, parseCode, includeIds), + openExecution: getProtocolNode(node.openExecution, removePersonalData, parseCode, includeIds) } if (includeIds) { stage.id = node.id @@ -271,8 +271,8 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseJSONStrings, includeIds), - takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseJSONStrings, includeIds) + stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds), + takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds) } if (includeIds) { stage.id = node.id @@ -284,7 +284,7 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - closeExecution: getProtocolNode(node.closeExecution, removePersonalData, parseJSONStrings, includeIds) + closeExecution: getProtocolNode(node.closeExecution, removePersonalData, parseCode, includeIds) } if (includeIds) { stage.id = node.id @@ -296,10 +296,10 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - triggerStage: getProtocolNode(node.triggerStage, removePersonalData, parseJSONStrings, includeIds), - openStage: getProtocolNode(node.openStage, removePersonalData, parseJSONStrings, includeIds), - manageStage: getProtocolNode(node.manageStage, removePersonalData, parseJSONStrings, includeIds), - closeStage: getProtocolNode(node.closeStage, removePersonalData, parseJSONStrings, includeIds) + triggerStage: getProtocolNode(node.triggerStage, removePersonalData, parseCode, includeIds), + openStage: getProtocolNode(node.openStage, removePersonalData, parseCode, includeIds), + manageStage: getProtocolNode(node.manageStage, removePersonalData, parseCode, includeIds), + closeStage: getProtocolNode(node.closeStage, removePersonalData, parseCode, includeIds) } if (includeIds) { strategy.id = node.id @@ -371,12 +371,12 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - baseAsset: getProtocolNode(node.baseAsset, removePersonalData, parseJSONStrings, includeIds), - timeRange: getProtocolNode(node.timeRange, removePersonalData, parseJSONStrings, includeIds), - timePeriod: getProtocolNode(node.timePeriod, removePersonalData, parseJSONStrings, includeIds), - slippage: getProtocolNode(node.slippage, removePersonalData, parseJSONStrings, includeIds), - feeStructure: getProtocolNode(node.feeStructure, removePersonalData, parseJSONStrings, includeIds), - key: getProtocolNode(node.key, removePersonalData, parseJSONStrings, includeIds) + baseAsset: getProtocolNode(node.baseAsset, removePersonalData, parseCode, includeIds), + timeRange: getProtocolNode(node.timeRange, removePersonalData, parseCode, includeIds), + timePeriod: getProtocolNode(node.timePeriod, removePersonalData, parseCode, includeIds), + slippage: getProtocolNode(node.slippage, removePersonalData, parseCode, includeIds), + feeStructure: getProtocolNode(node.feeStructure, removePersonalData, parseCode, includeIds), + key: getProtocolNode(node.key, removePersonalData, parseCode, includeIds) } if (includeIds) { object.id = node.id @@ -389,11 +389,11 @@ function newProtocolNode () { subType: node.subType, name: node.name, strategies: [], - parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds) + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds) } for (let m = 0; m < node.strategies.length; m++) { - let strategy = getProtocolNode(node.strategies[m], removePersonalData, parseJSONStrings, includeIds) + let strategy = getProtocolNode(node.strategies[m], removePersonalData, parseCode, includeIds) tradingSystem.strategies.push(strategy) } if (includeIds) { @@ -411,7 +411,7 @@ function newProtocolNode () { } for (let m = 0; m < node.exchangeAccounts.length; m++) { - let exchangeAccount = getProtocolNode(node.exchangeAccounts[m], removePersonalData, parseJSONStrings, includeIds) + let exchangeAccount = getProtocolNode(node.exchangeAccounts[m], removePersonalData, parseCode, includeIds) personalData.exchangeAccounts.push(exchangeAccount) } if (includeIds) { @@ -430,11 +430,11 @@ function newProtocolNode () { } for (let m = 0; m < node.assets.length; m++) { - let asset = getProtocolNode(node.assets[m], removePersonalData, parseJSONStrings, includeIds) + let asset = getProtocolNode(node.assets[m], removePersonalData, parseCode, includeIds) exchangeAccount.assets.push(asset) } for (let m = 0; m < node.keys.length; m++) { - let key = getProtocolNode(node.keys[m], removePersonalData, parseJSONStrings, includeIds) + let key = getProtocolNode(node.keys[m], removePersonalData, parseCode, includeIds) exchangeAccount.keys.push(key) } if (includeIds) { @@ -476,7 +476,7 @@ function newProtocolNode () { } for (let m = 0; m < node.layers.length; m++) { - let layer = getProtocolNode(node.layers[m], removePersonalData, parseJSONStrings, includeIds) + let layer = getProtocolNode(node.layers[m], removePersonalData, parseCode, includeIds) layerManager.layers.push(layer) } if (includeIds) { @@ -505,7 +505,7 @@ function newProtocolNode () { } for (let m = 0; m < node.tasks.length; m++) { - let task = getProtocolNode(node.tasks[m], removePersonalData, parseJSONStrings, includeIds) + let task = getProtocolNode(node.tasks[m], removePersonalData, parseCode, includeIds) taskManager.tasks.push(task) } if (includeIds) { @@ -518,7 +518,7 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - bot: getProtocolNode(node.bot, removePersonalData, parseJSONStrings, includeIds) + bot: getProtocolNode(node.bot, removePersonalData, parseCode, includeIds) } if (includeIds) { object.id = node.id @@ -535,10 +535,10 @@ function newProtocolNode () { } for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseJSONStrings, includeIds) + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds) bot.processes.push(process) } - if (parseJSONStrings) { + if (parseCode) { bot.code = JSON.parse(bot.code) } if (includeIds) { @@ -556,10 +556,10 @@ function newProtocolNode () { } for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseJSONStrings, includeIds) + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds) bot.processes.push(process) } - if (parseJSONStrings) { + if (parseCode) { bot.code = JSON.parse(bot.code) } if (includeIds) { @@ -577,10 +577,10 @@ function newProtocolNode () { } for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseJSONStrings, includeIds) + let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds) bot.processes.push(process) } - if (parseJSONStrings) { + if (parseCode) { bot.code = JSON.parse(bot.code) } if (includeIds) { @@ -594,9 +594,9 @@ function newProtocolNode () { subType: node.subType, name: node.name, code: node.code, - session: getProtocolNode(node.session, removePersonalData, parseJSONStrings, includeIds) + session: getProtocolNode(node.session, removePersonalData, parseCode, includeIds) } - if (parseJSONStrings) { + if (parseCode) { object.code = JSON.parse(object.code) } if (includeIds) { @@ -610,8 +610,12 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseJSONStrings, includeIds) + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds) + } + if (parseCode) { + object.code = JSON.parse(object.code) } if (includeIds) { object.id = node.id @@ -624,8 +628,12 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseJSONStrings, includeIds) + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds) + } + if (parseCode) { + object.code = JSON.parse(object.code) } if (includeIds) { object.id = node.id @@ -638,8 +646,12 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseJSONStrings, includeIds) + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds) + } + if (parseCode) { + object.code = JSON.parse(object.code) } if (includeIds) { object.id = node.id @@ -652,11 +664,12 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseJSONStrings, includeIds) + code: node.code, + parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds), + layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds) } - if (includeIds) { - object.id = node.id + if (parseCode) { + object.code = JSON.parse(object.code) } if (includeIds) { object.id = node.id @@ -673,7 +686,7 @@ function newProtocolNode () { } if (node.taskManagers !== undefined) { for (let m = 0; m < node.taskManagers.length; m++) { - let taskManager = getProtocolNode(node.taskManagers[m], removePersonalData, parseJSONStrings, includeIds) + let taskManager = getProtocolNode(node.taskManagers[m], removePersonalData, parseCode, includeIds) object.taskManagers.push(taskManager) } } @@ -691,7 +704,7 @@ function newProtocolNode () { } if (node.networkNodes !== undefined) { for (let m = 0; m < node.networkNodes.length; m++) { - let networkNode = getProtocolNode(node.networkNodes[m], removePersonalData, parseJSONStrings, includeIds) + let networkNode = getProtocolNode(node.networkNodes[m], removePersonalData, parseCode, includeIds) object.networkNodes.push(networkNode) } } @@ -705,9 +718,9 @@ function newProtocolNode () { type: node.type, subType: node.subType, name: node.name, - tradingSystem: getProtocolNode(node.tradingSystem, removePersonalData, parseJSONStrings, includeIds), - personalData: getProtocolNode(node.personalData, removePersonalData, parseJSONStrings, includeIds), - network: getProtocolNode(node.network, removePersonalData, parseJSONStrings, includeIds) + tradingSystem: getProtocolNode(node.tradingSystem, removePersonalData, parseCode, includeIds), + personalData: getProtocolNode(node.personalData, removePersonalData, parseCode, includeIds), + network: getProtocolNode(node.network, removePersonalData, parseCode, includeIds) } if (includeIds) { object.id = node.id diff --git a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js index b292b7882..ff0d1d6db 100644 --- a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js @@ -568,6 +568,7 @@ function newStringifyNode () { type: node.type, subType: node.subType, name: node.name, + code: node.code, parameters: prepareForStringify(node.parameters, removePersonalData), layerManager: prepareForStringify(node.layerManager, removePersonalData), savedPayload: getSavedPayload(node) @@ -580,6 +581,7 @@ function newStringifyNode () { type: node.type, subType: node.subType, name: node.name, + code: node.code, parameters: prepareForStringify(node.parameters, removePersonalData), layerManager: prepareForStringify(node.layerManager, removePersonalData), savedPayload: getSavedPayload(node) @@ -592,6 +594,7 @@ function newStringifyNode () { type: node.type, subType: node.subType, name: node.name, + code: node.code, parameters: prepareForStringify(node.parameters, removePersonalData), layerManager: prepareForStringify(node.layerManager, removePersonalData), savedPayload: getSavedPayload(node) @@ -604,6 +607,7 @@ function newStringifyNode () { type: node.type, subType: node.subType, name: node.name, + code: node.code, parameters: prepareForStringify(node.parameters, removePersonalData), layerManager: prepareForStringify(node.layerManager, removePersonalData), savedPayload: getSavedPayload(node)