This commit is contained in:
discountry
2025-10-03 15:28:16 +08:00
parent d5c4b04746
commit fcb83bd16b
925 changed files with 165721 additions and 4 deletions
@@ -0,0 +1,28 @@
- [Manual Rate Limiting Long Poller](./examples/py/)
```python
# -*- coding: utf-8 -*-
import os
import sys
import time
import ccxt # noqa: E402
# if you imported the ccxt library with `import ccxt` you can
# throttle your requests manually, by using the rateLimit property of an exchange
# to delay each request by waiting for some time to stay below request rate limits
exchange = ccxt.bitfinex()
# the rateLimit is in milliseconds → divide it by a thousand to get seconds
delay = exchange.rateLimit / 1000
for i in range(0, 10):
# this can be any call instead of fetch_ticker, really
print(exchange.fetch_ticker('BTC/USD'))
time.sleep(delay) # sleep a little before sending each next request
```