From abf95065f6d54d4d8b03059f9b79691bbf4596b7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 2 Oct 2019 16:31:46 +0200 Subject: [PATCH] First Part of Sesssions Implementation --- FloatingSpace/StrategyPart.js | 28 +- FloatingSpace/StrategyPartConstructor.js | 372 ++++++++++++++++++++++- FloatingSpace/StrategyPartTitle.js | 12 + Spaces/StrategySpace.js | 4 + 4 files changed, 400 insertions(+), 16 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 920daeda7..338534e42 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -231,7 +231,23 @@ function newStrategyPart () { compatibleSubType = undefined break case 'Parameters': - compatibleType = '->' + 'Trading System' + '->' + 'Process' + '->' + compatibleType = '->' + 'Trading System' + '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' + compatibleSubType = '->' + 'Trading Engine Process' + '->' + break + case 'Backtesting Session': + compatibleType = '->' + 'Process' + '->' + compatibleSubType = '->' + 'Trading Engine Process' + '->' + break + case 'Live Trading Session': + compatibleType = '->' + 'Process' + '->' + compatibleSubType = '->' + 'Trading Engine Process' + '->' + break + case 'Paper Trading Session': + compatibleType = '->' + 'Process' + '->' + compatibleSubType = '->' + 'Trading Engine Process' + '->' + break + case 'Fordward Testing Session': + compatibleType = '->' + 'Process' + '->' compatibleSubType = '->' + 'Trading Engine Process' + '->' break case 'Base Asset': @@ -397,6 +413,10 @@ function newStrategyPart () { 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 } + if (thisObject.payload.node.type === 'Backtesting Session' && nearbyNode.session !== undefined) { continue } + if (thisObject.payload.node.type === 'Live Trading Session' && nearbyNode.session !== undefined) { continue } + if (thisObject.payload.node.type === 'Fordward Testing Session' && nearbyNode.session !== undefined) { continue } + if (thisObject.payload.node.type === 'Paper Trading Session' && nearbyNode.session !== undefined) { continue } if (thisObject.payload.node.type === 'Base Asset' && nearbyNode.baseAsset !== undefined) { continue } if (thisObject.payload.node.type === 'Time Range' && nearbyNode.timeRange !== undefined) { continue } if (thisObject.payload.node.type === 'Time Period' && nearbyNode.timePeriod !== undefined) { continue } @@ -420,10 +440,8 @@ function newStrategyPart () { if (thisObject.payload.node.type === 'Next Phase Event' && nearbyNode.nextPhaseEvent !== undefined) { continue } if (thisObject.payload.node.type === 'Code' && nearbyNode.code !== undefined) { continue } /* Here we check if the subtypes are compatible. */ - if (nearbyNode.subType !== undefined) { - if (compatibleSubType.indexOf('->' + nearbyNode.subType + '->') >= 0) { - if (thisObject.payload.node.type === 'Parameters' && nearbyNode.parameters !== undefined) { continue } - } else { + if (nearbyNode.subType !== undefined && compatibleSubType !== undefined) { + if (compatibleSubType.indexOf('->' + nearbyNode.subType + '->') < 0) { continue } } diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 2f8bc3f03..d00f4a582 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -556,7 +556,7 @@ function newStrategyPartConstructor () { askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Process', + label: 'Delete Task', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -729,29 +729,192 @@ function newStrategyPartConstructor () { strategyPart.codeEditor.initialize() strategyPart.codeEditor.container.connectToParent(strategyPart.container, false, false, true, true, false, false, false, false) + addLeftIcons(menuItemsInitialValues, floatingObject) + + switch (payload.node.subType) { + case 'Trading Engine Process': { + menuItemsInitialValues.push( + { + action: 'Add Backtesting Session', + actionFunction: payload.onMenuItemClick, + label: 'Add Backtesting', + visible: true, + relatedStrategyPart: 'Backtesting Session', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -75 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Live Trading Session', + actionFunction: payload.onMenuItemClick, + label: 'Add Live Trading', + visible: true, + relatedStrategyPart: 'Live Trading Session', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Fordward Testing Session', + actionFunction: payload.onMenuItemClick, + label: 'Add Fordward Testing', + visible: true, + relatedStrategyPart: 'Fordward Testing Session', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Paper Trading Session', + actionFunction: payload.onMenuItemClick, + label: 'Add Paper Trading', + visible: true, + relatedStrategyPart: 'Paper Trading Session', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Edit Process', + actionFunction: strategyPart.codeEditor.activate, + label: 'Edit Process', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process', + 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 + } + default: { + menuItemsInitialValues.push( + { + action: 'Edit Process', + actionFunction: strategyPart.codeEditor.activate, + label: 'Edit Process', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40, + dontShowAtFullscreen: true + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process', + 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 + } + } + break + } + case 'Backtesting Session': { addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { - action: 'Edit Process', - actionFunction: strategyPart.codeEditor.activate, - label: 'Edit Process', + action: 'Run Backtesting Session', + actionFunction: payload.onMenuItemClick, + label: 'Run', + workingLabel: 'Stop', + workDoneLabel: 'Session Running', + workFailedLabel: 'Session Cannot be Run', + secondaryAction: 'Stop Session', + secondaryLabel: 'Stop', + secondaryWorkingLabel: 'Stopping...', + secondaryWorkDoneLabel: 'Session Stopped', + secondaryWorkFailedLabel: 'Session Cannot be Stopped', + secondaryIcon: 'stop', visible: true, - iconPathOn: 'html', - iconPathOff: 'html', + iconPathOn: 'paper-plane', + iconPathOff: 'paper-plane', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -40, - dontShowAtFullscreen: true + angle: -40 } ) menuItemsInitialValues.push( { - action: 'Delete Process', + action: 'Delete Backtesting Session', askConfirmation: true, confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, - label: 'Delete Process', + label: 'Delete Session', visible: true, iconPathOn: 'delete', iconPathOff: 'delete', @@ -774,7 +937,178 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: 40 } - ) + ) + break + } + case 'Live Trading Session': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Run Live Trading Session', + actionFunction: payload.onMenuItemClick, + label: 'Run', + workingLabel: 'Stop', + workDoneLabel: 'Session Running', + workFailedLabel: 'Session Cannot be Run', + secondaryAction: 'Stop Session', + secondaryLabel: 'Stop', + secondaryWorkingLabel: 'Stopping...', + secondaryWorkDoneLabel: 'Session Stopped', + secondaryWorkFailedLabel: 'Session Cannot be Stopped', + secondaryIcon: 'stop', + visible: true, + iconPathOn: 'paper-plane', + iconPathOff: 'paper-plane', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Live Trading Session', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Session', + 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 'Fordward Testing Session': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Run Fordward Testing Session', + actionFunction: payload.onMenuItemClick, + label: 'Run', + workingLabel: 'Stop', + workDoneLabel: 'Session Running', + workFailedLabel: 'Session Cannot be Run', + secondaryAction: 'Stop Session', + secondaryLabel: 'Stop', + secondaryWorkingLabel: 'Stopping...', + secondaryWorkDoneLabel: 'Session Stopped', + secondaryWorkFailedLabel: 'Session Cannot be Stopped', + secondaryIcon: 'stop', + visible: true, + iconPathOn: 'paper-plane', + iconPathOff: 'paper-plane', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Fordward Testing Session', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Session', + 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 'Paper Trading Session': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Run Paper Trading Session', + actionFunction: payload.onMenuItemClick, + label: 'Run', + workingLabel: 'Stop', + workDoneLabel: 'Session Running', + workFailedLabel: 'Session Cannot be Run', + secondaryAction: 'Stop Session', + secondaryLabel: 'Stop', + secondaryWorkingLabel: 'Stopping...', + secondaryWorkDoneLabel: 'Session Stopped', + secondaryWorkFailedLabel: 'Session Cannot be Stopped', + secondaryIcon: 'stop', + visible: true, + iconPathOn: 'paper-plane', + iconPathOff: 'paper-plane', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Paper Trading Session', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Session', + 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 'Personal Data': { @@ -2339,6 +2673,22 @@ function newStrategyPartConstructor () { break } case 'Process': { + level_2() + break + } + case 'Backtesting Session': { + level_4() + break + } + case 'Live Trading Session': { + level_4() + break + } + case 'Fordward Testing Session': { + level_4() + break + } + case 'Paper Trading Session': { level_4() break } diff --git a/FloatingSpace/StrategyPartTitle.js b/FloatingSpace/StrategyPartTitle.js index ff4517f4c..792bb88cf 100644 --- a/FloatingSpace/StrategyPartTitle.js +++ b/FloatingSpace/StrategyPartTitle.js @@ -79,6 +79,18 @@ function newStrategyPartTitle () { case 'Process': { break } + case 'Backtesting Session': { + break + } + case 'Live Trading Session': { + break + } + case 'Fordward Testing Session': { + break + } + case 'Paper Trading Session': { + break + } case 'Personal Data': { break } diff --git a/Spaces/StrategySpace.js b/Spaces/StrategySpace.js index 5533031dc..183e2aadd 100644 --- a/Spaces/StrategySpace.js +++ b/Spaces/StrategySpace.js @@ -48,6 +48,10 @@ function newStrategySpace () { ['Indicator', 'vector'], ['Trading Engine', 'brainstorming'], ['Process', 'grid'], + ['Backtesting Session', 'tap'], + ['Live Trading Session', 'startup'], + ['Fordward Testing Session', 'upload'], + ['Paper Trading Session', 'search'], ['Personal Data', 'security'], ['Exchange Account', 'approve'], ['Exchange Account Asset', 'paper-plane'],