File Cursos Cache Implemented
This commit is contained in:
1 parent
89f8e0574f
commit
4241499f63
7 files changed
+246
-90
No files matched your search
+9
-53
@@ -1,52 +1,20 @@
|
||||
|
||||
function newFileCache() {
|
||||
|
||||
let marketFilesPeriods =
|
||||
'[' +
|
||||
'[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' +
|
||||
'[' + 12 * 60 * 60 * 1000 + ',' + '"12-hs"' + ']' + ',' +
|
||||
'[' + 8 * 60 * 60 * 1000 + ',' + '"08-hs"' + ']' + ',' +
|
||||
'[' + 6 * 60 * 60 * 1000 + ',' + '"06-hs"' + ']' + ',' +
|
||||
'[' + 4 * 60 * 60 * 1000 + ',' + '"04-hs"' + ']' + ',' +
|
||||
'[' + 3 * 60 * 60 * 1000 + ',' + '"03-hs"' + ']' + ',' +
|
||||
'[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' +
|
||||
'[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']';
|
||||
|
||||
marketFilesPeriods = JSON.parse(marketFilesPeriods);
|
||||
|
||||
let dailyFilePeriods =
|
||||
'[' +
|
||||
'[' + 45 * 60 * 1000 + ',' + '"45-min"' + ']' + ',' +
|
||||
'[' + 40 * 60 * 1000 + ',' + '"40-min"' + ']' + ',' +
|
||||
'[' + 30 * 60 * 1000 + ',' + '"30-min"' + ']' + ',' +
|
||||
'[' + 20 * 60 * 1000 + ',' + '"20-min"' + ']' + ',' +
|
||||
'[' + 15 * 60 * 1000 + ',' + '"15-min"' + ']' + ',' +
|
||||
'[' + 10 * 60 * 1000 + ',' + '"10-min"' + ']' + ',' +
|
||||
'[' + 05 * 60 * 1000 + ',' + '"05-min"' + ']' + ',' +
|
||||
'[' + 04 * 60 * 1000 + ',' + '"04-min"' + ']' + ',' +
|
||||
'[' + 03 * 60 * 1000 + ',' + '"03-min"' + ']' + ',' +
|
||||
'[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' +
|
||||
'[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']';
|
||||
|
||||
dailyFilePeriods = JSON.parse(dailyFilePeriods);
|
||||
|
||||
let fileCache = {
|
||||
getMarketFile: getMarketFile,
|
||||
getFileCursor: getFileCursor,
|
||||
setDatetime: setDatetime,
|
||||
getFile: getFile,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
let fileCloud;
|
||||
|
||||
let marketFiles = new Map;
|
||||
let fileCursors = new Map;
|
||||
let files = new Map;
|
||||
|
||||
let datetime;
|
||||
|
||||
return fileCache;
|
||||
|
||||
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, pDatetime, callBackFunction) {
|
||||
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, callBackFunction) {
|
||||
|
||||
let product = ecosystem.getProduct(ecosystem.getBot(ecosystem.getTeam(pTeamCodeName), pBotCodeName), pProductCodeName);
|
||||
|
||||
@@ -75,6 +43,8 @@ function newFileCache() {
|
||||
fileCloud = newFileCloud();
|
||||
fileCloud.initialize(pTeamCodeName, pBotCodeName);
|
||||
|
||||
/* Now we will get the market files */
|
||||
|
||||
for (i = 0; i < marketFilesPeriods.length; i++) {
|
||||
|
||||
let periodTime = marketFilesPeriods[i][0];
|
||||
@@ -82,11 +52,11 @@ function newFileCache() {
|
||||
|
||||
if (layer.validPeriods.includes(periodName) === true) {
|
||||
|
||||
fileCloud.getMarketFile(product, exchange, pMarket, periodName, onFileReceived);
|
||||
fileCloud.getFile(product, exchange, pMarket, periodName, undefined, onFileReceived);
|
||||
|
||||
function onFileReceived(file) {
|
||||
|
||||
marketFiles.set(periodTime, file);
|
||||
files.set(periodTime, file);
|
||||
|
||||
callBackFunction(); // Note that the call back is called for every file loaded.
|
||||
|
||||
@@ -94,24 +64,10 @@ function newFileCache() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getMarketFile(pPeriod) {
|
||||
function getFile(pPeriod) {
|
||||
|
||||
return marketFiles.get(pPeriod);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getFileCursor(pPeriod) {
|
||||
|
||||
return fileCursors.get(pPeriod);
|
||||
|
||||
}
|
||||
|
||||
function setDatetime(newDatetime) {
|
||||
|
||||
datetime = newDatetime;
|
||||
return files.get(pPeriod);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user