diff --git a/Projects/Superalgos/TS/Globals/ProcessVariables.js b/Projects/Superalgos/TS/Globals/ProcessVariables.js index 9d1c231ca..fa2733972 100644 --- a/Projects/Superalgos/TS/Globals/ProcessVariables.js +++ b/Projects/Superalgos/TS/Globals/ProcessVariables.js @@ -29,6 +29,7 @@ exports.newSuperalgosGlobalsProcessVariables = function () { SIMULATION_STATE This is the state of a simulaation, as it is loaded from disk. PROCESS_DATETIME This holds the date currently being processed. DAILY_FILES_PROCESS_DATETIME When processing daily files, this holds the date of the file being processed. + TRADING_PROCESSING_DAILY_FILES When in a trading process, this tell us if we are processing Daily Files or not. */ return thisObject } \ No newline at end of file diff --git a/TaskServer/DebugLog.js b/TaskServer/DebugLog.js index 47e1bd0cd..d28b7484d 100644 --- a/TaskServer/DebugLog.js +++ b/TaskServer/DebugLog.js @@ -115,11 +115,7 @@ exports.newDebugLog = function (processIndex) { if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME !== undefined) { filePath = filePath + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/" + executionDatetime; } else { - if (thisObject.bot.LEARNING_SESSION !== undefined) { - filePath = filePath + thisObject.bot.LEARNING_SESSION.folderName + "/" + executionDatetime; - } else { - filePath = filePath + executionDatetime; - } + filePath = filePath + executionDatetime; } let fileName; diff --git a/TaskServer/LowFrequencyTrading/TradingOutput.js b/TaskServer/LowFrequencyTrading/TradingOutput.js index 565baf080..1e4812722 100644 --- a/TaskServer/LowFrequencyTrading/TradingOutput.js +++ b/TaskServer/LowFrequencyTrading/TradingOutput.js @@ -31,9 +31,9 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod try { if (timeFrame > TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[0][0]) { - bot.processingDailyFiles = false + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES = false } else { - bot.processingDailyFiles = true + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES = true } /* Preparing everything for the Simulation */ @@ -43,7 +43,7 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset') let outputDatasetsMap = new Map() - if (bot.processingDailyFiles === true) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES === true) { /* For Daily Files, we are going to initialize the outputs at the first execution if we are not resuming, but also at every following execution except when @@ -83,7 +83,7 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod return async function initializeOutputs() { - if (bot.processingDailyFiles) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { await initializeDailyFiles() } else { await initializeMarketFiles() @@ -118,7 +118,7 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod files in order to later append more information after the execution is over. Here in this function we are going to read those output files and get them ready for appending content during the simulation. */ - if (bot.processingDailyFiles) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { await readDailyFiles() } else { await readMarketFiles() @@ -175,7 +175,7 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod /* The output of files which were appended with information during the simulation execution, now needs to be saved. */ - if (bot.processingDailyFiles) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { await writeDailyFiles() } else { await writeMarketFiles() diff --git a/TaskServer/LowFrequencyTrading/TradingRecords.js b/TaskServer/LowFrequencyTrading/TradingRecords.js index 6f6f5188b..1be60f58f 100644 --- a/TaskServer/LowFrequencyTrading/TradingRecords.js +++ b/TaskServer/LowFrequencyTrading/TradingRecords.js @@ -45,11 +45,11 @@ exports.newTradingRecords = function (processIndex, bot, logger) { let product = dataset.parentNode let outputDatasetArray = outputDatasetsMap.get(product.config.codeName) - if (bot.processingDailyFiles === true && dataset.config.type === 'Daily Files') { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES === true && dataset.config.type === 'Daily Files') { persistRecords() } - if (bot.processingDailyFiles === false && dataset.config.type === 'Market Files') { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES === false && dataset.config.type === 'Market Files') { persistRecords() } @@ -241,7 +241,7 @@ exports.newTradingRecords = function (processIndex, bot, logger) { if (recordProperty.config.codeName === product.config.propertyNameThatDefinesObject) { let propertyValue = record[j] - if (bot.processingDailyFiles) { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { if (product.config.doNotCutObjectInDays !== true) { /* By default we will cut objects in days. diff --git a/TaskServer/LowFrequencyTrading/TradingSimulation.js b/TaskServer/LowFrequencyTrading/TradingSimulation.js index f189df8dc..394f80bf9 100644 --- a/TaskServer/LowFrequencyTrading/TradingSimulation.js +++ b/TaskServer/LowFrequencyTrading/TradingSimulation.js @@ -317,7 +317,7 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies) /* Finding the Current Element on Market Files */ - if (bot.processingDailyFiles) { + 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('-', '') @@ -426,7 +426,7 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin */ let candlesPerDay = TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS / sessionParameters.timeFrame.config.value if ( - bot.processingDailyFiles && + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES && tradingEngine.current.episode.candle.index.value + 1 + 1 === candlesPerDay ) { /* diff --git a/TaskServer/StatusReport.js b/TaskServer/StatusReport.js index 2986c2227..86f0f3bac 100644 --- a/TaskServer/StatusReport.js +++ b/TaskServer/StatusReport.js @@ -106,10 +106,6 @@ sessionPath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/" } - if (bot.LEARNING_SESSION !== undefined && statusDependencyNode.bottype === "Learning Bot") { - sessionPath = bot.LEARNING_SESSION.folderName + "/" - } - /* Now we will see where do we need to fetch this status report from. */ let network = TS.projects.superalgos.globals.taskConstants.NETWORK_NODE let processThisDependsOn = statusDependencyNode.referenceParent.parentNode @@ -274,7 +270,7 @@ On the contraty, if we are running a Sensor bot or an Indicator bot, we might, if necesary, use a previous version of a Status Report since there will be no big impact, just some reprocessing. */ - if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE !== undefined || bot.LEARNING_SESSION !== undefined) { + if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE !== undefined) { canUserPrevious = false } else { canUserPrevious = true diff --git a/TaskServer/TradingSession.js b/TaskServer/TradingSession.js index 539dc1069..67385ad4a 100644 --- a/TaskServer/TradingSession.js +++ b/TaskServer/TradingSession.js @@ -373,25 +373,25 @@ if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference === undefined) { let errorMessage = "Key Reference not defined. Please check that and try again." parentLogger.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, bot.LEARNING_SESSION, errorMessage, parentLogger) + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage, parentLogger) return false } if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent === undefined) { let errorMessage = "Key Reference not referencing an Exchange Account Key. Please check that and try again." parentLogger.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, bot.LEARNING_SESSION, errorMessage, parentLogger) + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage, parentLogger) return false } if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.codeName === undefined) { let errorMessage = "Key 'codeName' undefined. Paste there you key. Please check that and try again." parentLogger.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, bot.LEARNING_SESSION, errorMessage, parentLogger) + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage, parentLogger) return false } if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.keyReference.referenceParent.config.secret === undefined) { let errorMessage = "Key 'secret' undefined. Paste there you key secret. Please check that and try again." parentLogger.write(MODULE_NAME, "[ERROR] initialize -> checkKey -> " + errorMessage) - TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, bot.LEARNING_SESSION, errorMessage, parentLogger) + TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE, errorMessage, parentLogger) return false } return true