From 92577e2fd0f06b9ad16859240f40a71109b31ac3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 28 Aug 2020 22:49:04 +0200 Subject: [PATCH] Bug Fixed for Live --- .../FloatingSpace/CircularProgressBar.js | 2 +- .../LowFrequencyTrading/TradingSimulation.js | 22 +++++++++++-------- TaskServer/Session.js | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CanvasApp/FloatingSpace/CircularProgressBar.js b/CanvasApp/FloatingSpace/CircularProgressBar.js index afa76606d..348411ea0 100644 --- a/CanvasApp/FloatingSpace/CircularProgressBar.js +++ b/CanvasApp/FloatingSpace/CircularProgressBar.js @@ -110,7 +110,7 @@ function newCircularProgressBar() { if (canvas.floatingSpace.inMapMode === true) { return } if (needToDrawRing !== true) { return } - const VISIBLE_RADIUS = thisObject.container.frame.radius * 1.5 + const VISIBLE_RADIUS = thisObject.container.frame.radius let visiblePosition = { x: thisObject.container.frame.position.x, diff --git a/TaskServer/LowFrequencyTrading/TradingSimulation.js b/TaskServer/LowFrequencyTrading/TradingSimulation.js index eb70d24ac..89255ae3f 100644 --- a/TaskServer/LowFrequencyTrading/TradingSimulation.js +++ b/TaskServer/LowFrequencyTrading/TradingSimulation.js @@ -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() diff --git a/TaskServer/Session.js b/TaskServer/Session.js index 0e74351ad..135b2cc68 100644 --- a/TaskServer/Session.js +++ b/TaskServer/Session.js @@ -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()