Skip to main content

Crate opendeviationbar_client

Crate opendeviationbar_client 

Source
Expand description

Client library for consuming open deviation bar data via SSE.

Provides a typed Rust API for connecting to the ODB sidecar’s SSE endpoint and receiving completed bars as a stream.

§Example

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}"),
    }
}

Structs§

OdbBar
A completed or forming bar received via SSE, with typed fields.
OdbSseClient
Client for consuming open deviation bars via SSE from the ODB sidecar.
OdbSseConfig
Configuration for connecting to the ODB sidecar SSE endpoint.

Enums§

OdbSseEvent
Events emitted by the SSE client stream.