mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
- [Gdax Fetch Trades Pagination](./examples/js/)
|
||||
|
||||
|
||||
```javascript
|
||||
import ccxt from '../../js/ccxt.js';
|
||||
import ololog from 'ololog';
|
||||
|
||||
const { noLocate } = ololog;
|
||||
const log = noLocate;
|
||||
|
||||
const exchange = new ccxt.coinbasepro ()
|
||||
|
||||
;(async () => {
|
||||
|
||||
const symbol = 'ETH/BTC'
|
||||
const params = {}
|
||||
await exchange.loadMarkets ()
|
||||
while (true) {
|
||||
const trades = await exchange.fetchTrades (symbol, undefined, undefined, params)
|
||||
if (trades.length) {
|
||||
const firstTrade = trades[0]
|
||||
const lastTrade = trades[trades.length - 1]
|
||||
log.yellow ('Fetched', trades.length, symbol, 'trades from', firstTrade['datetime'], 'to', lastTrade['datetime'])
|
||||
if ('Cb-After' in exchange.last_response_headers) {
|
||||
params['after'] = exchange.last_response_headers['Cb-After'];
|
||||
}
|
||||
} else {
|
||||
log.green ('Done.')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}) ()
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user