From 78040472d1adc54bfadb36137e7227b58ce7783e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 21 Sep 2020 09:36:51 +0200 Subject: [PATCH] Bug fixed --- DataDependencies.js | 10 +++++++--- LowFrequencyTrading/TradingProcess.js | 6 ++++++ LowFrequencyTrading/TradingSimulation.js | 1 + server.js | 13 +++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/DataDependencies.js b/DataDependencies.js index 88e57be8e..552f6a64f 100644 --- a/DataDependencies.js +++ b/DataDependencies.js @@ -28,6 +28,13 @@ callBackFunction(global.DEFAULT_OK_RESPONSE) return } + /* + 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. + */ + thisObject.nodeArray = global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY(thisObject.nodeArray) + } else { logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have process dependencies, which means not data dependencies."); callBackFunction(global.DEFAULT_OK_RESPONSE) @@ -57,9 +64,7 @@ let addCount = 0; for (let i = 0; i < thisObject.nodeArray.length; i++) { - let dataSetModule = DATA_SET.newDataSet(BOT, logger); - dataSetModule.initialize(thisObject.nodeArray[i], onInitilized); function onInitilized(err) { @@ -71,7 +76,6 @@ callBackFunction(err); return; } - addDataSet(); } diff --git a/LowFrequencyTrading/TradingProcess.js b/LowFrequencyTrading/TradingProcess.js index 5960be476..b6298e6f0 100644 --- a/LowFrequencyTrading/TradingProcess.js +++ b/LowFrequencyTrading/TradingProcess.js @@ -505,6 +505,12 @@ /* 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') + /* + 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) if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return } diff --git a/LowFrequencyTrading/TradingSimulation.js b/LowFrequencyTrading/TradingSimulation.js index a1af9db6e..186f2872e 100644 --- a/LowFrequencyTrading/TradingSimulation.js +++ b/LowFrequencyTrading/TradingSimulation.js @@ -317,6 +317,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin 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) /* Finding the Current Element on Market Files */ if (bot.processingDailyFiles) { diff --git a/server.js b/server.js index c081bb175..754888678 100644 --- a/server.js +++ b/server.js @@ -272,6 +272,19 @@ global.FIND_NODE_IN_NODE_ARRAY = function (nodeArray, nodeType) { } } +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 +} + process.on('uncaughtException', function (err) { console.log('[ERROR] Task Server -> server -> uncaughtException -> err.message = ' + err.message)