Bug Fixed

This commit is contained in:
Luis Fernando Molina committed 2020-08-28 22:47:47 +02:00
1 parent 8e15a7dd81
commit 7ccd486558
2 files changed
+15 -11

No files matched your search

+13 -9
View File
@@ -121,6 +121,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
}
if (checkInitialDatetime() === false) {
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> loop -> Candle Before the Initia Date Time @ ' + (new Date(candle.begin)).toLocaleString()) }
continue
}
@@ -155,7 +156,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
had the chance to check for the status of placed orders or even cancel
the ones that needed cancellation.
*/
checkIfWeNeedToStop()
checkIfWeNeedToStopBetweenCycles()
/* Add new records to the process output */
tradingRecordsModule.appendRecords()
@@ -172,6 +173,8 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
tradingEngineModule.setCurrentCycle('Second')
await runCycle()
checkIfWeNeedToStopAfterBothCycles()
/* Add new records to the process output */
tradingRecordsModule.appendRecords()
@@ -186,8 +189,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
await tradingSystemModule.run()
}
function checkIfWeNeedToStop() {
/* Checking if we should continue processing this loop or not. */
function checkIfWeNeedToStopBetweenCycles() {
if (bot.STOP_SESSION === true) {
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] runSimulation -> controlLoop -> We are going to stop here bacause we were requested to stop processing this session.') }
updateEpisode('Session Stopped')
@@ -209,12 +211,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
return
}
if (checkNextCandle() === false) {
updateEpisode('All Available Candles Processed')
breakLoop = true
return
}
if (checkMinimunAndMaximunBalance() === false) {
closeEpisode('Min or Max Balance Reached')
breakLoop = true
@@ -222,6 +218,14 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
return
}
}
function checkIfWeNeedToStopAfterBothCycles() {
if (checkNextCandle() === false) {
updateEpisode('All Available Candles Processed')
breakLoop = true
return
}
}
}
tradingSystemModule.finalize()
+2 -2
View File
@@ -185,7 +185,7 @@
}
/* Session Type Forced Values */
let today = new Date((new Date()).valueOf())
let today = (new Date()).valueOf()
let aYearAgo = today - global.ONE_YEAR_IN_MILISECONDS
let aYearFromNow = today + global.ONE_YEAR_IN_MILISECONDS
switch (bot.SESSION.type) {
@@ -214,7 +214,7 @@
*/
/* Initial Datetime */
if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined) {
if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined || bot.SESSION.parameters.timeRange.config.allowStartingFromThePast !== true ) {
bot.SESSION.parameters.timeRange.config.initialDatetime = initialDefault
} else {
bot.SESSION.parameters.timeRange.config.initialDatetime = (new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf()