bot.processNode cleaned

This commit is contained in:
Luis Fernando Molina committed 2020-11-28 15:47:40 +01:00
1 parent 513fb00abb
commit 8620b24f17
30 files changed
+104 -106

No files matched your search

+2 -2
View File
@@ -19,8 +19,8 @@
function initialize(callBackFunction) {
try {
/* Basic Valdidations */
if (bot.processNode.referenceParent.processDependencies !== undefined) {
thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies !== undefined) {
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) {
logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all.");
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
+3 -3
View File
@@ -36,11 +36,11 @@
/* This bot is not ready for taking its code from the UI, then we need to load it from its repo. */
let filePath =
bot.processNode.referenceParent.parentNode.parentNode.project + // project
TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.project + // project
'/Bots-Plotters-Code/' +
TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName +
"/" + "bots" + "/" +
bot.processNode.referenceParent.parentNode.config.repo + "/" +
TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo + "/" +
pProcessConfig.codeName
filePath += "/User.Bot.js"
@@ -59,7 +59,7 @@
USER_BOT_MODULE = {}
USER_BOT_MODULE.newUserBot = eval(text); // TODO This needs to be changed function
filePath = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo
filePath = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + "bots" + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo
filePath += "/Commons.js"
fileStorage.getTextFile(filePath, onCommonsDownloaded);
+2 -2
View File
@@ -50,11 +50,11 @@
}
/* 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(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
let dataDependencies = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return }
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray (bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
if (commons.validateOutputDatasets(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. */
+10 -10
View File
@@ -1,4 +1,4 @@
exports.newLearningSession = function newLearningSession(bot, parentLogger) {
exports.newLearningSession = function (processIndex, bot, parentLogger) {
const MODULE_NAME = "Learning Session"
@@ -15,26 +15,26 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
try {
/* Initialize this info so that everything is logged propeerly */
bot.LEARNING_SESSION = {
name: bot.processNode.session.name,
id: bot.processNode.session.id
name: TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name,
id: TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id
}
/* Set the folderName for early logging */
if (bot.processNode.session.config.folderName === undefined) {
bot.LEARNING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.LEARNING_SESSION.id
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.config.folderName === undefined) {
bot.LEARNING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.LEARNING_SESSION.id
} else {
bot.LEARNING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.processNode.session.config.folderName
bot.LEARNING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.config.folderName
}
/* Check if there is a session */
if (bot.processNode.session === undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session === undefined) {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> Cannot run without a Session.");
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
return;
}
/* Listen to event to start or stop the session. */
bot.sessionKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id
bot.sessionKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id
TS.projects.superalgos.globals.taskVariables.SESSION_MAP.set(bot.sessionKey, bot.sessionKey)
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.sessionKey, 'Learning Session Status', undefined, bot.sessionKey, undefined, onSessionStatus)
@@ -169,9 +169,9 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
if (bot.LEARNING_SESSION.config !== undefined) {
config = bot.LEARNING_SESSION.config
if (config.folderName === undefined) {
bot.LEARNING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.LEARNING_SESSION.id
bot.LEARNING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.LEARNING_SESSION.id
} else {
bot.LEARNING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.processNode.session.config.folderName
bot.LEARNING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.config.folderName
}
}
}
@@ -1,4 +1,4 @@
exports.newAnnouncements = function newAnnouncements(bot, logger) {
exports.newAnnouncements = function (processIndex, bot, logger) {
const MODULE_NAME = 'Announcements'
@@ -1,4 +1,4 @@
exports.newExchangeAPI = function newExchangeAPI(bot, logger) {
exports.newExchangeAPI = function (processIndex, bot, logger) {
let MODULE_NAME = "Exchange API";
+1 -1
View File
@@ -1,4 +1,4 @@
exports.newSnapshots = function newSnapshots(bot, logger) {
exports.newSnapshots = function (processIndex, bot, logger) {
/*
This module encapsulates the snapshots functionality.
*/
@@ -1,4 +1,4 @@
exports.newTradingEpisode = function newTradingEpisode(bot, logger, tradingEngineModule) {
exports.newTradingEpisode = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Episodes.
*/
@@ -1,4 +1,4 @@
exports.newTradingExecution = function newTradingExecution(bot, logger, tradingEngineModule) {
exports.newTradingExecution = function (processIndex, bot, logger, tradingEngineModule) {
/*
The Trading Execution modules manages the execution nodes and execution algoritms.
*/
@@ -17,7 +17,7 @@ exports.newTradingExecution = function newTradingExecution(bot, logger, tradingE
let sessionParameters
const TRADING_ORDERS_MODULE = require('./TradingOrders.js')
let tradingOrdersModule = TRADING_ORDERS_MODULE.newTradingOrders(bot, logger, tradingEngineModule)
let tradingOrdersModule = TRADING_ORDERS_MODULE.newTradingOrders(processIndex, bot, logger, tradingEngineModule)
return thisObject
@@ -1,4 +1,4 @@
exports.newTradingOrders = function newTradingOrders(bot, logger, tradingEngineModule) {
exports.newTradingOrders = function (processIndex, bot, logger, tradingEngineModule) {
/*
The Trading Orders modules manages the execution of orders against the exchanges.
*/
@@ -17,10 +17,10 @@ exports.newTradingOrders = function newTradingOrders(bot, logger, tradingEngineM
let sessionParameters
const EXCHANGE_API_MODULE = require('./ExchangeAPI.js')
let exchangeAPIModule = EXCHANGE_API_MODULE.newExchangeAPI(bot, logger)
let exchangeAPIModule = EXCHANGE_API_MODULE.newExchangeAPI(processIndex, bot, logger)
const ANNOUNCEMENTS_MODULE = require('./Announcements.js')
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(bot, logger)
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, bot, logger)
return thisObject
@@ -40,7 +40,7 @@ exports.newTradingOutput = function (processIndex, bot, logger, tradingEngineMod
const TRADING_SIMULATION = require('./TradingSimulation.js')
let tradingSimulation = TRADING_SIMULATION.newTradingSimulation(processIndex, bot, logger, tradingEngineModule, UTILITIES)
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
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) {
@@ -1,4 +1,4 @@
exports.newTradingPosition = function newTradingPosition(bot, logger, tradingEngineModule) {
exports.newTradingPosition = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Positions.
*/
@@ -555,7 +555,7 @@
let mainDependency = {}
/* 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(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
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
@@ -565,7 +565,7 @@
if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return }
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
if (commons.validateOutputDatasets(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. */
@@ -624,7 +624,7 @@
}
async function writeProcessFiles() {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel)
await writeDataRanges()
@@ -703,7 +703,7 @@
}
async function writeDailyStatusReport(currentTimeFrameLabel) {
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
let thisReport = statusDependencies.statusReports.get(reportKey)
thisReport.file.lastExecution = bot.currentDaytime
@@ -714,7 +714,7 @@
}
async function writeMarketStatusReport(currentTimeFrameLabel) {
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
let thisReport = statusDependencies.statusReports.get(reportKey);
thisReport.file.lastExecution = bot.processDatetime
@@ -1,4 +1,4 @@
exports.newTradingRecords = function newTradingRecords(bot, logger) {
exports.newTradingRecords = function (processIndex, bot, logger) {
/*
This module facilitates the appending of records to the output of the process.
*/
@@ -37,7 +37,7 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
we have a pointer to the node that have the information we need to extract.
Later, based on the product record definition we will extract each individual value.
*/
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let i = 0; i < outputDatasets.length; i++) {
let outputDatasetNode = outputDatasets[i]
@@ -35,15 +35,15 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin
/* These are the Modules we will need to run the Simulation */
const TRADING_RECORDS_MODULE = require('./TradingRecords.js')
let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(bot, logger)
let tradingRecordsModule = TRADING_RECORDS_MODULE.newTradingRecords(processIndex, bot, logger)
tradingRecordsModule.initialize(outputDatasetsMap)
const TRADING_SYSTEM_MODULE = require('./TradingSystem.js')
let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(bot, logger, tradingEngineModule)
let tradingSystemModule = TRADING_SYSTEM_MODULE.newTradingSystem(processIndex, bot, logger, tradingEngineModule)
tradingSystemModule.initialize()
const TRADING_EPISODE_MODULE = require('./TradingEpisode.js')
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(bot, logger, tradingEngineModule)
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, bot, logger, tradingEngineModule)
tradingEpisodeModule.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. */
@@ -313,7 +313,7 @@ exports.newTradingSimulation = function (processIndex, bot, logger, tradingEngin
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(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
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 */
@@ -1,4 +1,4 @@
exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineModule) {
exports.newTradingStages = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Stages.
*/
@@ -21,22 +21,22 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM
}
const TRADING_STRATEGY_MODULE = require('./TradingStrategy.js')
let tradingStrategyModule = TRADING_STRATEGY_MODULE.newTradingStrategy(bot, logger, tradingEngineModule)
let tradingStrategyModule = TRADING_STRATEGY_MODULE.newTradingStrategy(processIndex, bot, logger, tradingEngineModule)
const TRADING_POSITION_MODULE = require('./TradingPosition.js')
let tradingPositionModule = TRADING_POSITION_MODULE.newTradingPosition(bot, logger, tradingEngineModule)
let tradingPositionModule = TRADING_POSITION_MODULE.newTradingPosition(processIndex, bot, logger, tradingEngineModule)
const TRADING_ENGINE_EXECUTION = require('./TradingExecution.js')
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(bot, logger, tradingEngineModule)
let tradingExecutionModule = TRADING_ENGINE_EXECUTION.newTradingExecution(processIndex, bot, logger, tradingEngineModule)
const ANNOUNCEMENTS_MODULE = require('./Announcements.js')
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(bot, logger)
let announcementsModule = ANNOUNCEMENTS_MODULE.newAnnouncements(processIndex, bot, logger)
const SNAPSHOTS_MODULE = require('./Snapshots.js')
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(bot, logger)
let snapshotsModule = SNAPSHOTS_MODULE.newSnapshots(processIndex, bot, logger)
const TRADING_EPISODE_MODULE = require('./TradingEpisode.js')
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(bot, logger)
let tradingEpisodeModule = TRADING_EPISODE_MODULE.newTradingEpisode(processIndex, bot, logger)
let tradingEngine
let tradingSystem
@@ -907,7 +907,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM
case 'Base Asset': {
if (
(
tradingEngineStage.stageBaseAsset.sizeFilled.value
tradingEngineStage.stageBaseAsset.sizeFilled.value
)
* ROUNDING_ERROR_CORRECTION_FACTOR
>=
@@ -922,7 +922,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM
case 'Quoted Asset': {
if (
(
tradingEngineStage.stageQuotedAsset.sizeFilled.value
tradingEngineStage.stageQuotedAsset.sizeFilled.value
)
* ROUNDING_ERROR_CORRECTION_FACTOR
>=
@@ -1,4 +1,4 @@
exports.newTradingStrategy = function newTradingStrategy(bot, logger, tradingEngineModule) {
exports.newTradingStrategy = function (processIndex, bot, logger, tradingEngineModule) {
/*
This module packages all functions related to Strategies.
*/
@@ -1,4 +1,4 @@
exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineModule) {
exports.newTradingSystem = function (processIndex, bot, logger, 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.
@@ -20,7 +20,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM
let dynamicIndicators
const TRADING_STAGES_MODULE = require('./TradingStages.js')
let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(bot, logger, tradingEngineModule)
let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(processIndex, bot, logger, tradingEngineModule)
return thisObject
+1 -1
View File
@@ -467,7 +467,7 @@
}
function writeDataRanges(callBack) {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetIndex = -1;
controlLoop()
+1 -1
View File
@@ -141,7 +141,7 @@
}
function writeTimeFramesFiles(callBack) {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray (bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetIndex = -1;
controlLoop()
+10 -10
View File
@@ -30,14 +30,14 @@
let name = 'Not Depends on any Process'
logger.fileName = MODULE_NAME + "." + name;
if (bot.processNode.referenceParent === undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent === undefined) {
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
logger.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because the Process Instance needs to have a Reference Parent.");
return
}
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 = bot.processNode.referenceParent.name + "-" + bot.processNode.referenceParent.type + "-" + bot.processNode.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.name + "-" + market
/*
A process can depend for its own execution on another process to finish, and
@@ -51,10 +51,10 @@
/*
Here we check if we can find this relationship at the Data Mine level.
*/
if (bot.processNode.referenceParent.executionStartedEvent !== undefined) {
if (bot.processNode.referenceParent.executionStartedEvent.referenceParent !== undefined) {
if (bot.processNode.referenceParent.executionStartedEvent.referenceParent.parentNode !== undefined) {
processThisDependsOn = bot.processNode.referenceParent.executionStartedEvent.referenceParent.parentNode
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent !== undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent.referenceParent !== undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent.referenceParent.parentNode !== undefined) {
processThisDependsOn = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent.referenceParent.parentNode
name = processThisDependsOn.name
logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the Data Mine depends on " + name)
@@ -65,10 +65,10 @@
/*
Here we check if at the task level if there is an overriding configuration.
*/
if (bot.processNode.executionStartedEvent !== undefined) {
if (bot.processNode.executionStartedEvent.referenceParent !== undefined) {
if (bot.processNode.executionStartedEvent.referenceParent.parentNode !== undefined) {
processThisDependsOn = bot.processNode.executionStartedEvent.referenceParent.parentNode
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent !== undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent.referenceParent !== undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent.referenceParent.parentNode !== undefined) {
processThisDependsOn = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent.referenceParent.parentNode
name = processThisDependsOn.name
logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the User's Task depends on " + name)
-2
View File
@@ -32,9 +32,7 @@
TS.projects.superalgos.globals.taskVariables.LOGGER_MAP.set('Pre-Bot-Main-Loop' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].id, logger)
logger.bot = botConfig;
botConfig.process = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
botConfig.debug = {};
botConfig.processNode = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex]
/* Logs Mantainance Stuff */
botConfig.LOGS_TO_DELETE_QUEUE = []
+5 -5
View File
@@ -1,4 +1,4 @@
exports.newProcessOutput = function newProcessOutput(BOT, logger) {
exports.newProcessOutput = function (processIndex, BOT, logger) {
/*
Here we emit the events that signals that a Dataset was updated.
@@ -19,8 +19,8 @@
try {
/* We will reaise the events for the datasets impacted by the process that just finished. */
if (bot.processNode.referenceParent.processOutput !== undefined) {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput !== undefined) {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let j = 0; j < outputDatasets.length; j++) {
let outputDataset = outputDatasets[j]
@@ -109,8 +109,8 @@
function asyncRaiseEvents(lastFile, timeFrames) {
if (bot.processNode.referenceParent.processOutput !== undefined) {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput !== undefined) {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let j = 0; j < outputDatasets.length; j++) {
let outputDataset = outputDatasets[j]
@@ -1,4 +1,4 @@
exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger) {
exports.newLearningBot = function (processIndex, bot, parentLogger) {
const MODULE_NAME = "Learning Bot";
const FULL_LOG = true;
@@ -8,7 +8,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
const SESSION = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'TradingSession');
let fileStorage = FILE_STORAGE.newFileStorage(parentLogger);
let session = SESSION.newLearningSession(bot, parentLogger)
let session = SESSION.newLearningSession(processIndex, bot, parentLogger)
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.
@@ -90,7 +90,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
/* High level log entry */
console.log(new Date().toISOString() + " " + pad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name, 20) + " " + pad(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, 10) + " " + pad(bot.codeName, 30) + " " + pad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName, 30)
+ " Main Loop # " + pad(Number(bot.loopCounter), 8) + " " + bot.processNode.session.type + " " + bot.processNode.session.name)
+ " Main Loop # " + pad(Number(bot.loopCounter), 8) + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name)
/* Checking if we need to need to emit any event */
if (bot.SESSION_STATUS === 'Idle' && bot.STOP_SESSION === false) {
@@ -106,10 +106,10 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
/* Checking if we should process this loop or not.*/
if (bot.STOP_SESSION === true) {
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Waiting for " + bot.processNode.session.type + " " + bot.processNode.session.name + " to be run."); }
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Waiting for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + " to be run."); }
console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName, 30)
+ " Waiting for " + bot.processNode.session.type + " " + bot.processNode.session.name + " to be run. ");
+ " Waiting for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + " to be run. ");
nextWaitTime = 'Waiting for Session';
loopControl(nextWaitTime);
@@ -548,7 +548,7 @@ exports.newLearningBot = function newLearningBot(processIndex, bot, parentLogger
waitingTime = waitTime / 1000
label = 'seconds'
}
processHeartBeat(undefined, undefined, "Waiting " + waitingTime + " " + label + " for " + bot.processNode.session.type + " " + bot.processNode.session.name + " to be run. ")
processHeartBeat(undefined, undefined, "Waiting " + waitingTime + " " + label + " for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + " to be run. ")
logger.persist();
}
break
@@ -555,7 +555,7 @@ exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
let mainDependency = {}
/* 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(bot.processNode.referenceParent.processDependencies, 'Data Dependency')
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
@@ -565,7 +565,7 @@ exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
if (commons.validateDataDependencies(dataDependencies, callBackFunction) !== true) { return }
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
if (commons.validateOutputDatasets(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. */
@@ -624,7 +624,7 @@ exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
}
async function writeProcessFiles() {
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(bot.processNode.referenceParent.processOutput, 'Output Dataset')
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel)
await writeDataRanges()
@@ -703,7 +703,7 @@ exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
}
async function writeDailyStatusReport(currentTimeFrameLabel) {
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
let thisReport = statusDependencies.statusReports.get(reportKey)
thisReport.file.lastExecution = bot.currentDaytime
@@ -714,7 +714,7 @@ exports.newLearningProcess = function (processIndex, bot, logger, UTILITIES) {
}
async function writeMarketStatusReport(currentTimeFrameLabel) {
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
let reportKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + bot.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
let thisReport = statusDependencies.statusReports.get(reportKey);
thisReport.file.lastExecution = bot.processDatetime
+3 -3
View File
@@ -35,11 +35,11 @@
}
let filePath =
bot.processNode.referenceParent.parentNode.parentNode.project + // project
TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.project + // project
'/Bots-Plotters-Code/' +
TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName +
"/" + "bots" + "/" +
bot.processNode.referenceParent.parentNode.config.repo + "/" +
TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo + "/" +
pProcessConfig.codeName
filePath += "/User.Bot.js"
@@ -62,7 +62,7 @@
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
}
filePath = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + "bots" + "/" + bot.processNode.referenceParent.parentNode.config.repo;
filePath = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "/" + "bots" + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.repo;
filePath += "/Commons.js"
fileStorage.getTextFile(filePath, onCommonsDownloaded);
+3 -3
View File
@@ -18,9 +18,9 @@
function initialize(callBackFunction) {
try {
/* Basic Valdidations */
if (bot.processNode.referenceParent.processDependencies !== undefined) {
if (bot.processNode.referenceParent.processDependencies.statusDependencies !== undefined) {
thisObject.nodeArray = bot.processNode.referenceParent.processDependencies.statusDependencies
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies !== undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies.statusDependencies !== undefined) {
thisObject.nodeArray = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies.statusDependencies
} else {
logger.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have status dependencies at all.");
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
+4 -4
View File
@@ -146,7 +146,7 @@
if (processThisDependsOn.id === processDefinition.id) {
if (process.type === 'Trading Process Instance') {
if (process.session !== undefined) {
if (bot.processNode.session.id !== process.session.id) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id !== process.session.id) {
continue
}
} else {
@@ -197,7 +197,7 @@
if (processThisDependsOn.id === processDefinition.id) {
if (process.type === 'Trading Process Instance') {
if (process.session !== undefined) {
if (bot.processNode.session.id !== process.session.id) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id !== process.session.id) {
continue
}
} else {
@@ -372,7 +372,7 @@
/* All good, lets emit the event that means data has been updated. */
let processOutput = PROCESS_OUTPUT.newProcessOutput(bot, logger)
let processOutput = PROCESS_OUTPUT.newProcessOutput(processIndex, bot, logger)
processOutput.raiseEvents(thisObject.file.lastFile, thisObject.file.timeFrames, callBackFunction);
return
}
@@ -399,7 +399,7 @@
}
/* All good, lets emit the event that means data has been updated. */
let processOutput = PROCESS_OUTPUT.newProcessOutput(bot, logger)
let processOutput = PROCESS_OUTPUT.newProcessOutput(processIndex, bot, logger)
processOutput.asyncRaiseEvents(thisObject.file.lastFile, thisObject.file.timeFrames)
}
}
+5 -5
View File
@@ -8,7 +8,7 @@
const SESSION = require(TS.projects.superalgos.globals.nodeJSConstants.REQUIRE_ROOT_DIR + 'TradingSession');
let fileStorage = FILE_STORAGE.newFileStorage(parentLogger);
let session = SESSION.newTradingSession(bot, parentLogger)
let session = SESSION.newTradingSession(processIndex, bot, parentLogger)
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.
@@ -90,7 +90,7 @@
/* High level log entry */
console.log(new Date().toISOString() + " " + pad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name, 20) + " " + pad(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, 10) + " " + pad(bot.codeName, 30) + " " + pad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName, 30)
+ " Main Loop # " + pad(Number(bot.loopCounter), 8) + " " + bot.processNode.session.type + " " + bot.processNode.session.name)
+ " Main Loop # " + pad(Number(bot.loopCounter), 8) + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name)
/* Checking if we need to need to emit any event */
if (bot.TRADING_SESSION_STATUS === 'Idle' && bot.STOP_SESSION === false) {
@@ -106,10 +106,10 @@
/* Checking if we should process this loop or not.*/
if (bot.STOP_SESSION === true) {
logger.write(MODULE_NAME, "[INFO] run -> loop -> Waiting for " + bot.processNode.session.type + " " + bot.processNode.session.name + " to be run.")
logger.write(MODULE_NAME, "[INFO] run -> loop -> Waiting for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + " to be run.")
console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName, 30)
+ " Waiting for " + bot.processNode.session.type + " " + bot.processNode.session.name + " to be run. ");
+ " Waiting for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + " to be run. ");
nextWaitTime = 'Waiting for Session';
loopControl(nextWaitTime);
@@ -548,7 +548,7 @@
waitingTime = waitTime / 1000
label = 'seconds'
}
processHeartBeat(undefined, undefined, "Waiting " + waitingTime + " " + label + " for " + bot.processNode.session.type + " " + bot.processNode.session.name + " to be run. ")
processHeartBeat(undefined, undefined, "Waiting " + waitingTime + " " + label + " for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + " to be run. ")
logger.persist();
}
break
+10 -10
View File
@@ -1,4 +1,4 @@
exports.newTradingSession = function newTradingSession(bot, parentLogger) {
exports.newTradingSession = function (processIndex, bot, parentLogger) {
const MODULE_NAME = "Trading Session"
@@ -15,26 +15,26 @@
try {
/* Initialize this info so that everything is logged propeerly */
bot.TRADING_SESSION = {
name: bot.processNode.session.name,
id: bot.processNode.session.id
name: TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name,
id: TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id
}
/* Set the folderName for early logging */
if (bot.processNode.session.config.folderName === undefined) {
bot.TRADING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.TRADING_SESSION.id
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.config.folderName === undefined) {
bot.TRADING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.TRADING_SESSION.id
} else {
bot.TRADING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.processNode.session.config.folderName
bot.TRADING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.config.folderName
}
/* Check if there is a session */
if (bot.processNode.session === undefined) {
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session === undefined) {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> Cannot run without a Session.");
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
return;
}
/* Listen to event to start or stop the session. */
bot.TRADING_SESSIONKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id
bot.TRADING_SESSIONKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.name + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id
TS.projects.superalgos.globals.taskVariables.SESSION_MAP.set(bot.TRADING_SESSIONKey, bot.TRADING_SESSIONKey)
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.TRADING_SESSIONKey, 'Trading Session Status', undefined, bot.TRADING_SESSIONKey, undefined, onSessionStatus)
@@ -169,9 +169,9 @@
if (bot.TRADING_SESSION.config !== undefined) {
config = bot.TRADING_SESSION.config
if (config.folderName === undefined) {
bot.TRADING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.TRADING_SESSION.id
bot.TRADING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.TRADING_SESSION.id
} else {
bot.TRADING_SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.processNode.session.config.folderName
bot.TRADING_SESSION.folderName = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.type.replace(' ', '-').replace(' ', '-') + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.config.folderName
}
}
}