OKX

Capabilities

  • Backfill: OHLC (full, history-candles), trades (full, history-trades, paged backward by timestamp), order-book snapshot.

  • Stream: OHLC, trades, order book.

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

Symbols

BTC-USDT (dash), instId format.

Example

async with Client() as c:
    await c.backfill("okx", "BTC/USDT", "trades", start="2024-01-01")

API

class OKXSource(http=None)[source]

OKX source adapter.

  • Backfill: OHLC (full, via history-candles), trades (full, via history-trades, paged backward by timestamp), order-book snapshot.

  • Stream: OHLC, trades, order book.

See also

dccd.Client

the public facade.

Examples

>>> from dccd.sources.okx import OKXSource
>>> OKXSource().capability_for(DataType.TRADES, 'rest', 'historical').history
'full'
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 = OKX after ts in ms).

OKX history-trades (type=2) returns records earlier than the after timestamp, newest first. We page backward from end_ns until the oldest item drops below start_ns or a short page arrives.

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.