Skip to main content

Module binance

Module binance 

Source
Available on crate feature live-binance only.
Expand description

Binance spot WebSocket kline feed.

Subscribes to Binance’s <symbol>@kline_<interval> stream and emits a KlineEvent every time the server pushes a new tick. The event tells you whether the current candle is still open or has just closed.

Example (requires the live-binance feature):

use wickra_data::live::binance::{BinanceKlineStream, Interval};
let mut stream = BinanceKlineStream::connect(&["BTCUSDT".to_string()], Interval::OneMinute).await?;
while let Some(event) = stream.next_event().await? {
    if event.is_closed {
        println!("closed {} @ {}", event.symbol, event.candle.close);
    }
}

Structs§

BinanceConfig
Tunable knobs for a BinanceKlineStream. The defaults match Binance’s public production endpoint and are right for almost every caller; the fields exist so an integration test or a Binance Testnet user can point the stream at a different base URL and shrink the reconnect timing.
BinanceKlineStream
A live Binance kline stream.
KlineEvent
One push from the Binance kline stream.
RawKline
RawKlinePayload
RawWsEnvelope
Wire-format representation of an incoming Binance kline tick. Public so callers can deserialize it themselves if they prefer.

Enums§

Interval
Supported Binance kline intervals. The as_str value matches Binance’s wire-format strings ("1m", "5m", "1h", etc.).