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.Clientthe 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]
- 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.