diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 547360851..e00cc7721 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -349,6 +349,12 @@ "propertyName": "processVariables", "functionName": "newSuperalgosGlobalsProcessVariables", "fileName": "ProcessVariables.js" + }, + { + "name": "NODE JS Constants", + "propertyName": "nodeJSConstants", + "functionName": "newSuperalgosGlobalsNodeJSConstants", + "fileName": "NodeJSConstants.js" } ], "functionLibraries": [ diff --git a/Projects/Superalgos/TS/Globals/NodeJSConstants.js b/Projects/Superalgos/TS/Globals/NodeJSConstants.js new file mode 100644 index 000000000..63ec87a66 --- /dev/null +++ b/Projects/Superalgos/TS/Globals/NodeJSConstants.js @@ -0,0 +1,8 @@ +exports.newSuperalgosGlobalsNodeJSConstants = function () { + + let thisObject = { + REQUIRE_ROOT_DIR: './' + } + + return thisObject +} \ No newline at end of file diff --git a/TaskServer/Globals.js b/TaskServer/Globals.js index 570eda75e..f8f7cb0f4 100644 --- a/TaskServer/Globals.js +++ b/TaskServer/Globals.js @@ -11,8 +11,7 @@ exports.newGlobals = function () { /* This is the Execution Datetime */ global.EXECUTION_DATETIME = new Date(); - global.ROOT_DIR = './'; - + global.LOGGER_MAP = new Map() // We will put all the loggers in a map, so that we can eventually finalize them. global.SESSION_MAP = new Map() // We will put all the sessions in a map, so that we can eventually finalize them. diff --git a/TaskServer/IndicatorBot.js b/TaskServer/IndicatorBot.js index 16d331354..5492824b3 100644 --- a/TaskServer/IndicatorBot.js +++ b/TaskServer/IndicatorBot.js @@ -5,12 +5,12 @@ let USER_BOT_MODULE; let COMMONS_MODULE; - const MULTI_PERIOD_MARKET = require(global.ROOT_DIR + 'MultiPeriodMarket'); - const MULTI_PERIOD_DAILY = require(global.ROOT_DIR + 'MultiPeriodDaily'); + const MULTI_PERIOD_MARKET = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'MultiPeriodMarket'); + const MULTI_PERIOD_DAILY = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'MultiPeriodDaily'); const FILE_STORAGE = require('./FileStorage.js'); let fileStorage = FILE_STORAGE.newFileStorage(parentLogger); - const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog'); + const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog'); let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble. let nextLoopTimeoutHandle; @@ -118,13 +118,13 @@ processHeartBeat() /* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */ - const UTILITIES = require(global.ROOT_DIR + 'CloudUtilities'); - const STATUS_REPORT = require(global.ROOT_DIR + 'StatusReport'); - const STATUS_DEPENDENCIES = require(global.ROOT_DIR + 'StatusDependencies'); - const DATA_DEPENDENCIES = require(global.ROOT_DIR + 'DataDependencies'); - const DATA_SET = require(global.ROOT_DIR + 'DataSet'); - const PROCESS_EXECUTION_EVENTS = require(global.ROOT_DIR + 'ProcessExecutionEvents'); - const PROCESS_OUTPUT = require(global.ROOT_DIR + 'ProcessOutput'); + const UTILITIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'CloudUtilities'); + const STATUS_REPORT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusReport'); + const STATUS_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusDependencies'); + const DATA_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DataDependencies'); + const DATA_SET = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DataSet'); + const PROCESS_EXECUTION_EVENTS = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessExecutionEvents'); + const PROCESS_OUTPUT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessOutput'); /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. diff --git a/TaskServer/ProcessInstance.js b/TaskServer/ProcessInstance.js index c0403b5d0..235272d0e 100644 --- a/TaskServer/ProcessInstance.js +++ b/TaskServer/ProcessInstance.js @@ -17,7 +17,7 @@ const INDICATOR_BOT_MODULE = require('./IndicatorBot'); const SENSOR_BOT = require('./SensorBot'); const TRADING_BOT_MODULE = require('./TradingBot'); - const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog'); + const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog'); let botInstance let logger diff --git a/TaskServer/ReinforcementLearning/LearningBot.js b/TaskServer/ReinforcementLearning/LearningBot.js index 474ac1e15..1070e40f3 100644 --- a/TaskServer/ReinforcementLearning/LearningBot.js +++ b/TaskServer/ReinforcementLearning/LearningBot.js @@ -3,14 +3,14 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { const MODULE_NAME = "Learning Bot"; const FULL_LOG = true; - const TRADING_PROCESS_MODULE = require(global.ROOT_DIR + '/LowFrequencyTrading/MachineLearningProcess.js'); + const TRADING_PROCESS_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + '/LowFrequencyTrading/MachineLearningProcess.js'); const FILE_STORAGE = require('./FileStorage.js'); - const SESSION = require(global.ROOT_DIR + 'TradingSession'); + const SESSION = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'TradingSession'); let fileStorage = FILE_STORAGE.newFileStorage(parentLogger); let session = SESSION.newLearningSession(bot, parentLogger) - const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog'); + const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog'); let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble. let nextLoopTimeoutHandle; @@ -77,13 +77,13 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) { processHeartBeat(undefined, undefined, "Running...") /* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */ - const UTILITIES = require(global.ROOT_DIR + 'CloudUtilities'); - const STATUS_REPORT = require(global.ROOT_DIR + 'StatusReport'); - const STATUS_DEPENDENCIES = require(global.ROOT_DIR + 'StatusDependencies'); - const DATA_DEPENDENCIES = require(global.ROOT_DIR + 'DataDependencies'); - const DATA_SET = require(global.ROOT_DIR + 'DataSet'); - const PROCESS_EXECUTION_EVENTS = require(global.ROOT_DIR + 'ProcessExecutionEvents'); - const PROCESS_OUTPUT = require(global.ROOT_DIR + 'ProcessOutput'); + const UTILITIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'CloudUtilities'); + const STATUS_REPORT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusReport'); + const STATUS_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusDependencies'); + const DATA_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DataDependencies'); + const DATA_SET = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DataSet'); + const PROCESS_EXECUTION_EVENTS = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessExecutionEvents'); + const PROCESS_OUTPUT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessOutput'); /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. diff --git a/TaskServer/SensorBot.js b/TaskServer/SensorBot.js index 77af290fd..02942b53f 100644 --- a/TaskServer/SensorBot.js +++ b/TaskServer/SensorBot.js @@ -9,7 +9,7 @@ const FILE_STORAGE = require('./FileStorage.js'); let fileStorage = FILE_STORAGE.newFileStorage(parentLogger); - const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog'); + const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog'); let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble. let nextLoopTimeoutHandle; @@ -125,11 +125,11 @@ processHeartBeat() /* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */ - const UTILITIES = require(global.ROOT_DIR + 'CloudUtilities'); - const STATUS_REPORT = require(global.ROOT_DIR + 'StatusReport'); - const STATUS_DEPENDENCIES = require(global.ROOT_DIR + 'StatusDependencies'); - const PROCESS_EXECUTION_EVENTS = require(global.ROOT_DIR + 'ProcessExecutionEvents'); - const PROCESS_OUTPUT = require(global.ROOT_DIR + 'ProcessOutput'); + const UTILITIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'CloudUtilities'); + const STATUS_REPORT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusReport'); + const STATUS_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusDependencies'); + const PROCESS_EXECUTION_EVENTS = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessExecutionEvents'); + const PROCESS_OUTPUT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessOutput'); /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. diff --git a/TaskServer/TradingBot.js b/TaskServer/TradingBot.js index 7f29f537c..bd29d4cc6 100644 --- a/TaskServer/TradingBot.js +++ b/TaskServer/TradingBot.js @@ -3,14 +3,14 @@ const MODULE_NAME = "Trading Bot"; const FULL_LOG = true; - const TRADING_PROCESS_MODULE = require(global.ROOT_DIR + '/LowFrequencyTrading/TradingProcess.js'); + const TRADING_PROCESS_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + '/LowFrequencyTrading/TradingProcess.js'); const FILE_STORAGE = require('./FileStorage.js'); - const SESSION = require(global.ROOT_DIR + 'TradingSession'); + const SESSION = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'TradingSession'); let fileStorage = FILE_STORAGE.newFileStorage(parentLogger); let session = SESSION.newTradingSession(bot, parentLogger) - const DEBUG_MODULE = require(global.ROOT_DIR + 'DebugLog'); + const DEBUG_MODULE = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DebugLog'); let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble. let nextLoopTimeoutHandle; @@ -77,13 +77,13 @@ processHeartBeat(undefined, undefined, "Running...") /* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */ - const UTILITIES = require(global.ROOT_DIR + 'CloudUtilities'); - const STATUS_REPORT = require(global.ROOT_DIR + 'StatusReport'); - const STATUS_DEPENDENCIES = require(global.ROOT_DIR + 'StatusDependencies'); - const DATA_DEPENDENCIES = require(global.ROOT_DIR + 'DataDependencies'); - const DATA_SET = require(global.ROOT_DIR + 'DataSet'); - const PROCESS_EXECUTION_EVENTS = require(global.ROOT_DIR + 'ProcessExecutionEvents'); - const PROCESS_OUTPUT = require(global.ROOT_DIR + 'ProcessOutput'); + const UTILITIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'CloudUtilities'); + const STATUS_REPORT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusReport'); + const STATUS_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'StatusDependencies'); + const DATA_DEPENDENCIES = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DataDependencies'); + const DATA_SET = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'DataSet'); + const PROCESS_EXECUTION_EVENTS = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessExecutionEvents'); + const PROCESS_OUTPUT = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'ProcessOutput'); /* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */ bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution.