From 672549a4ce5593495be1f845d9ee5eccdd267e48 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Mar 2020 10:27:02 +0200 Subject: [PATCH] Trading on Daily tested --- CanvasApp/Canvas.js | 1 + CanvasApp/FloatingSpace/CodeEditor.js | 2 ++ CanvasApp/Globals.js | 1 + TaskServer/MultiPeriod.js | 7 +------ TaskServer/TradingSimulation.js | 27 ++++++++++++++++++++++----- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/CanvasApp/Canvas.js b/CanvasApp/Canvas.js index 473851549..b50e017af 100644 --- a/CanvasApp/Canvas.js +++ b/CanvasApp/Canvas.js @@ -249,6 +249,7 @@ function newCanvas () { } function onKeyDown (event) { + if (EDITOR_ON_FOCUS === true) { return } thisObject.mouse.event = event thisObject.mouse.action = 'key down' diff --git a/CanvasApp/FloatingSpace/CodeEditor.js b/CanvasApp/FloatingSpace/CodeEditor.js index eb62d64e0..89bce2189 100644 --- a/CanvasApp/FloatingSpace/CodeEditor.js +++ b/CanvasApp/FloatingSpace/CodeEditor.js @@ -73,6 +73,7 @@ function newCodeEditor () { textArea.style.display = 'none' thisObject.payload.node.code = textArea.value } + EDITOR_ON_FOCUS = false } function activate (payload) { @@ -98,6 +99,7 @@ function newCodeEditor () { 'height: ' + thisObject.container.frame.height + 'px' textArea.style.display = 'block' textArea.focus() + EDITOR_ON_FOCUS = true } function getContainer (point) { diff --git a/CanvasApp/Globals.js b/CanvasApp/Globals.js index 1eea3dd41..4c4fd5ecc 100644 --- a/CanvasApp/Globals.js +++ b/CanvasApp/Globals.js @@ -122,6 +122,7 @@ dailyFilePeriods = JSON.parse(dailyFilePeriods); let SHOW_ANIMATION_PERFORMACE = false; let MENU_ITEM_ON_FOCUS +let EDITOR_ON_FOCUS let testUser = window.localStorage.getItem("test_user") let LOGGED_IN_USER_LOCAL_STORAGE_KEY diff --git a/TaskServer/MultiPeriod.js b/TaskServer/MultiPeriod.js index c71bf9c00..09d54057a 100644 --- a/TaskServer/MultiPeriod.js +++ b/TaskServer/MultiPeriod.js @@ -725,12 +725,7 @@ if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') { - logger.write(MODULE_NAME, "[ERROR] start -> processTimeFramesDailyFiles -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> Fail Because -> err = " + err.message); - logger.write(MODULE_NAME, "[ERROR] start -> processTimeFramesDailyFiles -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> filePath = " + filePath); - logger.write(MODULE_NAME, "[ERROR] start -> processTimeFramesDailyFiles -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> fileName = " + fileName); - logger.write(MODULE_NAME, "[ERROR] start -> processTimeFramesDailyFiles -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> You are trying to use data that does not exist. "); - logger.write(MODULE_NAME, "[ERROR] start -> processTimeFramesDailyFiles -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> Check that your Datasets building processes are running well. "); - + logger.write(MODULE_NAME, "[ERROR] The file " + filePath + '/' + fileName + ' does not exist and it is required to continue. This process will retry to read it in a while. In the meantime make yourself sure that the process that generates it has ran properly.'); callBackFunction(global.DEFAULT_RETRY_RESPONSE); return; } diff --git a/TaskServer/TradingSimulation.js b/TaskServer/TradingSimulation.js index 4182e20f5..9e92d6502 100644 --- a/TaskServer/TradingSimulation.js +++ b/TaskServer/TradingSimulation.js @@ -568,9 +568,19 @@ let processingDate = loopingDay.getUTCFullYear() + '-' + utilities.pad(loopingDay.getUTCMonth() + 1, 2) + '-' + utilities.pad(loopingDay.getUTCDate(), 2); if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Simulation " + bot.sessionKey + " Loop # " + currentCandleIndex + " @ " + processingDate) } - console.log("Trading-Engine -> " + MODULE_NAME + " -> runSimulation -> loop -> Simulation " + bot.sessionKey + " Loop # " + currentCandleIndex + " @ " + processingDate) - bot.sessionHeartBeat(processingDate) // tell the world we are alive and doing well + /* Telling the world we are alive and doing well */ + let fromDate = new Date(bot.VALUES_TO_USE.timeRange.initialDatetime.valueOf()) + let lastDate = new Date(bot.VALUES_TO_USE.timeRange.finalDatetime.valueOf()) + + let currentDateString = loopingDay.getUTCFullYear() + '-' + utilities.pad(loopingDay.getUTCMonth() + 1, 2) + '-' + utilities.pad(loopingDay.getUTCDate(), 2); + let currentDate = new Date(loopingDay) + let percentage = global.getPercentage(fromDate, currentDate, lastDate) + bot.processHeartBeat(currentDateString, percentage) + + if (global.areEqualDates(currentDate, new Date()) === false) { + logger.newInternalLoop(bot.codeName, bot.process, currentDate, percentage); + } } previousLoopingDay = loopingDay.valueOf() @@ -2749,8 +2759,15 @@ /* Checking if we should continue processing this loop or not.*/ 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."); } - console.log("[INFO] runSimulation -> controlLoop -> We are going to stop here bacause we were requested to stop processing.") + 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."); } + console.log("[INFO] runSimulation -> controlLoop -> We are going to stop here bacause we were requested to stop processing this session.") + afterLoop() + return + } + + if (global.STOP_TASK_GRACEFULLY === 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 task."); } + console.log("[INFO] runSimulation -> controlLoop -> We are going to stop here bacause we were requested to stop processing this task.") afterLoop() return } @@ -2800,7 +2817,7 @@ number: yesterday.currentStrategy.number, beginRate: yesterday.currentStrategy.beginRate, endRate: yesterday.currentStrategy.endRate, - triggerOnSituation: yesterday.curre.triggerOnSituation + triggerOnSituation: yesterday.currentStrategy.triggerOnSituation } interExecutionMemory.currentTrade = {