Binance

The reference adapter — full historical depth and every live channel.

Capabilities

  • Backfill: OHLC (klines, 1 000/req), trades (aggTrades, cursor-paginated by fromId), order-book snapshot (depth, ≤ 5 000).

  • Stream: OHLC (kline), trades (aggTrade), order book (depth).

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

Symbols

BTCUSDT (no separator) — pass BTC/USDT to dccd.

Example

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

API

class BinanceSource(http=None)[source]

Binance source adapter (spot).

The reference adapter — full historical depth and every live channel.

  • Backfill: OHLC (klines, 1 000/req), trades (aggTrades, cursor-paginated by fromId), order-book snapshot (depth, ≤ 5 000).

  • Stream: OHLC (kline), trades (aggTrade), order book (depth).

Adapters are not used directly — they are resolved by the engine from the registry. Drive them through dccd.Client or the CLI.

See also

dccd.Client

the public facade.

dccd.sources.registry.SourceRegistry

adapter resolution.

Examples

>>> from dccd.sources.binance import BinanceSource
>>> sorted({c.data_type.value for c in BinanceSource().capabilities()})
['ohlc', 'orderbook', 'trades']
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 aggregate trades (cursor = fromId).

First call (cursor=None) is time-bounded on start_ns; subsequent calls follow the fromId cursor. The next cursor is the last aggregate-trade id + 1, returned only while the page is full and the last trade is still inside the window.

render_symbol(s)[source]

Binance format: BTCUSDT (no separator).

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.