ccxt: Polling Binance fetchTickers every 5 seconds triggers a ban
I tried use param {enableRateLimit: true} to handle rate limit.
A strange thing about ‘binance’: when I call fetchTickers() to polling tickers (e.g., every 5 seconds), it will throw an error
{"code":-1003,"msg":"Way too many requests; IP banned until 1514883415037."}
This should not happened, 5 seconds should not trigger limit. Is there some extra info to explain this? I tried find information from ccxt and binance api docs, no idea.
Ref to: #929
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 15 (13 by maintainers)
Commits related to this issue
- added new v3 ticker endpoints for binance #1027 — committed to ccxt/ccxt by kroitor 6 years ago
Hi!
Binance uses a Machine Learning rate-limiting algorithm that scores your requests against an average user and accounts for the weight of each call.
From Binance:
From their tech team:
Next, if you go here: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics
You will notice that they have a special weight for the “all tickers” endpoint:
They say, that if you’re fetching all tickers, the rate limit should be multiplied by the amount of active traded symbols. They have 234 active symbols, so, it looks like you should not be polling their tickers more than once in 234 seconds. It’s a unique endpoint in terms of rate limiting. Unfortunately, there isn’t an easy workaround for this, if you’re mixing your requests. If you are only doing one type of
fetchTickers()request, then you can raise the rateLimit to 234 000 milliseconds (once in 234 seconds).Let me know if this answers your question or not.
Hi, @eMDi101 ! Thanks for the notice! The thing is: we are talking of the
allBookTickersendpoint. The library of sammchardy uses theallPricesendpoint – that one does not return full info, it will output price info only, without 24h ohlcv.Now, in ccxt we support both endpoints, the
allBookTickers+ theallPrices, but for the tickers we useallBookTickersby default because it gives us 24h stats – that is more than just prices: https://github.com/ccxt/ccxt/blob/master/python/ccxt/binance.py#L98Next, if you look carefully through each endpoint here:
… you will quickly notice two things:
allPricesandallBookTickersare now renamed to new endpoints, therefore both ccxt and sammchardy are outdated, but we are working on the update in ccxt (will be there in several hours).We are also going to switch to price-only tickers by default for Binance in one of the upcoming releases. Will update you here.
@orkenstein https://t.me/binance_api_english