diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 68df5b2fa..733940c64 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -582,6 +582,27 @@ "functionName": "newSuperalgosBotModulesTradingSimulation", "fileName": "TradingSimulation.js", "folderName": "Trading-Bot/Low-Frequency-Trading" + }, + { + "name": "Trading Episode", + "propertyName": "tradingEpisode", + "functionName": "newSuperalgosBotModulesTradingEpisode", + "fileName": "TradingEpisode.js", + "folderName": "Trading-Bot/Low-Frequency-Trading" + }, + { + "name": "Trading Records", + "propertyName": "tradingRecords", + "functionName": "newSuperalgosBotModulesTradingRecords", + "fileName": "TradingRecords.js", + "folderName": "Trading-Bot/Low-Frequency-Trading" + }, + { + "name": "Trading System", + "propertyName": "tradingSystem", + "functionName": "newSuperalgosBotModulesTradingSystem", + "fileName": "TradingSystem.js", + "folderName": "Trading-Bot/Low-Frequency-Trading" } ] }, diff --git a/TaskServer/LowFrequencyTrading/TradingEpisode.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js similarity index 99% rename from TaskServer/LowFrequencyTrading/TradingEpisode.js rename to Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js index 8d227e4b5..b9146d585 100644 --- a/TaskServer/LowFrequencyTrading/TradingEpisode.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js @@ -1,4 +1,4 @@ -exports.newTradingEpisode = function (processIndex, tradingEngineModule) { +exports.newSuperalgosBotModulesTradingEpisode = function (processIndex, tradingEngineModule) { /* This module packages all functions related to Episodes. */ diff --git a/TaskServer/LowFrequencyTrading/TradingRecords.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingRecords.js similarity index 99% rename from TaskServer/LowFrequencyTrading/TradingRecords.js rename to Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingRecords.js index f5fee8082..3b377af95 100644 --- a/TaskServer/LowFrequencyTrading/TradingRecords.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingRecords.js @@ -1,4 +1,4 @@ -exports.newTradingRecords = function (processIndex) { +exports.newSuperalgosBotModulesTradingRecords = function (processIndex) { /* This module facilitates the appending of records to the output of the process. */ 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 e92dd1620..c4badc758 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 @@ -34,17 +34,14 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex, tradi if (FULL_LOG === true) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, '[INFO] runSimulation -> finalDatetime = ' + sessionParameters.timeRange.config.finalDatetime) } /* These are the Modules we will need to run the Simulation */ - const TRADING_RECORDS_MODULE = require('./TradingRecords.js') - let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(processIndex) - tradingRecordsModule.initialize(outputDatasetsMap) + let tradingRecordsModuleObject = TS.projects.superalgos.botModules.tradingRecords.newSuperalgosBotModulesTradingRecords(processIndex) + tradingRecordsModuleObject.initialize(outputDatasetsMap) - const TRADING_SYSTEM_MODULE = require('./TradingSystem.js') - let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(processIndex, tradingEngineModule) - tradingSystemModule.initialize() + let tradingSystemModuleObject = TS.projects.superalgos.botModules.tradingSystem.newSuperalgosBotModulesTradingSystem(processIndex, tradingEngineModule) + tradingSystemModuleObject.initialize() - const TRADING_EPISODE_MODULE = require('./TradingEpisode.js') - let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, tradingEngineModule) - tradingEpisodeModule.initialize() + let tradingEpisodeModuleObject = TS.projects.superalgos.botModules.tradingEpisode.newSuperalgosBotModulesTradingEpisode(processIndex, tradingEngineModule) + tradingEpisodeModuleObject.initialize() /* Setting up the candles array: The whole simulation is based on the array of candles at the time-frame defined at the session parameters. */ let propertyName = 'at' + sessionParameters.timeFrame.config.label.replace('-', '') @@ -117,7 +114,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex, tradi heartBeat() /* Opening the Episode, if needed. */ - tradingEpisodeModule.openEpisode() + tradingEpisodeModuleObject.openEpisode() if (checkInitialDatetime() === false) { if (FULL_LOG === true) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Candle Before the Initia Date Time @ ' + (new Date(candle.begin)).toLocaleString()) } @@ -127,15 +124,15 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex, tradi positionChartAtCurrentCandle() /* The chart was recalculated based on the current candle. */ - tradingSystemModule.updateChart(chart) + tradingSystemModuleObject.updateChart(chart) /* Do the stuff needed previous to the run like Episode Counters and Statistics update. Mantaince is done once per simulation candle. */ - tradingSystemModule.mantain() - tradingEpisodeModule.mantain() + tradingSystemModuleObject.mantain() + tradingEpisodeModuleObject.mantain() tradingEngineModule.mantain() /* @@ -158,7 +155,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex, tradi checkIfWeNeedToStopBetweenCycles() /* Add new records to the process output */ - tradingRecordsModule.appendRecords() + tradingRecordsModuleObject.appendRecords() if (breakLoop === true) { break } /* @@ -175,21 +172,21 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex, tradi checkIfWeNeedToStopAfterBothCycles() /* Add new records to the process output */ - tradingRecordsModule.appendRecords() + tradingRecordsModuleObject.appendRecords() if (breakLoop === true) { break } async function runCycle() { /* Reset Data Structures */ - tradingSystemModule.reset() - tradingEpisodeModule.reset() + tradingSystemModuleObject.reset() + tradingEpisodeModuleObject.reset() tradingEngineModule.reset() let infoMessage = 'Processing candle # ' + tradingEngine.current.episode.candle.index.value + ' @ the ' + tradingEngine.current.episode.cycle.value + ' cycle.' if (FULL_LOG === true) { TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, '[INFO] runSimulation -> loop -> ' + infoMessage) } tradingSystem.infos.push([tradingSystem.id, infoMessage]) - await tradingSystemModule.run() + await tradingSystemModuleObject.run() } function checkIfWeNeedToStopBetweenCycles() { @@ -233,23 +230,23 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex, tradi } } - tradingSystemModule.finalize() - tradingRecordsModule.finalize() - tradingEpisodeModule.finalize() + tradingSystemModuleObject.finalize() + tradingRecordsModuleObject.finalize() + tradingEpisodeModuleObject.finalize() - tradingSystemModule = undefined - tradingRecordsModule = undefined - tradingEpisodeModule = undefined + tradingSystemModuleObject = undefined + tradingRecordsModuleObject = undefined + tradingEpisodeModuleObject = undefined await writeFiles() function closeEpisode(exitType) { - tradingEpisodeModule.updateExitType(exitType) - tradingEpisodeModule.closeEpisode() + tradingEpisodeModuleObject.updateExitType(exitType) + tradingEpisodeModuleObject.closeEpisode() } function updateEpisode(exitType) { - tradingEpisodeModule.updateExitType(exitType) + tradingEpisodeModuleObject.updateExitType(exitType) } function heartBeat() { diff --git a/TaskServer/LowFrequencyTrading/TradingSystem.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js similarity index 99% rename from TaskServer/LowFrequencyTrading/TradingSystem.js rename to Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js index 7d8aeaf3b..f5a09d071 100644 --- a/TaskServer/LowFrequencyTrading/TradingSystem.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js @@ -1,4 +1,4 @@ -exports.newTradingSystem = function (processIndex, tradingEngineModule) { +exports.newSuperalgosBotModulesTradingSystem = function (processIndex, tradingEngineModule) { /* The Trading System is the user defined set of rules compliant with the Trading Protocol that defines the trading logic to be applied during each cycle of the Simulation. diff --git a/TaskServer/LowFrequencyTrading/TradingStages.js b/TaskServer/LowFrequencyTrading/TradingStages.js index cfdbd0dc4..a34722eea 100644 --- a/TaskServer/LowFrequencyTrading/TradingStages.js +++ b/TaskServer/LowFrequencyTrading/TradingStages.js @@ -35,8 +35,7 @@ exports.newTradingStages = function (processIndex, tradingEngineModule) { const SNAPSHOTS_MODULE = require('./Snapshots.js') let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(processIndex) - const TRADING_EPISODE_MODULE = require('./TradingEpisode.js') - let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex) + let tradingEpisodeModuleObject = TS.projects.superalgos.botModules.tradingEpisode.newSuperalgosBotModulesTradingEpisode(processIndex) let tradingEngine let tradingSystem @@ -54,7 +53,7 @@ exports.newTradingStages = function (processIndex, tradingEngineModule) { announcementsModule.initialize() snapshotsModule.initialize() tradingExecutionModule.initialize() - tradingEpisodeModule.initialize() + tradingEpisodeModuleObject.initialize() } function finalize() { @@ -77,8 +76,8 @@ exports.newTradingStages = function (processIndex, tradingEngineModule) { tradingExecutionModule.finalize() tradingExecutionModule = undefined - tradingEpisodeModule.finalize() - tradingEpisodeModule = undefined + tradingEpisodeModuleObject.finalize() + tradingEpisodeModuleObject = undefined } function updateChart(pChart) { @@ -103,7 +102,7 @@ exports.newTradingStages = function (processIndex, tradingEngineModule) { } function cycleBasedStatistics() { - tradingEpisodeModule.cycleBasedStatistics() + tradingEpisodeModuleObject.cycleBasedStatistics() tradingPositionModule.cycleBasedStatistics() }