From 240d549fc794d5c3adb63cde22ff27105b7d11f0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 09:41:15 +0100 Subject: [PATCH 01/25] Dependency Fileter Refactoring --- .../UI/Function-Libraries/DependenciesFilter.js | 12 ++++++++---- .../Function-Libraries/LearningSessionFunctions.js | 2 +- .../UI/Function-Libraries/TradingSessionFunctions.js | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index d91490ba0..47e5ad594 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -1,20 +1,24 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { /* + A Dependency Filter is list of Indicators a Strategy depends + on, that is later used to filter out all the other indicators + the Trading Bot depends on. + The function will scen a node branch, most likely a Trading System, looking into the code property of each node. It will analyze it's content and try to make a list of all indicators mentioned at the code text and at which time frames they are mentioned. - It is important to note that all node that are not of the type - Javascript Code are going to be filtered out. + It is important to note that all nodes that are not of the type + Javascript Code or Formula are going to be ignored. */ thisObject = { - createFilter: createFilter + createDependencyFilter: createDependencyFilter } return thisObject - function createFilter(node) { + function createDependencyFilter(node) { let filters = new Map() recursiveFilter(node) diff --git a/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js index e56e35759..a9ffb2271 100644 --- a/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js @@ -122,7 +122,7 @@ function newSuperalgosFunctionLibraryLearningSessionFunctions() { let session = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) - let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createFilter(node.tradingSystemReference.payload.referenceParent) + let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createDependencyFilter(node.tradingSystemReference.payload.referenceParent) /* Raise event to run the session */ let event = { diff --git a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js index b591b9c1c..2b5733ba2 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js @@ -123,7 +123,7 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { let session = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) - let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createFilter(node.tradingSystemReference.payload.referenceParent) + let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createDependencyFilter(node.tradingSystemReference.payload.referenceParent) /* Raise event to run the session */ let event = { From b526ee8d2f0371d2a7253d24ad6ba02e2de50c82 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 10:57:46 +0100 Subject: [PATCH 02/25] Dependency Filter Upgraded --- .../TS/Utilities/DateTimeFunctions.js | 2 +- .../Function-Libraries/DependenciesFilter.js | 36 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js b/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js index 60e1cd53b..02582cacc 100644 --- a/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js +++ b/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js @@ -16,7 +16,7 @@ exports.newSuperalgosUtilitiesDateTimeFunctions = function () { function getPercentage(fromDate, currentDate, lastDate) { let fromDays = Math.trunc(fromDate.valueOf() / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let currentDays = Math.trunc(currentDate.valueOf() / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) - let lastDays = Math.trunc(lastDate.valueOf() / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let lastDays = Math.trunc((lastDate.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let percentage = (currentDays - fromDays) * 100 / (lastDays - fromDays) if ((lastDays - fromDays) === 0) { percentage = 100 diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index 47e5ad594..c07f0215f 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -3,7 +3,7 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { A Dependency Filter is list of Indicators a Strategy depends on, that is later used to filter out all the other indicators the Trading Bot depends on. - + The function will scen a node branch, most likely a Trading System, looking into the code property of each node. It will analyze it's content and try to make a list of all indicators mentioned at the code @@ -64,20 +64,38 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { function filter(code) { if (code === undefined) { return } - + /* + We will clean the code from symbols that we do not need during our dependency analysis. + */ + code = code.replaceAll(',', '') + code = code.replaceAll('(', '') + code = code.replaceAll(')', '') + code = code.replaceAll('{', '') + code = code.replaceAll('}', '') + code = code.replaceAll('!', '') + code = code.replaceAll('|', '') + code = code.replaceAll('<', '') + code = code.replaceAll('>', '') + code = code.replaceAll('=', '') + code = code.replaceAll('\n', '') + /* + We will analyze each instruction of the code. + */ let instructionsArray = code.split(' ') for (let i = 0; i < instructionsArray.length; i++) { let instruction = instructionsArray[i] - if (instruction.indexOf('chart') >= 0) { + /* + The first kind of instruction we will handle are the ones + related to the chart structure. For that we need the + instruction to start with the keyword 'chart'. + */ + if (instruction.indexOf('chart') === 0) { // Example: chart.at01hs.popularSMA.sma200 - chart.at01hs.popularSMA.sma100 < 10 let parts = instruction.split('.') let timeFrame = parts[1] let product = parts[2] - let productParts = product.split(',') - product = productParts[0] - productParts = product.split(')') - product = productParts[0] - - // Example: chart.at01hs.popularSMA.sma200 - chart.at01hs.popularSMA.sma100 < 10 + /* + From the instruction syntax we will get the timeFrame + */ if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } From ab9cc4afdf68f9b3f941e76b4099768047e37cad Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 11:32:56 +0100 Subject: [PATCH 03/25] Support at the Dependency Filert for market and exchange data structures --- .../TS/Function-Libraries/SessionFunctions.js | 2 + .../Function-Libraries/DependenciesFilter.js | 45 +++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js b/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js index 4cfc063ee..c1c6818a1 100644 --- a/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js +++ b/Projects/Superalgos/TS/Function-Libraries/SessionFunctions.js @@ -1,5 +1,7 @@ exports.newSuperalgosFunctionLibrariesSessionFunctions = function () { + const MODULE_NAME = "Session Functions" + let thisObject = { sessionHeartBeat: sessionHeartBeat, stopSession: stopSession, diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index c07f0215f..fca85b42e 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -25,9 +25,9 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { return Array.from(filters.keys()) function recursiveFilter(node) { - if (node.type === 'Javascript Code' || node.type === 'Formula' ) { + if (node.type === 'Javascript Code' || node.type === 'Formula') { filter(node.code) - } + } let schemaDocument = getSchemaDocument(node) if (schemaDocument !== undefined) { @@ -77,7 +77,7 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { code = code.replaceAll('<', '') code = code.replaceAll('>', '') code = code.replaceAll('=', '') - code = code.replaceAll('\n', '') + code = code.replaceAll('\n', ' ') /* We will analyze each instruction of the code. */ @@ -101,6 +101,45 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { } filters.set(timeFrame + '-' + product, true) } + /* + The second kind of instruction we will handle are the ones + related to the market data structure. For that we need + the instruction to start with the keyword 'market' + */ + if (instruction.indexOf('market') === 0) { // Example: market.BTC.USDT.chart.at01hs.popularSMA.sma200 - market.ETC.USDT.chart.at01hs.popularSMA.sma100 < 10 + let parts = instruction.split('.') + let baseAsset = parts[1] + let quotedAsset = parts[2] + let timeFrame = parts[4] + let product = parts[5] + /* + From the instruction syntax we will get the timeFrame + */ + if (timeFrame !== 'atAnyTimeFrame') { + timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) + } + filters.set(baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + } + /* + The third kind of instruction we will handle are the ones + related to the exchange data structure. For that we need + the instruction to start with the keyword 'market' + */ + if (instruction.indexOf('exchange') === 0) { // Example: exchange.binance.market.BTC.USDT.chart.at01hs.popularSMA.sma200 - exchange.poloniex.market.ETC.USDT.chart.at01hs.popularSMA.sma100 < 10 + let parts = instruction.split('.') + let exchange = parts[1] + let baseAsset = parts[3] + let quotedAsset = parts[4] + let timeFrame = parts[6] + let product = parts[7] + /* + From the instruction syntax we will get the timeFrame + */ + if (timeFrame !== 'atAnyTimeFrame') { + timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) + } + filters.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + } } } } From f42a46dc48dd27f88068e6af80012f96d0a85604 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 13:50:46 +0100 Subject: [PATCH 04/25] 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; From 56ca80ab92d5bbd3977324d1d3a45170e6dea51a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 13:53:41 +0100 Subject: [PATCH 05/25] Removing ; --- .../Low-Frequency-Trading/TradingProcess.js | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 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 8d7f4e81a..1bb487e1b 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 @@ -19,7 +19,7 @@ TS.projects.superalgos.globals.processModuleObjects.MODULE_OBJECTS_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_ENGINE_MODULE_OBJECT = TS.projects.superalgos.botModules.tradingEngine.newSuperalgosBotModulesTradingEngine(processIndex) let tradingOutputModuleObject = TS.projects.superalgos.botModules.tradingOutput.newSuperalgosBotModulesTradingOutput(processIndex) - return thisObject; + return thisObject function initialize(pStatusDependencies, pDataDependencies, callBackFunction) { try { @@ -33,7 +33,7 @@ } catch (err) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).UNEXPECTED_ERROR = err TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] initialize -> err = " + err.stack); + "[ERROR] initialize -> err = " + err.stack) callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } @@ -64,7 +64,7 @@ lastFile: undefined, // Datetime of the last file files successfully produced by this process. dateBeginOfMarket: undefined, // Datetime of the first trade file in the whole market history. dateEndOfMarket: undefined // Datetime of the last file available to be used as an input of this process. - }; + } if (getContextVariables() !== true) { return } @@ -223,8 +223,8 @@ function getContextVariables() { try { - let thisReport; - let statusReport; + let thisReport + let statusReport /* We are going to use the start date as beging of market date. */ contextVariables.dateBeginOfMarket = TS.projects.superalgos.utilities.dateTimeFunctions.removeTime(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime) @@ -235,65 +235,65 @@ if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); + "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. ") + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return false } if (statusReport.status === "Status Report is corrupt.") { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. "); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); + "[ERROR] start -> getContextVariables -> Can not continue because dependecy Status Report is corrupt. ") + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return false } - thisReport = statusReport.file; + thisReport = statusReport.file if (thisReport.lastFile === undefined) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport = " + JSON.stringify(thisReport)); + "[WARN] start -> getContextVariables -> Undefined Last File. -> thisReport = " + JSON.stringify(thisReport)) let customOK = { result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result, message: "Dependency not ready." } TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[WARN] start -> getContextVariables -> customOK = " + customOK.message); - callBackFunction(customOK); + "[WARN] start -> getContextVariables -> customOK = " + customOK.message) + callBackFunction(customOK) return false } - contextVariables.dateEndOfMarket = new Date(thisReport.lastFile.valueOf()); + contextVariables.dateEndOfMarket = new Date(thisReport.lastFile.valueOf()) /* Finally we get our own Status Report. */ statusReport = statusDependencies.reportsByMainUtility.get("Self Reference") if (statusReport === undefined) { // This means the status report does not exist, that could happen for instance at the begining of a month. TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. "); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); + "[WARN] start -> getContextVariables -> Status Report does not exist. Retrying Later. ") + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return false } if (statusReport.status === "Status Report is corrupt.") { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process."); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); + "[ERROR] start -> getContextVariables -> Can not continue because self dependecy Status Report is corrupt. Aborting Process.") + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return false } - thisReport = statusReport.file; - TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE = thisReport.simulationState; + thisReport = statusReport.file + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE = thisReport.simulationState if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE === undefined) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE = {} } // This should happen only when there is no status report if (thisReport.lastFile !== undefined) { if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_RESUMING !== true) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Starting from the begining because bot has just started and resume execution was true.") - startFromBegining(); + startFromBegining() return true } - contextVariables.lastFile = new Date(thisReport.lastFile); + contextVariables.lastFile = new Date(thisReport.lastFile) return true } else { @@ -304,12 +304,12 @@ */ TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> getContextVariables -> Starting from the begining of the market because own status report not found or lastFile was undefined.") - startFromBegining(); + startFromBegining() return true } function startFromBegining() { - contextVariables.lastFile = new Date(contextVariables.dateBeginOfMarket.getUTCFullYear() + "-" + (contextVariables.dateBeginOfMarket.getUTCMonth() + 1) + "-" + contextVariables.dateBeginOfMarket.getUTCDate() + " " + "00:00" + TS.projects.superalgos.globals.timeConstants.GMT_SECONDS); + contextVariables.lastFile = new Date(contextVariables.dateBeginOfMarket.getUTCFullYear() + "-" + (contextVariables.dateBeginOfMarket.getUTCMonth() + 1) + "-" + contextVariables.dateBeginOfMarket.getUTCDate() + " " + "00:00" + TS.projects.superalgos.globals.timeConstants.GMT_SECONDS) TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> getContextVariables -> startFromBegining -> contextVariables.lastFile = " + contextVariables.lastFile) @@ -318,23 +318,23 @@ } catch (err) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).UNEXPECTED_ERROR = err TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] start -> getContextVariables -> err = " + err.stack); + "[ERROR] start -> getContextVariables -> err = " + err.stack) if (err.message === "Cannot read property 'file' of undefined") { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. "); + "[HINT] start -> getContextVariables -> Check the bot configuration to see if all of its statusDependencies declarations are correct. ") TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)); + "[HINT] start -> getContextVariables -> Dependencies loaded -> keys = " + JSON.stringify(statusDependencies.keys)) } - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } async function processSingleFiles() { - dataFiles = new Map(); + dataFiles = new Map() for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex]; - let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]; + let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (datasetModule.node.config.codeName !== "Single-File") { continue @@ -344,8 +344,8 @@ continue } - let fileName = "Data.json"; - let filePath = datasetModule.node.parentNode.config.codeName + '/' + datasetModule.node.config.codeName; + let fileName = "Data.json" + let filePath = datasetModule.node.parentNode.config.codeName + '/' + datasetModule.node.config.codeName /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) @@ -364,8 +364,8 @@ throw (response.err) } - let dataFile = JSON.parse(response.text); - dataFiles.set(dependency.id, dataFile); + let dataFile = JSON.parse(response.text) + dataFiles.set(dependency.id, dataFile) } let mapKey = "Single Files" @@ -380,18 +380,18 @@ We will iterate through all posible timeFrames. */ for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) { - const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0]; - const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]; + const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] + const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] - dataFiles = new Map(); + dataFiles = new Map() 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]; - currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]; + currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] + currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] } for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex]; - let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]; + let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") { continue @@ -403,8 +403,8 @@ } } - let fileName = "Data.json"; - let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel; + let fileName = "Data.json" + let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) @@ -423,9 +423,9 @@ throw (response.err) } - let dataFile = JSON.parse(response.text); + let dataFile = JSON.parse(response.text) let trimmedDataFile = trimDataFile(dataFile, datasetModule.node.parentNode.record) - dataFiles.set(dependency.id, trimmedDataFile); + dataFiles.set(dependency.id, trimmedDataFile) function trimDataFile(dataFile, recordDefinition) { /* @@ -459,7 +459,7 @@ } } - let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1]; + let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] multiPeriodDataFiles.set(mapKey, dataFiles) } return true @@ -467,20 +467,20 @@ async function processDailyFiles() { /* Telling the world we are alive and doing well and which date we are processing right now. */ - let processingDateString = tradingProcessDate.getUTCFullYear() + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCMonth() + 1, 2) + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCDate(), 2); + let processingDateString = tradingProcessDate.getUTCFullYear() + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCMonth() + 1, 2) + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCDate(), 2) TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, processingDateString, undefined, "Running...") /* We will iterate through all posible timeFrames. */ for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) { - const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0]; - const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; + const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0] + const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames !== undefined) { - let validPeriod = false; + let validPeriod = false for (let i = 0; i < TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames.length; i++) { - let period = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames[i]; + let period = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames[i] if (period === timeFrameLabel) { validPeriod = true } } if (validPeriod === false) { @@ -489,19 +489,19 @@ } 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.dailyFilePeriods()[n][0]; - currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; + currentTimeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0] + currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] } - dataFiles = new Map(); + dataFiles = new Map() /* We will iterate through all dependencies, in order to load the files that later will end up at the chart data structure. */ for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex]; - let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex]; + let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") { continue @@ -531,9 +531,9 @@ async function getDataFileFromDate(processDate) { - let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2); + let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2) let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath - let fileName = "Data.json"; + let fileName = "Data.json" /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) @@ -554,7 +554,7 @@ return JSON.parse(response.text) } } - let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; + let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] multiPeriodDataFiles.set(mapKey, dataFiles) } return true @@ -697,8 +697,8 @@ outputDatasetIndex < outputDatasets.length; outputDatasetIndex++ ) { - let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName; - await writeDataRange(productCodeName); + let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName + await writeDataRange(productCodeName) } async function writeDataRange(productCodeName) { @@ -707,9 +707,9 @@ end: tradingProcessDate.valueOf() + TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS } - let fileContent = JSON.stringify(dataRange); - let fileName = '/Data.Range.json'; - let filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Output/" + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/" + productCodeName + "/" + 'Multi-Period-Daily' + fileName; + let fileContent = JSON.stringify(dataRange) + let fileName = '/Data.Range.json' + let filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Output/" + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/" + productCodeName + "/" + 'Multi-Period-Daily' + fileName let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n') @@ -736,7 +736,7 @@ outputDatasetIndex < outputDatasets.length; outputDatasetIndex++ ) { - let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName; + let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName await writeTimeFramesFile(currentTimeFrameLabel, productCodeName, 'Multi-Period-Daily') await writeTimeFramesFile(currentTimeFrameLabel, productCodeName, 'Multi-Period-Market') @@ -746,9 +746,9 @@ timeFramesArray.push(currentTimeFrameLabel) let fileContent = JSON.stringify(timeFramesArray) - let fileName = '/Time.Frames.json'; + let fileName = '/Time.Frames.json' - let filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Output/" + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/" + productCodeName + "/" + processType + fileName; + let filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Output/" + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/" + productCodeName + "/" + processType + fileName let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n') if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { @@ -770,7 +770,7 @@ async function writeMarketStatusReport(currentTimeFrameLabel) { let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName - let thisReport = statusDependencies.statusReports.get(reportKey); + let thisReport = statusDependencies.statusReports.get(reportKey) thisReport.file.lastExecution = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_DATETIME thisReport.file.simulationState = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE @@ -798,8 +798,8 @@ if (err.stack) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).UNEXPECTED_ERROR = err TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] start -> Unhandled Exception. Will Abort this process. err = " + err.stack); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); + "[ERROR] start -> Unhandled Exception. Will Abort this process. err = " + err.stack) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } @@ -807,7 +807,7 @@ if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] File not Found. Will Retry the Process Loop.") - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE); + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_RETRY_RESPONSE) return } @@ -815,8 +815,8 @@ if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).UNEXPECTED_ERROR = err TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] start -> Handled Exception. Will Abort this process. err = " + err.message); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); + "[ERROR] start -> Handled Exception. Will Abort this process. err = " + err.message) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } } @@ -826,7 +826,7 @@ let promise = new Promise((resolve, reject) => { - datasetModule.getTextFile(filePath, fileName, onFileReceived); + datasetModule.getTextFile(filePath, fileName, onFileReceived) function onFileReceived(err, text) { let response = { @@ -835,7 +835,7 @@ } resolve(response) } - }); + }) return promise } From 44322440418c8e8bfbeee4a2e988a22081420e35 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 15:17:23 +0100 Subject: [PATCH 06/25] Curated Node Array Refactoring --- .../Indicator-Bot/MultiPeriodDaily.js | 4 +-- .../Indicator-Bot/MultiPeriodMarket.js | 4 +-- .../Low-Frequency-Trading/TradingProcess.js | 15 ++++++---- .../TS/Process-Modules/DataDependencies.js | 29 ++++++++++--------- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js index c4ed56b43..636e7389d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js @@ -328,7 +328,7 @@ dependencyLoopBody() function dependencyLoopBody() { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] if (dependency === undefined) { 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() { dependencyIndex++; - if (dependencyIndex < dataDependenciesModule.nodeArray.length) { + if (dependencyIndex < dataDependenciesModule.curatedNodeArray.length) { dependencyLoopBody() } else { generateOutput() diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js index 120bdfef1..89dbba26a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js @@ -68,7 +68,7 @@ dependencyLoopBody() function dependencyLoopBody() { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] getFile() @@ -96,7 +96,7 @@ function dependencyControlLoop() { dependencyIndex++; - if (dependencyIndex < dataDependenciesModule.nodeArray.length) { + if (dependencyIndex < dataDependenciesModule.curatedNodeArray.length) { dependencyLoopBody() } else { generateOutput() 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 1bb487e1b..f2954f07f 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 @@ -332,8 +332,8 @@ async function processSingleFiles() { dataFiles = new Map() - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (datasetModule.node.config.codeName !== "Single-File") { @@ -385,12 +385,15 @@ 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) { currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] 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] if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") { @@ -499,8 +502,8 @@ We will iterate through all dependencies, in order to load the files that later will end up at the chart data structure. */ - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.nodeArray[dependencyIndex] + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") { diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index eec6b6d0b..5b18b86a3 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -3,7 +3,10 @@ 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. + 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 one's that ultimately know how to load a file based on the @@ -17,7 +20,7 @@ const MODULE_NAME = "Data Dependencies"; let thisObject = { - nodeArray: undefined, + curatedNodeArray: undefined, dataSetsModulesArray: [], isItADepenency: isItADepenency, initialize: initialize, @@ -35,8 +38,8 @@ /* 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') - if (thisObject.nodeArray.length === 0) { + thisObject.curatedNodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') + 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."); callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return @@ -46,7 +49,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 = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.nodeArray) + thisObject.curatedNodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.curatedNodeArray) } 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."); @@ -54,7 +57,7 @@ return } - if (thisObject.nodeArray.length === 0) { + if (thisObject.curatedNodeArray.length === 0) { // 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 addCount = 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 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 @@ -89,9 +92,9 @@ */ 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); - dataSetModule.initialize(thisObject.nodeArray[i], onInitilized); + dataSetModule.initialize(thisObject.curatedNodeArray[i], onInitilized); function onInitilized(err, wasInitialized) { @@ -105,7 +108,7 @@ if (wasInitialized === true) { addCount++; - newNodeArray.push(thisObject.nodeArray[i]) + newNodeArray.push(thisObject.curatedNodeArray[i]) addDataSet() } else { skipCount++ @@ -118,10 +121,10 @@ } function checkIfWeAreDone() { - if (addCount + skipCount === thisObject.nodeArray.length) { + if (addCount + skipCount === thisObject.curatedNodeArray.length) { if (alreadyCalledBack === false) { alreadyCalledBack = true - thisObject.nodeArray = newNodeArray + thisObject.curatedNodeArray = newNodeArray callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } From ea092fa6e5224c5afd7d0710d85ccbd857d1538a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Feb 2021 16:06:56 +0100 Subject: [PATCH 07/25] Dependency Filer at the UI expanded to include the market and exchange data structures --- Projects/Superalgos/Schemas/AppSchema.json | 2 +- .../TS/Process-Modules/DataDependencies.js | 63 ++++++++++++++++--- .../Function-Libraries/DependenciesFilter.js | 36 +++++++++-- 3 files changed, 85 insertions(+), 16 deletions(-) diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index b509ef075..50e348b90 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -11580,7 +11580,7 @@ }, "level": 4, "attachingRules": { - "compatibleTypes": "->Target Size In Base Asset->Target Size In Quoted Asset->Target Rate->Phase->Simulated Actual Rate->Situation->Indicator Function->" + "compatibleTypes": "->Target Size In Base Asset->Target Size In Quoted Asset->Target Rate->Phase->Simulated Actual Rate->Situation->Indicator Function->Order Rate->" }, "propertyNameAtParent": "formula" }, diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index 5b18b86a3..1e34a07f1 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -20,6 +20,7 @@ const MODULE_NAME = "Data Dependencies"; let thisObject = { + filters: undefined, curatedNodeArray: undefined, dataSetsModulesArray: [], isItADepenency: isItADepenency, @@ -27,7 +28,20 @@ finalize: finalize }; - let filter = new Map() + thisObject.filters = { + chart: { + list: new Map(), + products: new Map() + }, + market: { + list: new Map(), + products: new Map() + }, + exchange: { + list: new Map(), + products: new Map() + } + } return thisObject; @@ -60,19 +74,47 @@ if (thisObject.curatedNodeArray.length === 0) { // We allow old indicators not to declare their data dependencies. - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return; } - /* Session based dependency filters */ - if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER !== undefined) { - for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER.length; i++) { - let key = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER[i] - filter.set(key, true) + /* Session based dependency thisObject.filters */ + let dependencyFilter = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER + if (dependencyFilter !== undefined) { + + /* + Javascript Maps can not travel stringified at ta JSON object, so we receive + these maps in an Array format, and here we will just convert them to Maps, + that is how we need them. + */ + arrayToMap(dependencyFilter.chart.list, thisObject.filters.chart.list) + arrayToMap(dependencyFilter.chart.products, thisObject.filters.chart.products) + + arrayToMap(dependencyFilter.market.list, thisObject.filters.market.list) + arrayToMap(dependencyFilter.market.products, thisObject.filters.market.products) + + arrayToMap(dependencyFilter.exchange.list, thisObject.filters.exchange.list) + arrayToMap(dependencyFilter.exchange.products, thisObject.filters.exchange.products) + + function arrayToMap(array, map) { + for (let i = 0; i < array.length; i++) { + let key = array[i] + map.set(key, true) + } } } - + /* + At our filter structure, we will add the Task default exchange and market. + This will help us lateer to build other structures in a generic way. + */ + thisObject.filters.exchange.list.set( + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + ) + thisObject.filters.market.list.set( + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + + "-" + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + ) /* For each dependency declared at the curatedNodeArray, we will initialize a DataSet as part of this initialization process. */ @@ -145,13 +187,14 @@ dataSetModule.finalize() } thisObject.dataSetsModulesArray = undefined - filter = undefined + thisObject.curatedNodeArray = undefined + thisObject.filters = undefined bot = undefined } function isItADepenency(timeFrame, product) { let key = timeFrame + '-' + product - return filter.get(key) + return thisObject.filters.get(key) } }; diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index fca85b42e..ff6e4c4b3 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -19,10 +19,33 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { return thisObject function createDependencyFilter(node) { - let filters = new Map() + let filters = { + chart: { + list: new Map(), + products: new Map() + }, + market: { + list: new Map(), + products: new Map() + }, + exchange: { + list: new Map(), + products: new Map() + } + } recursiveFilter(node) - return Array.from(filters.keys()) + /* Transform the Map into arrays */ + filters.chart.list = Array.from(filters.chart.list.keys()) + filters.chart.products = Array.from(filters.chart.products.keys()) + + filters.market.list = Array.from(filters.market.list.keys()) + filters.market.products = Array.from(filters.market.products.keys()) + + filters.exchange.list = Array.from(filters.exchange.list.keys()) + filters.exchange.products = Array.from(filters.exchange.products.keys()) + + return filters function recursiveFilter(node) { if (node.type === 'Javascript Code' || node.type === 'Formula') { @@ -99,7 +122,8 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } - filters.set(timeFrame + '-' + product, true) + filters.chart.products.set(timeFrame + '-' + product, true) + filters.chart.list.set(timeFrame, true) } /* The second kind of instruction we will handle are the ones @@ -118,7 +142,8 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } - filters.set(baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + filters.market.products.set(baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + filters.market.list.set(baseAsset + '-' + quotedAsset, true) } /* The third kind of instruction we will handle are the ones @@ -138,7 +163,8 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } - filters.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + filters.exchange.products.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + filters.exchange.list.set(exchange, true) } } } From f630ecf2125f8f51d59676e42bded6d81ad88c43 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 09:50:36 +0100 Subject: [PATCH 08/25] Function to find the networkNode for a Dataset reimplemented --- .../Indicator-Bot/MultiPeriodDaily.js | 4 +- .../Indicator-Bot/MultiPeriodMarket.js | 4 +- .../Low-Frequency-Trading/TradingProcess.js | 18 +- .../TS/Process-Modules/DataDependencies.js | 182 ++++++++++++------ .../Superalgos/TS/Process-Modules/Dataset.js | 159 ++++++++++++++- .../Superalgos/TS/Utilities/NodeFunctions.js | 2 +- .../Function-Libraries/DependenciesFilter.js | 3 + 7 files changed, 289 insertions(+), 83 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js index 636e7389d..957e29291 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js @@ -328,7 +328,7 @@ dependencyLoopBody() function dependencyLoopBody() { - let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] if (dependency === undefined) { 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() { dependencyIndex++; - if (dependencyIndex < dataDependenciesModule.curatedNodeArray.length) { + if (dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length) { dependencyLoopBody() } else { generateOutput() diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js index 89dbba26a..6dd051d6b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodMarket.js @@ -68,7 +68,7 @@ dependencyLoopBody() function dependencyLoopBody() { - let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] getFile() @@ -96,7 +96,7 @@ function dependencyControlLoop() { dependencyIndex++; - if (dependencyIndex < dataDependenciesModule.curatedNodeArray.length) { + if (dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length) { dependencyLoopBody() } else { generateOutput() 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 f2954f07f..62be039f2 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 @@ -332,15 +332,15 @@ async function processSingleFiles() { dataFiles = new Map() - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (datasetModule.node.config.codeName !== "Single-File") { continue } - if (dataDependenciesModule.isItADepenency('atAnyTimeFrame', datasetModule.node.parentNode.config.singularVariableName) !== true) { + if (dataDependenciesModule.isItAChartDepenency('atAnyTimeFrame', datasetModule.node.parentNode.config.singularVariableName) !== true) { continue } @@ -392,15 +392,15 @@ } /* Loop across the list of curated dependencies */ - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") { continue } - if (dataDependenciesModule.isItADepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { + if (dataDependenciesModule.isItAChartDepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { continue } @@ -502,8 +502,8 @@ We will iterate through all dependencies, in order to load the files that later will end up at the chart data structure. */ - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedNodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.curatedNodeArray[dependencyIndex] + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") { @@ -513,7 +513,7 @@ /* If it is not a dependency then we pass.. */ - if (dataDependenciesModule.isItADepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { + if (dataDependenciesModule.isItAChartDepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { continue } diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index 1e34a07f1..02811f93d 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -17,16 +17,16 @@ to filter out data dependencies based on the code written by users at the Javascript Code and Formula nodes. */ - const MODULE_NAME = "Data Dependencies"; + const MODULE_NAME = "Data Dependencies" let thisObject = { filters: undefined, - curatedNodeArray: undefined, + curatedDependencyNodeArray: undefined, dataSetsModulesArray: [], - isItADepenency: isItADepenency, + isItAChartDepenency: isItAChartDepenency, initialize: initialize, finalize: finalize - }; + } thisObject.filters = { chart: { @@ -39,11 +39,12 @@ }, exchange: { list: new Map(), + markets: new Map(), products: new Map() } } - return thisObject; + return thisObject function initialize(callBackFunction) { try { @@ -52,9 +53,9 @@ /* First we will get all the data dependencies of the bot, as defined at the Trading Mine. */ - thisObject.curatedNodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') - 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."); + thisObject.curatedDependencyNodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') + if (thisObject.curatedDependencyNodeArray.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.") callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) return } @@ -63,38 +64,39 @@ This will allow the user to have less Data Mines loaded at the workspace that the ones that a Trading Mine depends on. */ - thisObject.curatedNodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.curatedNodeArray) + thisObject.curatedDependencyNodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.curatedDependencyNodeArray) } 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.") callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) return } - if (thisObject.curatedNodeArray.length === 0) { + if (thisObject.curatedDependencyNodeArray.length === 0) { // We allow old indicators not to declare their data dependencies. - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); - return; + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + return } /* Session based dependency thisObject.filters */ - let dependencyFilter = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER - if (dependencyFilter !== undefined) { + let receivedDependencyFilters = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER + if (receivedDependencyFilters !== undefined) { /* Javascript Maps can not travel stringified at ta JSON object, so we receive these maps in an Array format, and here we will just convert them to Maps, that is how we need them. */ - arrayToMap(dependencyFilter.chart.list, thisObject.filters.chart.list) - arrayToMap(dependencyFilter.chart.products, thisObject.filters.chart.products) + arrayToMap(receivedDependencyFilters.chart.list, thisObject.filters.chart.list) + arrayToMap(receivedDependencyFilters.chart.products, thisObject.filters.chart.products) - arrayToMap(dependencyFilter.market.list, thisObject.filters.market.list) - arrayToMap(dependencyFilter.market.products, thisObject.filters.market.products) + arrayToMap(receivedDependencyFilters.market.list, thisObject.filters.market.list) + arrayToMap(receivedDependencyFilters.market.products, thisObject.filters.market.products) - arrayToMap(dependencyFilter.exchange.list, thisObject.filters.exchange.list) - arrayToMap(dependencyFilter.exchange.products, thisObject.filters.exchange.products) + arrayToMap(receivedDependencyFilters.exchange.list, thisObject.filters.exchange.list) + arrayToMap(receivedDependencyFilters.exchange.markets, thisObject.filters.exchange.markets) + arrayToMap(receivedDependencyFilters.exchange.products, thisObject.filters.exchange.products) function arrayToMap(array, map) { for (let i = 0; i < array.length; i++) { @@ -107,23 +109,23 @@ At our filter structure, we will add the Task default exchange and market. This will help us lateer to build other structures in a generic way. */ - thisObject.filters.exchange.list.set( - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName - ) - thisObject.filters.market.list.set( + let defaultExchange = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + let defautMarket = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - ) + thisObject.filters.exchange.list.set(defaultExchange, true) + thisObject.filters.exchange.markets.set(defaultExchange + '-' + defautMarket, true) + thisObject.filters.market.list.set(true) /* - For each dependency declared at the curatedNodeArray, we will initialize a DataSet as part of this initialization process. + For each dependency declared at the curatedDependencyNodeArray, we will initialize a DataSet as part of this initialization process. */ let alreadyCalledBack = false let addCount = 0 let skipCount = 0 /* - The current curatedNodeArray that we have includes all the dependencies daclared in the Data Mine | Trading Mine | Learning Mine + The current curatedDependencyNodeArray 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 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 @@ -134,41 +136,97 @@ */ let newNodeArray = [] - for (let i = 0; i < thisObject.curatedNodeArray.length; i++) { - let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex); - dataSetModule.initialize(thisObject.curatedNodeArray[i], onInitilized); + let exchangeList = Array.from(thisObject.filters.exchange.list.keys()) + let marketList = Array.from(thisObject.filters.market.list.keys()) - function onInitilized(err, wasInitialized) { - - if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)); - - alreadyCalledBack = true; - callBackFunction(err); - return; - } - - if (wasInitialized === true) { - addCount++; - newNodeArray.push(thisObject.curatedNodeArray[i]) - addDataSet() + /* + For each Exchange / Market we will add the datasets objects to our collection. + */ + for (let e = 0; e < exchangeList.length; e++) { + let exchange = exchangeList[e] + for (let m = 0; m < marketList.length; m++) { + let market = marketList[m] + if (receivedDependencyFilters !== undefined) { + /* + If we received a Dependency Filter from the UI, we will apply it here so + as not to add DataSets that we wont actually need. + */ + if (thisObject.filters.exchange.markets.get(exchange + '-' + market) === true) { + addDataSets(exchange, market) + } } else { - skipCount++ + /* + If we did not received these dependency filters, like when we are processing + Indicators, we will just add all datasets from exchange / market combination + because it will only be one combination: the default exchange and the default market. + */ + addDataSets(exchange, market) } - checkIfWeAreDone() } + } - function addDataSet() { - thisObject.dataSetsModulesArray.push(dataSetModule); - } + function addDataSets(exchange, market) { + for (let i = 0; i < thisObject.curatedDependencyNodeArray.length; i++) { + + if (receivedDependencyFilters !== undefined) { + /* + If we received a Dependency Filter from the UI, we will make these excta checks + before instantiating a Data Set Module. + */ + if (exchange === defaultExchange && market === defautMarket) { + + } + + // Validaciones para llegar hasta el producto: datasetModule.node.parentNode.config.singularVariableName + // Que el producto este en el filtro + // Necesito un filtro exchange mercado producto que venga desde la UI + // Para eso la funcion que los arma tiene que saber cual es el default Exchange y el Defautl market. + // Quizas vuele el concepto de filtro de chart , de market y de exchange separados + + // dentro del dataset que se valide que el network node que llega hasta el producto pase por el market y exchange + + if (thisObject.filters.exchange.markets.get(exchange + '-' + market) === true) { + addDataSets(exchange, market) + } + } + + + + let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) + dataSetModule.initialize(exchange, market, thisObject.curatedDependencyNodeArray[i], onInitilized) + + function onInitilized(err, wasInitialized) { + + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)) - function checkIfWeAreDone() { - if (addCount + skipCount === thisObject.curatedNodeArray.length) { - if (alreadyCalledBack === false) { alreadyCalledBack = true - thisObject.curatedNodeArray = newNodeArray - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); - return; + callBackFunction(err) + return + } + + if (wasInitialized === true) { + addCount++ + newNodeArray.push(thisObject.curatedDependencyNodeArray[i]) + addDataSet() + } else { + skipCount++ + } + checkIfWeAreDone() + } + + function addDataSet() { + thisObject.dataSetsModulesArray.push(dataSetModule) + } + + function checkIfWeAreDone() { + if (addCount + skipCount === thisObject.curatedDependencyNodeArray.length) { + if (alreadyCalledBack === false) { + alreadyCalledBack = true + thisObject.curatedDependencyNodeArray = newNodeArray + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + return + } } } } @@ -176,8 +234,8 @@ } catch (err) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).UNEXPECTED_ERROR = err - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack) + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } } @@ -187,14 +245,14 @@ dataSetModule.finalize() } thisObject.dataSetsModulesArray = undefined - thisObject.curatedNodeArray = undefined + thisObject.curatedDependencyNodeArray = undefined thisObject.filters = undefined bot = undefined } - function isItADepenency(timeFrame, product) { + function isItAChartDepenency(timeFrame, product) { let key = timeFrame + '-' + product - return thisObject.filters.get(key) + return thisObject.filters.chart.products.get(key) } -}; +} diff --git a/Projects/Superalgos/TS/Process-Modules/Dataset.js b/Projects/Superalgos/TS/Process-Modules/Dataset.js index 7ce2b8b2c..d0a664010 100644 --- a/Projects/Superalgos/TS/Process-Modules/Dataset.js +++ b/Projects/Superalgos/TS/Process-Modules/Dataset.js @@ -9,6 +9,8 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { let thisObject = { node: undefined, networkNode: undefined, + exchange: undefined, + market: undefined, initialize: initialize, finalize: finalize, getTextFile: getTextFile, @@ -20,10 +22,12 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { return thisObject; - function initialize(dataDependency, callBackFunction) { + function initialize(exchange, market, dataDependency, callBackFunction) { try { thisObject.node = dataDependency.referenceParent; + thisObject.exchange = exchange + thisObject.market = market /* Some very basic validations that we have all the information needed. */ if (thisObject.node === undefined) { @@ -76,15 +80,18 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { /* Now we will see where do we need to fetch this data from. */ let network = TS.projects.superalgos.globals.taskConstants.NETWORK_NODE - let datasetProductDefinition = thisObject.node.parentNode + let productDefinition = thisObject.node.parentNode - let nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeMeshToPathArray(network, datasetProductDefinition.id) - let networkNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeArray(nodeArray, 'Network Node') + /* + We will find the networkNode that leads to this Product Definition + and is related to this exchange and market. + */ + let networkNode = fincNetworkNode(network, productDefinition, thisObject.exchange, thisObject.market) if (networkNode === undefined) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> Network Node not found.") TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> Initialization Failed because we could not find where the data of this dataset is located within the network. Check the logs for more info."); - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> Could not find where " + datasetProductDefinition.name + " for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + " is stored within the network."); + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> Could not find where " + productDefinition.name + " for " + thisObject.exchange + " " + thisObject.market + " is stored within the network."); callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, false); return } @@ -105,6 +112,8 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { function finalize() { fileStorage = undefined thisObject.networkNode = undefined + thisObject.exchange = undefined + thisObject.market = undefined bot = undefined thisObject = undefined } @@ -117,7 +126,7 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { let project = thisObject.node.parentNode.parentNode.parentNode.project let botCodeName = thisObject.node.parentNode.parentNode.config.codeName - let filePathRoot = 'Project/' + project + "/" + mineType + "/" + mine + "/" + botCodeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let filePathRoot = 'Project/' + project + "/" + mineType + "/" + mine + "/" + botCodeName + '/' + thisObject.exchange + "/" + thisObject.market let filePath = filePathRoot + "/Output/" + pFolderPath; filePath += '/' + pFileName @@ -155,7 +164,7 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { return; } - let filePathRoot = 'Project/' + thisObject.node.project + "/" + thisObject.node.mineType + "/" + thisObject.node.dataMine + "/" + thisObject.node.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let filePathRoot = 'Project/' + thisObject.node.project + "/" + thisObject.node.mineType + "/" + thisObject.node.dataMine + "/" + thisObject.node.bot + '/' + thisObject.exchange + "/" + thisObject.market let filePath = filePathRoot + "/Output/" + pFolderPath + '/' + pFileName; fileStorage.createTextFile(filePath, pFileContent, onFileCreated); @@ -170,4 +179,140 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE); } } + + function fincNetworkNode(network, productDefinition, exchange, market) { + /* + + The problem that we need to solve here is the following: + + A. We are interested in a particular Exchange and Market. + B. We have the Network we received from the UI whe the user ran the Task. + C. We have the Product Definition that is the parent node of the Data Set represented by this object. + D. This Product Definition is referenced by one or more Data Products nodes at some branch of the Network Hirierchy. + E. We need to find the right Data Product node, the one who is itself a descendent of the Market Data Products + node that is referencing the market and exchange that we have as a parameter of this function. + + So, the strategy we will implement is the following: + + 1. We will scan all the branches of the Network received from the UI. + 2. Once we find a Market Data Products, Market Trading Products o Market Learning Products we will check + that they are referencing the market and exchange we need, other wise we ignore them and continue + with the scanning. + 3. Once found, we will go into their own branches and find a path until the Product Definition we need to reach. + 4. Once reached, we will know which Network Node is on the full path from the Network to the Product Definition and + we solved the problem. + + */ + let found = false + let networkNode + let splittedMarket = market.split('-') + let baseAsset = splittedMarket[0] + let quotedAsset = splittedMarket[1] + + scanNodeMesh(network) + + if (found === true) { + return networkNode + } else { + return + } + + function scanNodeMesh(startingNode) { + if (startingNode === undefined) { return } + + let schemaDocument = TS.projects.superalgos.globals.taskConstants.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type) + if (schemaDocument === undefined) { return } + + if (startingNode.id === productDefinition.id) { + /* + We reached the point that we found a path to the Product Definition. + Now we know that the last netwrokNode is the node that has the correct + path. + */ + found = true + return + } + + if (startingNode.type === 'Network Node') { + /* + We will store the Network Node here so that if we find the rignt path + we can know from which Netwrok Node it going through. + */ + networkNode = startingNode + } + + if ( + startingNode.type === 'Market Data Products' || + startingNode.type === 'Market Trading Products' || + startingNode.type === 'Market Learning Products' + ) { + /* + We will check that this guy is referencing the right market and the + market is a descendant of the right exchange. Otherwise we wont process + their children. + */ + if (startingNode.referenceParent === undefined) { + return + } + if (startingNode.referenceParent.baseAsset === undefined) { + return + } + if (startingNode.referenceParent.quotedAsset === undefined) { + return + } + if (startingNode.referenceParent.baseAsset.referenceParent === undefined) { + return + } + if (startingNode.referenceParent.quotedAsset.referenceParent === undefined) { + return + } + if (startingNode.referenceParent.baseAsset.referenceParent.config.codeName !== baseAsset) { + return + } + if (startingNode.referenceParent.quotedAsset.referenceParent.config.codeName !== quotedAsset) { + return + } + if (startingNode.referenceParent.parentNode === undefined) { + return + } + if (startingNode.referenceParent.parentNode.parentNode === undefined) { + return + } + if (startingNode.referenceParent.parentNode.parentNode.codeName !== exchange) { + return + } + } + + /* We scan through this node children */ + if (schemaDocument.childrenNodesProperties !== undefined) { + for (let i = 0; i < schemaDocument.childrenNodesProperties.length; i++) { + let property = schemaDocument.childrenNodesProperties[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) + } + } + } }; diff --git a/Projects/Superalgos/TS/Utilities/NodeFunctions.js b/Projects/Superalgos/TS/Utilities/NodeFunctions.js index 13a95bdfc..7ca293528 100644 --- a/Projects/Superalgos/TS/Utilities/NodeFunctions.js +++ b/Projects/Superalgos/TS/Utilities/NodeFunctions.js @@ -103,7 +103,7 @@ exports.newSuperalgosUtilitiesNodeFunctions = function () { function nodeMeshToPathArray (node, nodeId) { /* - This function scans a node mesh for a certain node if and + This function scans a node mesh for a certain node id and returns an array with the path within that mesh to the requested node. */ diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index ff6e4c4b3..e79fc7fac 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -30,6 +30,7 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { }, exchange: { list: new Map(), + markets: new Map(), products: new Map() } } @@ -43,6 +44,7 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { filters.market.products = Array.from(filters.market.products.keys()) filters.exchange.list = Array.from(filters.exchange.list.keys()) + filters.exchange.markets = Array.from(filters.exchange.markets.keys()) filters.exchange.products = Array.from(filters.exchange.products.keys()) return filters @@ -164,6 +166,7 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } filters.exchange.products.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + filters.exchange.markets.set(exchange + '-' + baseAsset + '-' + quotedAsset, true) filters.exchange.list.set(exchange, true) } } From 74e80cb43c88977b15f2231195ea1ae38e2107f6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 11:19:15 +0100 Subject: [PATCH 09/25] Data Dependencies and Dataset implementation done --- .../Low-Frequency-Trading/TradingProcess.js | 7 +- .../TS/Process-Modules/DataDependencies.js | 51 ++++++------ .../Superalgos/TS/Process-Modules/Dataset.js | 2 + .../Function-Libraries/DependenciesFilter.js | 38 +++++---- .../TradingSessionFunctions.js | 81 +++++++++++++++---- 5 files changed, 119 insertions(+), 60 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 62be039f2..3e86e4c9a 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 @@ -400,7 +400,12 @@ continue } - if (dataDependenciesModule.isItAChartDepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { + if (dataDependenciesModule.filters.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { + /* + If we can not find the current data set is used at the current time + frame we will skip this file, unless we are in the only special + case that we are retrieving candles. + */ if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { continue } diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index 02811f93d..aff88fdc1 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -29,18 +29,14 @@ } thisObject.filters = { - chart: { - list: new Map(), - products: new Map() - }, market: { - list: new Map(), - products: new Map() + list: new Map() }, exchange: { list: new Map(), markets: new Map(), - products: new Map() + products: new Map(), + timeFrames: new Map() } } @@ -88,15 +84,12 @@ these maps in an Array format, and here we will just convert them to Maps, that is how we need them. */ - arrayToMap(receivedDependencyFilters.chart.list, thisObject.filters.chart.list) - arrayToMap(receivedDependencyFilters.chart.products, thisObject.filters.chart.products) - arrayToMap(receivedDependencyFilters.market.list, thisObject.filters.market.list) - arrayToMap(receivedDependencyFilters.market.products, thisObject.filters.market.products) arrayToMap(receivedDependencyFilters.exchange.list, thisObject.filters.exchange.list) arrayToMap(receivedDependencyFilters.exchange.markets, thisObject.filters.exchange.markets) arrayToMap(receivedDependencyFilters.exchange.products, thisObject.filters.exchange.products) + arrayToMap(receivedDependencyFilters.exchange.timeFrames, thisObject.filters.exchange.timeFrames) function arrayToMap(array, map) { for (let i = 0; i < array.length; i++) { @@ -168,32 +161,36 @@ function addDataSets(exchange, market) { for (let i = 0; i < thisObject.curatedDependencyNodeArray.length; i++) { + let dataDependency = thisObject.curatedDependencyNodeArray[i] + if (receivedDependencyFilters !== undefined) { /* If we received a Dependency Filter from the UI, we will make these excta checks before instantiating a Data Set Module. */ - if (exchange === defaultExchange && market === defautMarket) { - + if (dataDependency.referenceParent === undefined) { + continue } - - // Validaciones para llegar hasta el producto: datasetModule.node.parentNode.config.singularVariableName - // Que el producto este en el filtro - // Necesito un filtro exchange mercado producto que venga desde la UI - // Para eso la funcion que los arma tiene que saber cual es el default Exchange y el Defautl market. - // Quizas vuele el concepto de filtro de chart , de market y de exchange separados - - // dentro del dataset que se valide que el network node que llega hasta el producto pase por el market y exchange - - if (thisObject.filters.exchange.markets.get(exchange + '-' + market) === true) { - addDataSets(exchange, market) + if (dataDependency.referenceParent.parentNode === undefined) { + continue } + if (dataDependency.referenceParent.parentNode.config.singularVariableName === undefined) { + continue + } + /* + This is the product related to this Data Dependency, as the user would type it + at a Condition or Formula and appear at the UI provided filter. + */ + let product = dataDependency.referenceParent.parentNode.config.singularVariableName + + if (thisObject.filters.products.get(exchange + '-' + market + '-' + product) !== true) { + continue + } + addDataSets(exchange, market) } - - let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) - dataSetModule.initialize(exchange, market, thisObject.curatedDependencyNodeArray[i], onInitilized) + dataSetModule.initialize(exchange, market, dataDependency, onInitilized) function onInitilized(err, wasInitialized) { diff --git a/Projects/Superalgos/TS/Process-Modules/Dataset.js b/Projects/Superalgos/TS/Process-Modules/Dataset.js index d0a664010..3c8ca1199 100644 --- a/Projects/Superalgos/TS/Process-Modules/Dataset.js +++ b/Projects/Superalgos/TS/Process-Modules/Dataset.js @@ -11,6 +11,7 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { networkNode: undefined, exchange: undefined, market: undefined, + product: undefined, initialize: initialize, finalize: finalize, getTextFile: getTextFile, @@ -81,6 +82,7 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { /* Now we will see where do we need to fetch this data from. */ let network = TS.projects.superalgos.globals.taskConstants.NETWORK_NODE let productDefinition = thisObject.node.parentNode + thisObject.product = productDefinition.config.singularVariableName /* We will find the networkNode that leads to this Product Definition diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index e79fc7fac..5caff8d29 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -18,34 +18,27 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { return thisObject - function createDependencyFilter(node) { + function createDependencyFilter(tradingSystem, defaultExchange, defaultMarket) { let filters = { - chart: { - list: new Map(), - products: new Map() - }, market: { - list: new Map(), - products: new Map() + list: new Map() }, exchange: { list: new Map(), markets: new Map(), - products: new Map() + products: new Map(), + timeFrames: new Map() } } - recursiveFilter(node) + recursiveFilter(tradingSystem) /* Transform the Map into arrays */ - filters.chart.list = Array.from(filters.chart.list.keys()) - filters.chart.products = Array.from(filters.chart.products.keys()) - filters.market.list = Array.from(filters.market.list.keys()) - filters.market.products = Array.from(filters.market.products.keys()) filters.exchange.list = Array.from(filters.exchange.list.keys()) filters.exchange.markets = Array.from(filters.exchange.markets.keys()) filters.exchange.products = Array.from(filters.exchange.products.keys()) + filters.exchange.timeFrames = Array.from(filters.exchange.timeFrames.keys()) return filters @@ -124,8 +117,12 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } - filters.chart.products.set(timeFrame + '-' + product, true) - filters.chart.list.set(timeFrame, true) + filters.market.list.set(defaultMarket, true) + + filters.exchange.timeFrames.set(defaultExchange + '-' + defaultMarket + '-' + product + '-' + timeFrame, true) + filters.exchange.products.set(defaultExchange + '-' + defaultMarket + '-' + product, true) + filters.exchange.markets.set(defaultExchange + '-' + defaultMarket, true) + filters.exchange.list.set(defaultExchange, true) } /* The second kind of instruction we will handle are the ones @@ -144,8 +141,12 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } - filters.market.products.set(baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) filters.market.list.set(baseAsset + '-' + quotedAsset, true) + + filters.exchange.timeFrames.set(defaultExchange + '-' + baseAsset + '-' + quotedAsset + '-' + product + '-' + timeFrame, true) + filters.exchange.products.set(defaultExchange + '-' + baseAsset + '-' + quotedAsset + '-' + product, true) + filters.exchange.markets.set(defaultExchange + '-' + baseAsset + '-' + quotedAsset, true) + filters.exchange.list.set(defaultExchange, true) } /* The third kind of instruction we will handle are the ones @@ -165,7 +166,10 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { if (timeFrame !== 'atAnyTimeFrame') { timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) } - filters.exchange.products.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true) + filters.market.list.set(baseAsset + '-' + quotedAsset, true) + + filters.exchange.timeFrames.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + product + '-' + timeFrame, true) + filters.exchange.products.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + product, true) filters.exchange.markets.set(exchange + '-' + baseAsset + '-' + quotedAsset, true) filters.exchange.list.set(exchange, true) } diff --git a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js index 2b5733ba2..3d64eca5a 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js @@ -1,6 +1,6 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { thisObject = { - syncronizeSessionWithBackEnd: syncronizeSessionWithBackEnd, + syncronizeSessionWithBackEnd: syncronizeSessionWithBackEnd, runSession: runSession, stopSession: stopSession } @@ -8,7 +8,7 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { return thisObject function syncronizeSessionWithBackEnd(node) { - let networkNode = validations(node) + let networkNode = validations(node).networkNode if (networkNode === undefined) { /* Nodes that do not belong to a network can not get ready. */ return @@ -27,7 +27,7 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { function onStatus(message) { eventsServerClient.stopListening(key, eventSubscriptionIdOnStatus, node.id) - if (message.event.status === 'Trading Session Runnning' ) { + if (message.event.status === 'Trading Session Runnning') { node.payload.uiObject.menu.internalClick('Run Trading Session') } } @@ -37,7 +37,8 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { } function runSession(node, resume, callBackFunction) { - let networkNode = validations(node) + let validationsResult = validations(node) + let networkNode = validationsResult.networkNode if (networkNode === undefined) { /* This means that the validations failed. */ callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) @@ -123,7 +124,14 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { let session = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) - let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createDependencyFilter(node.tradingSystemReference.payload.referenceParent) + let defaultExchange = validationsResult.exchange.config.codeName + let defaultMarket = validationsResult.market.baseAsset.payload.referenceParent.config.codeName + '-' + validationsResult.market.quotedAsset.payload.referenceParent.config.codeName + + let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createDependencyFilter( + defaultExchange, + defaultMarket, + node.tradingSystemReference.payload.referenceParent + ) /* Raise event to run the session */ let event = { @@ -147,13 +155,13 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { } function stopSession(node, callBackFunction) { - let networkNode = validations(node) + let networkNode = validations(node).networkNode if (networkNode === undefined) { /* This means that the validations failed. */ callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return } - + let eventsServerClient = UI.projects.superalgos.spaces.designSpace.workspace.eventsServerClients.get(networkNode.id) let key = node.name + '-' + node.type + '-' + node.id @@ -163,6 +171,9 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { } function validations(node) { + + let result = {} + if (node.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.') return @@ -183,34 +194,34 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { return } - let taskManager = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode + result.taskManager = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode - if (taskManager.payload.parentNode === undefined) { + if (result.taskManager.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs to be inside Mine Tasks.') return } - if (taskManager.payload.parentNode.payload.parentNode === undefined) { + if (result.taskManager.payload.parentNode.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs to be inside Market Tasks.') return } - if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + if (result.taskManager.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs to be inside Exchange Tasks.') return } - if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + if (result.taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs to be inside a Testing or Production Trading Tasks.') return } - if (taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + if (result.taskManager.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs to be inside a Network Node.') return } - let networkNode = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(taskManager, 'Network Node', undefined, true, false, true, false) + result.networkNode = UI.projects.superalgos.utilities.meshes.findNodeInNodeMesh(result.taskManager, 'Network Node', undefined, true, false, true, false) if (node.tradingSystemReference === undefined) { node.payload.uiObject.setErrorMessage('Session needs a child Trading System Reference.') @@ -231,6 +242,46 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { node.payload.uiObject.setErrorMessage('Trading Engine Reference needs to reference a Trading Engine.') return } - return networkNode + + if (result.taskManager.payload.parentNode.payload.parentNode.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to have a Default Market.') + return + } + + result.market = result.taskManager.payload.parentNode.payload.parentNode.payload.referenceParent + + if (market.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Default Market needs to be a child of Exchange Markets.') + return + } + + if (market.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Exchange Markets neeed to be a child of Crypto Exchange.') + return + } + + if (market.baseAsset === undefined) { + node.payload.uiObject.setErrorMessage('Default Market needs to have a Base Asset.') + return + } + + if (market.quotedAsset === undefined) { + node.payload.uiObject.setErrorMessage('Default Market needs to have a Quoted Asset.') + return + } + + if (market.baseAsset.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Market Base Asset needs to reference an Asset.') + return + } + + if (market.quotedAsset.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Market Quoted Asset needs to reference an Asset.') + return + } + + result.exchange = market.payload.parentNode.payload.parentNode + + return result.networkNode } } From b18fc0335a8a9b2a230311c38b68a5277a0b8a7a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 11:22:45 +0100 Subject: [PATCH 10/25] Upto loading the right files implemented --- .../Low-Frequency-Trading/TradingProcess.js | 16 +++++++++++----- .../TS/Process-Modules/DataDependencies.js | 7 ------- 2 files changed, 11 insertions(+), 12 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 3e86e4c9a..7c3170064 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 @@ -340,7 +340,11 @@ continue } - if (dataDependenciesModule.isItAChartDepenency('atAnyTimeFrame', datasetModule.node.parentNode.config.singularVariableName) !== true) { + if (dataDependenciesModule.filters.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, 'atAnyTimeFrame') !== true) { + /* + If we can not find the current data set is used at the current time + frame we will skip this file. + */ continue } @@ -515,10 +519,12 @@ continue } - /* - If it is not a dependency then we pass.. - */ - if (dataDependenciesModule.isItAChartDepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { + if (dataDependenciesModule.filters.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { + /* + If we can not find the current data set is used at the current time + frame we will skip this file, unless we are in the only special + case that we are retrieving candles. + */ if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { continue } diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index aff88fdc1..66ab8552e 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -23,7 +23,6 @@ filters: undefined, curatedDependencyNodeArray: undefined, dataSetsModulesArray: [], - isItAChartDepenency: isItAChartDepenency, initialize: initialize, finalize: finalize } @@ -246,10 +245,4 @@ thisObject.filters = undefined bot = undefined } - - function isItAChartDepenency(timeFrame, product) { - let key = timeFrame + '-' + product - - return thisObject.filters.chart.products.get(key) - } } From 2eb96dc048689240de0ae08ebaea4d18a59591a5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 13:25:42 +0100 Subject: [PATCH 11/25] Implementation finished, chart, market and exchange data structures available to conditions and formulas. --- .../Low-Frequency-Trading/TradingOutput.js | 11 +- .../Low-Frequency-Trading/TradingProcess.js | 150 +++++++++++++----- .../TradingSimulation.js | 8 +- .../Low-Frequency-Trading/TradingSystem.js | 20 ++- .../TS/Process-Modules/DataDependencies.js | 12 +- 5 files changed, 149 insertions(+), 52 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js index c6b2f28ca..fb3c06aa4 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js @@ -26,7 +26,14 @@ exports.newSuperalgosBotModulesTradingOutput = function (processIndex) { } - async function start(chart, timeFrame, timeFrameLabel, tradingProcessDate) { + async function start( + chart, + exchange, + market, + timeFrame, + timeFrameLabel, + tradingProcessDate + ) { try { if (timeFrame > TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[0][0]) { @@ -73,6 +80,8 @@ exports.newSuperalgosBotModulesTradingOutput = function (processIndex) { await tradingSimulationModuleObject.runSimulation( chart, + exchange, + market, outputDatasetsMap, writeFiles ) 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 7c3170064..9011001b5 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 @@ -14,7 +14,7 @@ let statusDependencies let dataDependenciesModule let dataFiles = new Map() - let multiPeriodDataFiles = new Map() + let multiTimeFrameDataFiles = new Map() let fileStorage = TS.projects.superalgos.taskModules.fileStorage.newFileStorage(processIndex) TS.projects.superalgos.globals.processModuleObjects.MODULE_OBJECTS_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_ENGINE_MODULE_OBJECT = TS.projects.superalgos.botModules.tradingEngine.newSuperalgosBotModulesTradingEngine(processIndex) let tradingOutputModuleObject = TS.projects.superalgos.botModules.tradingOutput.newSuperalgosBotModulesTradingOutput(processIndex) @@ -47,7 +47,7 @@ tradingOutputModuleObject = undefined dataFiles = undefined - multiPeriodDataFiles = undefined + multiTimeFrameDataFiles = undefined statusDependencies = undefined dataDependenciesModule = undefined fileStorage = undefined @@ -115,10 +115,11 @@ return } /* - This is the Data Structure used at the Simulation with all indicator data. - We start creating it right here. + These are the Data Structures used by end users at Conditions Code or Formulas. */ let chart = {} + let market = {} + let exchange = {} /* Here we check if we need to get Daily Files or not. As an optimization, when we are running on a Time Frame of 1hs or above, we are not going to load @@ -133,7 +134,7 @@ data structure that will be used in user-defied conditions and formulas. */ TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Waking up') - buildCharts(chart) + buildDataStructures(chart) if (checkThereAreCandles(chart) === true) { TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Running') @@ -172,7 +173,7 @@ With all the indicators data files loaded, we will build the chart object data structure that will be used in user-defied conditions and formulas. */ - buildCharts(chart) + buildDataStructures(chart) /* The process of generating the output includes the trading simulation. */ @@ -209,7 +210,7 @@ */ callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) - function checkThereAreCandles(chart) { + function checkThereAreCandles() { let sessionParameters = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters let propertyName = 'at' + sessionParameters.timeFrame.config.label.replace('-', '') let candles = chart[propertyName].candles @@ -373,7 +374,7 @@ } let mapKey = "Single Files" - multiPeriodDataFiles.set(mapKey, dataFiles) + multiTimeFrameDataFiles.set(mapKey, dataFiles) } async function processMarketFiles() { @@ -472,7 +473,7 @@ } let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] - multiPeriodDataFiles.set(mapKey, dataFiles) + multiTimeFrameDataFiles.set(mapKey, dataFiles) } return true } @@ -569,7 +570,7 @@ } } let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] - multiPeriodDataFiles.set(mapKey, dataFiles) + multiTimeFrameDataFiles.set(mapKey, dataFiles) } return true } @@ -600,7 +601,7 @@ } } - function buildCharts(chart) { + function buildDataStructures() { /* Fisrt Phase: Validations */ let mainDependency = {} /* @@ -639,47 +640,108 @@ 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) - let products = {} - if (dataFiles !== undefined) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + let exchangeList = Array.from(dataDependenciesModule.filters.exchange.list.keys()) + let marketList = Array.from(dataDependenciesModule.filters.market.list.keys()) - let propertyName = 'at' + timeFrameLabel.replace('-', '') - chart[propertyName] = products + for (let e = 0; e < exchangeList.length; e++) { + let currentExchange = exchangeList[e] + for (let m = 0; m < marketList.length; m++) { + let currentMarket = marketList[m] + let splittedMarket = currentMarket.split('-') + let baseAsset = splittedMarket[0] + let quotedAsset = splittedMarket[1] + + /* Market Files */ + 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 = multiTimeFrameDataFiles.get(timeFrameLabel) + let products = {} + + if (dataFiles !== undefined) { + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + + let propertyName = 'at' + timeFrameLabel.replace('-', '') + addProducs(propertyName) + } + } + + /* Daily Files */ + for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) { + let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1] + let dataFiles = multiTimeFrameDataFiles.get(timeFrameLabel) + let products = {} + + if (dataFiles !== undefined) { + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + + let propertyName = 'at' + timeFrameLabel.replace('-', '') + addProducs(propertyName) + } + } + + /* Single Files */ + let dataFiles = multiTimeFrameDataFiles.get('Single Files') + let products = {} + + if (dataFiles !== undefined) { + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + + let propertyName = 'atAnyTimeFrame' + addProducs(propertyName) + } + + function addProducs(propertyName) { + /* + The chart data structure allow users to simplify the syntax when they are using + the default exchange and the default market. + */ + if (currentExchange === dataDependenciesModule.defaultExchange && currentMarket === dataDependenciesModule.defaultMarket) { + chart[propertyName] = products + } + /* + The market data structure allow users to simplify the syntax when they are using + the default exchange. + */ + if (currentExchange === dataDependenciesModule.defaultExchange) { + if (market[baseAsset] === undefined) { + market[baseAsset] = {} + } + if (market[baseAsset][quotedAsset] === undefined) { + market[baseAsset][quotedAsset] = {} + } + if (market[baseAsset][quotedAsset].chart === undefined) { + market[baseAsset][quotedAsset].chart = {} + } + market[baseAsset][quotedAsset].chart[propertyName] = products + } + + if (exchange[currentExchange] === undefined) { + exchange[currentExchange] = {} + } + if (exchange[currentExchange].market === undefined) { + exchange[currentExchange].market = {} + } + if (exchange[currentExchange].market[baseAsset] === undefined) { + exchange[currentExchange].market[baseAsset] = {} + } + if (exchange[currentExchange].market[baseAsset][quotedAsset] === undefined) { + exchange[currentExchange].market[baseAsset][quotedAsset] = {} + } + if (exchange[currentExchange].market[baseAsset][quotedAsset].chart === undefined) { + exchange[currentExchange].market[baseAsset][quotedAsset].chart = {} + } + exchange[currentExchange].market[baseAsset][quotedAsset].chart[propertyName] = products + } } } - - for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) { - let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1] - let dataFiles = multiPeriodDataFiles.get(timeFrameLabel) - let products = {} - - if (dataFiles !== undefined) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) - - let propertyName = 'at' + timeFrameLabel.replace('-', '') - chart[propertyName] = products - } - } - - /* Single Files */ - let dataFiles = multiPeriodDataFiles.get('Single Files') - let products = {} - - if (dataFiles !== undefined) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) - - let propertyName = 'atAnyTimeFrame' - chart[propertyName] = products - } } - async function generateOutput(chart) { + async function generateOutput() { await tradingOutputModuleObject.start( chart, + market, + exchange, currentTimeFrame, currentTimeFrameLabel, tradingProcessDate diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js index 0c941284b..a4c95762f 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js @@ -17,6 +17,8 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { async function runSimulation( chart, + exchange, + market, outputDatasetsMap, writeFiles, ) { @@ -146,7 +148,11 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { positionChartAtCurrentCandle() /* The chart was recalculated based on the current candle. */ - tradingSystemModuleObject.updateChart(chart) + tradingSystemModuleObject.updateChart( + chart, + exchange, + market + ) /* Do the stuff needed previous to the run like diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js index fbc9c9dea..baff85703 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js @@ -13,7 +13,14 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) { finalize: finalize } + /* + These 3 are the main data structures available to users + when writing conditions and formulas. + */ let chart + let exchange + let market + let tradingSystem let tradingEngine let sessionParameters @@ -115,6 +122,8 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) { tradingStagesModuleObject = undefined chart = undefined + exchange = undefined + market = undefined tradingSystem.conditions = undefined tradingSystem.formulas = undefined @@ -151,8 +160,15 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) { tradingSystem.announcements = [] } - function updateChart(pChart) { - chart = pChart // We need chat to be a local object accessible from conditions and formulas. + function updateChart(pChart, pExchange, pMarket) { + /* + We need these 3 data structures to be a local objects + accessible while evaluating conditions and formulas. + */ + chart = pChart + exchange = pExchange + market = pMarket + tradingStagesModuleObject.updateChart(pChart) } diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index 66ab8552e..cc77da285 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -21,6 +21,8 @@ let thisObject = { filters: undefined, + defaultExchange: undefined, + defaultMarket: undefined, curatedDependencyNodeArray: undefined, dataSetsModulesArray: [], initialize: initialize, @@ -101,13 +103,13 @@ At our filter structure, we will add the Task default exchange and market. This will help us lateer to build other structures in a generic way. */ - let defaultExchange = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName - let defautMarket = + thisObject.defaultExchange = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + thisObject.defautMarket = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - thisObject.filters.exchange.list.set(defaultExchange, true) - thisObject.filters.exchange.markets.set(defaultExchange + '-' + defautMarket, true) + thisObject.filters.exchange.list.set(thisObject.defaultExchange, true) + thisObject.filters.exchange.markets.set(thisObject.defaultExchange + '-' + thisObject.defautMarket, true) thisObject.filters.market.list.set(true) /* For each dependency declared at the curatedDependencyNodeArray, we will initialize a DataSet as part of this initialization process. @@ -243,6 +245,8 @@ thisObject.dataSetsModulesArray = undefined thisObject.curatedDependencyNodeArray = undefined thisObject.filters = undefined + thisObject.defaultExchange = undefined + thisObject.defaultMarket = undefined bot = undefined } } From 0341fe8eccdfbdf95fd7006e9fef6e25a0166af3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 14:39:12 +0100 Subject: [PATCH 12/25] Bug fixed seting up filders at the UI --- .../Function-Libraries/TradingSessionFunctions.js | 14 +++++++------- .../UI/Spaces/Docs-Space/SearchEngine.js | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js index 3d64eca5a..2353ef43f 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js @@ -250,37 +250,37 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { result.market = result.taskManager.payload.parentNode.payload.parentNode.payload.referenceParent - if (market.payload.parentNode === undefined) { + if (result.market.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Default Market needs to be a child of Exchange Markets.') return } - if (market.payload.parentNode.payload.parentNode === undefined) { + if (result.market.payload.parentNode.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Exchange Markets neeed to be a child of Crypto Exchange.') return } - if (market.baseAsset === undefined) { + if (result.market.baseAsset === undefined) { node.payload.uiObject.setErrorMessage('Default Market needs to have a Base Asset.') return } - if (market.quotedAsset === undefined) { + if (result.market.quotedAsset === undefined) { node.payload.uiObject.setErrorMessage('Default Market needs to have a Quoted Asset.') return } - if (market.baseAsset.payload.referenceParent === undefined) { + if (result.market.baseAsset.payload.referenceParent === undefined) { node.payload.uiObject.setErrorMessage('Market Base Asset needs to reference an Asset.') return } - if (market.quotedAsset.payload.referenceParent === undefined) { + if (result.market.quotedAsset.payload.referenceParent === undefined) { node.payload.uiObject.setErrorMessage('Market Quoted Asset needs to reference an Asset.') return } - result.exchange = market.payload.parentNode.payload.parentNode + result.exchange = result.market.payload.parentNode.payload.parentNode return result.networkNode } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js index 101ce7823..ea44ac22f 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js @@ -17,6 +17,8 @@ function newSuperalgosDocsSearchEngine() { } function setUpSearchEngine(callbackFunction) { + callbackFunction() + return let totalAsyncCallsMade = 0 let totalAsyncCallsFinished = 0 From 604b1fbb0d1ba6595d414fd76229402f645d16dd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 14:50:31 +0100 Subject: [PATCH 13/25] Bug fixed on filters at the UI --- .../TradingSessionFunctions.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js index 2353ef43f..c22b11bf4 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js @@ -8,7 +8,12 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { return thisObject function syncronizeSessionWithBackEnd(node) { - let networkNode = validations(node).networkNode + let validationsResult = validations(node) + if (validationsResult === undefined) { + /* If something fails at validations we just quit. */ + return + } + let networkNode = validationsResult.networkNode if (networkNode === undefined) { /* Nodes that do not belong to a network can not get ready. */ return @@ -38,6 +43,10 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { function runSession(node, resume, callBackFunction) { let validationsResult = validations(node) + if (validationsResult === undefined) { + /* If something fails at validations we just quit. */ + return + } let networkNode = validationsResult.networkNode if (networkNode === undefined) { /* This means that the validations failed. */ @@ -155,7 +164,12 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { } function stopSession(node, callBackFunction) { - let networkNode = validations(node).networkNode + let validationsResult = validations(node) + if (validationsResult === undefined) { + /* If something fails at validations we just quit. */ + return + } + let networkNode = validationsResult.networkNode if (networkNode === undefined) { /* This means that the validations failed. */ callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) From 463f8e0cdaca3793bb604980e896bee1e0184938 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 15:08:52 +0100 Subject: [PATCH 14/25] Using the Exchange codeName instead of the Exchange name as folder name and in keys --- .../Bollinger-Bands/BollingerBandsMultiPeriodDaily.js | 4 ++-- .../Bollinger-Bands/BollingerBandsMultiPeriodMarket.js | 2 +- .../Candles-Volumes/CandlesVolumesMultiPeriodDaily.js | 6 +++--- .../Candles-Volumes/CandlesVolumesMultiPeriodMarket.js | 4 ++-- .../TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js | 2 +- .../Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js | 2 +- .../TS/Bot-Modules/Sensor-Bot/Webhooks/CheckWebhook.js | 2 +- .../Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js | 2 +- .../Trading-Bot/Low-Frequency-Trading/TradingProcess.js | 2 +- .../TS/Function-Libraries/SingleMarketFunctions.js | 4 ++-- .../Superalgos/TS/Process-Modules/ProcessExecutionEvents.js | 4 ++-- Projects/Superalgos/TS/Process-Modules/ProcessOutput.js | 4 ++-- Projects/Superalgos/TS/Process-Modules/StatusReport.js | 2 +- UI/Data-Files/src/FileCursor.js | 4 ++-- UI/Data-Files/src/FileSequence.js | 2 +- UI/Data-Files/src/MarketFiles.js | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodDaily.js index b00255d6e..726ed72cd 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodDaily.js @@ -349,7 +349,7 @@ TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + - "Candles-Volumes" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + "Candles-Volumes" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + CANDLES_FOLDER_NAME + '/' + "Multi-Period-Daily" + "/" + timeFrame + "/" + dateForPath; @@ -395,7 +395,7 @@ TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + - "Candles-Volumes" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + "Candles-Volumes" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + CANDLES_FOLDER_NAME + '/' + "Multi-Period-Daily" + "/" + timeFrame + "/" + dateForPath; diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodMarket.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodMarket.js index 6ff41f11b..9e3d81aad 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodMarket.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Bollinger-Bands/BollingerBandsMultiPeriodMarket.js @@ -70,7 +70,7 @@ 'Project/' + TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + - "Candles-Volumes" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + "Candles-Volumes" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + CANDLES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrame; diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodDaily.js index d8a666447..ed9686b0d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodDaily.js @@ -301,7 +301,7 @@ TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + "Exchange-Raw-Data" + '/' + - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + CANDLES_FOLDER_NAME + '/' + CANDLES_ONE_MIN + '/' + dateForPath @@ -422,7 +422,7 @@ TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + - "Exchange-Raw-Data" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + "Exchange-Raw-Data" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = @@ -709,7 +709,7 @@ TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + pProductFolder + "-" + - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let event = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodMarket.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodMarket.js index 958dee176..3bf3bb8e9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodMarket.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/Candles-Volumes/CandlesVolumesMultiPeriodMarket.js @@ -521,7 +521,7 @@ TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + - "Exchange-Raw-Data" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + "Exchange-Raw-Data" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + CANDLES_FOLDER_NAME + '/' + CANDLES_ONE_MIN + '/' + dateForPath; @@ -648,7 +648,7 @@ TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.type.replace(' ', '-') + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + - "Exchange-Raw-Data" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + "Exchange-Raw-Data" + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + VOLUMES_FOLDER_NAME + '/' + VOLUMES_ONE_MIN + '/' + dateForPath; diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js index 957e29291..99acc71f5 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/MultiPeriodDaily.js @@ -549,7 +549,7 @@ } let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + productCodeName + "-" + - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let event = { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js index eabe00757..16e37a46a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js @@ -43,7 +43,7 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { try { statusDependencies = pStatusDependencies; - exchangeId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name.toLowerCase().replace(' ', '') + exchangeId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName /* Applying the parameters defined by the user at the Exchange Node Config */ if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.API !== undefined) { diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Webhooks/CheckWebhook.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Webhooks/CheckWebhook.js index f005f8ee7..261576ef9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Webhooks/CheckWebhook.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Webhooks/CheckWebhook.js @@ -93,7 +93,7 @@ exports.newSuperalgosBotModulesCheckWebhook = function (processIndex) { let url = 'http://' + global.env.WEB_SERVER_URL + ':' + global.env.HTTP_INTERFACE_PORT + '/Webhook/Fetch-Messages/' + - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js index 4961f5091..65e427db7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/APIs/ExchangeAPI.js @@ -23,7 +23,7 @@ function initialize() { tradingSystem = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingSystem - exchangeId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name.toLowerCase() + exchangeId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName let key let secret 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 9011001b5..0dedfd6c9 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 @@ -796,7 +796,7 @@ /* Raise the event that the Data Range was Updated. */ - let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + productCodeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + productCodeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let event = { dateRange: dataRange } diff --git a/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js b/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js index 0246e4b63..3534e24eb 100644 --- a/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js +++ b/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js @@ -520,7 +520,7 @@ dateForPath = "/" + currentDay.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(currentDay.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(currentDay.getUTCDate(), 2); } - let filePathRoot = 'Project/' + contextSummary.project + "/" + contextSummary.mineType + "/" + contextSummary.dataMine + "/" + contextSummary.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let filePathRoot = 'Project/' + contextSummary.project + "/" + contextSummary.mineType + "/" + contextSummary.dataMine + "/" + contextSummary.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let filePath = filePathRoot + "/Output/" + contextSummary.product + "/" + contextSummary.dataset + "/" + timeFrameLabel + dateForPath; filePath += '/' + fileName @@ -649,7 +649,7 @@ "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + '/' + - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + diff --git a/Projects/Superalgos/TS/Process-Modules/ProcessExecutionEvents.js b/Projects/Superalgos/TS/Process-Modules/ProcessExecutionEvents.js index 0b4ce70c2..2a0912ca4 100644 --- a/Projects/Superalgos/TS/Process-Modules/ProcessExecutionEvents.js +++ b/Projects/Superalgos/TS/Process-Modules/ProcessExecutionEvents.js @@ -33,7 +33,7 @@ } let market = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - currentProcessKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.type + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.id + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + market + currentProcessKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.type + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.id + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + market /* A process can depend for its own execution on another process to finish, and @@ -191,7 +191,7 @@ let extraCallerId = '-' + Math.trunc(Math.random() * 10000) + '-' let market = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - let key = processThisDependsOn.name + "-" + processThisDependsOn.type + "-" + processThisDependsOn.id + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + market + let key = processThisDependsOn.name + "-" + processThisDependsOn.type + "-" + processThisDependsOn.id + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + market let callerId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName + extraCallerId let subscriptionId diff --git a/Projects/Superalgos/TS/Process-Modules/ProcessOutput.js b/Projects/Superalgos/TS/Process-Modules/ProcessOutput.js index dfcc1dbec..938cb5900 100644 --- a/Projects/Superalgos/TS/Process-Modules/ProcessOutput.js +++ b/Projects/Superalgos/TS/Process-Modules/ProcessOutput.js @@ -87,7 +87,7 @@ let product = outputDataset.referenceParent.parentNode.config.codeName let dataset = outputDataset.referenceParent.config.codeName - let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let event = { lastFile: lastFile, timeFrames: timeFrames @@ -170,7 +170,7 @@ let product = outputDataset.referenceParent.parentNode.config.codeName let dataset = outputDataset.referenceParent.config.codeName - let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let event = { lastFile: lastFile, timeFrames: timeFrames diff --git a/Projects/Superalgos/TS/Process-Modules/StatusReport.js b/Projects/Superalgos/TS/Process-Modules/StatusReport.js index 3fe00aa99..f7ac102b2 100644 --- a/Projects/Superalgos/TS/Process-Modules/StatusReport.js +++ b/Projects/Superalgos/TS/Process-Modules/StatusReport.js @@ -252,7 +252,7 @@ if (ownerId !== botId) { - let filePathRoot = 'Project/' + statusDependencyNode.project + "/" + statusDependencyNode.mineType + "/" + statusDependencyNode.dataMine + "/" + statusDependencyNode.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + let filePathRoot = 'Project/' + statusDependencyNode.project + "/" + statusDependencyNode.mineType + "/" + statusDependencyNode.dataMine + "/" + statusDependencyNode.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName filePath = filePathRoot + "/Reports/" + sessionPath + statusDependencyNode.process } else { filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Reports/" + sessionPath + statusDependencyNode.process diff --git a/UI/Data-Files/src/FileCursor.js b/UI/Data-Files/src/FileCursor.js index 2cae02a22..fdb933c95 100644 --- a/UI/Data-Files/src/FileCursor.js +++ b/UI/Data-Files/src/FileCursor.js @@ -108,11 +108,11 @@ function newFileCursor() { endDateRange = pEndDateRange eventsServerClient = pEventsServerClient - let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset + let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.config.codeName + '-' + market.baseAsset + '/' + market.quotedAsset let callerId = key + '-' + periodName + newUniqueId() eventsServerClient.listenToEvent(key, 'Dataset Updated', undefined, callerId, onResponseDataSet, updateFiles) - key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset + key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + exchange.config.codeName + '-' + market.baseAsset + '/' + market.quotedAsset callerId = key + '-' + periodName + newUniqueId() eventsServerClient.listenToEvent(key, 'Data Range Updated', undefined, callerId, onResponseDataRange, updateDataRange) diff --git a/UI/Data-Files/src/FileSequence.js b/UI/Data-Files/src/FileSequence.js index 9ff177f0b..5434e4c64 100644 --- a/UI/Data-Files/src/FileSequence.js +++ b/UI/Data-Files/src/FileSequence.js @@ -88,7 +88,7 @@ function newFileSequence () { callerId = newUniqueId() - let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset + let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.config.codeName + '-' + market.baseAsset + '/' + market.quotedAsset eventsServerClient.listenToEvent(key, 'Dataset Updated', undefined, callerId, onResponse, updateFiles) function onResponse (message) { diff --git a/UI/Data-Files/src/MarketFiles.js b/UI/Data-Files/src/MarketFiles.js index 819ec288f..ccfadcdd2 100644 --- a/UI/Data-Files/src/MarketFiles.js +++ b/UI/Data-Files/src/MarketFiles.js @@ -177,7 +177,7 @@ function newMarketFiles() { } if (filesLoaded + filesNotLoaded === marketFilesPeriods.length) { - let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset + let key = mine.config.codeName + '-' + bot.config.codeName + '-' + product.config.codeName + '-' + dataset.config.codeName + '-' + exchange.config.codeName + '-' + market.baseAsset + '/' + market.quotedAsset let callerId = key + '-' + periodName + newUniqueId() eventsServerClient.listenToEvent(key, 'Dataset Updated', undefined, callerId, onResponse, updateFiles) From 5fbb451d33dfd35a6a68bc89487bc0a1ec967407 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 15:32:26 +0100 Subject: [PATCH 15/25] UI implementation debugged --- .../UI/Function-Libraries/DependenciesFilter.js | 2 +- .../UI/Function-Libraries/TradingSessionFunctions.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js index 5caff8d29..295b8baf8 100644 --- a/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js +++ b/Projects/Superalgos/UI/Function-Libraries/DependenciesFilter.js @@ -18,7 +18,7 @@ function newSuperalgosFunctionLibraryDependenciesFilter() { return thisObject - function createDependencyFilter(tradingSystem, defaultExchange, defaultMarket) { + function createDependencyFilter(defaultExchange, defaultMarket, tradingSystem) { let filters = { market: { list: new Map() diff --git a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js index c22b11bf4..1a1ac95d9 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TradingSessionFunctions.js @@ -133,8 +133,11 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { let session = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) - let defaultExchange = validationsResult.exchange.config.codeName - let defaultMarket = validationsResult.market.baseAsset.payload.referenceParent.config.codeName + '-' + validationsResult.market.quotedAsset.payload.referenceParent.config.codeName + let defaultExchange = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(validationsResult.exchange.payload, 'codeName') + let defaultMarket = + UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(validationsResult.market.baseAsset.payload.referenceParent.payload, 'codeName') + + '-' + + UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(validationsResult.market.quotedAsset.payload.referenceParent.payload, 'codeName') let dependencyFilter = UI.projects.superalgos.functionLibraries.dependenciesFilter.createDependencyFilter( defaultExchange, @@ -296,6 +299,6 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() { result.exchange = result.market.payload.parentNode.payload.parentNode - return result.networkNode + return result } } From d524e237a455a35457180136ce99cd75b0d12695 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 17:32:27 +0100 Subject: [PATCH 16/25] Dataset.js fully debugged --- .../TS/Process-Modules/DataDependencies.js | 69 ++++++++++--------- .../Superalgos/TS/Process-Modules/Dataset.js | 18 +++-- .../UI/Function-Libraries/TaskFunctions.js | 2 + 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index cc77da285..e45eb7127 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -108,9 +108,6 @@ TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - thisObject.filters.exchange.list.set(thisObject.defaultExchange, true) - thisObject.filters.exchange.markets.set(thisObject.defaultExchange + '-' + thisObject.defautMarket, true) - thisObject.filters.market.list.set(true) /* For each dependency declared at the curatedDependencyNodeArray, we will initialize a DataSet as part of this initialization process. */ @@ -184,47 +181,51 @@ */ let product = dataDependency.referenceParent.parentNode.config.singularVariableName - if (thisObject.filters.products.get(exchange + '-' + market + '-' + product) !== true) { + if (thisObject.filters.exchange.products.get(exchange + '-' + market + '-' + product) !== true) { continue } - addDataSets(exchange, market) + addDataSet(exchange, market) + } else { + addDataSet(exchange, market) } - let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) - dataSetModule.initialize(exchange, market, dataDependency, onInitilized) + function addDataSet(exchange, market) { + let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) + dataSetModule.initialize(exchange, market, dataDependency, onInitilized) - function onInitilized(err, wasInitialized) { + function onInitilized(err, wasInitialized) { - if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)) + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)) - alreadyCalledBack = true - callBackFunction(err) - return - } - - if (wasInitialized === true) { - addCount++ - newNodeArray.push(thisObject.curatedDependencyNodeArray[i]) - addDataSet() - } else { - skipCount++ - } - checkIfWeAreDone() - } - - function addDataSet() { - thisObject.dataSetsModulesArray.push(dataSetModule) - } - - function checkIfWeAreDone() { - if (addCount + skipCount === thisObject.curatedDependencyNodeArray.length) { - if (alreadyCalledBack === false) { alreadyCalledBack = true - thisObject.curatedDependencyNodeArray = newNodeArray - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + callBackFunction(err) return } + + if (wasInitialized === true) { + addCount++ + newNodeArray.push(thisObject.curatedDependencyNodeArray[i]) + addDataSet() + } else { + skipCount++ + } + checkIfWeAreDone() + } + + function addDataSet() { + thisObject.dataSetsModulesArray.push(dataSetModule) + } + + function checkIfWeAreDone() { + if (addCount + skipCount === thisObject.curatedDependencyNodeArray.length) { + if (alreadyCalledBack === false) { + alreadyCalledBack = true + thisObject.curatedDependencyNodeArray = newNodeArray + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + return + } + } } } } diff --git a/Projects/Superalgos/TS/Process-Modules/Dataset.js b/Projects/Superalgos/TS/Process-Modules/Dataset.js index 3c8ca1199..45a40ffb2 100644 --- a/Projects/Superalgos/TS/Process-Modules/Dataset.js +++ b/Projects/Superalgos/TS/Process-Modules/Dataset.js @@ -280,7 +280,7 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { if (startingNode.referenceParent.parentNode.parentNode === undefined) { return } - if (startingNode.referenceParent.parentNode.parentNode.codeName !== exchange) { + if (startingNode.referenceParent.parentNode.parentNode.config.codeName !== exchange) { return } } @@ -292,14 +292,18 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { switch (property.type) { case 'node': { - scanNodeMesh(startingNode[property.name]) + if (found !== true) { + 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]) + if (found !== true) { + scanNodeMesh(startingNodePropertyArray[m]) + } } } break @@ -309,11 +313,15 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { } /* We scan parents nodes. */ if (startingNode.parentNode !== undefined) { - scanNodeMesh(startingNode.parentNode) + if (found !== true) { + scanNodeMesh(startingNode.parentNode) + } } /* We scan reference parents too. */ if (startingNode.referenceParent !== undefined) { - scanNodeMesh(startingNode.referenceParent) + if (found !== true) { + scanNodeMesh(startingNode.referenceParent) + } } } } diff --git a/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js index 59da53e38..5a47da8de 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js @@ -158,6 +158,8 @@ function newSuperalgosFunctionLibraryTaskFunctions() { 'Project Data Products->Project Trading Products->Project Learning Products->' + 'Exchange Data Products->Exchange Trading Products->Exchange Learning Products->' + 'Market Data Products->Market Trading Products->Market Learning Products->' + + 'Market->Market Base Asset->Market Quoted Asset->Asset->' + + 'Exchange Markets->Crypto Exchange->' + 'Data Mine Products->Bot Products->' + 'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' + 'Data Product->Product Definition->' + From 2789487ae205d5a3b2164886186fcd4dfb0f3458 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 18:08:09 +0100 Subject: [PATCH 17/25] Bug Fixes at Trading Process --- .../Low-Frequency-Trading/TradingProcess.js | 12 ++-- .../TS/Process-Modules/DataDependencies.js | 62 +++++++++---------- 2 files changed, 35 insertions(+), 39 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 0dedfd6c9..c8cf63784 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 @@ -341,7 +341,7 @@ continue } - if (dataDependenciesModule.filters.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, 'atAnyTimeFrame') !== true) { + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, 'atAnyTimeFrame') !== true) { /* If we can not find the current data set is used at the current time frame we will skip this file. @@ -405,7 +405,7 @@ continue } - if (dataDependenciesModule.filters.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { /* If we can not find the current data set is used at the current time frame we will skip this file, unless we are in the only special @@ -520,7 +520,7 @@ continue } - if (dataDependenciesModule.filters.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { /* If we can not find the current data set is used at the current time frame we will skip this file, unless we are in the only special @@ -658,7 +658,7 @@ let dataFiles = multiTimeFrameDataFiles.get(timeFrameLabel) let products = {} - if (dataFiles !== undefined) { + if (dataFiles !== undefined && dataFiles.size > 0) { TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'at' + timeFrameLabel.replace('-', '') @@ -672,7 +672,7 @@ let dataFiles = multiTimeFrameDataFiles.get(timeFrameLabel) let products = {} - if (dataFiles !== undefined) { + if (dataFiles !== undefined && dataFiles.size > 0) { TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'at' + timeFrameLabel.replace('-', '') @@ -684,7 +684,7 @@ let dataFiles = multiTimeFrameDataFiles.get('Single Files') let products = {} - if (dataFiles !== undefined) { + if (dataFiles !== undefined && dataFiles.size > 0) { TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'atAnyTimeFrame' diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index e45eb7127..147fac5d3 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -76,6 +76,15 @@ return } + /* + Store here the default exchange and market. + */ + thisObject.defaultExchange = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName + thisObject.defaultMarket = + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + + "-" + + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + /* Session based dependency thisObject.filters */ let receivedDependencyFilters = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER if (receivedDependencyFilters !== undefined) { @@ -98,22 +107,20 @@ map.set(key, true) } } + } else { + /* + If we did not receive any filters, like in the case of Indicators and Sensors, + we need to add the default exchange and market to these maps in order + for the following sections to work. + */ + thisObject.filters.exchange.list.set(thisObject.defaultExchange, true) + thisObject.filters.exchange.markets.set(thisObject.defaultExchange + '-' + thisObject.defautMarket, true) } /* - At our filter structure, we will add the Task default exchange and market. - This will help us lateer to build other structures in a generic way. - */ - thisObject.defaultExchange = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName - thisObject.defautMarket = - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + - "-" + - TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - /* - For each dependency declared at the curatedDependencyNodeArray, we will initialize a DataSet as part of this initialization process. - */ + For each dependency declared at the curatedDependencyNodeArray, we will initialize a + DataSet as part of this initialization process. + */ let alreadyCalledBack = false - let addCount = 0 - let skipCount = 0 /* The current curatedDependencyNodeArray that we have includes all the dependencies daclared in the Data Mine | Trading Mine | Learning Mine @@ -156,6 +163,13 @@ } } + if (alreadyCalledBack === false) { + alreadyCalledBack = true + thisObject.curatedDependencyNodeArray = newNodeArray + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + return + } + function addDataSets(exchange, market) { for (let i = 0; i < thisObject.curatedDependencyNodeArray.length; i++) { @@ -190,6 +204,7 @@ } function addDataSet(exchange, market) { + let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) dataSetModule.initialize(exchange, market, dataDependency, onInitilized) @@ -204,27 +219,8 @@ } if (wasInitialized === true) { - addCount++ newNodeArray.push(thisObject.curatedDependencyNodeArray[i]) - addDataSet() - } else { - skipCount++ - } - checkIfWeAreDone() - } - - function addDataSet() { - thisObject.dataSetsModulesArray.push(dataSetModule) - } - - function checkIfWeAreDone() { - if (addCount + skipCount === thisObject.curatedDependencyNodeArray.length) { - if (alreadyCalledBack === false) { - alreadyCalledBack = true - thisObject.curatedDependencyNodeArray = newNodeArray - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) - return - } + thisObject.dataSetsModulesArray.push(dataSetModule) } } } From 85211ab486feff002690a83e9abb1a896677d4ac Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 18:44:15 +0100 Subject: [PATCH 18/25] Bug Fixed, almost all debuged --- .../Low-Frequency-Trading/Snapshots.js | 16 +++++++++++- .../Low-Frequency-Trading/TradingOutput.js | 4 +-- .../Low-Frequency-Trading/TradingProcess.js | 26 ++++++++++--------- .../TradingSimulation.js | 12 ++++++--- .../Low-Frequency-Trading/TradingStages.js | 4 +-- .../Low-Frequency-Trading/TradingSystem.js | 2 +- 6 files changed, 43 insertions(+), 21 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js index 4af1bcfbd..031eab5d9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/Snapshots.js @@ -38,7 +38,13 @@ exports.newSuperalgosBotModulesSnapshots = function (processIndex) { let positionValues let addToPositionValues + /* + These 3 are the main data structures available to users + when writing conditions and formulas. + */ let chart + let exchange + let market return thisObject @@ -58,10 +64,18 @@ exports.newSuperalgosBotModulesSnapshots = function (processIndex) { strategyKeys = undefined chart = undefined + exchange = undefined + market = undefined } - function updateChart(pChart) { + function updateChart(pChart, pExchange, pMarket) { + /* + We need these 3 data structures to be a local objects + accessible while evaluating conditions and formulas. + */ chart = pChart + exchange = pExchange + market = pMarket } function strategyEntry() { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js index fb3c06aa4..d0a799b9a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOutput.js @@ -28,8 +28,8 @@ exports.newSuperalgosBotModulesTradingOutput = function (processIndex) { async function start( chart, - exchange, market, + exchange, timeFrame, timeFrameLabel, tradingProcessDate @@ -80,8 +80,8 @@ exports.newSuperalgosBotModulesTradingOutput = function (processIndex) { await tradingSimulationModuleObject.runSimulation( chart, - exchange, market, + exchange, outputDatasetsMap, writeFiles ) 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 c8cf63784..613f41d2f 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 @@ -341,7 +341,7 @@ continue } - if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, 'atAnyTimeFrame') !== true) { + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + 'atAnyTimeFrame') !== true) { /* If we can not find the current data set is used at the current time frame we will skip this file. @@ -405,7 +405,7 @@ continue } - if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + timeFrameLabel) !== true) { /* If we can not find the current data set is used at the current time frame we will skip this file, unless we are in the only special @@ -520,7 +520,7 @@ continue } - if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange, datasetModule.market, datasetModule.product, timeFrameLabel) !== true) { + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + timeFrameLabel) !== true) { /* If we can not find the current data set is used at the current time frame we will skip this file, unless we are in the only special @@ -662,7 +662,7 @@ TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'at' + timeFrameLabel.replace('-', '') - addProducs(propertyName) + addProducs(propertyName, products) } } @@ -676,22 +676,24 @@ TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'at' + timeFrameLabel.replace('-', '') - addProducs(propertyName) + addProducs(propertyName, products) } } /* Single Files */ - let dataFiles = multiTimeFrameDataFiles.get('Single Files') - let products = {} + { + let dataFiles = multiTimeFrameDataFiles.get('Single Files') + let products = {} - if (dataFiles !== undefined && dataFiles.size > 0) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + if (dataFiles !== undefined && dataFiles.size > 0) { + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) - let propertyName = 'atAnyTimeFrame' - addProducs(propertyName) + let propertyName = 'atAnyTimeFrame' + addProducs(propertyName, products) + } } - function addProducs(propertyName) { + function addProducs(propertyName, products) { /* The chart data structure allow users to simplify the syntax when they are using the default exchange and the default market. diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js index a4c95762f..4bab96ff7 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js @@ -17,8 +17,8 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { async function runSimulation( chart, - exchange, market, + exchange, outputDatasetsMap, writeFiles, ) { @@ -152,7 +152,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { chart, exchange, market - ) + ) /* Do the stuff needed previous to the run like @@ -220,7 +220,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { type: 'TS LF Trading Bot Info - Candle And Cycle', placeholder: {} } - + contextInfo = { candleIndex: tradingEngine.current.episode.candle.index.value, cycle: tradingEngine.current.episode.cycle.value @@ -368,6 +368,8 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { let propertyName = 'at' + mapKey.replace('-', '') let thisChart = chart[propertyName] + if (thisChart === undefined) { continue } + for (let k = 0; k < dataDependencies.length; k++) { let dataDependencyNode = dataDependencies[k] if (dataDependencyNode.referenceParent.config.codeName !== 'Multi-Period-Daily') { continue } @@ -389,6 +391,8 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { let propertyName = 'at' + mapKey.replace('-', '') let thisChart = chart[propertyName] + if (thisChart === undefined) { continue } + for (let k = 0; k < dataDependencies.length; k++) { let dataDependencyNode = dataDependencies[k] if (dataDependencyNode.referenceParent.config.codeName !== 'Multi-Period-Market') { continue } @@ -407,6 +411,8 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { let propertyName = 'atAnyTimeFrame' let thisChart = chart[propertyName] + if (thisChart === undefined) { return } + for (let k = 0; k < dataDependencies.length; k++) { let dataDependencyNode = dataDependencies[k] if (dataDependencyNode.referenceParent.config.codeName !== 'Single-File') { continue } diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js index 7dbdd2c5e..ef55ba96c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js @@ -71,8 +71,8 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) { tradingEpisodeModuleObject = undefined } - function updateChart(pChart) { - snapshotsModuleObject.updateChart(pChart) + function updateChart(pChart, pExchange, pMarket) { + snapshotsModuleObject.updateChart(pChart, pExchange, pMarket) } function mantain() { diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js index baff85703..e784c7e28 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js @@ -169,7 +169,7 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) { exchange = pExchange market = pMarket - tradingStagesModuleObject.updateChart(pChart) + tradingStagesModuleObject.updateChart(pChart, pExchange, pMarket) } function buildDynamicIndicators() { From 57ecc910398c05004ced854c8bae07b759ba7251 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 19:02:34 +0100 Subject: [PATCH 19/25] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 73391dd5e..dec5b0068 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# Superalgos Beta 9 + # Getting Started Guide All procedures are the same for Windows, Linux, or Mac OS. From d763639cb61f5d46656f205821b0b131a3b97889 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 3 Feb 2021 09:47:26 +0100 Subject: [PATCH 20/25] All code implemented for supporting new data sructures --- .../TradingSimulation.js | 97 +++++++++++-------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js index 4bab96ff7..0bf723599 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js @@ -145,7 +145,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { continue } - positionChartAtCurrentCandle() + positionDataStructuresAtCurrentCandle() /* The chart was recalculated based on the current candle. */ tradingSystemModuleObject.updateChart( @@ -352,19 +352,56 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { } } - function positionChartAtCurrentCandle() { + function positionDataStructuresAtCurrentCandle() { /* In conditions and Formulas, we want users to have an easy sintax to refer to indicators. In order to achieve that, we need the user to have 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 = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') - dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) - /* Finding the Current Element on Market Files */ - if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { - for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) { - let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1] + for (const exchangeCodeName in exchange) { + let currentExchange = exchange[exchangeCodeName] + for (const baseAssetCodeName in currentExchange.market) { + let currentBaseAsset = currentExchange.market[baseAssetCodeName] + for (const quotedAssetCodeName in currentBaseAsset) { + let currentQuotedAsset = currentBaseAsset[quotedAssetCodeName] + let currentChart = currentQuotedAsset.chart + positionChart(currentChart) + } + } + } + + function positionChart(chart) { + let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') + dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) + + /* Finding the Current Element on Market Files */ + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { + for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) { + let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1] + let propertyName = 'at' + mapKey.replace('-', '') + let thisChart = chart[propertyName] + + if (thisChart === undefined) { continue } + + for (let k = 0; k < dataDependencies.length; k++) { + let dataDependencyNode = dataDependencies[k] + if (dataDependencyNode.referenceParent.config.codeName !== 'Multi-Period-Daily') { continue } + let singularVariableName = dataDependencyNode.referenceParent.parentNode.config.singularVariableName + let pluralVariableName = dataDependencyNode.referenceParent.parentNode.config.pluralVariableName + if (thisChart[pluralVariableName] !== undefined) { + let currentElement = getElement(thisChart[pluralVariableName], 'Daily' + '-' + mapKey + '-' + pluralVariableName) + if (currentElement !== undefined) { + thisChart[singularVariableName] = currentElement + } + } + } + } + } + + /* Finding the Current Element on Market Files */ + for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) { + let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[j][1] let propertyName = 'at' + mapKey.replace('-', '') let thisChart = chart[propertyName] @@ -372,59 +409,37 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { for (let k = 0; k < dataDependencies.length; k++) { let dataDependencyNode = dataDependencies[k] - if (dataDependencyNode.referenceParent.config.codeName !== 'Multi-Period-Daily') { continue } + if (dataDependencyNode.referenceParent.config.codeName !== 'Multi-Period-Market') { continue } let singularVariableName = dataDependencyNode.referenceParent.parentNode.config.singularVariableName let pluralVariableName = dataDependencyNode.referenceParent.parentNode.config.pluralVariableName if (thisChart[pluralVariableName] !== undefined) { - let currentElement = getElement(thisChart[pluralVariableName], 'Daily' + '-' + mapKey + '-' + pluralVariableName) + let currentElement = getElement(thisChart[pluralVariableName], 'Market' + '-' + mapKey + '-' + pluralVariableName) if (currentElement !== undefined) { thisChart[singularVariableName] = currentElement } } } } - } - /* Finding the Current Element on Market Files */ - for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) { - let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[j][1] - let propertyName = 'at' + mapKey.replace('-', '') + /* Finding the Current Element At Single Files*/ + let propertyName = 'atAnyTimeFrame' let thisChart = chart[propertyName] - if (thisChart === undefined) { continue } + if (thisChart === undefined) { return } for (let k = 0; k < dataDependencies.length; k++) { let dataDependencyNode = dataDependencies[k] - if (dataDependencyNode.referenceParent.config.codeName !== 'Multi-Period-Market') { continue } + if (dataDependencyNode.referenceParent.config.codeName !== 'Single-File') { continue } let singularVariableName = dataDependencyNode.referenceParent.parentNode.config.singularVariableName let pluralVariableName = dataDependencyNode.referenceParent.parentNode.config.pluralVariableName - if (thisChart[pluralVariableName] !== undefined) { - let currentElement = getElement(thisChart[pluralVariableName], 'Market' + '-' + mapKey + '-' + pluralVariableName) - if (currentElement !== undefined) { - thisChart[singularVariableName] = currentElement - } + let elementArray = thisChart[pluralVariableName] + let currentElement + if (elementArray !== undefined) { + currentElement = elementArray[elementArray.length - 1] } + thisChart[singularVariableName] = currentElement } } - - /* Finding the Current Element At Single Files*/ - let propertyName = 'atAnyTimeFrame' - let thisChart = chart[propertyName] - - if (thisChart === undefined) { return } - - for (let k = 0; k < dataDependencies.length; k++) { - let dataDependencyNode = dataDependencies[k] - if (dataDependencyNode.referenceParent.config.codeName !== 'Single-File') { continue } - let singularVariableName = dataDependencyNode.referenceParent.parentNode.config.singularVariableName - let pluralVariableName = dataDependencyNode.referenceParent.parentNode.config.pluralVariableName - let elementArray = thisChart[pluralVariableName] - let currentElement - if (elementArray !== undefined) { - currentElement = elementArray[elementArray.length - 1] - } - thisChart[singularVariableName] = currentElement - } } function getElement(pArray, datasetName) { From 3f78190575c091135fbc07e67c1a7cb854d62552 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 3 Feb 2021 10:55:48 +0100 Subject: [PATCH 21/25] bug fixed --- Projects/Superalgos/TS/Utilities/DateTimeFunctions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js b/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js index 02582cacc..0dacf20b3 100644 --- a/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js +++ b/Projects/Superalgos/TS/Utilities/DateTimeFunctions.js @@ -8,7 +8,7 @@ exports.newSuperalgosUtilitiesDateTimeFunctions = function () { return thisObject - function removeTime (datetime) { + function removeTime(datetime) { let date = new Date(datetime) return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + TS.projects.superalgos.globals.timeConstants.GMT_SECONDS); } @@ -21,6 +21,7 @@ exports.newSuperalgosUtilitiesDateTimeFunctions = function () { if ((lastDays - fromDays) === 0) { percentage = 100 } + if (percentage > 100) { percentage = 100 } return percentage } From bc0ccd019c1096c5ff9eb0caa4be655c38c4b0d4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 3 Feb 2021 11:40:05 +0100 Subject: [PATCH 22/25] Final Bug Fixes --- .../Low-Frequency-Trading/TradingProcess.js | 487 ++++++++++-------- .../UI/Spaces/Docs-Space/SearchEngine.js | 2 - 2 files changed, 279 insertions(+), 210 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 613f41d2f..f008588a4 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 @@ -331,224 +331,46 @@ } async function processSingleFiles() { - dataFiles = new Map() - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] - let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] - - if (datasetModule.node.config.codeName !== "Single-File") { - continue - } - - if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + 'atAnyTimeFrame') !== true) { - /* - If we can not find the current data set is used at the current time - frame we will skip this file. - */ - continue - } - - let fileName = "Data.json" - let filePath = datasetModule.node.parentNode.config.codeName + '/' + datasetModule.node.config.codeName - - /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ - let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) - - if (response.err.message === 'File does not exist.') { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") - return false - } - - if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - throw (response.err) - } - - let dataFile = JSON.parse(response.text) - dataFiles.set(dependency.id, dataFile) - } - - let mapKey = "Single Files" - multiTimeFrameDataFiles.set(mapKey, dataFiles) - } - - async function processMarketFiles() { /* - We do market files first since if the simulation is run on daily files, there will - be a loop to get each of those files and we do not need that loop to reload market files. - - We will iterate through all posible timeFrames. + We will iterate through all the exchanges and markets involved. */ - for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) { - const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] - const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] + let exchangeList = Array.from(dataDependenciesModule.filters.exchange.list.keys()) + let marketList = Array.from(dataDependenciesModule.filters.market.list.keys()) - dataFiles = new Map() + for (let e = 0; e < exchangeList.length; e++) { + let currentExchange = exchangeList[e] + for (let m = 0; m < marketList.length; m++) { + let currentMarket = marketList[m] - /* Current Time Frame detection */ - 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] - currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] - } + dataFiles = new Map() - /* Loop across the list of curated dependencies */ - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] - let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] + let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] - if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") { - continue - } - - if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + timeFrameLabel) !== true) { - /* - If we can not find the current data set is used at the current time - frame we will skip this file, unless we are in the only special - case that we are retrieving candles. - */ - if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { + if (datasetModule.node.config.codeName !== "Single-File") { continue } - } - let fileName = "Data.json" - let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel - - /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ - let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) - - if (response.err.message === 'File does not exist.') { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") - return false - } - - if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - throw (response.err) - } - - let dataFile = JSON.parse(response.text) - let trimmedDataFile = trimDataFile(dataFile, datasetModule.node.parentNode.record) - dataFiles.set(dependency.id, trimmedDataFile) - - function trimDataFile(dataFile, recordDefinition) { - /* - Here we will discard all the records in a file that are outside of the current time range. - We will include the las element previous to the begining of the time range. This is needed - because during the simulation, the current period is not the open one, but the previous to - the open, and if we do not include the previous to the initial datetime there will be no - current objects at the begining of the simulation for many time frames. - */ - let beginIndex - let endIndex - let result = [] - for (let i = 0; i < recordDefinition.properties.length; i++) { - let property = recordDefinition.properties[i] - if (property.config.codeName === 'begin') { - beginIndex = i - } - if (property.config.codeName === 'end') { - endIndex = i - } - } - for (let i = 0; i < dataFile.length; i++) { - let dataRecord = dataFile[i] - let begin = dataRecord[beginIndex] - let end = dataRecord[endIndex] - if (end + timeFrame < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime - 1) { continue } // /1 because we need the previous closed element - if (begin > TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.finalDatetime) { continue } - result.push(dataRecord) - } - return result - } - } - - let mapKey = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] - multiTimeFrameDataFiles.set(mapKey, dataFiles) - } - return true - } - - async function processDailyFiles() { - /* Telling the world we are alive and doing well and which date we are processing right now. */ - let processingDateString = tradingProcessDate.getUTCFullYear() + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCMonth() + 1, 2) + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCDate(), 2) - TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, processingDateString, undefined, "Running...") - - /* - We will iterate through all posible timeFrames. - */ - for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) { - const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0] - const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] - - if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames !== undefined) { - let validPeriod = false - for (let i = 0; i < TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames.length; i++) { - let period = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames[i] - if (period === timeFrameLabel) { validPeriod = true } - } - if (validPeriod === false) { - continue - } - } - - 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.dailyFilePeriods()[n][0] - currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] - } - - dataFiles = new Map() - - /* - We will iterate through all dependencies, in order to load the - files that later will end up at the chart data structure. - */ - for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { - let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] - let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] - - if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") { - continue - } - - if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + timeFrameLabel) !== true) { - /* - If we can not find the current data set is used at the current time - frame we will skip this file, unless we are in the only special - case that we are retrieving candles. - */ - if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { + if (datasetModule.exchange !== currentExchange) { continue } - } - /* - We will need to fetch the data of the current day and the previous day, in order for .previous properties in conditions and formulas to work well. - */ - let previousDate = new Date(tradingProcessDate.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) - let currentDate = new Date(tradingProcessDate.valueOf()) + if (datasetModule.market !== currentMarket) { + continue + } - let previousFile = await getDataFileFromDate(previousDate) - if (previousFile === false) { return false } - let currentFile = await getDataFileFromDate(currentDate) - if (currentFile === false) { return false } - let bothFiles = previousFile.concat(currentFile) - dataFiles.set(dependency.id, bothFiles) + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + 'atAnyTimeFrame') !== true) { + /* + If we can not find the current data set is used at the current time + frame we will skip this file. + */ + continue + } - async function getDataFileFromDate(processDate) { - - let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2) - let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath let fileName = "Data.json" + let filePath = datasetModule.node.parentNode.config.codeName + '/' + datasetModule.node.config.codeName /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) @@ -562,15 +384,264 @@ "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") return false } + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { throw (response.err) } - return JSON.parse(response.text) + let dataFile = JSON.parse(response.text) + dataFiles.set(dependency.id, dataFile) + } + + let mapKey = currentExchange + '-' + currentMarket + '-' + "Single Files" + multiTimeFrameDataFiles.set(mapKey, dataFiles) + } + } + } + + async function processMarketFiles() { + /* + We do market files first since if the simulation is run on daily files, there will + be a loop to get each of those files and we do not need that loop to reload market files. + */ + + /* + We will iterate through all the exchanges and markets involved. + */ + let exchangeList = Array.from(dataDependenciesModule.filters.exchange.list.keys()) + let marketList = Array.from(dataDependenciesModule.filters.market.list.keys()) + + for (let e = 0; e < exchangeList.length; e++) { + let currentExchange = exchangeList[e] + for (let m = 0; m < marketList.length; m++) { + let currentMarket = marketList[m] + /* + We will iterate through all posible timeFrames. + */ + for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; n++) { + const timeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] + const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] + + 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) { + currentTimeFrame = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][0] + currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] + } + + /* Loop across the list of curated dependencies */ + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] + let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] + + if (dependency.referenceParent.config.codeName !== "Multi-Period-Market") { + continue + } + + if (datasetModule.exchange !== currentExchange) { + continue + } + + if (datasetModule.market !== currentMarket) { + continue + } + + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + timeFrameLabel) !== true) { + /* + If we can not find the current data set is used at the current time + frame we will skip this file, unless we are in the only special + case that we are retrieving candles. + */ + if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { + continue + } + if (currentExchange !== dataDependenciesModule.defaultExchange || currentMarket !== dataDependenciesModule.defaultMarket) { + continue + } + } + + let fileName = "Data.json" + let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + + /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ + let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) + + if (response.err.message === 'File does not exist.') { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") + return false + } + + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { + throw (response.err) + } + + let dataFile = JSON.parse(response.text) + let trimmedDataFile = trimDataFile(dataFile, datasetModule.node.parentNode.record) + dataFiles.set(dependency.id, trimmedDataFile) + + function trimDataFile(dataFile, recordDefinition) { + /* + Here we will discard all the records in a file that are outside of the current time range. + We will include the las element previous to the begining of the time range. This is needed + because during the simulation, the current period is not the open one, but the previous to + the open, and if we do not include the previous to the initial datetime there will be no + current objects at the begining of the simulation for many time frames. + */ + let beginIndex + let endIndex + let result = [] + for (let i = 0; i < recordDefinition.properties.length; i++) { + let property = recordDefinition.properties[i] + if (property.config.codeName === 'begin') { + beginIndex = i + } + if (property.config.codeName === 'end') { + endIndex = i + } + } + for (let i = 0; i < dataFile.length; i++) { + let dataRecord = dataFile[i] + let begin = dataRecord[beginIndex] + let end = dataRecord[endIndex] + if (end + timeFrame < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime - 1) { continue } // /1 because we need the previous closed element + if (begin > TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.finalDatetime) { continue } + result.push(dataRecord) + } + return result + } + } + + let mapKey = currentExchange + '-' + currentMarket + '-' + TS.projects.superalgos.globals.timeFrames.marketFilesPeriods()[n][1] + multiTimeFrameDataFiles.set(mapKey, dataFiles) } } - let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] - multiTimeFrameDataFiles.set(mapKey, dataFiles) + } + return true + } + + async function processDailyFiles() { + /* Telling the world we are alive and doing well and which date we are processing right now. */ + let processingDateString = tradingProcessDate.getUTCFullYear() + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCMonth() + 1, 2) + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCDate(), 2) + TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, processingDateString, undefined, "Running...") + + /* + We will iterate through all the exchanges and markets involved. + */ + let exchangeList = Array.from(dataDependenciesModule.filters.exchange.list.keys()) + let marketList = Array.from(dataDependenciesModule.filters.market.list.keys()) + + for (let e = 0; e < exchangeList.length; e++) { + let currentExchange = exchangeList[e] + for (let m = 0; m < marketList.length; m++) { + let currentMarket = marketList[m] + /* + We will iterate through all posible timeFrames. + */ + for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) { + const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0] + const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] + + if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames !== undefined) { + let validPeriod = false + for (let i = 0; i < TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames.length; i++) { + let period = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames[i] + if (period === timeFrameLabel) { validPeriod = true } + } + if (validPeriod === false) { + continue + } + } + + 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.dailyFilePeriods()[n][0] + currentTimeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] + } + + dataFiles = new Map() + + /* + We will iterate through all dependencies, in order to load the + files that later will end up at the chart data structure. + */ + for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.curatedDependencyNodeArray.length; dependencyIndex++) { + let dependency = dataDependenciesModule.curatedDependencyNodeArray[dependencyIndex] + let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex] + + if (dependency.referenceParent.config.codeName !== "Multi-Period-Daily") { + continue + } + + if (datasetModule.exchange !== currentExchange) { + continue + } + + if (datasetModule.market !== currentMarket) { + continue + } + + if (dataDependenciesModule.filters.exchange.timeFrames.get(datasetModule.exchange + '-' + datasetModule.market + '-' + datasetModule.product + '-' + timeFrameLabel) !== true) { + /* + If we can not find the current data set is used at the current time + frame we will skip this file, unless we are in the only special + case that we are retrieving candles. + */ + if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { + continue + } + if (currentExchange !== dataDependenciesModule.defaultExchange || currentMarket !== dataDependenciesModule.defaultMarket) { + continue + } + } + + /* + We will need to fetch the data of the current day and the previous day, in order for .previous properties in conditions and formulas to work well. + */ + let previousDate = new Date(tradingProcessDate.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let currentDate = new Date(tradingProcessDate.valueOf()) + + let previousFile = await getDataFileFromDate(previousDate) + if (previousFile === false) { return false } + let currentFile = await getDataFileFromDate(currentDate) + if (currentFile === false) { return false } + let bothFiles = previousFile.concat(currentFile) + dataFiles.set(dependency.id, bothFiles) + + async function getDataFileFromDate(processDate) { + + let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2) + let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath + let fileName = "Data.json" + + /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ + let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) + + if (response.err.message === 'File does not exist.') { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] File not Found. This process will wait until you run your Data Mining and this file is created. File = " + filePath + '/' + fileName) + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] Your strategy depends on the dataset " + dependency.name + '.') + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[ERROR] The reason that it depends on this dataset is becuase in one of your condition's Javascript Code node, you have written an expression that references this dataset. If you don't want to depend on this dataset, just locate that code and remove the mention.") + return false + } + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { + throw (response.err) + } + + return JSON.parse(response.text) + } + } + let mapKey = currentExchange + '-' + currentMarket + '-' + TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] + multiTimeFrameDataFiles.set(mapKey, dataFiles) + } + + } } return true } @@ -655,7 +726,7 @@ /* Market Files */ 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 = multiTimeFrameDataFiles.get(timeFrameLabel) + let dataFiles = multiTimeFrameDataFiles.get(currentExchange + '-' + currentMarket + '-' + timeFrameLabel) let products = {} if (dataFiles !== undefined && dataFiles.size > 0) { @@ -669,7 +740,7 @@ /* Daily Files */ for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; j++) { let timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[j][1] - let dataFiles = multiTimeFrameDataFiles.get(timeFrameLabel) + let dataFiles = multiTimeFrameDataFiles.get(currentExchange + '-' + currentMarket + '-' + timeFrameLabel) let products = {} if (dataFiles !== undefined && dataFiles.size > 0) { @@ -682,7 +753,7 @@ /* Single Files */ { - let dataFiles = multiTimeFrameDataFiles.get('Single Files') + let dataFiles = multiTimeFrameDataFiles.get(currentExchange + '-' + currentMarket + '-' + 'Single Files') let products = {} if (dataFiles !== undefined && dataFiles.size > 0) { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js index ea44ac22f..101ce7823 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js @@ -17,8 +17,6 @@ function newSuperalgosDocsSearchEngine() { } function setUpSearchEngine(callbackFunction) { - callbackFunction() - return let totalAsyncCallsMade = 0 let totalAsyncCallsFinished = 0 From 74b2ef40f85a37a5322e9a0fca2497866a343e75 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 3 Feb 2021 12:48:12 +0100 Subject: [PATCH 23/25] Documentation ready --- .../Docs-Concepts/default-exchange.json | 13 ++++ .../Schemas/Docs-Concepts/default-market.json | 13 ++++ ...1-lf-trading-bot-chart-data-structure.json | 72 +++++++++++++++++ ...-lf-trading-bot-market-data-structure.json | 72 +++++++++++++++++ ...f-trading-bot-exchange-data-structure.json | 77 +++++++++++++++++++ Projects/Superalgos/UI/Utilities/Strings.js | 7 +- 6 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/default-exchange.json create mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/default-market.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-001-lf-trading-bot-chart-data-structure.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-002-lf-trading-bot-market-data-structure.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-003-lf-trading-bot-exchange-data-structure.json diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/default-exchange.json b/Projects/Superalgos/Schemas/Docs-Concepts/default-exchange.json new file mode 100644 index 000000000..da0550999 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Concepts/default-exchange.json @@ -0,0 +1,13 @@ +{ + "type": "Default Exchange", + "definition": { + "text": "The Default Exchange is the one referenced by the Exchange Data Tasks, Exchange Trading Tasks, Exchange Learning Tasks nodes of which a certain Task decends from. The Trading Bot running inside that Task will considere that referenced exchange to be it's Default Exchange.", + "updated": 1612352828045 + }, + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/default-market.json b/Projects/Superalgos/Schemas/Docs-Concepts/default-market.json new file mode 100644 index 000000000..8415e1960 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Concepts/default-market.json @@ -0,0 +1,13 @@ +{ + "type": "Default Market", + "definition": { + "text": "The Default Market is the one referenced by the Market Data Tasks, Market Trading Tasks, Market Learning Tasks nodes of which a certain Task decends from. The Trading Bot running inside that Task will considered that reference market to be it's Default Market.", + "updated": 1612352846165 + }, + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-001-lf-trading-bot-chart-data-structure.json b/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-001-lf-trading-bot-chart-data-structure.json new file mode 100644 index 000000000..d0ef677fe --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-001-lf-trading-bot-chart-data-structure.json @@ -0,0 +1,72 @@ +{ + "topic": "LF Trading Bot Available Data Structures", + "pageNumber": "1", + "type": "LF Trading Bot - Chart Data Structure", + "definition": { + "text": "The Chart Data Structure is an object that contains Indicator or Sensor bots data, available at runtime, that can be accessed from the code of Conditions and Formulas.", + "updated": 1612349390525 + }, + "paragraphs": [ + { + "style": "Note", + "text": "This Javascript object, together with the other two data structures available, ultimately defines the syntax that can be used to write conditions and formulas, and more precisely the sintax to retrieve Indicator Bot and Sensor Bot data.", + "updated": 1612349521002 + }, + { + "style": "Title", + "text": "Structure" + }, + { + "style": "List", + "text": "The root of the object is called...", + "updated": 1612351077417 + }, + { + "style": "Json", + "text": "chart" + }, + { + "style": "List", + "text": "After it these are it's valid properties...", + "updated": 1612351085368 + }, + { + "style": "Json", + "text": "at01min, at02min ... at45min, at01hs ... at24hs", + "updated": 1612349768772 + }, + { + "style": "List", + "text": "After that, it is expected the singleVariableName defined at the config of the Product Definition of an Indicator or Sensor.", + "updated": 1612351093008 + }, + { + "style": "List", + "text": "Finally the last property must be the codeName of a Record Property Node, belonging to the same Product Definition mentioned earlier.", + "updated": 1612350081190 + }, + { + "style": "Title", + "text": "Examples", + "updated": 1612350235632 + }, + { + "style": "Text", + "text": "chart.at01min.support.support5Rate", + "updated": 1612349808636 + }, + { + "style": "Text", + "text": "chart.at05min.candle.open", + "updated": 1612350213519 + }, + { + "style": "Text", + "text": "chart.at24hs.bollingerBand.movingAverage" + }, + { + "style": "Text", + "text": "" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-002-lf-trading-bot-market-data-structure.json b/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-002-lf-trading-bot-market-data-structure.json new file mode 100644 index 000000000..cdd0ec5bd --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-002-lf-trading-bot-market-data-structure.json @@ -0,0 +1,72 @@ +{ + "topic": "LF Trading Bot Available Data Structures", + "pageNumber": "2", + "type": "LF Trading Bot - Market Data Structure", + "definition": { + "text": "The Market Data Structure is one of the 3 data structures available at Conditions and Formulas with data from Indicator and Sensor bots.", + "updated": 1612351166683 + }, + "paragraphs": [ + { + "style": "Note", + "text": "This Javascript object can be used when you want to specify a market which is different fomr the Default Market. In this way you can access data of the ETH/USDT market from a stragegy running for example at the BTC/USDT market.", + "updated": 1612351365558 + }, + { + "style": "Title", + "text": "Structure" + }, + { + "style": "List", + "text": "The root of the object is called..." + }, + { + "style": "Json", + "text": "market", + "updated": 1612351449944 + }, + { + "style": "List", + "text": "After it you need to spacify the codeName of an Asset representing the Market Base Asset, like the following...", + "updated": 1612351559165 + }, + { + "style": "Json", + "text": "BTC, USDT, ETH... etc.", + "updated": 1612351687073 + }, + { + "style": "List", + "text": "After that again the codeName of an Asset but this time representing the Market Quoted Asset.." + }, + { + "style": "Json", + "text": "BTC, USDT, ETH... etc." + }, + { + "style": "List", + "text": "Finally you continue with the syntax of the LF Trading Bot - Chart Data Structure", + "updated": 1612352138708 + }, + { + "style": "Title", + "text": "Examples", + "updated": 1612352364588 + }, + { + "style": "Text", + "text": "market.ETH.BTC.chart.at01min.support.support5Rate", + "updated": 1612351751906 + }, + { + "style": "Text", + "text": "market.BTC.USDT.chart.at05min.candle.open", + "updated": 1612351782297 + }, + { + "style": "Text", + "text": "market.ETH.USDT.chart.at24hs.bollingerBand.movingAverage", + "updated": 1612351804074 + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-003-lf-trading-bot-exchange-data-structure.json b/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-003-lf-trading-bot-exchange-data-structure.json new file mode 100644 index 000000000..69d6eec72 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/lf-trading-bot-available-data-structures-003-lf-trading-bot-exchange-data-structure.json @@ -0,0 +1,77 @@ +{ + "topic": "LF Trading Bot Available Data Structures", + "pageNumber": "3", + "type": "LF Trading Bot - Exchange Data Structure", + "definition": { + "text": "Write a summary for this topic page." + }, + "paragraphs": [ + { + "style": "Note", + "text": "This Javascript object can be used when you want to specify a Cryto Exchage which is different fomr the Default Exchange. In this way you can access data from Coinbase Pro from a stragegy running for example at Binance.", + "updated": 1612351988656 + }, + { + "style": "Title", + "text": "Structure" + }, + { + "style": "List", + "text": "The root of the object is called..." + }, + { + "style": "Json", + "text": "exchange", + "updated": 1612352008621 + }, + { + "style": "List", + "text": "After it you need to spacify the codeName of a Crypto Exchange, like the following...", + "updated": 1612352057634 + }, + { + "style": "Json", + "text": "biance, bitfinex, coinbasepro... etc.", + "updated": 1612352082792 + }, + { + "style": "List", + "text": "Finally you continue with the syntax of the LF Trading Bot - Market Data Structure", + "updated": 1612352124926 + }, + { + "style": "Title", + "text": "Examples", + "updated": 1612352354839 + }, + { + "style": "Text", + "text": "exchange.poloniex.market.ETH.BTC.chart.at01min.support.support5Rate", + "updated": 1612352167087 + }, + { + "style": "Text", + "text": "exchange.bitfinex.market.BTC.USDT.chart.at05min.candle.open", + "updated": 1612352188098 + }, + { + "style": "Text", + "text": "exchange.binance.market.ETH.USDT.chart.at24hs.bollingerBand.movingAverage", + "updated": 1612352200136 + }, + { + "style": "Title", + "text": "Formula Example", + "updated": 1612352272503 + }, + { + "style": "Text", + "text": "As you can see at the following example you can have a mix of chart, market and exchange usage withing the same Formula or Condition. " + }, + { + "style": "Json", + "text": "chart.at01min.support.support5Rate +\nexchange.poloniex.market.ETH.USDT.chart.at05min.candle.close", + "updated": 1612352290634 + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/UI/Utilities/Strings.js b/Projects/Superalgos/UI/Utilities/Strings.js index 6a21f9691..6f3c955cc 100644 --- a/Projects/Superalgos/UI/Utilities/Strings.js +++ b/Projects/Superalgos/UI/Utilities/Strings.js @@ -58,7 +58,12 @@ function newSuperalgosUtilitiesStrings() { if (text[i - 1] === '.') { return false } } - if (character === '.') { dotsDetected = true } + if (character === '.') { + dotsDetected = true + if (text[i-1] !== undefined && text[i+1] !== undefined && text[i-1] !== '.' && text[i+1] !== '.'){ + return true + } + } } /* Check that there is at lest one upper case before numbers or dots */ From 86f67df3bedf99c00c6e3f67b4cf83d1c769e20b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 3 Feb 2021 13:03:16 +0100 Subject: [PATCH 24/25] Beta 9 Fully Implemented --- .../Images/sa-beta9-logo-horiz-dark.png | Bin 0 -> 5465 bytes Client/client.js | 6 ++-- Client/httpInterface.js | 2 +- ...1-lf-trading-bot-chart-data-structure.json | 29 ++++++++++++++++++ .../UI/Spaces/Top-Space/TopSpace.js | 2 +- run.js | 2 +- 6 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 Client/WebServer/Images/sa-beta9-logo-horiz-dark.png diff --git a/Client/WebServer/Images/sa-beta9-logo-horiz-dark.png b/Client/WebServer/Images/sa-beta9-logo-horiz-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..b7121cbad31366f63c17a4fcb1dacfc9b63ca49f GIT binary patch literal 5465 zcmb_gB(P(*4laMCEHA!U`ODt`lv_i# zq@)_zqH5Y%n3F*%pXsvqnQoJuPMOyy=W4uh`Yf6ueZ7;)mr~{C4oxblG@`5*H><( zHu;yM7k_q<)MWi|ZC1I?d}y0FtJ&%uq}0fR+vD{1?C+#fRJLqFC~&C3R+r+$ZE-4E3Sv};ucq7@-=^WosgjI<1bDp7ZNVgpM)@@{~>_y-*kEY zwO0d2xPr*8128~2MqZ?hd@JA|j4u4-7=Z=bjr&S?h0=9V4V^!j`VQ|F>2IKNCOo!R!$4?@Zc3f~E(r)v*a<}|oJ6$Q0%y+E|S#($7|hT21`2?7;CfH{gO`vAHa zMXy8&iZkjze{?1(H|L&b$Uhi8;YH=uVOFuxfXK;-oskpcUyw&i{z(%v@rbr1S0<|v z$e{A;><|In@y!B&_br_+3IEL6^t?4}Ye8N$%TG#w?2S%-1)CL%_~v<@h8{es;_6-XZ@F=MA=>t2 ztcv}x_8pCJR%wGUd)!GwV9^RRf6bpIoz=#ecYrO(1#9dAtL6JR7`v}4m2%W{uNgL+ zh4^81z%#e-hb}vw^U_%j{`nxJZzeEp7U?gMu1PbQ00FMa358Wwl*Zpal3?d*_>J`gPJAF3P0*WRmJ51swtv zR5C*3#fjFg9(k0BRA-4MblT*?eOPs?Uf{)py7mK4G+ZyM>9f0!onlDUvu!`4s^4g* zF3ey6_l)P;q9?}Z|1Euq6Bc-hRyxhz5{r(xze_F+W&o}{xA=XqHm#M87Q}RXScKqX zt%7EJ1s?PvpBk9Yclzk81>dI~Pp0 zb@cdYZ=-z4CP8iaRZ0L*{nWB`pw)V4+k<*2C0?}5i8&OqZ0QmG@Rjnvz zG-_|24Fb{3^$0`We2Xl>E_M;Q47qBRrzhbz7rr_Je)7QeetUVpp$_t%PL~j2GaA(mz zkMiJP0o=M1wCz@3*+tT%ze(LV${rz+02um0HL;l$d5G{9-w6z?O zM5zEC+x%ps2l|%V5A$>Pmz+)R&y~XrC4xgK{;N4Ot&exHX=hR~0o)c_8m!fJqcBw_ zRpk}zqP1!c-;2lMr^m7u-`uOUU~P`%Bd1=q?IUggOjE^P}nr`SjfJ+_QOs z0MdJZ&+WeN^?TJuuD(jHpLfbeFUWZrlSs0gTMSaW%p|O?L0h(-zy1)Jx!-OwWyqrR zLPz@3omqu7XQj0q#b&uW|NFj=^S=bWv(a6P$=P4P5>y3qiGtxqw~798f5wAFet`ED z^(8WNV+;v7c0s}y#n|K>-9}2Q{EOfX3EK$8)llkpN^h;K#v|2P=2hia-xE2fQ%qMm zz7M*+s6QGU=a&ZIBOS6jv1+bnYW*~C3O)9@p1v`wS^ZK*Wzwle}BaEeLlxEcOV%+S+-{UQ6h0L$pyNuJKA!zh1c zQq6ZI``iW!M(rU%%)4^q;g&N?+V6Vbbn&f1c)ZKzuPHcq;zBvTo^~KqQ~U%m*#kZ2 zM(48aq3oHJH=0%Czn;HGYG%PXnK0QS-WhSDU9{bVo}fkBn!u1|=PP=LwVF4S-&Hs* z-hJ;JV+a5)S{+_}?)JG86q~$nAfr%p5aya{(2HN)+l_$m7r!EDr5W%qmagA{cydB= z2*8Fk072p@1GBdA=;Kb96TbkfWBCc2$UUerl=jvuI+P0+|BAVGfMDK_DdK7q6ds8qB!gagF`G;yi4`QdGyEhbHRIp zvpYI9rcHbdLX*2$io0Et53BdUuw<6b^AkmdJ$QaPe>ragfTP$2 zAnUdw|Ghl#f8GU^Wj2vvIUARfI2T=KWZaf*H@`3Kn_AXa(k9sc_iu<3LQ5vQ`uOcF zbN!y(SKqQJE^Xu>OKyHXM&pr~?;q57$2Vc_Hy7a3wQ~6jYpbw}Mx((%6X1$X!#Ms1Y}=3ukASQtdv^4gpI|p7J5}Gkk?B zHw8k_)V9DivCYE6v#|M1H9ALk_{n>M^lc=YrA`r#HAk&u$FAd$R=X-mEh3*9X!4pQ z^j5r-v_oGO)5_OB(G;5eFhGeqOmToggvHbMu8ZUiOQS0!8)?bfv^sgHM^I>r(Q+Z zQS5nY1HL=-!cFev&$Uv!@C3x}L`P8X z9H(%SZx2W^pg2wKG9@QLXkNIrz7@+tY*=c}LP6r!`TGT~OrD*8l3f<@SIXge@pHeq zwCb9Gzn<$BhsIINwsilF$&J_=zmZt<7^K@pP$WqgE9xS@E2kn3L8VEXsZLZg0YT#<5X{QJ*DxTU84^1x8ori0b-3b zKetA|4afTE%Hr=?-Y^Oss-{CZT1~hXsEn(bRNdb`X#H?YPil{@A_ojWDwjvy5Vaev z@EnOO1)kmf znJkIEEe0bTFc~irRTNQCHvP4+%*V<39*UkA`rALNoX!KRY_Lb^Rm^1FvA89jChtJo z1bi2NoYd0&(7xk`8p3hrutx_r`k~(zychATthuaq=*xO{X13-DYv#Eefejt&vJJm= zoD;|pkWZ2os^*yNU?@ia<(C%MZ~h?f{U_%+UD}BPHo8N}>h)Fz8+)y)lfJf0o(qNQ ze#NTp9P0YDZVQpGk?zIQ4;uC`n)}jep#w7c!^Xj$y5AUH+63bx=i5piSr>Qetze0u zhZiJWn;E}f%ZsffYd%QGa~#%x;WIi<#+jtZS&Xry8EqY?qFhNYlls`y#qpJQyAD@VtrZta(lY4UPfQ;q}RFlD~62@cOOs%L7?9t z&072WXjDb%maCZ@L8L(;;Tc*-Rh`M$@@klL29T4g^~J#+`tjpJSmb^lv;}w zD0srspUbR`xZ)o?9}XCsWd#pHfFQhQ(2g+Ex_-(g(?$|3#5sn0J@ zfi3kAxZ_aF?&J8naHK`?uynK2$3T!*Y`04;Jk-Pwt8H+u;5EgEzY;ofPr^gaRN$Nj zUDkiD9$)4U{xN7Uw|Y8b2}=0b{Vq+2spR50?1aU_9k%iYxV=sh{g~#+;aDXt=AvMs@KojZLIqzC z#b1S=;ZmC$`0yj^(w9^_kVKXXt_bVb;EN2^|H)EYQ z{isK&^f1?eSlu!)vz)1wQC<+D95Wxcd^<;tPmiI0rU)Ych%0n8_pc`6!K}6Ytnm)n z^QNV{M$E0k1${JM>l|kHGlFRo;{G<4pY`I>$GRH+oEBQU$k9cU)9h-TdZPKv#RXJ1 zlp0&5B;sculz-=Z4P%@0{K`O3X2zf{-nFuJDcX+nRIG`^1`Ll}`LP|i6ZlCCBB}8T zI&tEa--CO99?pDbnXem3%>Fv;qI~{)hOo45117dZBU}^7UJP>94b8ceA}1Oi0wEjq zqG8(WGD?TjAJ*KYoW=WTM|!&-)Sr;sv3~%jaxa63En%}o_WYR89=JQ58z z%aU$hx^u!%lIu2Er=H2QfAaEzH-(zlm5_-RpVp7vFBK83y#dFIDr@JjQw7sBNxz(K z=H{hRZ>ToybQeQDuPVc5>Fz~`DQ!d}=5j3bOM~Uc5VeC{nC%*E3Pc^YQhq`=zLOt>TpWa>~7MiewDR2hz!K{SUIu^3A$-rlRTjI8$ka3#^^hN z%s}STMjV|Qq3+Y^@!9Pc&EnG60!cAwA?;M7m>YcP;7y0L;wTB`26?A~Ip;MO!2>d7 z9`cA5VgLAeUldOYMUm)x9xU-*QzTGuwa{DYCNWs18tt`Z6~VjbT}rVM0ezA@MA%Y> zGW|29phFBMKJ$e_Q$(9S8h%T-?(P}AJ01J)lGX6pL~= 1 hour." + }, { "style": "Text", "text": "" diff --git a/Projects/Superalgos/UI/Spaces/Top-Space/TopSpace.js b/Projects/Superalgos/UI/Spaces/Top-Space/TopSpace.js index cca8414b0..8fff424c3 100644 --- a/Projects/Superalgos/UI/Spaces/Top-Space/TopSpace.js +++ b/Projects/Superalgos/UI/Spaces/Top-Space/TopSpace.js @@ -24,7 +24,7 @@ function newSuperalgosTopSpace() { logoImage = new Image() loadImage('superalgos-header-background', backgroundImage) - loadImage('sa-beta8-logo-horiz-dark', logoImage) + loadImage('sa-beta9-logo-horiz-dark', logoImage) function loadImage(name, image) { const PATH = 'Images/' diff --git a/run.js b/run.js index dcea2c68b..338678a50 100644 --- a/run.js +++ b/run.js @@ -11,7 +11,7 @@ if ( console.log('Superalgos') console.log('') - console.log('VERSION: Beta 8') + console.log('VERSION: Beta 9') console.log('') console.log('WEB: https://www.superalgos.org') console.log('') From 44947c76bcdc8e71c3680c2766ef3fabbaf98cec Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 3 Feb 2021 13:08:16 +0100 Subject: [PATCH 25/25] Deppscan corrections --- .../Low-Frequency-Trading/TradingProcess.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 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 f008588a4..edcee3374 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 @@ -134,11 +134,11 @@ data structure that will be used in user-defied conditions and formulas. */ TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Waking up') - buildDataStructures(chart) + buildDataStructures() - if (checkThereAreCandles(chart) === true) { + if (checkThereAreCandles() === true) { TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Running') - await generateOutput(chart) + await generateOutput() TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Saving') await writeProcessFiles() TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Sleeping') @@ -173,13 +173,13 @@ With all the indicators data files loaded, we will build the chart object data structure that will be used in user-defied conditions and formulas. */ - buildDataStructures(chart) + buildDataStructures() /* The process of generating the output includes the trading simulation. */ - if (checkThereAreCandles(chart) === true) { + if (checkThereAreCandles() === true) { TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Running') - await generateOutput(chart) + await generateOutput() TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Saving') await writeProcessFiles() TS.projects.superalgos.functionLibraries.sessionFunctions.sessionHeartBeat(processIndex, undefined, undefined, 'Sleeping') @@ -544,7 +544,6 @@ We will iterate through all posible timeFrames. */ for (let n = 0; n < TS.projects.superalgos.globals.timeFrames.dailyFilePeriods().length; n++) { - const timeFrame = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][0] const timeFrameLabel = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1] if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.framework.validtimeFrames !== undefined) {