Sources

One adapter per exchange, each implementing the fine-grained Source protocols and declaring its Capability set. The engine resolves an adapter from the registry; you drive them through dccd.Client.

For each exchange’s capabilities, quirks and adapter class, see the per-exchange pages.

Adding an exchange

Implement the relevant protocol mixins below and a capabilities() method, then register the adapter in build_registry.

Registry

class SourceRegistry[source]

Maps exchange names to source adapter instances.

Examples

>>> reg = SourceRegistry()
>>> # reg.register('binance', BinanceSource())
>>> # src = reg.get_ohlc_history('binance')
property exchanges

Names of all registered exchanges.

get(exchange)[source]

Return the adapter registered for name (raises NoCapability if absent).

get_ohlc_history(exchange)[source]

Return name as an OHLCHistory or raise NoCapability.

get_ohlc_live(exchange)[source]

Return name as an OHLCLive or raise NoCapability.

get_orderbook_live(exchange)[source]

Return name as an OrderBookLive or raise NoCapability.

get_orderbook_snapshot(exchange)[source]

Return name as an OrderBookSnapshotREST or raise NoCapability.

get_trades_history(exchange)[source]

Return name as a TradesHistory or raise NoCapability.

get_trades_live(exchange)[source]

Return name as a TradesLive or raise NoCapability.

register(exchange, adapter)[source]

Register an adapter for an exchange.

resolve(exchange, data_type, transport, mode)[source]

Return appropriate adapter or raise NoCapability.

Source protocols

Source protocols — fine-grained per (data_type × mode).

class OHLCHistory[source]

Bases: Source

Protocol: can fetch historical OHLC pages via REST.

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

Fetch up to limit OHLC bars of span seconds in [start_ns, end_ns].

class OHLCLive[source]

Bases: Source

Protocol: can stream live OHLC bars via WebSocket.

stream_ohlc(symbol, span)[source]

Yield live OHLC bars of span seconds over WebSocket.

class OrderBookLive[source]

Bases: Source

Protocol: can stream live order book snapshots/deltas via WebSocket.

stream_orderbook(symbol, depth)[source]

Yield live order-book snapshots/deltas over WebSocket.

class OrderBookSnapshotREST[source]

Bases: Source

Protocol: can fetch an order book snapshot via REST.

async fetch_orderbook(symbol, depth)[source]

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

class Source[source]

Bases: object

Base mixin for all source adapters.

Adapters inherit from Source and one or more capability protocols. They declare capabilities and render exchange-specific symbol strings.

capabilities()[source]

Return list of declared capabilities.

capability_for(data_type, transport, mode)[source]

Return the declared Capability for this combination, or None.

render_symbol(s)[source]

Render a canonical Symbol to the exchange-specific string.

class TradesHistory[source]

Bases: Source

Protocol: can fetch historical trade pages via REST.

Cursor contract: fetch_trades_page returns (trades, next_cursor). The cursor is an opaque, adapter-defined string used to continue inside the [start_ns, end_ns) window:

  • cursor=None on the first call — anchor on start_ns (or end_ns for adapters that page backward).

  • next_cursor is None when the window is exhausted (the adapter returned a short/last page, or the next item would fall outside the window). Returning a non-None cursor tells the paginator to call again.

This lets the generic paginator drain a window completely — fixing the capped-single-page data loss that affected every liquid pair — without per-exchange chunking in the application layer.

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

Fetch one page of trades; return (trades, next_cursor) (see class).

class TradesLive[source]

Bases: Source

Protocol: can stream live trades via WebSocket.

stream_trades(symbol)[source]

Yield live trades over WebSocket.