Bybit¶
Capabilities¶
Backfill: OHLC (full), order-book snapshot. No trades.
Stream: OHLC, trades, order book.
OHLC fidelity:
quote_volume✅ native ·trades— null.
Note
Bybit spot exposes only the ~60 most recent trades and no history, so trades
backfill raises NoCapability rather than
returning a misleading recent slice. Live trades are available via the stream.
Symbols¶
BTCUSDT (no separator), spot category.
Example¶
async with Client() as c:
await c.backfill("bybit", "BTC/USDT", "ohlc", span=3600, start="2024-01-01")
API¶
- class BybitSource(http=None)[source]¶
Bybit source adapter (spot + USDT-perpetual funding/open interest).
Backfill: OHLC (full), order-book snapshot, realized funding (
linearperpmarket only), open interest (linearperp, full history back to symbol launch). No trades (see Notes).Stream: OHLC, trades, order book.
See also
dccd.Clientthe public facade.
Notes
Bybit spot exposes only the ~60 most recent trades and no history, so
TradesHistoryis deliberately not implemented — a trades backfill raisesNoCapabilityrather than returning a misleading recent slice. Live trades are still available via the stream.Funding history (
GET /v5/market/funding/history) has two quirks: Bybit rejects a request carryingstartTimewithoutendTime(both must always be sent), and pages come back newest-first — the adapter walks backward, using each page’s oldest timestamp minus one millisecond as the next page’sendTime.Open interest (
GET /v5/market/open-interest) is span-typed (5minto1dbuckets viabybit_oi_interval) and, unlike funding, exposes a realnextPageCursor— it is passed through unchanged as the opaque cursor instead of being reconstructed from timestamps.Examples
>>> from dccd.sources.bybit import BybitSource >>> BybitSource().capability_for(DataType.TRADES, 'rest', 'historical') is None True
- async fetch_funding_page(symbol, start_ns, end_ns, limit, cursor=None)[source]¶
Fetch one page of realized funding rates, walking backward from
end_ns.Bybit’s
funding/historyendpoint rejects a request that carriesstartTimewithoutendTime— both are always sent. Pages are newest-first, so cursor (when set) is the previous page’s oldest timestamp minus 1 ms, reused as this call’sendTime;startTimestays pinned tostart_nsthroughout the walk.linearcategory only — this endpoint has no spot equivalent.
- async fetch_ohlc_page(symbol, span, start_ns, end_ns, limit)[source]¶
Fetch one page of OHLC bars (see
fetch_ohlc_page).
- async fetch_oi_page(symbol, span, start_ns, end_ns, limit, cursor=None)[source]¶
Fetch one page of open interest, following Bybit’s real cursor.
Unlike
funding/history,open-interestreturns a genuineresult.nextPageCursor— it is passed through unchanged rather than reconstructed from timestamps.linearcategory only (no spot equivalent). Returns([], None)when span has nobybit_oi_intervalmapping.
- async fetch_orderbook(symbol, depth)[source]¶
Fetch a current order-book snapshot up to depth levels.