add rate limiting to ccxt.
- Rate limit per endpoint
pip install "git+https://github.com/richmanbtc/ccxt_rate_limiter.git@v0.0.6#egg=ccxt_rate_limiter"
- RateLimiterGroup handles rate limiting by tags.
from ccxt_rate_limiter import scale_limits
from ccxt_rate_limiter.bybit import bybit_limits
from ccxt_rate_limiter.rate_limiter_group import RateLimiterGroup
limits = bybit_limits()
limits = scale_limits(limits, 0.75) # Multiply the rate limit value by a certain magnification to allow a margin.
rate_limiter_group = RateLimiterGroup(limits=limits)
- RateLimiterGroup can be shared between multiple ccxt instances.
- RateLimiterGroup can be shared between multiple threads (thread-safe).
import ccxt
from ccxt_rate_limiter import wrap_object
from ccxt_rate_limiter.bybit import bybit_wrap_defs
bybit = ccxt.bybit({
'enableRateLimit': False, # disable built-in rate limiter
})
wrap_object(bybit, rate_limiter_group=rate_limiter_group, wrap_defs=bybit_wrap_defs())
bybit.publicGetTickers()
# rate limiter status
print(rate_limiter_group.status_info())
Custom rate limiting settings can be used.
see
- ccxt_rate_limiter/binance.py
- ccxt_rate_limiter/bybit.py
- ccxt_rate_limiter/ftx.py
- binance
- bybit
- ftx
CC0
python3 -m unittest tests/test_*