Bug Fixes to make Trading Bots start again
This commit is contained in:
1 parent
5b5a752e79
commit
ce1264dd39
5 files changed
+21
-15
No files matched your search
@@ -22,6 +22,7 @@
|
||||
let month;
|
||||
let year;
|
||||
let currentProcessKey
|
||||
let datetimeForLogs = ''
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -33,6 +34,10 @@
|
||||
month = pMonth;
|
||||
year = pYear;
|
||||
|
||||
if (month && year) {
|
||||
datetimeForLogs = "Month: " + month + " Year: " + year
|
||||
}
|
||||
|
||||
let name = 'Not Depends on any Process'
|
||||
|
||||
if (bot.processNode.referenceParent !== undefined) {
|
||||
@@ -48,7 +53,7 @@
|
||||
if (processThisDependsOn.code.monthlyInstances === true) {
|
||||
logger.fileName = MODULE_NAME + "." + name + "." + year + "." + month;
|
||||
}
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + "Month: " + month + " Year: " + year + " depends on " + name); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + datetimeForLogs + " depends on " + name); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +112,7 @@
|
||||
global.SYSTEM_EVENT_HANDLER.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.SYSTEM_EVENT_HANDLER.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> " + currentProcessKey + " Process Execution Started because " + key + " Month: " + month + " Year: " + year + " Finished."); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> " + currentProcessKey + " Process Execution Started because " + key + datetimeForLogs + " Finished."); }
|
||||
}
|
||||
|
||||
callBackFunction(message.event.err);
|
||||
@@ -121,7 +126,7 @@
|
||||
global.SYSTEM_EVENT_HANDLER.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.SYSTEM_EVENT_HANDLER.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> " + currentProcessKey + " Process Execution Started Month: " + month + " Year: " + year); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> " + currentProcessKey + " Process Execution Started " + datetimeForLogs); }
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
@@ -144,7 +149,7 @@
|
||||
|
||||
global.SYSTEM_EVENT_HANDLER.createEventHandler(currentProcessKey, 'Process Execution Finished')
|
||||
global.SYSTEM_EVENT_HANDLER.raiseEvent(currentProcessKey, 'Process Execution Finished', event)
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] finish -> " + currentProcessKey + " Process Execution Finished Month: " + month + " Year: " + year); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] finish -> " + currentProcessKey + " Process Execution Finished " + datetimeForLogs); }
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
|
||||
|
||||
@@ -142,43 +142,46 @@
|
||||
|
||||
/* Some very basic validations that we have all the information needed. */
|
||||
if (processInstance.referenceParent === undefined) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start-> Process Instance without Reference Parent. Process Instance = " + JSON.stringify(processInstance));
|
||||
console.log(logDisplace + "Root : [INFO] start -> Process Instance without Reference Parent. Process Instance = " + JSON.stringify(processInstance));
|
||||
global.EXIT_NODE_PROCESS()
|
||||
return
|
||||
}
|
||||
|
||||
if (processInstance.referenceParent.code.codeName === undefined) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start-> Process Definition witn no codeName defined. Process Definition = " + JSON.stringify(processInstance.referenceParent));
|
||||
console.log(logDisplace + "Root : [INFO] start -> Process Definition witn no codeName defined. Process Definition = " + JSON.stringify(processInstance.referenceParent));
|
||||
global.EXIT_NODE_PROCESS()
|
||||
return
|
||||
}
|
||||
|
||||
if (processInstance.referenceParent.parentNode === undefined) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start-> Process Definition not attached to a Bot Definition. Process Definition = " + JSON.stringify(processInstance.referenceParent));
|
||||
console.log(logDisplace + "Root : [INFO] start -> Process Definition not attached to a Bot Definition. Process Definition = " + JSON.stringify(processInstance.referenceParent));
|
||||
global.EXIT_NODE_PROCESS()
|
||||
return
|
||||
}
|
||||
|
||||
if (processInstance.referenceParent.parentNode.code.codeName === undefined) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start-> Bot Definition witn no codeName defined. Bot Definition = " + JSON.stringify(processInstance.referenceParent.parentNode));
|
||||
console.log(logDisplace + "Root : [INFO] start -> Bot Definition witn no codeName defined. Bot Definition = " + JSON.stringify(processInstance.referenceParent.parentNode));
|
||||
global.EXIT_NODE_PROCESS()
|
||||
return
|
||||
}
|
||||
|
||||
if (processInstance.referenceParent.parentNode.parentNode === undefined) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start-> Bot Definition not attached to a Team. Bot Definition = " + JSON.stringify(processInstance.referenceParent.parentNode));
|
||||
console.log(logDisplace + "Root : [INFO] start -> Bot Definition not attached to a Team. Bot Definition = " + JSON.stringify(processInstance.referenceParent.parentNode));
|
||||
global.EXIT_NODE_PROCESS()
|
||||
return
|
||||
}
|
||||
|
||||
if (processInstance.referenceParent.parentNode.parentNode.code.codeName === undefined) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start-> Team witn no codeName defined. Team = " + JSON.stringify(processInstance.referenceParent.parentNode.parentNode));
|
||||
console.log(logDisplace + "Root : [INFO] start -> Team witn no codeName defined. Team = " + JSON.stringify(processInstance.referenceParent.parentNode.parentNode));
|
||||
global.EXIT_NODE_PROCESS()
|
||||
return
|
||||
}
|
||||
|
||||
/* Here we will check if we need to load the configuration and code of the bot from a file or we will take that from the UI. */
|
||||
if (processInstance.referenceParent.code.framework !== undefined) {
|
||||
if (
|
||||
processInstance.referenceParent.code.framework !== undefined &&
|
||||
(processInstance.referenceParent.code.framework.name === 'Multi-Period-Market' || processInstance.referenceParent.code.framework.name === 'Multi-Period-Daily')
|
||||
) {
|
||||
botConfig = processInstance.referenceParent.parentNode.code
|
||||
botConfig.definedByUI = true
|
||||
bootingBot(processIndex)
|
||||
|
||||
@@ -45,8 +45,6 @@
|
||||
|
||||
function runSession(message) {
|
||||
|
||||
console.log(message.event.definition)
|
||||
|
||||
/* We are going to run the Definition comming at the event. */
|
||||
bot.DEFINITION = JSON.parse(message.event.definition)
|
||||
bot.SESSION = JSON.parse(message.event.session)
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
|
||||
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
|
||||
|
||||
processExecutionEvents.initialize(pMonth, pYear, onInizialized);
|
||||
processExecutionEvents.initialize(undefined, undefined, onInizialized);
|
||||
|
||||
function onInizialized(err) {
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ function preLoader() {
|
||||
if (taskId !== undefined) {
|
||||
/* The Task Manager sent the info via a process argument. 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 -> Listening to starting event -> key = ' + 'Task Server - ' + taskId)
|
||||
console.log('[INFO] Task Server -> server -> preLoader -> Listening to starting event -> key = ' + 'Task Server - ' + taskId)
|
||||
global.SYSTEM_EVENT_HANDLER.listenToEvent('Task Server - ' + taskId, 'Run Task', undefined, undefined, undefined, eventReceived)
|
||||
function eventReceived(message) {
|
||||
global.TASK_NODE = message
|
||||
|
||||
Reference in new issue
Block a user