Execution Started Event at Task

This commit is contained in:
Luis Fernando Molina committed 2020-08-21 11:38:33 +02:00
1 parent 7469c58e0e
commit 70cbbe5587
10 files changed
+74 -41

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents.initialize(onInizialized);
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
try {
@@ -460,10 +460,8 @@
again.
*/
if (bot.simulationState.tradingEngine.current.episode.headOfTheMarket.value === true) {
console.log('YES at the head of the market')
return false
}
console.log('NOT at the head of the market')
}
function checkStopTaskGracefully() {
@@ -86,7 +86,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
/*
Main Simulation Loop
*/
console.log('initialCandle = ' + initialCandle)
/* We are going to use this to exit the loop if needed. */
let breakLoop = false
@@ -106,7 +105,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
for (let i = initialCandle; i < candles.length - 1; i++) {
tradingEngine.current.episode.candle.index.value = i
console.log('index = ' + tradingEngine.current.episode.candle.index.value)
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Processing candle # ' + tradingEngine.current.episode.candle.index.value) }
let candle = candles[tradingEngine.current.episode.candle.index.value] // This is the current candle the Simulation is working at.
@@ -124,7 +122,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
}
if (checkInitialDatetime() === false) {
console.log(' Esta candle esta dentras del Initial Datetime')
continue
}
@@ -179,9 +176,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
if (breakLoop === true) { break }
async function runCycle() {
console.log(new Date(), 'Function runCycle', ' Cycle = ' + tradingEngine.current.episode.cycle.value)
/* Reset Data Structures */
tradingSystemModule.reset()
tradingEpisodeModule.reset()
+35 -10
View File
@@ -1,12 +1,9 @@
exports.newProcessExecutionEvents = function newProcessExecutionEvents(BOT, logger) {
/*
Here we manage the process execution events. This allow us to emit events when the process starts and finishes. Also to wait for a dependent event
Here we manage the process execution events. This allow us to emit events
when the process starts and finishes. Also to wait for a dependent event
of another process.
*/
const MODULE_NAME = "Process Execution Events";
logger.fileName = MODULE_NAME
@@ -28,7 +25,7 @@
return thisObject;
function initialize(callBackFunction) {
function initialize(processConfig, callBackFunction) {
try {
let name = 'Not Depends on any Process'
logger.fileName = MODULE_NAME + "." + name;
@@ -42,22 +39,50 @@
let market = bot.market.baseAsset + '/' + bot.market.quotedAsset
currentProcessKey = bot.processNode.referenceParent.name + "-" + bot.processNode.referenceParent.type + "-" + bot.processNode.referenceParent.id + "-" + bot.exchange + "-" + market
/*
A process can depend for its own execution on another process to finish, and
this can be achieved in two different ways. The first one is by referencing
the Execution Started Event node from a Process Definition node to a Execution
Ended Event node of another Process Definition. The second way is when there is
a Execution Started Event node at a Process Instance. This allows the user to
override the definition created by the Data Mine for an specific task.
*/
/*
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
name = processThisDependsOn.name
if (processThisDependsOn.config.monthlyInstances === true) {
logger.fileName = MODULE_NAME + "." + name;
}
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " depends on " + name); }
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true)
{ logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the Data Mine depends on " + name); }
}
}
}
/*
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
name = processThisDependsOn.name
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true)
{ logger.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the User's Task depends on " + name); }
}
}
}
if (processThisDependsOn !== undefined) {
/* We need to remember that this process waits for another process in order to start. */
processConfig.waitsForExecutionFinishedEvent = true
/* We need to find at which network node is running the process that we need to hear from when it finished. */
let network = global.TASK_NETWORK
+1 -1
View File
@@ -148,7 +148,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents.initialize(onInizialized);
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
try {
-2
View File
@@ -324,7 +324,6 @@
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[ERROR] initialize -> startLiveTrading -> Key 'codeName' or 'secret' not provided. Plese check that and try again."); }
return false
}
pProcessConfig.liveWaitTime = bot.SESSION.parameters.timeFrame.config.value
return true
}
@@ -357,7 +356,6 @@
}
function startPaperTrading(message) {
pProcessConfig.normalWaitTime = bot.SESSION.parameters.timeFrame.config.value
return true
}
+21 -17
View File
@@ -131,7 +131,7 @@
function initializeProcessExecutionEvents() {
try {
processExecutionEvents = PROCESS_EXECUTION_EVENTS.newProcessExecutionEvents(bot, logger)
processExecutionEvents.initialize(onInizialized);
processExecutionEvents.initialize(processConfig, onInizialized);
function onInizialized(err) {
try {
@@ -560,23 +560,27 @@
break
case 'Normal': {
let waitTime
switch (bot.SESSION.type) {
case 'Live Trading Session': {
waitTime = processConfig.liveTradingWaitTime
if (processConfig.waitsForExecutionFinishedEvent === true) {
waitTime = 0
} else {
switch (bot.SESSION.type) {
case 'Live Trading Session': {
waitTime = bot.SESSION.parameters.timeFrame.config.value
break
}
case 'Fordward Tessting Session': {
waitTime = bot.SESSION.parameters.timeFrame.config.value
break
}
case 'Paper Trading Session': {
waitTime = bot.SESSION.parameters.timeFrame.config.value
break
}
case 'Backtesting Session': {
waitTime = 0
break
}
}
break
case 'Fordward Tessting Session': {
waitTime = processConfig.fordwardTestingWaitTime
}
break
case 'Paper Trading Session': {
waitTime = processConfig.paperTradingWaitTime
}
break
case 'Backtesting Session': {
waitTime = processConfig.backtestingWaitTime
}
break
}
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (waitTime / 1000 / 60) + " minute/s."); }