diff --git a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/IndicatorOutput.js b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/IndicatorOutput.js index 14a132d2f..714e0f766 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/IndicatorOutput.js +++ b/Projects/Superalgos/TS/Bot-Modules/Indicator-Bot/IndicatorOutput.js @@ -48,13 +48,13 @@ /* The first phase here is about checking that we have everything we need at the definition level. */ let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency') - if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return } + if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateDataDependencies(processIndex, dataDependencies, callBackFunction) !== true) { return } let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset') - if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return } + 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. */ - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timeFrame) + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, timeFrame) /* During the third phase, we need to generate the data of the different products this process produces an output */ for (let i = 0; i < outputDatasets.length; i++) { @@ -83,7 +83,7 @@ } /* Build the data */ - jsonData = TS.projects.superalgos.functionLibraries.singleMarketFunctions.dataBuildingProcedure( + jsonData = TS.projects.superalgos.functionLibraries.singleMarketFunctions.dataBuildingProcedure(processIndex, products, mainDependency, recordDefinition, @@ -100,7 +100,7 @@ /* Add the calculated properties */ if (outputDatasetNode.referenceParent.parentNode.calculations !== undefined) { - outputData = TS.projects.superalgos.functionLibraries.singleMarketFunctions.calculationsProcedure(jsonData, recordDefinition, outputDatasetNode.referenceParent.parentNode.calculations, singularVariableName, timeFrame) + outputData = TS.projects.superalgos.functionLibraries.singleMarketFunctions.calculationsProcedure(processIndex, jsonData, recordDefinition, outputDatasetNode.referenceParent.parentNode.calculations, singularVariableName, timeFrame) } else { outputData = jsonData } @@ -132,8 +132,8 @@ contextSummary.mineType = dataMineNode.type.replace(' ', '-') contextSummary.project = dataMineNode.project - let fileContent = TS.projects.superalgos.functionLibraries.singleMarketFunctions.generateFileContent(outputData, outputDatasetNode.referenceParent.parentNode.record, resultsWithIrregularPeriods, processingDailyFiles, currentDay, callBackFunction) - TS.projects.superalgos.functionLibraries.singleMarketFunctions.writeFile(contextSummary, fileContent, anotherFileWritten, processingDailyFiles, timeFrameLabel, currentDay, callBackFunction) + let fileContent = TS.projects.superalgos.functionLibraries.singleMarketFunctions.generateFileContent(processIndex, outputData, outputDatasetNode.referenceParent.parentNode.record, resultsWithIrregularPeriods, processingDailyFiles, currentDay, callBackFunction) + TS.projects.superalgos.functionLibraries.singleMarketFunctions.writeFile(processIndex, contextSummary, fileContent, anotherFileWritten, processingDailyFiles, timeFrameLabel, currentDay, callBackFunction) } diff --git a/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js b/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js index 888cbef50..4b7c57c49 100644 --- a/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js +++ b/Projects/Superalgos/TS/Function-Libraries/SingleMarketFunctions.js @@ -1,4 +1,4 @@ -exports.newSuperalgosFunctionLibrariesSingleMarketFunctions = function (processIndex) { +exports.newSuperalgosFunctionLibrariesSingleMarketFunctions = function () { const MODULE_NAME = "Single Market Functions"; @@ -12,11 +12,9 @@ writeFile: writeFile }; - let fileStorage = TS.projects.superalgos.taskModules.fileStorage.newFileStorage(processIndex); - return thisObject; - function validateDataDependencies(dataDependencies, callBackFunction) { + function validateDataDependencies(processIndex, dataDependencies, callBackFunction) { for (let i = 0; i < dataDependencies.length; i++) { let dataDependencyNode = dataDependencies[i] @@ -41,7 +39,7 @@ return true } - function validateOutputDatasets(outputDatasets, callBackFunction) { + function validateOutputDatasets(processIndex, outputDatasets, callBackFunction) { for (let i = 0; i < outputDatasets.length; i++) { let outputDatasetNode = outputDatasets[i] @@ -144,7 +142,7 @@ return true } - function inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, timeFrame) { + function inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, timeFrame) { /* For each dataDependencyNode in our data dependencies, we should have a dataFile containing the records needed as an imput for this process. What we need to do first is transform those records into JSON objects that can be used by user-defined formulas. @@ -166,10 +164,10 @@ recordDefinition = dataDependencyNode.referenceParent.parentNode.record singularVariableName = dataDependencyNode.referenceParent.parentNode.config.singularVariableName /* Transform the raw data into JSON objects */ - jsonData = jsonifyDataFile(dataFile, recordDefinition) + jsonData = jsonifyDataFile(processIndex, dataFile, recordDefinition) /* Add the calculated properties */ if (dataDependencyNode.referenceParent.parentNode.calculations !== undefined) { - inputData = calculationsProcedure(jsonData, recordDefinition, dataDependencyNode.referenceParent.parentNode.calculations, singularVariableName, timeFrame) + inputData = calculationsProcedure(processIndex, jsonData, recordDefinition, dataDependencyNode.referenceParent.parentNode.calculations, singularVariableName, timeFrame) } else { inputData = jsonData } @@ -182,7 +180,7 @@ } } - function jsonifyDataFile(dataFile, recordDefinition) { + function jsonifyDataFile(processIndex, dataFile, recordDefinition) { /* This function has as an input the raw data on files and creates with it an array of JSON objects @@ -210,7 +208,7 @@ return jsonifiedArray } - function calculationsProcedure(jsonArray, recordDefinition, calculationsProcedure, variableName, timeFrame) { + function calculationsProcedure(processIndex, jsonArray, recordDefinition, calculationsProcedure, variableName, timeFrame) { /* This function has as an input an array of JSON objects, and it adds calculated properties to @@ -285,6 +283,7 @@ } function dataBuildingProcedure( + processIndex, products, mainDependency, recordDefinition, @@ -447,7 +446,7 @@ return results } - function generateFileContent(records, recordDefinition, resultsWithIrregularPeriods, processingDailyFiles, currentDay, callBackFunction) { + function generateFileContent(processIndex, records, recordDefinition, resultsWithIrregularPeriods, processingDailyFiles, currentDay, callBackFunction) { try { let fileContent = ""; @@ -509,7 +508,7 @@ } } - function writeFile(contextSummary, fileContent, anotherFileWritten, processingDailyFiles, timeFrameLabel, currentDay, callBackFunction) { + function writeFile(processIndex, contextSummary, fileContent, anotherFileWritten, processingDailyFiles, timeFrameLabel, currentDay, callBackFunction) { try { let fileName = 'Data.json'; @@ -523,6 +522,7 @@ let filePath = filePathRoot + "/Output/" + contextSummary.product + "/" + contextSummary.dataset + "/" + timeFrameLabel + dateForPath; filePath += '/' + fileName + let fileStorage = TS.projects.superalgos.taskModules.fileStorage.newFileStorage(processIndex); fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/TaskServer/.vscode/TaskServer.code-workspace b/TaskServer/.vscode/TaskServer.code-workspace new file mode 100644 index 000000000..449b3c3df --- /dev/null +++ b/TaskServer/.vscode/TaskServer.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "C:\\Superalgos\\TaskServer" + }, + { + "path": "C:\\Superalgos\\Projects" + } + ], + "settings": {} +} \ No newline at end of file diff --git a/TaskServer/LowFrequencyTrading/TradingProcess.js b/TaskServer/LowFrequencyTrading/TradingProcess.js index b5a9ae4e5..a3bdc61f3 100644 --- a/TaskServer/LowFrequencyTrading/TradingProcess.js +++ b/TaskServer/LowFrequencyTrading/TradingProcess.js @@ -559,10 +559,10 @@ */ dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) - if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return } + if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateDataDependencies(processIndex, dataDependencies, callBackFunction) !== true) { return } let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset') - if (TS.projects.superalgos.functionLibraries.singleMarketFunctions.validateOutputDatasets(outputDatasets, callBackFunction) !== true) { return } + 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. */ for (let j = 0; j < TS.projects.superalgos.globals.timeFrames.marketFilesPeriods().length; j++) { @@ -571,7 +571,7 @@ let products = {} if (dataFiles !== undefined) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'at' + timeFrameLabel.replace('-', '') chart[propertyName] = products @@ -584,7 +584,7 @@ let products = {} if (dataFiles !== undefined) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'at' + timeFrameLabel.replace('-', '') chart[propertyName] = products @@ -596,7 +596,7 @@ let products = {} if (dataFiles !== undefined) { - TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) + TS.projects.superalgos.functionLibraries.singleMarketFunctions.inflateDatafiles(processIndex, dataFiles, dataDependencies, products, mainDependency, currentTimeFrame) let propertyName = 'atAnyTimeFrame' chart[propertyName] = products