From 926c4495b60b2ae76df4c758d25fd524bbd6d48a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 6 Jul 2018 09:16:35 +0200 Subject: [PATCH] Comments Improved --- Assistant.js | 15 ++++++++++++++- Context.js | 29 ++++++++--------------------- DebugLog.js | 6 +++++- Root.js | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Assistant.js b/Assistant.js index 5fc14a2a5..e01f395da 100644 --- a/Assistant.js +++ b/Assistant.js @@ -402,7 +402,7 @@ /* - Here we check that all the positions we know we have are still at the exchange. If they are not, we will try to take appropiate + Here we check that all the positions we know we still have at the exchange. If they are not, we will try to take appropiate actions. Reasons why the positions might not be there are: 1. The user / account owner closed the positions manually. @@ -419,6 +419,8 @@ */ + if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] ordersExecutionCheck -> JSON.stringify(context.executionContext.positions) = " + JSON.stringify(context.executionContext.positions)); } + let openPositions = []; for (let a = 0; a < context.executionContext.positions.length; a++) { @@ -430,8 +432,19 @@ } } + /* + + This removes all orders leaving only the not executed position. Consider that we do want executed positions to be recored on the file so as to + have a record of their execution. But at next execution these records must be deleted bedore the new Execution Context file is created and + this is what we do here. + + */ + context.executionContext.positions = openPositions; + if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] ordersExecutionCheck -> Removing executed positions."); } + if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] ordersExecutionCheck -> JSON.stringify(context.executionContext.positions) = " + JSON.stringify(context.executionContext.positions)); } + /* Now we can start checking what happened at the exchange. */ let i = 0; diff --git a/Context.js b/Context.js index 08f829955..9fceb3106 100644 --- a/Context.js +++ b/Context.js @@ -6,30 +6,17 @@ /* - This module allows deals with keeping the context between different executions of the bot. - It deals with these 3 different files that helps the bot process remember where it is standing: + This module deals with keeping the context between different executions of the bot. Conceptually this context is divided in 3 main parts: - 1. The Status Report. - 2. The Execution History. - 3. The Execution Context. + I. The non-business information which helps the mechanisms of giving continuety to the bots execution over time. This information goes in a file + called the Status Report, and there is a module, child of this one called Status Report that deals with loading and saving the contents of that file. - */ + II. The business information around the bot execution, including its balance, positions at exchanges, trades executed and many other things. These + are platform data mantained on behalf of the executing bot. All these is kept in one file per execution called the Execution Context. The collection + of all these files can later reconstruct the vital business information the bot had at each moment in time. - - - /* - - Here we will keep the last status report, to be available during the whole process. The Status Report is a file the bot process - reads and saves again after each execution. Its main purpose is to know when the last execution was in order to locate the execution - context. When the bot runs for the first time it takes some vital parameters from there and it checks them through its lifecycle to see - if they changed. The Status Report file can eventually be manipulated by the bot operators / developers in order to change those parameters - or to point the last execution to a different date. Humans are not supose to manipulate the Execution Histroy or the execution Context files. - - The Execution History is basically an index with dates of all the executions the bot did across its history. It allows the bot plotter - to know which datetimes have informacion about the bots execution in order to display it. - - The Execution Context file records all the context information of the bot at the moment of execution and the final state of all of its - positions on the market. + II. Execution of any bot cannot be guaranteed that will be on fixed interval of times. We need an index of all executions that points to the detailed files + with all the business informatino the bot had each time it executed. We call this index the Execution History and there is one file to store it. */ diff --git a/DebugLog.js b/DebugLog.js index 2cc9376cb..f29c0c1f9 100644 --- a/DebugLog.js +++ b/DebugLog.js @@ -147,7 +147,11 @@ try { - /* console.log("AACloud" + spacePad(pModule, 50) + " : " + pMessage); */ + if (global.CURRENT_EXECUTION_AT = "IDE") { + + console.log("AACloud" + spacePad(pModule, 50) + " : " + pMessage); + + } if (disableLogging === true) { return; } diff --git a/Root.js b/Root.js index cf2dd5839..1fe0135d1 100644 --- a/Root.js +++ b/Root.js @@ -132,7 +132,7 @@ exports.newRoot = function newRoot() { logInfo: true, logWarnings: false, logErrors: true, - logContent: false, + logContent: true, intensiveLogging: false } };