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 adapters¶
Read-only view of all registered adapters keyed by exchange name.
Used by
dccd.Clientto enter/exit every adapter’s HTTP client in a singleasync withblock, keeping one pool alive for the lifetime of the context.
- property exchanges¶
Names of all registered exchanges.
- get_ohlc_history(exchange)[source]¶
Return name as an
OHLCHistoryor raise NoCapability.
- get_orderbook_live(exchange)[source]¶
Return name as an
OrderBookLiveor raise NoCapability.
- get_orderbook_snapshot(exchange)[source]¶
Return name as an
OrderBookSnapshotRESTor raise NoCapability.
- get_trades_history(exchange)[source]¶
Return name as a
TradesHistoryor raise NoCapability.
- get_trades_live(exchange)[source]¶
Return name as a
TradesLiveor raise NoCapability.
Source protocols¶
Source protocols — fine-grained per (data_type × mode).
- class OrderBookLive[source]¶
Bases:
SourceProtocol: can stream live order book snapshots/deltas via WebSocket.
- stream_orderbook(symbol, depth, *, min_interval=0.0)[source]¶
Yield live order-book snapshots over WebSocket.
- Parameters:
- symbolSymbol
- depthint
Maximum number of levels per side to include in each snapshot.
- min_intervalfloat, optional
Minimum seconds between emitted snapshots.
0.0(default) preserves the legacy per-frame behaviour — every WS frame yields a snapshot. Passsnapshot_intervalfrom the job spec to move the throttle upstream so pydantic objects are only constructed for frames that will actually be saved.
- class OrderBookSnapshotREST[source]¶
Bases:
SourceProtocol: can fetch an order book snapshot via REST.
- class Source[source]¶
Bases:
objectBase mixin for all source adapters.
Adapters inherit from
Sourceand one or more capability protocols. They declare capabilities and render exchange-specific symbol strings.- capability_for(data_type, transport, mode)[source]¶
Return the declared
Capabilityfor this combination, or None.
- property http_client¶
Return the adapter’s shared
AsyncHTTPClient.REST adapters store their client in
self._httpand return it here so callers (e.g.backfill) can hold the context open for an entire multi-page operation — keeping_depth >= 1across pages so no TCP/TLS re-handshake occurs between pages.WebSocket-only adapters return
None(default).
- class TradesHistory[source]¶
Bases:
SourceProtocol: can fetch historical trade pages via REST.
Cursor contract:
fetch_trades_pagereturns(trades, next_cursor). The cursor is an opaque, adapter-defined string used to continue inside the[start_ns, end_ns)window:cursor=Noneon the first call — anchor onstart_ns(orend_nsfor adapters that page backward).next_cursorisNonewhen the window is exhausted (the adapter returned a short/last page, or the next item would fall outside the window). Returning a non-Nonecursor 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.
- default_http_client(exchange)[source]¶
Build an
AsyncHTTPClientwired to the limiter.REST adapters call this to construct their default shared client so that every outbound request is throttled by the process-wide per-exchange
shared_limiter. Keeping the wiring here (rather than in each adapter) means a single seam controls proactive rate-limiting for all exchanges.- Parameters:
- exchangestr
Exchange name used to key the limiter bucket.
- Returns:
- AsyncHTTPClient