Class OrderBookRealTimeClient

Orderbook API client

See

Example

import {
OrderBookRealTimeClient,
OrderBookRealTimeClientEvent,
type L2OrderBook
} from '@idexio/idex-sdk';

// type is just to show it will match the form string-string.
// actual type will be typed as string
type MarketSymbol = `${string}-${string}`;

const LIMIT = 10;
const MARKETS: MarketSymbol[] = ['IDEX-USD'];

const client = new OrderBookRealTimeClient({
sandbox: true,
});

client.start(MARKETS);

const orderbooksMap = new Map<MarketSymbol, L2OrderBook>()

async function handleOrderBookLevel2(market: MarketSymbol) {
const levelTwoOrderBook = await client.getOrderBookL2(market, LIMIT);

orderbooksMap.set(market, levelTwoOrderBook)

console.log('Updated OrderBook for market: ', market, levelTwoOrderBook);
}

client.on(OrderBookRealTimeClientEvent.ready, () => {
MARKETS.forEach(market => {
handleOrderBookLevel2(market)
})
});

client.on(OrderBookRealTimeClientEvent.l2, handleOrderBookLevel2);

Hierarchy

  • EventEmitter<{
        ready: [market: string];
        connected: [];
        disconnected: [];
        error: [error: Error];
        l1: [market: string];
        l2: [market: string];
        sync: [market: string];
    }>
    • OrderBookRealTimeClient

Accessors

Connection Management

Constructor

Requests

Accessors

When creating an OrderBookRealTimeClient, a public client is automatically created and can be used based to make additional public requests if needed.

  • Can be utilized to fetch public data instead of creating both clients.

Connection Management

Constructor

Requests