From d5370220f562e695b25bafac52cec760da73eb27 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Apr 2020 16:21:56 +0200 Subject: [PATCH] Dependencies filters tested --- MultiPeriod.js | 24 ++++++++++++++++-------- TradingSimulation.js | 10 ++++++++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/MultiPeriod.js b/MultiPeriod.js index bc3d0b196..9a54e8978 100644 --- a/MultiPeriod.js +++ b/MultiPeriod.js @@ -409,8 +409,10 @@ } if (dataDependenciesModule.isItADepenency(timeFrameLabel, datasetModule.node.parentNode.code.singularVariableName) !== true) { - dependencyControlLoop(); - return + if (!(bot.VALUES_TO_USE.timeFrame === timeFrameLabel && datasetModule.node.parentNode.code.pluralVariableName === 'candles')) { + dependencyControlLoop(); + return + } } let fileName = "Data.json"; @@ -719,8 +721,10 @@ } if (dataDependenciesModule.isItADepenency(timeFrameLabel, datasetModule.node.parentNode.code.singularVariableName) !== true) { - dependencyControlLoop(); - return + if (!(bot.VALUES_TO_USE.timeFrame === timeFrameLabel && datasetModule.node.parentNode.code.pluralVariableName === 'candles')) { + dependencyControlLoop(); + return + } } let dateForPath = previousDay.getUTCFullYear() + '/' + utilities.pad(previousDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(previousDay.getUTCDate(), 2); @@ -789,17 +793,21 @@ } function getCurrentFile() { - try { - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> processDailyFiles -> timeFramesLoopBody -> dependencyLoopBody -> getCurrentFile -> Entering function."); } - if (dependency.referenceParent.code.codeName === "Multi-Period-Market") { - + if (dependency.referenceParent.code.codeName !== "Multi-Period-Daily") { dependencyControlLoop(); return } + if (dataDependenciesModule.isItADepenency(timeFrameLabel, datasetModule.node.parentNode.code.singularVariableName) !== true) { + if (!(bot.VALUES_TO_USE.timeFrame === timeFrameLabel && datasetModule.node.parentNode.code.pluralVariableName === 'candles')) { + dependencyControlLoop(); + return + } + } + let dateForPath = bot.multiPeriodProcessDatetime.getUTCFullYear() + '/' + utilities.pad(bot.multiPeriodProcessDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.multiPeriodProcessDatetime.getUTCDate(), 2); let filePath if (dependency.referenceParent.code.codeName === "Multi-Period-Daily") { diff --git a/TradingSimulation.js b/TradingSimulation.js index a97fd1bc4..4f6ce4397 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -571,7 +571,10 @@ let singularVariableName = dataDependencyNode.referenceParent.parentNode.code.singularVariableName let pluralVariableName = dataDependencyNode.referenceParent.parentNode.code.pluralVariableName let elementArray = thisChart[pluralVariableName] - let currentElement = elementArray[elementArray.length - 1] + let currentElement + if (elementArray !== undefined) { + currentElement = elementArray[elementArray.length - 1] + } thisChart[singularVariableName] = currentElement } @@ -615,6 +618,7 @@ previousLoopingDay = loopingDay.valueOf() /* If any of the needed data dependencies is missing for this particular candle, then we jump the candle*/ + /* for (let k = 0; k < dataDependencies.length; k++) { let dataDependencyNode = dataDependencies[k] let singularVariableName = dataDependencyNode.referenceParent.parentNode.code.singularVariableName @@ -629,6 +633,7 @@ return } } + */ periods++; days = periods * timeFrame / ONE_DAY_IN_MILISECONDS; @@ -2905,7 +2910,7 @@ } function getElement(pArray, currentCandle, datasetName) { - + if (pArray === undefined) {return} try { let element; for (let i = 0; i < pArray.length; i++) { @@ -2938,6 +2943,7 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] runSimulation -> getElement -> datasetName = " + datasetName); + logger.write(MODULE_NAME, "[ERROR] runSimulation -> getElement -> err = " + err.stack); callBackFunction(global.DEFAULT_FAIL_RESPONSE); } }