mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
46 lines
948 B
Markdown
46 lines
948 B
Markdown
- [Gdax Fetch My Trades Pagination](./examples/py/)
|
|
|
|
|
|
```python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
|
|
import ccxt # noqa: E402
|
|
|
|
'''
|
|
Example snippet to traverse GDAX / CoinBase Pro pagination.
|
|
Useful for reaching back more than 100 myTrades, the same works
|
|
for fetchClosedOrders
|
|
'''
|
|
|
|
exchange = ccxt.gdax({
|
|
"apiKey": "123456",
|
|
"secret": "/abcdefghijklmnop/w==",
|
|
"password": "987654321",
|
|
"enableRateLimit": True
|
|
})
|
|
|
|
param_key = ''
|
|
param_value = ''
|
|
allMyTrades = []
|
|
|
|
while True:
|
|
myTrades = exchange.fetch_my_trades(symbol='BTC/USD', params={param_key: param_value})
|
|
|
|
# Handle gdax with pagination ...
|
|
if exchange.last_response_headers._store.get('cb-after'):
|
|
param_key = 'after'
|
|
param_value = exchange.last_response_headers._store['cb-after'][1]
|
|
|
|
allMyTrades.extend(myTrades)
|
|
|
|
else:
|
|
allMyTrades.extend(myTrades)
|
|
break
|
|
|
|
for trade in allMyTrades:
|
|
print(trade)
|
|
|
|
``` |