Functionality for reading the Data Range introduced.
This commit is contained in:
1 parent
5b4643d299
commit
61e843876a
9 files changed
+159
-24
No files matched your search
Binary file not shown.
+83
-9
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+30
-3
@@ -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) {
|
||||
|
||||
|
||||
+38
-4
@@ -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 {
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
+2
-2
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user