Curated Node Array Refactoring

This commit is contained in:
Luis Fernando Molina committed 2021-02-01 15:17:23 +01:00
1 parent 56ca80ab92
commit 4432244041
4 files changed
+29 -23

No files matched your search

@@ -328,7 +328,7 @@
dependencyLoopBody() dependencyLoopBody()
function dependencyLoopBody() { function dependencyLoopBody() {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex] let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex]
if (dependency === undefined) { if (dependency === undefined) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
@@ -453,7 +453,7 @@
function dependencyControlLoop() { function dependencyControlLoop() {
dependencyIndex++; dependencyIndex++;
if (dependencyIndex < dataDependenciesModule.nodeArray.length) { if (dependencyIndex < dataDependenciesModule.curatedNodeArray.length) {
dependencyLoopBody() dependencyLoopBody()
} else { } else {
generateOutput() generateOutput()
@@ -68,7 +68,7 @@
dependencyLoopBody() dependencyLoopBody()
function dependencyLoopBody() { function dependencyLoopBody() {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex] let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex]
let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]
getFile() getFile()
@@ -96,7 +96,7 @@
function dependencyControlLoop() { function dependencyControlLoop() {
dependencyIndex++; dependencyIndex++;
if (dependencyIndex < dataDependenciesModule.nodeArray.length) { if (dependencyIndex < dataDependenciesModule.curatedNodeArray.length) {
dependencyLoopBody() dependencyLoopBody()
} else { } else {
generateOutput() generateOutput()
@@ -332,8 +332,8 @@
async function processSingleFiles() { async function processSingleFiles() {
dataFiles = new Map() dataFiles = new Map()
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex] let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex]
let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]
if (datasetModule.node.config.codeName !== "Single-File") { if (datasetModule.node.config.codeName !== "Single-File") {
@@ -385,12 +385,15 @@
dataFiles = new Map() dataFiles = new Map()
/* Current Time Frame detection */
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel) { if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel) {
currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0]
currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]
} }
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex] /* Loop across the list of curated dependencies */
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) {
let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex]
let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]
if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") { if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") {
@@ -499,8 +502,8 @@
We will iterate through all dependencies, in order to load the We will iterate through all dependencies, in order to load the
files that later will end up at the chart data structure. files that later will end up at the chart data structure.
*/ */
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) {
let dependency = dataDependenciesModule.nodeArray[dependencyIndex] let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex]
let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]
if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") { if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") {
@@ -3,7 +3,10 @@
This module mantains a curated array of Data Dependency nodes, This module mantains a curated array of Data Dependency nodes,
which is not exactly the ones listed at the Process Dependencies, which is not exactly the ones listed at the Process Dependencies,
but a smaller subset based on the circunstances found at the user's but a smaller subset based on the circunstances found at the user's
workspace. workspace. For example:
1. Dependencies without a Reference Parent are filtered out.
2. Dependencies which don't have a Data Set are filtered out.
It also mantains an array of Data Set Modules, which are the 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 one's that ultimately know how to load a file based on the
@@ -17,7 +20,7 @@
const MODULE_NAME = "Data Dependencies"; const MODULE_NAME = "Data Dependencies";
let thisObject = { let thisObject = {
nodeArray: undefined, curatedNodeArray: undefined,
dataSetsModulesArray: [], dataSetsModulesArray: [],
isItADepenency: isItADepenency, isItADepenency: isItADepenency,
initialize: initialize, initialize: initialize,
@@ -35,8 +38,8 @@
/* /*
First we will get all the data dependencies of the bot, as defined at the Trading Mine. First we will get all the data dependencies of the bot, as defined at the Trading Mine.
*/ */
thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') thisObject.curatedNodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
if (thisObject.nodeArray.length === 0) { if (thisObject.curatedNodeArray.length === 0) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all."); TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all.");
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE)
return return
@@ -46,7 +49,7 @@
This will allow the user to have less Data Mines loaded at 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. that the ones that a Trading Mine depends on.
*/ */
thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.nodeArray) thisObject.curatedNodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.curatedNodeArray)
} else { } else {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible not to have process dependencies, which means not data dependencies."); TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible not to have process dependencies, which means not data dependencies.");
@@ -54,7 +57,7 @@
return return
} }
if (thisObject.nodeArray.length === 0) { if (thisObject.curatedNodeArray.length === 0) {
// We allow old indicators not to declare their data dependencies. // We allow old indicators not to declare their data dependencies.
@@ -71,14 +74,14 @@
} }
/* /*
For each dependency declared at the nodeArray, we will initialize a DataSet as part of this initialization process. For each dependency declared at the curatedNodeArray, we will initialize a DataSet as part of this initialization process.
*/ */
let alreadyCalledBack = false let alreadyCalledBack = false
let addCount = 0 let addCount = 0
let skipCount = 0 let skipCount = 0
/* /*
The current nodeArray that we have includes all the dependencies daclared in the Data Mine | Trading Mine | Learning Mine The current curatedNodeArray that we have includes all the dependencies daclared in the Data Mine | Trading Mine | Learning Mine
process dependencies, minus the ones without reference parent, meaning that references Data Mines that are process dependencies, minus the ones without reference parent, meaning that references Data Mines that are
not present at the workspace. From all the remaining dependencies there will be others that we need to not present at the workspace. From all the remaining dependencies there will be others that we need to
filter out, and they are the ones which the user does not have a data product anywhere on the network where filter out, and they are the ones which the user does not have a data product anywhere on the network where
@@ -89,9 +92,9 @@
*/ */
let newNodeArray = [] let newNodeArray = []
for (let i = 0; i < thisObject.nodeArray.length; i++) { for (let i = 0; i < thisObject.curatedNodeArray.length; i++) {
let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex); let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex);
dataSetModule.initialize(thisObject.nodeArray[i], onInitilized); dataSetModule.initialize(thisObject.curatedNodeArray[i], onInitilized);
function onInitilized(err, wasInitialized) { function onInitilized(err, wasInitialized) {
@@ -105,7 +108,7 @@
if (wasInitialized === true) { if (wasInitialized === true) {
addCount++; addCount++;
newNodeArray.push(thisObject.nodeArray[i]) newNodeArray.push(thisObject.curatedNodeArray[i])
addDataSet() addDataSet()
} else { } else {
skipCount++ skipCount++
@@ -118,10 +121,10 @@
} }
function checkIfWeAreDone() { function checkIfWeAreDone() {
if (addCount + skipCount === thisObject.nodeArray.length) { if (addCount + skipCount === thisObject.curatedNodeArray.length) {
if (alreadyCalledBack === false) { if (alreadyCalledBack === false) {
alreadyCalledBack = true alreadyCalledBack = true
thisObject.nodeArray = newNodeArray thisObject.curatedNodeArray = newNodeArray
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
return; return;
} }