Skip to main content

Module kline

Module kline 

Source
Expand description

Live kline (candle) wire models common to BinanceSpot (@kline_) and BinanceFuturesUsd (@continuousKline_). Live Binance kline (candle) WebSocket payloads and their normalisation to Candle.

Covers both the BinanceSpot @kline_<interval> stream and the BinanceFuturesUsdMarket @continuousKline_<interval> stream (perpetual-only). Endpoints are public/unauthenticated.

§Closed candles only (no repaint)

rustrade emits closed candles only — an in-progress kline (k.x == false) yields an empty MarketIter, so consumers never see a repainting/lookahead value. The exclusive close_time boundary is recomputed library-side as open + interval (see close_time_from_open), not taken from Binance’s wire T (its period-end − 1ms convention) — consumers comparing against the raw T will see a 1ms difference by design.

§Reconnection: no replay, no dedup (consumer policy)

Across a reconnect the underlying Connector / ReconnectingStream re-subscribes but does not replay or de-duplicate: a closed candle straddling the disconnect may be re-delivered or skipped. De-duplication and gap-back-fill are consumer policy, not library policy (consistent with rustrade’s “no consumer-specific policy in the library” rule). A consumer wanting a gapless series should reconcile the live candle stream against a fetch_candles backfill keyed on close_time (the field both paths agree on, since open ≡ close − interval).

Structs§

BinanceContinuousKline
BinanceFuturesUsdMarket real-time continuous-contract (perpetual) kline message.
BinanceKline
BinanceSpot real-time kline (candle) message.
BinanceKlineData
The inner k payload shared by the BinanceSpot @kline_ and BinanceFuturesUsdMarket @continuousKline_ streams.