Back to Ccxt

Builtin Rate Limiting Rest Poller

wiki/examples/ts/builtin-rate-limiting-rest-poller.md

4.5.60649 B
Original Source
javascript
// @NO_AUTO_TRANSPILE



import ccxt from '../../js/ccxt.js';
import log from 'ololog';
// @ts-ignore
import { nice as ansi } from 'ansicolor';
import asTable from 'as-table';

const exchange = new ccxt.coinbaseexchange ()
const repeat   = 100

async function test (symbol) {

    for (let i = 0; i < repeat; i++) {
        let ticker = await exchange.fetchTicker (symbol)
        log ((exchange.id as any).green, exchange.iso8601 (exchange.milliseconds ()), ticker['datetime'], symbol.green, ticker['last'])
    }
}

const concurrent = [
    test ('BTC/USD'),
    test ('ETH/BTC'),
    test ('ETH/USD')
]

Promise.all (concurrent)