From f42a46dc48dd27f88068e6af80012f96d0a85604 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 13:50:46 +0100 Subject: [PATCH] Improving Code Comments --- .../Low-Frequency-Trading/TradingProcess.js | 37 +++++++++++++++---- .../TS/Process-Modules/DataDependencies.js | 24 +++++++++--- .../Superalgos/TS/Process-Modules/Dataset.js | 8 ++-- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index 6c8f56339..8d7f4e81a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -587,23 +587,44 @@ } function buildCharts(chart) { + /* Fisrt Phase: Validations */ let mainDependency = {} - - /* The first phase here is about checking that we have everything we need at the definition level. */ + /* + THe first thing we do is to build an array of all the + declared dependencies of the Trading Bot. + */ let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].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. + Then we will filter out declared dependencies that are + not referencing nodes currently present at the workspace. + This will allow the user to have less Data Mines loaded at + the workspace that the ones that a Trading Bot depends on. */ dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) - + /* + We will run some validations to prevent starting the process + if all needed config and nodes are not present. + */ if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateDataDependencies(processIndex, dataDependencies, callBackFunction) !== true) { return } - + /* + Next we will build an array of output datasets of this process. + We are not going to use it right now, but later down the line, + we do it just to be able to validate that all nodes and config + are ok before letting this provess run too far. + */ let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset') + /* + Here we check that all output datasets configs are ok. + */ if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateOutputDatasets(processIndex, 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. */ + /* Second Phase: Bilding the chart data structure */ + + /* + This phase is about transforming the inputs into a format, + or data structure that can be used in Javascript Code and + Formula nodes to access Indicator's data. + */ for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) { let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[j][1] let dataFiles = multiPeriodDataFiles.get(timeFrameLabel) diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index 1c7789468..eec6b6d0b 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -1,5 +1,19 @@ exports.newSuperalgosProcessModulesDataDependencies = function (processIndex) { + /* + This module mantains a curated array of Data Dependency nodes, + which is not exactly the ones listed at the Process Dependencies, + but a smaller subset based on the circunstances found at the user's + workspace. + It also mantains an array of Data Set Modules, which are the + one's that ultimately know how to load a file based on the + network configuration found at the workspace at the moment this + Task was launched. + + Finally it mantains a Filter map, that allows the users of this module + to filter out data dependencies based on the code written by users + at the Javascript Code and Formula nodes. + */ const MODULE_NAME = "Data Dependencies"; let thisObject = { @@ -28,7 +42,7 @@ return } /* - We will filter ourt declared dependencies that are not present in the workspace. + We will filter out 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. */ @@ -72,7 +86,7 @@ out is by analizyng the response of the initialization call to the DataSet module. If it did not fail but it was not initialized, then we will assume this happened because the data could not be located and we will assume the user did this on purpose and we will filter out this dependency by not putting it on this new array. - */ + */ let newNodeArray = [] for (let i = 0; i < thisObject.nodeArray.length; i++) { @@ -92,14 +106,14 @@ if (wasInitialized === true) { addCount++; newNodeArray.push(thisObject.nodeArray[i]) - addDataSet() + addDataSet() } else { skipCount++ } - checkIfWeAreDone() + checkIfWeAreDone() } - function addDataSet() { + function addDataSet() { thisObject.dataSetsModulesArray.push(dataSetModule); } diff --git a/Projects/Superalgos/TS/Process-Modules/Dataset.js b/Projects/Superalgos/TS/Process-Modules/Dataset.js index 69175b4d4..7ce2b8b2c 100644 --- a/Projects/Superalgos/TS/Process-Modules/Dataset.js +++ b/Projects/Superalgos/TS/Process-Modules/Dataset.js @@ -1,5 +1,9 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { - + /* + This module represents a Dataset at a certain localtion on the + network, and it is able to load a file from that dataset or + write one into it. + */ const MODULE_NAME = "Dataset"; let thisObject = { @@ -12,8 +16,6 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { }; /* Storage account to be used here. */ - - let fileStorage return thisObject;