mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 01:08:07 +00:00
commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
- [Async Generator Multiple Tickers](./examples/py/)
|
||||
|
||||
|
||||
```python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import asyncio
|
||||
import ccxt.async_support as ccxt
|
||||
|
||||
|
||||
async def poll(tickers):
|
||||
i = 0
|
||||
kraken = ccxt.kraken()
|
||||
while True:
|
||||
symbol = tickers[i % len(tickers)]
|
||||
yield (symbol, await kraken.fetch_ticker(symbol))
|
||||
i += 1
|
||||
await asyncio.sleep(kraken.rateLimit / 1000)
|
||||
|
||||
|
||||
async def main():
|
||||
async for (symbol, ticker) in poll(['BTC/USD', 'ETH/BTC', 'BTC/EUR']):
|
||||
print(symbol, ticker)
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user