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§
- Binance
Config - 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. - Binance
Kline Stream - A live Binance kline stream.
- Kline
Event - One push from the Binance kline stream.
- RawKline
- RawKline
Payload - RawWs
Envelope - 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_strvalue matches Binance’s wire-format strings ("1m","5m","1h", etc.).