diff --git a/CanvasApp/Animation.js b/CanvasApp/Animation.js index 14b9f8376..b06c4eb6d 100644 --- a/CanvasApp/Animation.js +++ b/CanvasApp/Animation.js @@ -61,11 +61,11 @@ function newAnimation () { try { if (window.canvasApp.visible === true) { /* We set the canvas to its normal width and height */ - browserCanvas.width = window.innerWidth - browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN + // browserCanvas.width = window.innerWidth + // browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN /* First thing is to clear the actual canvas */ - // clearBrowserCanvas() + clearBrowserCanvas() /* We loop through the callback functions collections and execute them all. */ let performanceMap = new Map() @@ -162,12 +162,7 @@ function newAnimation () { } function clearBrowserCanvas () { - browserCanvasContext.beginPath() - - browserCanvasContext.rect(0, 0, browserCanvas.width, browserCanvas.height) browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.closePath() - browserCanvasContext.fill() + browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height) } } diff --git a/CanvasApp/Plotter.js b/CanvasApp/Plotter.js index e23e87dc3..fdd1cce45 100644 --- a/CanvasApp/Plotter.js +++ b/CanvasApp/Plotter.js @@ -24,7 +24,6 @@ function newPlotter () { thisObject.container = container let coordinateSystem - let plotterModuleConfig let slotHeight = (canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available let mustRecalculateDataPoints = false let atMousePositionFillStyles = new Map() @@ -82,7 +81,6 @@ function newPlotter () { finalizeCoordinateSystem() coordinateSystem = undefined - plotterModuleConfig = undefined slotHeight = undefined mustRecalculateDataPoints = undefined atMousePositionFillStyles = undefined @@ -498,6 +496,10 @@ function newPlotter () { for (let i = 0; i < records.length; i++) { let record = records[i] + /* + In the formulas to create plotters, we allos users to reference the previous record. + To enable that we need to link all records to the previous one in this way. + */ if (i == 0) { record.previous = record } else { @@ -555,7 +557,7 @@ function newPlotter () { if (logged === false) { logged = true } - /* Only calculate the datapoints for this record, if we have not calculate it before. */ + /* It seems we need to calculate the data points this time. */ for (let k = 0; k < productDefinition.referenceParent.shapes.chartPoints.length; k++) { let chartPoints = productDefinition.referenceParent.shapes.chartPoints[k] for (let j = 0; j < chartPoints.points.length; j++) { @@ -582,13 +584,6 @@ function newPlotter () { /* Store the data point at the local map */ dataPoints.set(point.id, dataPoint) - - if (plotterModuleConfig !== undefined) { - if (plotterModuleConfig.slot !== undefined) { - /* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */ - dataPoint.y = (-1) * y * coordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + canvas.chartingSpace.viewport.visibleArea.topLeft.y - } - } } } } @@ -769,7 +764,7 @@ function newPlotter () { } } - if (coordinateSystem.autoMinYScale === true || coordinateSystem.autosMaxScale === true) { + if (coordinateSystem.autoMinYScale === true || coordinateSystem.autoMinYScale === true) { mustRecalculateDataPoints = true } else { mustRecalculateDataPoints = false diff --git a/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js b/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js index 002e336b7..5b9af5b85 100644 --- a/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js +++ b/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Daily/User.Bot.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) { const FULL_LOG = true; const INTENSIVE_LOG = false; @@ -21,6 +21,7 @@ }; let utilities = UTILITIES.newCloudUtilities(bot, logger); + let fileStorage = FILE_STORAGE.newFileStorage(logger); let statusDependencies; let beginingOfMarket diff --git a/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js b/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js index be189f43e..e85e3a4b1 100644 --- a/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js +++ b/Legacy-Code/Masters/bots/Bollinger-Bands-Indicator-Bot/Multi-Period-Market/User.Bot.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -17,6 +17,7 @@ }; let statusDependencies; + let fileStorage = FILE_STORAGE.newFileStorage(logger); return thisObject; diff --git a/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js b/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js index 996fb574e..92edb34fa 100644 --- a/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js +++ b/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Daily/User.Bot.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -23,6 +23,7 @@ }; let utilities = UTILITIES.newCloudUtilities(bot, logger); + let fileStorage = FILE_STORAGE.newFileStorage(logger); let statusDependencies; let beginingOfMarket diff --git a/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.bot.js b/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.bot.js index c6ebfdc3a..71e16bd6c 100644 --- a/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.bot.js +++ b/Legacy-Code/Masters/bots/Candles-Volumes-Indicator-Bot/Multi-Period-Market/User.bot.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -23,6 +23,7 @@ }; let utilities = UTILITIES.newCloudUtilities(bot, logger); + let fileStorage = FILE_STORAGE.newFileStorage(logger); let statusDependencies; let beginingOfMarket diff --git a/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js b/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js index 40e16a935..f1e24bc01 100644 --- a/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js +++ b/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-OHLCVs/User.Bot.js @@ -1,5 +1,5 @@  -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage, STATUS_REPORT, EXCHANGE_API) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -15,6 +15,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt }; let utilities = UTILITIES.newCloudUtilities(bot, logger) + let fileStorage = FILE_STORAGE.newFileStorage(logger); let statusDependencies const ONE_MIN = 60000 diff --git a/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js b/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js index 0779c1419..3b5ddff99 100644 --- a/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js +++ b/Legacy-Code/Masters/bots/Exchange-Raw-Data-Sensor-Bot/Historic-Trades/User.Bot.js @@ -1,5 +1,5 @@  -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage, STATUS_REPORT, EXCHANGE_API) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -14,6 +14,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt }; let utilities = UTILITIES.newCloudUtilities(bot, logger) + let fileStorage = FILE_STORAGE.newFileStorage(logger); let statusDependencies const ONE_MINUTE = 60000 diff --git a/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Daily/User.Bot.js b/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Daily/User.Bot.js index a77b2eba8..92d915427 100644 --- a/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Daily/User.Bot.js +++ b/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Daily/User.Bot.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) { const FULL_LOG = true; const INTENSIVE_LOG = false; @@ -24,6 +24,7 @@ }; let utilities = UTILITIES.newCloudUtilities(bot, logger); + let fileStorage = FILE_STORAGE.newFileStorage(logger); let statusDependencies; let beginingOfMarket diff --git a/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Market/User.Bot.js b/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Market/User.Bot.js index f425326d8..f0e976090 100644 --- a/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Market/User.Bot.js +++ b/Legacy-Code/Masters/bots/Stairs-Patterns-Indicator-Bot/Multi-Period-Market/User.Bot.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -23,6 +23,7 @@ }; let statusDependencies; + let fileStorage = FILE_STORAGE.newFileStorage(logger); return thisObject; diff --git a/TaskServer/FileStorage.js b/TaskServer/FileStorage.js index 8bca500eb..43a9933d0 100644 --- a/TaskServer/FileStorage.js +++ b/TaskServer/FileStorage.js @@ -8,6 +8,7 @@ exports.newFileStorage = function newFileStorage(logger) { const RETRY_TIME_IN_MILISECONDS = 250 let currentRetryGetTextFile = 0 let currentRetryWriteTextFile = 0 + let currentRetryDeleteTextFile = 0 if (logger === undefined) { // Dummy logger logger = {} @@ -242,14 +243,14 @@ exports.newFileStorage = function newFileStorage(logger) { } function retry() { - if (currentRetryWriteTextFile < MAX_RETRY) { - currentRetryWriteTextFile++ - logger.write(MODULE_NAME, '[WARN] FileStorage -> createTextFile -> retry -> Will try to write the file again -> Retry #: ' + currentRetryWriteTextFile) + if (currentRetryDeleteTextFile < MAX_RETRY) { + currentRetryDeleteTextFile++ + logger.write(MODULE_NAME, '[WARN] FileStorage -> deleteTextFile -> retry -> Will try to delete the file again -> Retry #: ' + currentRetryDeleteTextFile) createTextFile(filePath, fileContent, callBackFunction) } else { - currentRetryWriteTextFile = 0 - logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.') - logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> file = ' + fileLocation) + currentRetryDeleteTextFile = 0 + logger.write(MODULE_NAME, '[ERROR] FileStorage -> deleteTextFile -> retry -> Max retries reached deleting a file. Giving up.') + logger.write(MODULE_NAME, '[ERROR] FileStorage -> deleteTextFile -> retry -> file = ' + fileLocation) callBackFunction(global.DEFAULT_FAIL_RESPONSE) } } diff --git a/TaskServer/IndicatorBotProcessMainLoop.js b/TaskServer/IndicatorBotProcessMainLoop.js index 8915e5649..17eceba01 100644 --- a/TaskServer/IndicatorBotProcessMainLoop.js +++ b/TaskServer/IndicatorBotProcessMainLoop.js @@ -493,7 +493,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); } - usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage); + usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE); usertBot.initialize(statusDependencies, onInizialized); diff --git a/TaskServer/SensorBotProcessMainLoop.js b/TaskServer/SensorBotProcessMainLoop.js index 4238fe306..669a503b9 100644 --- a/TaskServer/SensorBotProcessMainLoop.js +++ b/TaskServer/SensorBotProcessMainLoop.js @@ -391,7 +391,7 @@ if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); } - usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage, STATUS_REPORT, exchangeAPI); + usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE, STATUS_REPORT, exchangeAPI); usertBot.initialize(statusDependencies, onInizialized); diff --git a/TaskServer/server.js b/TaskServer/server.js index 449a93514..c7523ea32 100644 --- a/TaskServer/server.js +++ b/TaskServer/server.js @@ -163,8 +163,7 @@ function bootLoader() { let event = { seconds: (new Date()).getSeconds() } - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event) - + global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event) } for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) {