From b454eea2a654ee0d9d75e1a99d16a63ecd1184ee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Nov 2020 16:58:29 +0100 Subject: [PATCH] Node Utilites migrated --- Projects/ProjectsSchema.json | 9 +- .../Superalgos/TS/Utilities/NodeFunctions.js | 195 ++++++++++++++++++ TaskServer/Commons.js | 12 +- TaskServer/DataDependencies.js | 4 +- TaskServer/DataSet.js | 4 +- TaskServer/Globals.js | 183 ---------------- TaskServer/IndicatorOutput.js | 8 +- .../LowFrequencyTrading/TradingOutput.js | 2 +- .../LowFrequencyTrading/TradingProcess.js | 8 +- .../LowFrequencyTrading/TradingRecords.js | 2 +- .../LowFrequencyTrading/TradingSimulation.js | 4 +- TaskServer/MultiPeriodDaily.js | 2 +- TaskServer/MultiPeriodMarket.js | 2 +- TaskServer/ProcessOutput.js | 20 +- .../ReinforcementLearning/LearningProcess.js | 8 +- 15 files changed, 241 insertions(+), 222 deletions(-) create mode 100644 Projects/Superalgos/TS/Utilities/NodeFunctions.js diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index bac911504..ff131c3c2 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -353,7 +353,14 @@ "fileName": "ProcessFunctions.js" } ], - "utilities": [], + "utilities": [ + { + "name": "Node Functions", + "propertyName": "nodeFunctions", + "functionName": "newSuperalgosUtilitiesNodeFunctions", + "fileName": "NodeFunctions.js" + } + ], "botClasses": [] }, "CL": {} diff --git a/Projects/Superalgos/TS/Utilities/NodeFunctions.js b/Projects/Superalgos/TS/Utilities/NodeFunctions.js new file mode 100644 index 000000000..be3c0c014 --- /dev/null +++ b/Projects/Superalgos/TS/Utilities/NodeFunctions.js @@ -0,0 +1,195 @@ +exports.newSuperalgosUtilitiesNodeFunctions = function () { + + let thisObject = { + nodeBrachToArray: nodeBrachToArray, + findNodeInNodeMesh: findNodeInNodeMesh, + nodeMeshToPathArray: nodeMeshToPathArray, + findNodeInNodeArray: findNodeInNodeArray, + filterOutNodeWihtoutReferenceParentFromNodeArray: filterOutNodeWihtoutReferenceParentFromNodeArray + } + + return thisObject + + function nodeBrachToArray(node, nodeType) { + let resultArray = [] + scanNodeBranch(node, nodeType) + return resultArray + + function scanNodeBranch(startingNode) { + let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) + if (nodeDefinition === undefined) { return } + + if (startingNode.type === nodeType) { + resultArray.push(startingNode) + return + } + + if (nodeDefinition.properties === undefined) { return } + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + scanNodeBranch(startingNode[property.name]) + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + scanNodeBranch(startingNodePropertyArray[m]) + } + } + break + } + } + } + } + } + + function findNodeInNodeMesh (node, nodeType) { + /* + This function scans a node mesh for a certain node type and + returns the first instance found. + */ + let nodeFound + scanNodeMesh(node, nodeType) + return nodeFound + + function scanNodeMesh(startingNode) { + if (startingNode === undefined) { return } + if (nodeFound !== undefined) { return } + + let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) + if (nodeDefinition === undefined) { return } + + if (startingNode.type === nodeType) { + nodeFound = startingNode + return + } + + /* We scan through this node children */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + scanNodeMesh(startingNode[property.name]) + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + scanNodeMesh(startingNodePropertyArray[m]) + } + } + break + } + } + } + } + /* We scan parents nodes. */ + if (startingNode.parentNode !== undefined) { + scanNodeMesh(startingNode.parentNode) + } + /* We scan reference parents too. */ + if (startingNode.referenceParent !== undefined) { + scanNodeMesh(startingNode.referenceParent) + } + } + } + + function nodeMeshToPathArray (node, nodeId) { + /* + This function scans a node mesh for a certain node if and + returns an array with the path within that mesh to the + requested node. + */ + let nodeArray = [] + scanNodeMesh(node) + return nodeArray + + function scanNodeMesh(startingNode) { + if (startingNode === undefined) { return } + + let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) + if (nodeDefinition === undefined) { return } + + if (startingNode.id === nodeId) { + nodeArray.push(startingNode) + return + } + + /* We scan through this node children */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + scanNodeMesh(startingNode[property.name]) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + scanNodeMesh(startingNodePropertyArray[m]) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + } + break + } + } + } + } + /* We scan parents nodes. */ + if (startingNode.parentNode !== undefined) { + scanNodeMesh(startingNode.parentNode) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + /* We scan reference parents too. */ + if (startingNode.referenceParent !== undefined) { + scanNodeMesh(startingNode.referenceParent) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + } + } + + function findNodeInNodeArray (nodeArray, nodeType) { + for (let i = 0; i < nodeArray.length; i++) { + let node = nodeArray[i] + if (node.type === nodeType) { + return node + } + } + } + + function filterOutNodeWihtoutReferenceParentFromNodeArray (nodeArray) { + let filteredNodeArray = [] + for (let i = 0; i < nodeArray.length; i++) { + let arrayItem = nodeArray[i] + if (arrayItem.referenceParent === undefined) { + continue + } else { + filteredNodeArray.push(arrayItem) + } + } + return filteredNodeArray + } +} \ No newline at end of file diff --git a/TaskServer/Commons.js b/TaskServer/Commons.js index d361b3028..10518a35d 100644 --- a/TaskServer/Commons.js +++ b/TaskServer/Commons.js @@ -92,12 +92,12 @@ return } - let botNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Indicator Bot') + let botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Indicator Bot') if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Trading Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Trading Bot') } if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Learning Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Learning Bot') } if (botNode === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Product Definition not attached to a Bot. Product Definition = "); @@ -111,11 +111,11 @@ return } - let dataMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Data Mine') + let dataMineNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Data Mine') if (dataMineNode === undefined) { - let tradingMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Trading Mine') + let tradingMineNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Trading Mine') if (tradingMineNode === undefined) { - let learningMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Learning Mine') + let learningMineNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Learning Mine') if (learningMineNode === undefined) { logger.write(MODULE_NAME, "[ERROR] start -> Bot not attached to a Data Mine, Trading Mine or Learning Mine."); callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); diff --git a/TaskServer/DataDependencies.js b/TaskServer/DataDependencies.js index cc392d7b1..cfda35f87 100644 --- a/TaskServer/DataDependencies.js +++ b/TaskServer/DataDependencies.js @@ -20,7 +20,7 @@ try { /* Basic Valdidations */ if (bot.processNode.referenceParent.processDependencies !== undefined) { - thisObject.nodeArray = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processDependencies, 'Data Dependency') + thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency') if (thisObject.nodeArray.length === 0) { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all."); callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) @@ -31,7 +31,7 @@ This will allow the user to have less Data Mines loaded at the workspace that the ones that a Trading Mine depends on. */ - thisObject.nodeArray = global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY(thisObject.nodeArray) + thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.nodeArray) } else { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible not to have process dependencies, which means not data dependencies."); diff --git a/TaskServer/DataSet.js b/TaskServer/DataSet.js index 76995af1b..add00c8de 100644 --- a/TaskServer/DataSet.js +++ b/TaskServer/DataSet.js @@ -81,8 +81,8 @@ exports.newDataSet = function newDataSet(BOT, logger) { let network = global.TASK_NETWORK let datasetProductDefinition = thisObject.node.parentNode - let nodeArray = global.NODE_MESH_TO_PATH_ARRAY(network, datasetProductDefinition.id) - let networkNode = global.FIND_NODE_IN_NODE_ARRAY(nodeArray, 'Network Node') + let nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeMeshToPathArray(network, datasetProductDefinition.id) + let networkNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeArray(nodeArray, 'Network Node') if (networkNode === undefined) { logger.write(MODULE_NAME, "[WARN] initialize -> Network Node not found.") diff --git a/TaskServer/Globals.js b/TaskServer/Globals.js index 7964d00f6..6ee5d68e7 100644 --- a/TaskServer/Globals.js +++ b/TaskServer/Globals.js @@ -33,189 +33,6 @@ exports.newGlobals = function newGlobals() { return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + GMT_SECONDS); } - global.NODE_BRANCH_TO_ARRAY = function (node, nodeType) { - let resultArray = [] - scanNodeBranch(node, nodeType) - return resultArray - - function scanNodeBranch(startingNode) { - let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) - if (nodeDefinition === undefined) { return } - - if (startingNode.type === nodeType) { - resultArray.push(startingNode) - return - } - - if (nodeDefinition.properties === undefined) { return } - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - scanNodeBranch(startingNode[property.name]) - } - break - case 'array': { - let startingNodePropertyArray = startingNode[property.name] - if (startingNodePropertyArray !== undefined) { - for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeBranch(startingNodePropertyArray[m]) - } - } - break - } - } - } - } - } - - global.FIND_NODE_IN_NODE_MESH = function (node, nodeType) { - /* - This function scans a node mesh for a certain node type and - returns the first instance found. - */ - let nodeFound - scanNodeMesh(node, nodeType) - return nodeFound - - function scanNodeMesh(startingNode) { - if (startingNode === undefined) { return } - if (nodeFound !== undefined) { return } - - let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) - if (nodeDefinition === undefined) { return } - - if (startingNode.type === nodeType) { - nodeFound = startingNode - return - } - - /* We scan through this node children */ - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - scanNodeMesh(startingNode[property.name]) - } - break - case 'array': { - let startingNodePropertyArray = startingNode[property.name] - if (startingNodePropertyArray !== undefined) { - for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeMesh(startingNodePropertyArray[m]) - } - } - break - } - } - } - } - /* We scan parents nodes. */ - if (startingNode.parentNode !== undefined) { - scanNodeMesh(startingNode.parentNode) - } - /* We scan reference parents too. */ - if (startingNode.referenceParent !== undefined) { - scanNodeMesh(startingNode.referenceParent) - } - } - } - - global.NODE_MESH_TO_PATH_ARRAY = function (node, nodeId) { - /* - This function scans a node mesh for a certain node if and - returns an array with the path within that mesh to the - requested node. - */ - let nodeArray = [] - scanNodeMesh(node) - return nodeArray - - function scanNodeMesh(startingNode) { - if (startingNode === undefined) { return } - - let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) - if (nodeDefinition === undefined) { return } - - if (startingNode.id === nodeId) { - nodeArray.push(startingNode) - return - } - - /* We scan through this node children */ - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - scanNodeMesh(startingNode[property.name]) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - break - case 'array': { - let startingNodePropertyArray = startingNode[property.name] - if (startingNodePropertyArray !== undefined) { - for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeMesh(startingNodePropertyArray[m]) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - } - break - } - } - } - } - /* We scan parents nodes. */ - if (startingNode.parentNode !== undefined) { - scanNodeMesh(startingNode.parentNode) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - /* We scan reference parents too. */ - if (startingNode.referenceParent !== undefined) { - scanNodeMesh(startingNode.referenceParent) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - } - } - - global.FIND_NODE_IN_NODE_ARRAY = function (nodeArray, nodeType) { - for (let i = 0; i < nodeArray.length; i++) { - let node = nodeArray[i] - if (node.type === nodeType) { - return node - } - } - } - - global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY = function (nodeArray) { - let filteredNodeArray = [] - for (let i = 0; i < nodeArray.length; i++) { - let arrayItem = nodeArray[i] - if (arrayItem.referenceParent === undefined) { - continue - } else { - filteredNodeArray.push(arrayItem) - } - } - return filteredNodeArray - } - global.EMIT_SESSION_STATUS = function (status, key) { switch (status) { case 'Running': { diff --git a/TaskServer/IndicatorOutput.js b/TaskServer/IndicatorOutput.js index 6e83fd57a..167f6b29d 100644 --- a/TaskServer/IndicatorOutput.js +++ b/TaskServer/IndicatorOutput.js @@ -50,11 +50,11 @@ } /* The first phase here is about checking that we have everything we need at the definition level. */ - let dataDependencies = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processDependencies, 'Data Dependency') + let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency') if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return } - let outputDatasets = global.NODE_BRANCH_TO_ARRAY (bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray (bot.processNode.referenceParent.processOutput, 'Output Dataset') if (commons.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return } /* The second phase is about transforming the inputs into a format that can be used to apply the user defined code. */ @@ -129,9 +129,9 @@ contextSummary.dataset = outputDatasetNode.referenceParent.config.codeName contextSummary.product = outputDatasetNode.referenceParent.parentNode.config.codeName - let botNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Indicator Bot') + let botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Indicator Bot') contextSummary.bot = botNode.config.codeName - let dataMineNode = global.FIND_NODE_IN_NODE_MESH(outputDatasetNode, 'Data Mine') + let dataMineNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Data Mine') contextSummary.dataMine = dataMineNode.config.codeName contextSummary.mineType = dataMineNode.type.replace(' ', '-') contextSummary.project = dataMineNode.project diff --git a/TaskServer/LowFrequencyTrading/TradingOutput.js b/TaskServer/LowFrequencyTrading/TradingOutput.js index 81960c2a5..f91ea5ef6 100644 --- a/TaskServer/LowFrequencyTrading/TradingOutput.js +++ b/TaskServer/LowFrequencyTrading/TradingOutput.js @@ -40,7 +40,7 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, tradingEngineM const TRADING_SIMULATION = require('./TradingSimulation.js') let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(bot, logger, tradingEngineModule, UTILITIES) - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') let outputDatasetsMap = new Map() if (bot.processingDailyFiles === true) { diff --git a/TaskServer/LowFrequencyTrading/TradingProcess.js b/TaskServer/LowFrequencyTrading/TradingProcess.js index 0d48724e7..0cbb0ddb8 100644 --- a/TaskServer/LowFrequencyTrading/TradingProcess.js +++ b/TaskServer/LowFrequencyTrading/TradingProcess.js @@ -555,17 +555,17 @@ let mainDependency = {} /* The first phase here is about checking that we have everything we need at the definition level. */ - let dataDependencies = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processDependencies, 'Data Dependency') + let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency') /* We will filter ourt declared dependencies that are not present in the workspace. This will allow the user to have less Data Mines loaded at the workspace that the ones that a Trading Mine depends on. */ - dataDependencies = global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY(dataDependencies) + dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return } - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') if (commons.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return } /* The second phase is about transforming the inputs into a format that can be used to apply the user defined code. */ @@ -624,7 +624,7 @@ } async function writeProcessFiles() { - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel) await writeDataRanges() diff --git a/TaskServer/LowFrequencyTrading/TradingRecords.js b/TaskServer/LowFrequencyTrading/TradingRecords.js index 8777fc2b6..3473ead31 100644 --- a/TaskServer/LowFrequencyTrading/TradingRecords.js +++ b/TaskServer/LowFrequencyTrading/TradingRecords.js @@ -37,7 +37,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) { we have a pointer to the node that have the information we need to extract. Later, based on the product record definition we will extract each individual value. */ - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') for (let i = 0; i < outputDatasets.length; i++) { let outputDatasetNode = outputDatasets[i] diff --git a/TaskServer/LowFrequencyTrading/TradingSimulation.js b/TaskServer/LowFrequencyTrading/TradingSimulation.js index 9a86f2fae..369f766b3 100644 --- a/TaskServer/LowFrequencyTrading/TradingSimulation.js +++ b/TaskServer/LowFrequencyTrading/TradingSimulation.js @@ -313,8 +313,8 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin easy access to the current candle for instance, or the current bollinger band, meaning the one the Simulation is currently standing at. For that reason we do the following processing, to have at the chart data structure the current objects of each indicator / time frame. */ - let dataDependencies = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processDependencies, 'Data Dependency') - dataDependencies = global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY(dataDependencies) + let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency') + dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) /* Finding the Current Element on Market Files */ if (bot.processingDailyFiles) { diff --git a/TaskServer/MultiPeriodDaily.js b/TaskServer/MultiPeriodDaily.js index e26090c2c..461f73ef2 100644 --- a/TaskServer/MultiPeriodDaily.js +++ b/TaskServer/MultiPeriodDaily.js @@ -467,7 +467,7 @@ } function writeDataRanges(callBack) { - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') let outputDatasetIndex = -1; controlLoop() diff --git a/TaskServer/MultiPeriodMarket.js b/TaskServer/MultiPeriodMarket.js index 4ca45d651..c016764cb 100644 --- a/TaskServer/MultiPeriodMarket.js +++ b/TaskServer/MultiPeriodMarket.js @@ -141,7 +141,7 @@ } function writeTimeFramesFiles(callBack) { - let outputDatasets = global.NODE_BRANCH_TO_ARRAY (bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray (bot.processNode.referenceParent.processOutput, 'Output Dataset') let outputDatasetIndex = -1; controlLoop() diff --git a/TaskServer/ProcessOutput.js b/TaskServer/ProcessOutput.js index a465b79cb..bb3aa4351 100644 --- a/TaskServer/ProcessOutput.js +++ b/TaskServer/ProcessOutput.js @@ -20,20 +20,20 @@ /* We will reaise the events for the datasets impacted by the process that just finished. */ if (bot.processNode.referenceParent.processOutput !== undefined) { - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') for (let j = 0; j < outputDatasets.length; j++) { let outputDataset = outputDatasets[j] - let botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Indicator Bot') + let botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot') if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Trading Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot') } if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Sensor Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot') } if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Learning Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot') } /* Some validations to verify that everything is in place. */ @@ -110,20 +110,20 @@ function asyncRaiseEvents(lastFile, timeFrames) { if (bot.processNode.referenceParent.processOutput !== undefined) { - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') for (let j = 0; j < outputDatasets.length; j++) { let outputDataset = outputDatasets[j] - let botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Indicator Bot') + let botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot') if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Trading Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot') } if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Sensor Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot') } if (botNode === undefined) { - botNode = global.FIND_NODE_IN_NODE_MESH(outputDataset, 'Learning Bot') + botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot') } /* Some validations to verify that everything is in place. */ diff --git a/TaskServer/ReinforcementLearning/LearningProcess.js b/TaskServer/ReinforcementLearning/LearningProcess.js index 957871261..8fcf11c7c 100644 --- a/TaskServer/ReinforcementLearning/LearningProcess.js +++ b/TaskServer/ReinforcementLearning/LearningProcess.js @@ -555,17 +555,17 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) let mainDependency = {} /* The first phase here is about checking that we have everything we need at the definition level. */ - let dataDependencies = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processDependencies, 'Data Dependency') + let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency') /* We will filter ourt declared dependencies that are not present in the workspace. This will allow the user to have less Data Mines loaded at the workspace that the ones that a Trading Mine depends on. */ - dataDependencies = global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY(dataDependencies) + dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return } - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') if (commons.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return } /* The second phase is about transforming the inputs into a format that can be used to apply the user defined code. */ @@ -624,7 +624,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES) } async function writeProcessFiles() { - let outputDatasets = global.NODE_BRANCH_TO_ARRAY(bot.processNode.referenceParent.processOutput, 'Output Dataset') + let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBrachToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset') await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel) await writeDataRanges()