Standarizing
This commit is contained in:
1 parent
8bb14854b7
commit
93d9cd403e
10 files changed
+43
-40
No files matched your search
+21
-3
@@ -365,7 +365,7 @@ exports.newGlobals = function newGlobals() {
|
||||
global.EXIT_NODE_PROCESS = function exitProcess() {
|
||||
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.taskError(undefined, "An unexpected error caused the Task to stop.")
|
||||
global.TASK_ERROR(undefined, "An unexpected error caused the Task to stop.")
|
||||
}
|
||||
|
||||
if (global.SHUTTING_DOWN_PROCESS === true) { return }
|
||||
@@ -408,7 +408,7 @@ exports.newGlobals = function newGlobals() {
|
||||
|
||||
global.STOP_TASK_GRACEFULLY = false;
|
||||
|
||||
global.getPercentage = function (fromDate, currentDate, lastDate) {
|
||||
global.GET_PERCENTAGE = function (fromDate, currentDate, lastDate) {
|
||||
let fromDays = Math.trunc(fromDate.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let currentDays = Math.trunc(currentDate.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let lastDays = Math.trunc(lastDate.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
@@ -419,7 +419,7 @@ exports.newGlobals = function newGlobals() {
|
||||
return percentage
|
||||
}
|
||||
|
||||
global.areEqualDates = function (date1, date2) {
|
||||
global.GET_EQUAL_DATES = function (date1, date2) {
|
||||
let day1Days = Math.trunc(date1.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let day2Days = Math.trunc(date2.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
|
||||
@@ -429,5 +429,23 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Error', event)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
|
||||
|
||||
let currentDateString = heartBeatDate.getUTCFullYear() + '-' + utilities.pad(heartBeatDate.getUTCMonth() + 1, 2) + '-' + utilities.pad(heartBeatDate.getUTCDate(), 2)
|
||||
let currentDate = new Date(heartBeatDate)
|
||||
let percentage = global.getPercentage(fromDate, currentDate, lastDate)
|
||||
let percentage = global.GET_PERCENTAGE(fromDate, currentDate, lastDate)
|
||||
|
||||
/*
|
||||
Theere are a few tasks that we need to do only when the date changes,
|
||||
@@ -279,7 +279,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Simulation ' + bot.TRADING_SESSIONKey + ' Loop # ' + tradingEngine.current.episode.candle.index.value + ' @ ' + processingDate) }
|
||||
|
||||
/* Logging to console and disk */
|
||||
if (global.areEqualDates(currentDate, new Date()) === false) {
|
||||
if (global.GET_EQUAL_DATES(currentDate, new Date()) === false) {
|
||||
logger.newInternalLoop(bot.codeName, bot.process, currentDate, percentage)
|
||||
}
|
||||
|
||||
|
||||
@@ -248,10 +248,10 @@
|
||||
/* Telling the world we are alive and doing well */
|
||||
let currentDateString = bot.multiPeriodDailyProcessDatetime.getUTCFullYear() + '-' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCMonth() + 1, 2) + '-' + utilities.pad(bot.multiPeriodDailyProcessDatetime.getUTCDate(), 2)
|
||||
let currentDate = new Date(bot.multiPeriodDailyProcessDatetime)
|
||||
let percentage = global.getPercentage(fromDate, currentDate, lastDate)
|
||||
let percentage = global.GET_PERCENTAGE(fromDate, currentDate, lastDate)
|
||||
bot.processHeartBeat(currentDateString, percentage)
|
||||
|
||||
if (global.areEqualDates(currentDate, new Date()) === false) {
|
||||
if (global.GET_EQUAL_DATES(currentDate, new Date()) === false) {
|
||||
logger.newInternalLoop(bot.codeName, bot.process, currentDate, percentage)
|
||||
}
|
||||
checkStopTaskGracefully()
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
}
|
||||
thisReport.save(callBack)
|
||||
|
||||
if (global.areEqualDates(bot.processDatetime, new Date()) === false) {
|
||||
if (global.GET_EQUAL_DATES(bot.processDatetime, new Date()) === false) {
|
||||
logger.newInternalLoop(bot.codeName, bot.process, bot.processDatetime)
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@
|
||||
let currentDateString = bot.processDatetime.getUTCFullYear() + '-' + utilities.pad(bot.processDatetime.getUTCMonth() + 1, 2) + '-' + utilities.pad(bot.processDatetime.getUTCDate(), 2)
|
||||
let currentDate = new Date(bot.processDatetime)
|
||||
let lastDate = new Date()
|
||||
bot.processHeartBeat(currentDateString, global.getPercentage(currentDate, currentDate, lastDate))
|
||||
bot.processHeartBeat(currentDateString, global.GET_PERCENTAGE(currentDate, currentDate, lastDate))
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
+6
-21
@@ -42,9 +42,13 @@ function preLoader() {
|
||||
console.log('[ERROR] Task Server -> server -> preLoader -> global.TASK_NODE = ' + JSON.stringify(global.TASK_NODE).substring(0, 1000))
|
||||
}
|
||||
}
|
||||
else { /* This process was started not by the Task Manager, but independently (most likely for debugging purposes). In this case we listen to an event with the Task Info that should be emitted at the UI */
|
||||
else {
|
||||
/*
|
||||
This process was started not by the Task Manager, but independently
|
||||
(most likely for debugging purposes). In this case we listen to an event
|
||||
with the Task Info that should be emitted at the UI
|
||||
*/
|
||||
try {
|
||||
//console.log('[INFO] Task Server -> server -> preLoader -> Waiting for event to start debugging...')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent('Task Server', 'Debug Task Started', undefined, 'Task Server', undefined, startDebugging)
|
||||
function startDebugging(message) {
|
||||
try {
|
||||
@@ -94,25 +98,6 @@ function bootLoader() {
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
global.taskError = 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
|
||||
}
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Error', event)
|
||||
}
|
||||
|
||||
|
||||
for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) {
|
||||
let config = global.TASK_NODE.bot.processes[processIndex].config
|
||||
|
||||
|
||||
Reference in new issue
Block a user