diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo index cc2147a35..c4072ea2e 100644 Binary files a/.vs/AAWeb/v15/.suo and b/.vs/AAWeb/v15/.suo differ diff --git a/Files/DailyFiles.js b/Files/DailyFiles.js index ac67a86f0..bd044b890 100644 --- a/Files/DailyFiles.js +++ b/Files/DailyFiles.js @@ -48,22 +48,96 @@ function newDailyFiles() { fileCloud = newFileCloud(); fileCloud.initialize(pBot); - /* Now we will get the daily files */ + /* First we will get the Data Range */ - for (i = 0; i < dailyFilePeriods.length; i++) { + fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, true, onDataRangeReceived); - let periodTime = dailyFilePeriods[i][0]; - let periodName = dailyFilePeriods[i][1]; + function onDataRangeReceived(err, pFile) { - if (pSet.validPeriods.includes(periodName) === true) { + try { - let fileCursor = newFileCursor(); - fileCursor.initialize(fileCloud, pDevTeam, pBot, pSet, exchange, pMarket, periodName, periodTime, pDatetime, pTimePeriod, onFileReceived); + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Entering function."); } - fileCursors.set(periodTime, fileCursor); + let beginDateRange; + let endDateRange; - expectedFiles = expectedFiles + fileCursor.getExpectedFiles(); + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received OK Response."); } + + beginDateRange = new Date(pFile.begin); + endDateRange = new Date(pFile.end); + + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received FAIL Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> err.message = " + err.message); } + + if (err.message === "File does not exist.") { + + if (INFO_LOG === true) { logger.write("[WARN] initialize -> onFileReceived -> No Date Range file found. maxDate will be set to current datetime. "); } + + endDateRange = new Date(); + break; + } + + if (err.message === "Missing Configuration.") { + + if (ERROR_LOG === true) { logger.write("[WARN] initialize -> onFileReceived -> The needed configuration for the dateRange at the dataSet of the product was not found."); } + if (ERROR_LOG === true) { logger.write("[WARN] initialize -> onFileReceived -> maxDate will be set to current datetime."); } + + endDateRange = new Date(); + break; + } + + /* If none of the previous conditions are met, the we return the err to the caller. */ + + callBackFunction(err); + return; + } + + default: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received Unexpected Response."); } + callBackFunction(err); + return; + } + } + + /* Now we will get the daily files */ + + for (i = 0; i < dailyFilePeriods.length; i++) { + + let periodTime = dailyFilePeriods[i][0]; + let periodName = dailyFilePeriods[i][1]; + + if (pSet.validPeriods.includes(periodName) === true) { + + let fileCursor = newFileCursor(); + fileCursor.initialize(fileCloud, pDevTeam, pBot, pSet, exchange, pMarket, periodName, periodTime, pDatetime, pTimePeriod, beginDateRange, endDateRange, onFileReceived); + + fileCursors.set(periodTime, fileCursor); + + expectedFiles = expectedFiles + fileCursor.getExpectedFiles(); + + } + } + + } catch (err) { + + if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> err = " + err); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/Files/FileCloud.js b/Files/FileCloud.js index fd172c5a0..7fed6bb54 100644 --- a/Files/FileCloud.js +++ b/Files/FileCloud.js @@ -31,15 +31,42 @@ function newFileCloud() { } - function getFile(pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, callBackFunction) { + function getFile(pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) { try { if (INFO_LOG === true) { logger.write("[INFO] getFile -> Entering function."); } if (INFO_LOG === true) { logger.write("[INFO] getFile -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pSet.filePath + "-" + pSet.fileName); } - let fileName = pSet.fileName; - let filePath = pSet.filePath; + let fileName; + let filePath; + + if (pDataRange === undefined) { + + fileName = pSet.fileName; + filePath = pSet.filePath; + + } else { + + if (pSet.dataRange !== undefined) { + + fileName = pSet.dataRange.fileName; + filePath = pSet.dataRange.filePath; + + } else { + + let customErr = { + result: GLOBAL.CUSTOM_FAIL_RESPONSE.result, + message: "Missing Configuration." + }; + + if (ERROR_LOG === true) { logger.write("[WARN] getFile -> onFileReceived -> customErr.message = " + customErr.message); } + if (ERROR_LOG === true) { logger.write("[WARN] getFile -> onFileReceived -> Data Range configuration could not be found. "); } + + callBackFunction(customErr); + return; + } + } if (fileName === undefined) { diff --git a/Files/FileCursor.js b/Files/FileCursor.js index 1a716c103..4a65ac2ad 100644 --- a/Files/FileCursor.js +++ b/Files/FileCursor.js @@ -31,10 +31,12 @@ function newFileCursor() { let thisSet; let periodName; let timePeriod; + let beginDateRange; + let endDateRange; return thisObject; - function initialize(pFileCloud, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pTimePeriod, pCursorDate, pCurrentTimePeriod, callBackFunction) { + function initialize(pFileCloud, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pTimePeriod, pCursorDate, pCurrentTimePeriod, pBeginDateRange, pEndDateRange, callBackFunction) { try { @@ -50,6 +52,8 @@ function newFileCursor() { periodName = pPeriodName; cursorDate = pCursorDate; timePeriod = pTimePeriod; + beginDateRange = pBeginDateRange; + endDateRange = pEndDateRange; setTimePeriod(pCurrentTimePeriod, pCursorDate, callBackFunction); @@ -289,8 +293,6 @@ function newFileCursor() { } } - - function setDatetime(pDatetime, callBackFunction) { try { @@ -346,6 +348,38 @@ function newFileCursor() { } } + let compareTargetDate = new Date(targetDate.toDateString()); + + if (beginDateRange !== undefined) { + + let compareBeginDate = new Date(beginDateRange.toDateString()); + + if (compareTargetDate.valueOf() < compareBeginDate.valueOf()) { + + if (INFO_LOG === true) { logger.write("[INFO] getFiles -> getNextFile -> compareTargetDate < compareBeginDate -> Not loading the file for this date."); } + if (INFO_LOG === true) { logger.write("[INFO] getFiles -> getNextFile -> compareTargetDate < compareBeginDate -> compareTargetDate = " + compareTargetDate); } + if (INFO_LOG === true) { logger.write("[INFO] getFiles -> getNextFile -> compareTargetDate < compareBeginDate -> compareBeginDate = " + compareBeginDate); } + + controlLoop(); + return; + } + } + + if (endDateRange !== undefined) { + + let compareEndDate = new Date(endDateRange.toDateString()); + + if (compareTargetDate.valueOf() > compareEndDate.valueOf()) { + + if (INFO_LOG === true) { logger.write("[INFO] getFiles -> getNextFile -> compareTargetDate > compareEndDate -> Not loading the file for this date."); } + if (INFO_LOG === true) { logger.write("[INFO] getFiles -> getNextFile -> compareTargetDate > compareEndDate -> compareTargetDate = " + compareTargetDate); } + if (INFO_LOG === true) { logger.write("[INFO] getFiles -> getNextFile -> compareTargetDate > compareEndDate -> compareEndDate = " + compareEndDate); } + + controlLoop(); + return; + } + } + dateString = targetDate.getUTCFullYear() + '-' + pad(targetDate.getUTCMonth() + 1, 2) + '-' + pad(targetDate.getUTCDate(), 2); let currentDay = Math.trunc((new Date()).valueOf() / (24 * 60 * 60 * 1000)); @@ -359,7 +393,7 @@ function newFileCursor() { if (thisObject.files.get(dateString) === undefined) { // We dont reload files we already have. - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, targetDate, undefined, onFileReceived); + fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, targetDate, undefined, undefined, onFileReceived); } else { diff --git a/Files/FileSequence.js b/Files/FileSequence.js index a6e4013cc..2665e0840 100644 --- a/Files/FileSequence.js +++ b/Files/FileSequence.js @@ -44,7 +44,7 @@ function newFileSequence() { /* First we will get the sequence max number */ - fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, "Sequence", onSequenceFileReceived); + fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, "Sequence", undefined, onSequenceFileReceived); function onSequenceFileReceived(err, file) { @@ -99,7 +99,7 @@ function newFileSequence() { for (let i = 0; i <= maxSequence; i++) { - fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, i, onFileReceived); + fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, i, undefined, onFileReceived); function onFileReceived(err, file) { diff --git a/Files/MarketFiles.js b/Files/MarketFiles.js index ee9fe0035..cd8c20946 100644 --- a/Files/MarketFiles.js +++ b/Files/MarketFiles.js @@ -49,7 +49,7 @@ function newMarketFiles() { if (pSet.validPeriods.includes(periodName) === true) { - fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, periodName, undefined, undefined, onFileReceived); + fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, periodName, undefined, undefined, undefined, onFileReceived); function onFileReceived(err, file) { diff --git a/Files/SingleFile.js b/Files/SingleFile.js index 710346470..38e4602c4 100644 --- a/Files/SingleFile.js +++ b/Files/SingleFile.js @@ -37,7 +37,7 @@ function newSingleFile() { /* Now we will get the file */ - fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, onFileReceived); + fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, undefined, onFileReceived); function onFileReceived(err, pFile) { diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index e8a3e6e6e..e02f31910 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -12,14 +12,14 @@ var container = newContainer(); - container.name = "Bots Product Panel"; + container.name = "Algobots Product Panel"; container.initialize(); container.isDraggeable = true; container.isWheelable = true; thisObject.container = container; - thisObject.container.frame.containerName = "Bot's Products"; + thisObject.container.frame.containerName = "Algobots's Products"; let isInitialized = false; let productCards = []; diff --git a/SplashScreen.js b/SplashScreen.js index 2fbca421d..b8fb64aaa 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -128,11 +128,11 @@ function newSplashScreen() { browserCanvasContext.fillStyle = 'rgba(255, 0, 0, ' + opacity + ')'; browserCanvasContext.fillText(title, titlePoint.x, titlePoint.y); - /* Trading Bots Competitions Sub Title */ + /* Algo Bots Competitions Sub Title */ fontSize = 50; - title = "Trading Bots Competitions" + title = "Algobots Competitions" titlePoint = { x: splashScreen.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO + 0,