From 269eca845d576916d67d20b2af2419248d1800c9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 3 Nov 2020 09:31:10 +0100 Subject: [PATCH] Adding new nodes and its related code --- .../ChartingSpaceFunctions.js | 33 +++- .../CryptoEcosystemFunctions.js | 31 ++++ .../Function-Libraries/TaskFunctions.js | 62 ++++++-- Projects/Superalgos/Schemas/AppSchema.json | 146 ++++++++++++++++++ .../Spaces/Charting-Space/PlottersManager.js | 8 +- .../Superalgos/Spaces/Panel-Space/Layer.js | 32 ++-- .../Spaces/Panel-Space/PanelSpace.js | 2 +- 7 files changed, 285 insertions(+), 29 deletions(-) diff --git a/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js b/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js index fa5d1aefd..e59bd6126 100644 --- a/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js +++ b/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js @@ -180,7 +180,7 @@ function newChartingSpaceFunctions() { } } /* - We need to create a Timeline Chart for each Data Mine Indicators. + We need to create a Timeline Chart for each Data Mine Products. */ mineProducts = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Data Mine Products') for (let j = 0; j < mineProducts.length; j++) { @@ -206,6 +206,37 @@ function newChartingSpaceFunctions() { timelineChart.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 timelineChart.layerManager.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + let menu = timelineChart.layerManager.payload.uiObject.menu + menu.internalClick('Add All Mine Layers') + menu.internalClick('Add All Mine Layers') + } + /* + We need to create a Timeline Chart for each Intel Mine Products. + */ + mineProducts = UI.projects.superalgos.utilities.branches.nodeBranchToArray(networkNode, 'Intel Mine Products') + for (let j = 0; j < mineProducts.length; j++) { + let mineProduct = mineProducts[j] + /* + We need to filter out the ones that do not belong to the market where + the session is running at. + */ + if (mineProduct.payload.parentNode.payload.referenceParent === undefined) { continue } + if (mineProduct.payload.parentNode.payload.referenceParent.id !== market.id) { continue } + + let timelineChart = functionLibraryUiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart') + /* + The Mine Product Node might be collapesd and since its creation it never + received the physics call, so we will do the call so that it properly + sets its own name, which we are going to reuse here. + */ + mineProduct.payload.uiObject.invisiblePhysics() + timelineChart.name = mineProduct.name + timelineChart.layerManager.payload.referenceParent = mineProduct + timelineChart.payload.floatingObject.collapseToggle() + timelineChart.layerManager.payload.floatingObject.collapseToggle() + timelineChart.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + timelineChart.layerManager.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + let menu = timelineChart.layerManager.payload.uiObject.menu menu.internalClick('Add All Mine Layers') menu.internalClick('Add All Mine Layers') diff --git a/Projects/Superalgos/Function-Libraries/CryptoEcosystemFunctions.js b/Projects/Superalgos/Function-Libraries/CryptoEcosystemFunctions.js index e914778ce..58815e381 100644 --- a/Projects/Superalgos/Function-Libraries/CryptoEcosystemFunctions.js +++ b/Projects/Superalgos/Function-Libraries/CryptoEcosystemFunctions.js @@ -266,6 +266,21 @@ function newCryptoEcosystemFunctions() { UI.projects.superalgos.utilities.menu.menuClick(marketDataTask, 'Add Missing Data Mine Tasks', true) UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketDataTask.dataMineTasks, 'Add All Tasks', true) + /* + Here we complete the missing stuff at Intel Mining + */ + let intelMining = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Intel Mining', node, true) + if (intelMining === undefined) { + node.payload.uiObject.setErrorMessage('Intel Mining node not found at Network Node ' + networkNode.name) + return + } + + let exchangeLearningTasks = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(intelMining, 'Exchange Learning Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes) + exchangeLearningTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + let marketLearningTask = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeLearningTasks, 'Market Learning Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) + + UI.projects.superalgos.utilities.menu.menuClick(marketLearningTask, 'Add Missing Intel Mine Tasks', true) + UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketLearningTask.intelMineTasks, 'Add All Tasks', true) let sessionsCreatedArray = [] /* @@ -319,6 +334,22 @@ function newCryptoEcosystemFunctions() { UI.projects.superalgos.utilities.menu.menuClick(marketDataProducts, 'Add All Data Mine Products', true) UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketDataProducts.dataMineProducts, 'Add All Data Products', true) /* + Here we complete the missing stuff at Intel Mines Data + */ + let intelMineData = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Intel Mines Data', node, true) + if (intelMineData === undefined) { + node.payload.uiObject.setErrorMessage('Intel Mines Data node not found at Network Node ' + networkNode.name) + return + } + + let exchangeIntelProducts = UI.projects.superalgos.utilities.children.findOrCreateChildWithReference(intelMineData, 'Exchange Intel Products', cryptoExchange, functionLibraryUiObjectsFromNodes) + exchangeIntelProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + let marketIntelProducts = UI.projects.superalgos.utilities.children.findAndRecreateChildWithReference(exchangeIntelProducts, 'Market Intel Products', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) + marketIntelProducts.payload.floatingObject.collapseToggle() + + UI.projects.superalgos.utilities.menu.menuClick(marketIntelProducts, 'Add All Intel Mine Products', true) + UI.projects.superalgos.utilities.menu.menuClickOfNodeArray(marketIntelProducts.intelMineProducts, 'Add All Intel Products', true) + /* Finally we complete the missing stuff at Trading Mines Data */ let tradingMinesData = UI.projects.superalgos.utilities.branches.findInBranch(networkNode, 'Trading Mines Data', node, true) diff --git a/Projects/Superalgos/Function-Libraries/TaskFunctions.js b/Projects/Superalgos/Function-Libraries/TaskFunctions.js index 99c82e3c7..3f0f1b879 100644 --- a/Projects/Superalgos/Function-Libraries/TaskFunctions.js +++ b/Projects/Superalgos/Function-Libraries/TaskFunctions.js @@ -101,16 +101,18 @@ function newTaskFunctions() { 'Sensor Bot Instance->' + 'Indicator Bot Instance->Time Frames Filter->' + 'Trading Bot Instance->' + - 'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' + + 'AI Bot Instance->' + + 'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->AI Process Instance->' + 'Execution Started Event->' + 'Key Reference->Exchange Account Key->' + 'Task Manager->' + - 'Data Mine Tasks->Trading Mine Tasks->' + + 'Data Mine Tasks->Trading Mine Tasks->Intel Mine Tasks->' + 'Market Data Tasks->Market Trading Tasks->' + - 'Exchange Data Tasks->Exchange Trading Tasks->' + + 'Exchange Data Tasks->Exchange Trading Tasks->Exchange Learning Tasks->' + 'Market->Exchange Markets->Crypto Exchange->' + 'Market Base Asset->Market Quoted Asset->Asset->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Forward Testing Session->' + + 'Learning Session->' + 'Process Definition->' + 'Process Output->' + 'Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->' + @@ -134,7 +136,8 @@ function newTaskFunctions() { 'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' + 'Indicator Bot->' + 'Trading Bot->' + - 'Data Mine->Trading Mine->' + 'AI Bot->' + + 'Data Mine->Trading Mine->Intel Mine->' let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath) @@ -145,13 +148,13 @@ function newTaskFunctions() { 'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' + 'Data Product->Product Definition->' + 'Data Mining->Testing Environment->Production Environment->' + - 'Exchange Data Tasks->Exchange Trading Tasks->Crypto Exchange->' + - 'Market Data Tasks->Market Trading Tasks->Market->' + - 'Data Mine Tasks->Trading Mine Tasks->' + + 'Exchange Data Tasks->Exchange Trading Tasks->Exchange Learning Tasks->Crypto Exchange->' + + 'Market Data Tasks->Market Trading Tasks->Market Learning Tasks->Market->' + + 'Data Mine Tasks->Trading Mine Tasks->Intel Mine Tasks->' + 'Task Manager->Task->' + - 'Indicator Bot Instance->Sensor Bot Instance->Trading Bot Instance->' + - 'Indicator Process Instance->Sensor Process Instance->Trading Process Instance->' + - 'Paper Trading Session->Forward Testing Session->Backtesting Session->Live Trading Session->' + + 'Indicator Bot Instance->Sensor Bot Instance->Trading Bot Instance->AI Bot Instance->' + + 'Indicator Process Instance->Sensor Process Instance->Trading Process Instance->AI Process Instance->' + + 'Paper Trading Session->Forward Testing Session->Backtesting Session->Live Trading Session->Learning Session->' + 'Market->' + 'Process Definition->' @@ -582,6 +585,10 @@ function newTaskFunctions() { addDataTasks() break } + case 'Intel Mine Tasks': { + addLearningTasks() + break + } case 'Trading Mine Tasks': { addTradingTasks() break @@ -592,6 +599,10 @@ function newTaskFunctions() { addTaskForTradinSystem() } + function addLearningTasks() { + addTaskForTradinSystem() + } + function addTradingTasks() { for (let i = 0; i < rootNodes.length; i++) { let rootNode = rootNodes[i] @@ -639,6 +650,11 @@ function newTaskFunctions() { botInstance.name = bot.name break } + case 'AI Bot': { + botInstance = functionLibraryUiObjectsFromNodes.addUIObject(task, 'AI Bot Instance') + botInstance.name = bot.name + break + } } for (let j = 0; j < bot.processes.length; j++) { @@ -680,6 +696,32 @@ function newTaskFunctions() { } break + function addSession(sessionType) { + session = functionLibraryUiObjectsFromNodes.addUIObject(processInstance, sessionType) + session.name = task.name + let config = JSON.parse(session.config) + config.folderName = session.name.split(" ").join("-") + session.config = JSON.stringify(config) + + for (let m = 0; m < rootNodes.length; m++) { + let rootNode = rootNodes[m] + if (rootNode.type === 'Trading Engine' && rootNode.isPlugin === true) { + let tradingEngine = rootNode + session.tradingEngineReference.payload.referenceParent = tradingEngine + session.tradingSystemReference.payload.referenceParent = tradingSystem + } + } + } + } + case 'AI Bot': { + processInstance = functionLibraryUiObjectsFromNodes.addUIObject(botInstance, 'AI Process Instance') + processInstance.payload.referenceParent = process + + let session + + addSession('Learning Session') + break + function addSession(sessionType) { session = functionLibraryUiObjectsFromNodes.addUIObject(processInstance, sessionType) session.name = task.name diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index 4d4050ba3..cc8881d6e 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -16046,6 +16046,59 @@ } ] }, + { + "type": "Exchange Intel Products", + "menuItems": [ + { + "action": "Add UI Object", + "label": "Add Market Intel Products", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "marketIntelProducts", + "relatedUiObject": "Market Intel Products", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add Missing Market Intel Products", + "label": "Add Missing Markets", + "askConfirmation": true, + "confirmationLabel": "Confirm to Proceed", + "workDoneLabel": "Done", + "relatedUiObject": "Market Intel Products", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete", + "iconPathOff": "delete", + "actionFunction": "payload.executeAction" + } + ], + "alternativeIcons": "Use Reference Parent", + "title": [ + "Use Reference Parent" + ], + "isTitleAllwaysVisible": true, + "addLeftIcons": true, + "level": 3, + "referenceAttachesTo": { + "compatibleTypes": "->Crypto Exchange->" + }, + "chainAttachesTo": { + "compatibleTypes": "->Intel Mines Data->" + }, + "propertyNameAtParent": "exchangeIntelProducts", + "properties": [ + { + "name": "marketIntelProducts", + "type": "array", + "childType": "Market Intel Products", + "autoAdd": false + } + ] + }, { "type": "Trading Mines Data", "menuItems": [ @@ -16088,6 +16141,49 @@ } ] }, + { + "type": "Intel Mines Data", + "menuItems": [ + { + "action": "Add UI Object", + "label": "Add Exchange Intel Products", + "relatedUiObject": "Exchange Intel Products", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add Missing Exchange Intel Products", + "label": "Add Missing Exchanges", + "askConfirmation": true, + "confirmationLabel": "Confirm to Proceed", + "workDoneLabel": "Done", + "relatedUiObject": "Exchange Intel Products", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete", + "iconPathOff": "delete", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 3, + "chainAttachesTo": { + "compatibleTypes": "->Data Storage->" + }, + "propertyNameAtParent": "intelMinesData", + "properties": [ + { + "name": "exchangeIntelProducts", + "type": "array", + "childType": "Exchange Intel Products" + } + ], + "icon": "bitcoin" + }, { "type": "Session Reference", "menuItems": [ @@ -16266,6 +16362,56 @@ } ] }, + { + "type": "Market Intel Products", + "menuItems": [ + { + "action": "Add UI Object", + "label": "Add Session Reference", + "relatedUiObject": "Session Reference", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add Missing Session References", + "label": "Add Missing Sessions", + "askConfirmation": true, + "confirmationLabel": "Confirm to Proceed", + "workDoneLabel": "Done", + "relatedUiObject": "Session Reference", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete", + "iconPathOff": "delete", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 3, + "isTitleAllwaysVisible": true, + "title": [ + "Use Reference Parent Parent Parent", + "Use Reference Parent" + ], + "referenceAttachesTo": { + "compatibleTypes": "->Market->" + }, + "chainAttachesTo": { + "compatibleTypes": "->Exchange Intel Products->" + }, + "propertyNameAtParent": "marketIntelProducts", + "properties": [ + { + "name": "sessionReferences", + "type": "array", + "childType": "Session Reference" + } + ] + }, { "type": "Data Product", "menuItems": [ diff --git a/Projects/Superalgos/Spaces/Charting-Space/PlottersManager.js b/Projects/Superalgos/Spaces/Charting-Space/PlottersManager.js index 5c09f3459..75947abc9 100644 --- a/Projects/Superalgos/Spaces/Charting-Space/PlottersManager.js +++ b/Projects/Superalgos/Spaces/Charting-Space/PlottersManager.js @@ -134,7 +134,7 @@ function newPlottersManager() { } let productDefinition = layer.productDefinition let bot = layer.bot - let dataMine = layer.dataMine + let mine = layer.mine let exchange = layer.exchange let plotterModule = layer.plotterModule let session @@ -170,7 +170,7 @@ function newPlottersManager() { let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(layer.networkNode.id) storage.initialize( - dataMine, + mine, bot, session, productDefinition, @@ -192,7 +192,7 @@ function newPlottersManager() { if (plotterModule.config.isLegacy !== true) { plotter = newPlotter() } else { - plotter = getNewPlotter(dataMine.config.codeName, plotterModule.parentNode.config.codeName, plotterModule.config.codeName) + plotter = getNewPlotter(mine.config.codeName, plotterModule.parentNode.config.codeName, plotterModule.config.codeName) } plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) @@ -218,7 +218,7 @@ function newPlottersManager() { let panel = plotterModule.panels[i] let parameters = { - dataMine: dataMine.config.codeName, + mine: mine.config.codeName, plotterCodeName: plotterModule.parentNode.config.codeName, moduleCodeName: plotterModule.config.codeName, panelNode: panel diff --git a/Projects/Superalgos/Spaces/Panel-Space/Layer.js b/Projects/Superalgos/Spaces/Panel-Space/Layer.js index a62963138..d29b4c02f 100644 --- a/Projects/Superalgos/Spaces/Panel-Space/Layer.js +++ b/Projects/Superalgos/Spaces/Panel-Space/Layer.js @@ -17,7 +17,7 @@ function newLayer() { exchange: undefined, bot: undefined, productDefinition: undefined, - dataMine: undefined, + mine: undefined, plotterModule: undefined, exchangeIcon: undefined, plotterTypeIcon: undefined, @@ -135,7 +135,7 @@ function newLayer() { thisObject.networkNode = undefined thisObject.bot = undefined thisObject.productDefinition = undefined - thisObject.dataMine = undefined + thisObject.mine = undefined } function initialize(callBackFunction) { @@ -161,20 +161,23 @@ function newLayer() { '->Layer->' + 'Data Product->' + 'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' + - 'Bot Products->Data Mine Products->Trading Mine Products->' + + 'Bot Products->Data Mine Products->Trading Mine Products->Intel Mine Products->' + 'Market Data Products->Exchange Data Products->' + - 'Session Reference->Market Trading Products->Exchange Trading Products->' + - 'Data Mines Data->Trading Mines Data->Data Storage->Network Node->' + + 'Session Reference->' + + 'Market Trading Products->Exchange Trading Products->' + + 'Market Intel Products->Exchange Intel Products->' + + 'Data Mines Data->Trading Mines Data->Intel Mines Data->Data Storage->Network Node->' + 'Data Storage->Network Node->' + 'Backtesting Session->Paper Trading Session->Forward Testing Session->Live Trading Session->' + + 'Learning Session->' + 'Trading System Reference->Trading Engine Reference->Trading System->Trading Engine->' + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + 'Exchange Markets->Crypto Exchange->' + 'Product Definition->' + 'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' + - 'Sensor Bot->Indicator Bot->Trading Bot->' + - 'Data Mine->Trading Mine->' + + 'Sensor Bot->Indicator Bot->Trading Bot->AI Bot->' + + 'Data Mine->Trading Mine->Intel Mine->' + 'Dataset Definition->' + 'Record Definition->Record Property->Formula->' + 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + @@ -233,12 +236,15 @@ function newLayer() { return } - thisObject.dataMine = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(thisObject.definition, 'Data Mine', undefined, false, true, true, true) - if (thisObject.dataMine === undefined) { - thisObject.dataMine = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(thisObject.definition, 'Trading Mine', undefined, false, true, true, true) - if (thisObject.dataMine === undefined) { - thisObject.payload.uiObject.setErrorMessage('Data Mine or Trading Mine not Found') - return + thisObject.mine = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(thisObject.definition, 'Data Mine', undefined, false, true, true, true) + if (thisObject.mine === undefined) { + thisObject.mine = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(thisObject.definition, 'Trading Mine', undefined, false, true, true, true) + if (thisObject.mine === undefined) { + thisObject.mine = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(thisObject.definition, 'Intelli Mine', undefined, false, true, true, true) + if (thisObject.mine === undefined) { + thisObject.payload.uiObject.setErrorMessage('Data Mine or Trading Mine or Intelli Mine not Found') + return + } } } diff --git a/Projects/Superalgos/Spaces/Panel-Space/PanelSpace.js b/Projects/Superalgos/Spaces/Panel-Space/PanelSpace.js index 23d4acd02..c8b2ee86f 100644 --- a/Projects/Superalgos/Spaces/Panel-Space/PanelSpace.js +++ b/Projects/Superalgos/Spaces/Panel-Space/PanelSpace.js @@ -56,7 +56,7 @@ function newSuperalgosPanelSpace() { panel.session = pSession panel.initialize(pParameters.panelNode) } else { - panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName) + panel = getNewPlotterPanel(pParameters.mine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName) panel.fitFunction = UI.projects.superalgos.spaces.chartingSpace.fitFunction panel.container.isVisibleFunction = UI.projects.superalgos.spaces.chartingSpace.isThisPointVisible panel.session = pSession