Market Files reading Time Frames Files

This commit is contained in:
Luis Fernando Molina committed 2020-07-27 12:06:52 +02:00
1 parent 3b6ed944fa
commit d4443b0350
2 files changed
+95 -34

No files matched your search

+40 -29
View File
@@ -144,43 +144,54 @@ function newDailyFiles () {
}
function createFileCursors () {
try {
/* Now we will get the daily files */
for (i = 0; i < dailyFilePeriods.length; i++) {
let periodTime = dailyFilePeriods[i][0]
let periodName = dailyFilePeriods[i][1]
for (i = 0; i < dailyFilePeriods.length; i++) {
let periodTime = dailyFilePeriods[i][0]
let periodName = dailyFilePeriods[i][1]
if (pDataset.config.validTimeFrames.includes(periodName) === false) { continue }
if (timeFrames !== undefined) {
if (timeFrames.includes(periodName) === false) { continue }
}
if (pDataset.config.validTimeFrames.includes(periodName) === false) {
filesLoaded++
continue
}
if (timeFrames !== undefined) {
if (timeFrames.includes(periodName) === false) {
filesLoaded++
continue
}
}
let fileCursor = newFileCursor()
fileCursor.eventHandler = thisObject.eventHandler // We share our event handler with each file cursor, so that they can raise events there when files are changed.s
fileCursor.initialize(fileCloud, pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, periodName, periodTime, pDatetime, pTimeFrame, beginDateRange, endDateRange, pEventsServerClient, onInitialized)
function onInitialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
break
let fileCursor = newFileCursor()
fileCursor.eventHandler = thisObject.eventHandler // We share our event handler with each file cursor, so that they can raise events there when files are changed.s
fileCursor.initialize(fileCloud, pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, periodName, periodTime, pDatetime, pTimeFrame, beginDateRange, endDateRange, pEventsServerClient, onInitialized)
function onInitialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBackWhenFileReceived(err)
return
}
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBackWhenFileReceived(err)
return
}
fileCursors.set(periodTime, fileCursor)
expectedFiles = expectedFiles + fileCursor.getExpectedFiles()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> onInitialized -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
fileCursors.set(periodTime, fileCursor)
expectedFiles = expectedFiles + fileCursor.getExpectedFiles()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> onInitialized -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
loadThemAll()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> createFileCursors -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
loadThemAll()
}
function loadThemAll () {
+55 -5
View File
@@ -82,6 +82,8 @@ function newMarketFiles () {
pEventsServerClient,
callBackFunction) {
try {
let timeFrames
exchange = pExchange
market = pMarket
dataMine = pDataMine
@@ -102,13 +104,61 @@ function newMarketFiles () {
return
}
/* Now we will get the market files */
getTimeFramesFile()
for (let i = 0; i < marketFilesPeriods.length; i++) {
let periodTime = marketFilesPeriods[i][0]
let periodName = marketFilesPeriods[i][1]
function getTimeFramesFile () {
/* First we will get the Data Range */
fileCloud.getFile(pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, undefined, undefined, undefined, undefined, true, onTimeFramesReceived)
function onTimeFramesReceived (err, pFile) {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
timeFrames = pFile
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
if (err.message === 'File does not exist.') {
/* It is ok, we will deal with this later */
break
}
if (err.message === 'Missing Configuration.') {
if (ERROR_LOG === true) { logger.write('[WARN] initialize -> onFileReceived -> The needed configuration to locate the timeFrames is missing at the dataSet.') }
if (ERROR_LOG === true) { logger.write('[WARN] initialize -> onFileReceived -> Time Frames Filters will be ignored -> Product = ' + pProduct.config.codeName) }
break
}
callBackFunction(err)
return
}
default: {
callBackFunction(err)
return
}
}
getMarketFiles()
}
}
function getMarketFiles () {
/* Now we will get the market files */
for (let i = 0; i < marketFilesPeriods.length; i++) {
let periodTime = marketFilesPeriods[i][0]
let periodName = marketFilesPeriods[i][1]
if (dataset.config.validTimeFrames.includes(periodName) === false) {
filesNotLoaded++
continue
}
if (timeFrames !== undefined) {
if (timeFrames.includes(periodName) === false) {
filesNotLoaded++
continue
}
}
if (dataset.config.validTimeFrames.includes(periodName) === true) {
fileCloud.getFile(dataMine, bot, session, product, dataset, exchange, market, periodName, undefined, undefined, undefined, undefined, onFileReceived)
function onFileReceived (err, file) {