diff --git a/Historic-OHLCVs/User.Bot.js b/Historic-OHLCVs/User.Bot.js index c31bdade7..0f1cfde11 100644 --- a/Historic-OHLCVs/User.Bot.js +++ b/Historic-OHLCVs/User.Bot.js @@ -33,7 +33,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt let exchangeId let options = {} let firstId - let rateLimit + let rateLimit = 500 let exchange let uiStartDate = new Date(bot.uiStartDate) let fisrtTimeThisProcessRun = false @@ -110,6 +110,15 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt function start(callBackFunction) { try { + let lastCandle = { + begin: 0, + end: 0, + open: 0, + close: 0, + min: 0, + max: 0 + } + if (global.STOP_TASK_GRACEFULLY === true) { callBackFunction(global.DEFAULT_OK_RESPONSE); return @@ -205,6 +214,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt bot.processHeartBeat("Fetching " + allOHLCVs.length.toFixed(0) + " OHLCVs from " + bot.exchange + " " + symbol + " @ " + processingDate) // tell the world we are alive and doing well /* Fetching the OHLCVs from the exchange.*/ + await new Promise(resolve => setTimeout(resolve, rateLimit)) // rate limit const OHLCVs = await exchange.fetchOHLCV(symbol, '1m', since, limit, params) /* @@ -290,14 +300,6 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt let error let separator let heartBeatCounter = 0 - let lastCandle = { - begin: 0, - end: 0, - open: 0, - close: 0, - min: 0, - max: 0 - } let lastVolume = { begin: 0, end: 0, @@ -342,10 +344,6 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt volume: record[5] } - if (OHLCV.open === 11478 || OHLCV.hight === 11478 || OHLCV.low === 11478 || OHLCV.close === 11478) { - console.log('FROM HERE') - } - let candleMinute = Math.trunc(candle.begin / ONE_MIN) let OHLCVMinute