mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
37 lines
759 B
Markdown
37 lines
759 B
Markdown
- [Kucoin Fetch Closed Orders Pagination](./examples/py/)
|
|
|
|
|
|
```python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
|
|
|
|
import ccxt # noqa: E402
|
|
|
|
exchange = ccxt.kucoin({
|
|
"apiKey": "YOUR_API_KEY",
|
|
"secret": "YOUR_SECRET",
|
|
"password": "YOUR_PASSWORD"
|
|
})
|
|
|
|
symbol = 'ETH/USDT'
|
|
now = exchange.milliseconds()
|
|
day = 24 * 3600 * 1000
|
|
week = 7 * day
|
|
since = now - 365 * day # start one year back
|
|
limit = 20
|
|
|
|
while since < now:
|
|
|
|
end = min(since + week, now)
|
|
params = {'endAt': end}
|
|
orders = exchange.fetch_closed_orders(symbol, since, limit, params)
|
|
print(exchange.iso8601(since), '-', exchange.iso8601(end), len(orders), 'orders')
|
|
if len(orders) == limit:
|
|
since = orders[-1]['timestamp']
|
|
else:
|
|
since += week
|
|
|
|
``` |