ccxt: Gate.io ratelimit seems to be wrongly applied
- OS: linux
- Programming Language version: python
- CCXT version: 1.57.3
something seems off with gateio’s ratelimiting.
With the code below (rateLimit of 500ms), i’d expect ~2 calls per second - so the below code (doing 4 requests) should take roughly 2 seconds.
This code however runs for more than 2 minutes (i got bored by then and aborted …).
import ccxt
exchange = ccxt.gateio({"enableRateLimit": True, "rateLimit": 500})
lm = exchange.load_markets()
-- Time starting from here - i used a different Jupyter sell with %%time ...
for pair in range(4):
_ = exchange.fetch_ohlcv('BTC/USDT', "5m", limit=500)
Running the same code against binance, i get a response in roughly 2 seconds.
import ccxt
exchange = ccxt.binance({"enableRateLimit": True, "rateLimit": 500})
lm = exchange.load_markets()
for pair in range(4):
_ = exchange.fetch_ohlcv('BTC/USDT', "5m", limit=500)
Now i know that the limits above are “over the top” for gate.io (which can go down to 3ms) - but using a high enough value will expose this odd, misaligned behaviour (which honestly, from looking at the JS sources, i’m unable to grasp).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (24 by maintainers)
Commits related to this issue
- fix rate limiter problems like in #10111 — committed to frosty00/ccxt by frosty00 3 years ago
You’re right - i was misled - i’ll open a new issue for that - as it’s not rate-limit related.
Seeing the approach you’re taking now (#10113 , …) seems to be a good way 👍
I must admit, i’ve completely missed the change on how you handle rateLimits now - it seems to work just great (currently testing for binance, but i assume it’ll work similarily great for other pairs). This will probably lead to freqtrade changing recommendations on how to handle ratelimits - and simply rely 100% on ccxt (we previously adjusted them slightly to be faster (binance) or slower (kraken) …
@xmatthias we have discussed this within the team and, as was mentioned above, the rateLimit property still operates in terms of milliseconds and will behave very close to the way it worked before, as explained in the documented Manual. In other words, there is (there will be) no inconsistency in regard of that. Most of the exchanges in the current master are not directly affected by this change, even if you redefine the rateLimit and set it higher to a less efficient value than the default. There are 3 exchanges that may be affected (apart from gate.io that is now fixed): OKEX, Bitmart and Btcturk, we will push a new revision shortly for those exchanges – that should bring them back in line with the Manual. Thx for pointing it out!
Will fix this shortly.
that’s strange, what code are you using to replicate it (which endpoints in particular), i’m not able to replicate it
@kroitor @frosty00 maybe a stupid question - but has the rate-limit for gate.io been rolled back properly?
without setting a ratelimit myself, i’m currently getting torched by it after about 1-2 seconds …
Can confirm, new version fixes this 👍 Thanks a lot for the prompt response
@xmatthias it is supposed to work in a non-breaking manner, investigating…