More Function Libraries
This commit is contained in:
1 parent
b454eea2a6
commit
9427ebeb53
8 files changed
+74
-46
No files matched your search
+2
-42
@@ -33,20 +33,6 @@ exports.newGlobals = function newGlobals() {
|
||||
return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + GMT_SECONDS);
|
||||
}
|
||||
|
||||
global.EMIT_SESSION_STATUS = function (status, key) {
|
||||
switch (status) {
|
||||
case 'Running': {
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Running')
|
||||
break
|
||||
}
|
||||
case 'Stopped': {
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Stopped')
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
global.FINALIZE_LOGGERS = function () {
|
||||
global.LOGGER_MAP.forEach(forEachLogger)
|
||||
|
||||
@@ -57,27 +43,19 @@ exports.newGlobals = function newGlobals() {
|
||||
}
|
||||
}
|
||||
|
||||
global.FINALIZE_SESSIONS = function () {
|
||||
global.SESSION_MAP.forEach(forEachSession)
|
||||
|
||||
function forEachSession(session) {
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(session, 'Stopped')
|
||||
}
|
||||
}
|
||||
|
||||
global.SHUTTING_DOWN_PROCESS = false
|
||||
|
||||
global.EXIT_NODE_PROCESS = function exitProcess() {
|
||||
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.TASK_ERROR(undefined, "An unexpected error caused the Task to stop.")
|
||||
TS.projects.superalgos.functionLibraries.taskFunctions.taskError(undefined, "An unexpected error caused the Task to stop.")
|
||||
}
|
||||
|
||||
if (global.SHUTTING_DOWN_PROCESS === true) { return }
|
||||
global.SHUTTING_DOWN_PROCESS = true
|
||||
|
||||
/* Signal that all sessions are stopping. */
|
||||
global.FINALIZE_SESSIONS()
|
||||
TS.projects.superalgos.functionLibraries.sessionFunctions.finalizeSessions()
|
||||
|
||||
/* Cleaning Before Exiting. */
|
||||
clearInterval(global.HEARTBEAT_INTERVAL_HANDLER)
|
||||
@@ -134,23 +112,5 @@ exports.newGlobals = function newGlobals() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
global.TASK_ERROR = function taskError(node, errorMessage) {
|
||||
let event
|
||||
if (node !== undefined) {
|
||||
event = {
|
||||
nodeName: node.name,
|
||||
nodeType: node.type,
|
||||
nodeId: node.id,
|
||||
errorMessage: errorMessage
|
||||
}
|
||||
} else {
|
||||
event = {
|
||||
errorMessage: errorMessage
|
||||
}
|
||||
}
|
||||
let key = global.TASK_NODE.name + '-' + global.TASK_NODE.type + '-' + global.TASK_NODE.id
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Error', event)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@
|
||||
} else {
|
||||
/* We are processing Daily Files */
|
||||
do {
|
||||
global.EMIT_SESSION_STATUS(bot.TRADING_SESSION_STATUS, bot.TRADING_SESSIONKey)
|
||||
TS.projects.superalgos.functionLibraries.sessionFunctions.emitSessionStatus(bot.TRADING_SESSION_STATUS, bot.TRADING_SESSIONKey)
|
||||
/*
|
||||
We update the Trading Process Date with the date calculated at the simulation.
|
||||
We will use this date to load indicator and output files. After that we will
|
||||
|
||||
@@ -101,7 +101,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) {
|
||||
bot.SESSION_STATUS = 'Stopped'
|
||||
}
|
||||
|
||||
global.EMIT_SESSION_STATUS (bot.SESSION_STATUS, bot.sessionKey)
|
||||
TS.projects.superalgos.functionLibraries.sessionFunctions.emitSessionStatus (bot.SESSION_STATUS, bot.sessionKey)
|
||||
|
||||
/* Checking if we should process this loop or not.*/
|
||||
if (bot.STOP_SESSION === true) {
|
||||
|
||||
@@ -159,7 +159,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
|
||||
} else {
|
||||
/* We are processing Daily Files */
|
||||
do {
|
||||
global.EMIT_SESSION_STATUS(bot.TRADING_SESSION_STATUS, bot.TRADING_SESSIONKey)
|
||||
TS.projects.superalgos.functionLibraries.sessionFunctions.emitSessionStatus(bot.TRADING_SESSION_STATUS, bot.TRADING_SESSIONKey)
|
||||
/*
|
||||
We update the Trading Process Date with the date calculated at the simulation.
|
||||
We will use this date to load indicator and output files. After that we will
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
bot.TRADING_SESSION_STATUS = 'Stopped'
|
||||
}
|
||||
|
||||
global.EMIT_SESSION_STATUS(bot.TRADING_SESSION_STATUS, bot.TRADING_SESSIONKey)
|
||||
TS.projects.superalgos.functionLibraries.sessionFunctions.emitSessionStatus(bot.TRADING_SESSION_STATUS, bot.TRADING_SESSIONKey)
|
||||
|
||||
/* Checking if we should process this loop or not.*/
|
||||
if (bot.STOP_SESSION === true) {
|
||||
|
||||
Reference in new issue
Block a user