BitMEX

Capabilities

  • Backfill: OHLC (bucketed — 1m / 5m / 1h / 1d only), trades (full), order-book snapshot (orderBook/L2).

  • Stream: OHLC, trades, order book.

  • OHLC fidelity: quote_volume — null · trades — null.

Note

BitMEX only buckets candles at 1m / 5m / 1h / 1d — other spans raise.

Symbols

XBTUSD — BitMEX uses XBT for Bitcoin.

Example

async with Client() as c:
    await c.backfill("bitmex", "BTC/USD", "ohlc", span=3600, start="2024-01-01")
    await c.backfill("bitmex", "BTC/USD", "trades", start="2024-01-01")

API

class BitMEXSource(http=None)[source]

BitMEX source adapter.

  • Backfill: OHLC (bucketed — 1m / 5m / 1h / 1d only), trades (full), order-book snapshot (orderBook/L2).

  • Stream: OHLC, trades, order book.

See also

dccd.Client

the public facade.

Notes

BitMEX buckets candles, so only the four spans above are available; other spans raise. BTC is rendered XBT (e.g. XBTUSD).

Examples

>>> from dccd.sources.bitmex import BitMEXSource
>>> sorted(BitMEXSource().capability_for(DataType.OHLC, 'rest', 'historical').spans)
[60, 300, 3600, 86400]
capabilities()[source]

Declared capabilities, one per (data type × transport × mode).

async fetch_ohlc_page(symbol, span, start_ns, end_ns, limit)[source]

Fetch one page of OHLC bars (see fetch_ohlc_page).

async fetch_orderbook(symbol, depth)[source]

Fetch a current order-book snapshot up to depth levels.

async fetch_trades_page(symbol, start_ns, end_ns, limit, cursor=None)[source]

Fetch one page of trades (cursor = ISO startTime, forward).

BitMEX returns up to 1 000 trades ascending from startTime. On a full page we advance the cursor to the last timestamp + 1 ms to avoid re-fetching the boundary trade, and continue until the window is drained.

render_symbol(s)[source]

Render a canonical Symbol to this exchange’s string.

stream_ohlc(symbol, span)[source]

Stream live OHLC bars over WebSocket.

stream_orderbook(symbol, depth)[source]

Stream live order-book snapshots/deltas over WebSocket.

stream_trades(symbol)[source]

Stream live trades over WebSocket.