opendeviationbar-client
Client library for consuming open deviation bar data via SSE from the ODB sidecar.
Usage
use opendeviationbar_client::{OdbSseClient, OdbSseConfig, OdbSseEvent};
use futures::StreamExt;
let client = OdbSseClient::new(OdbSseConfig {
host: "127.0.0.1".into(),
port: 8081,
symbols: vec!["BTCUSDT".into()],
thresholds: vec![250],
});
let mut stream = std::pin::pin!(client.connect());
while let Some(event) = stream.next().await {
match event {
OdbSseEvent::Bar(bar) => println!("{} @{}: {}", bar.symbol, bar.threshold, bar.close),
OdbSseEvent::Connected => println!("connected"),
OdbSseEvent::Heartbeat => {},
OdbSseEvent::DeserializationError { error, .. } => eprintln!("bad bar: {error}"),
OdbSseEvent::Disconnected(reason) => println!("disconnected: {reason}"),
}
}
Features
- SSE protocol: Full RFC compliance via
eventsource-client
- Reconnection: Built-in exponential backoff + jitter, server
retry: directive honoring
- Typed bars:
OdbBar with OHLCV, microstructure features, and #[serde(flatten)] for forward compatibility
- Transport: Pluggable reqwest-based HTTP transport (no hyper dependency)
License
MIT