finance_query/streaming/mod.rs
1//! Real-time price streaming with pluggable provider backends.
2//!
3//! This module provides a Stream-based API for receiving real-time price updates,
4//! similar to Kotlin Flow or Rx observables.
5//!
6//! # Overview
7//!
8//! A [`StreamSource`](source::StreamSource) trait abstracts the provider-specific
9//! transport and wire protocol. Yahoo ([`YahooStreamSource`](yahoo::YahooStreamSource))
10//! is the reference implementation, with additional providers (e.g. Polygon)
11//! supported through the same abstraction.
12//!
13//! This module handles:
14//!
15//! - Provider-agnostic reconnection logic
16//! - Subscription management with automatic heartbeats
17//! - Protobuf message decoding (Yahoo)
18//! - A clean Stream API for consuming updates
19//!
20//! # Example
21//!
22//! ```no_run
23//! use finance_query::streaming::PriceStream;
24//! use futures::StreamExt;
25//!
26//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
27//! // Subscribe to symbols
28//! let mut stream = PriceStream::subscribe(["AAPL", "NVDA", "TSLA"]).await?;
29//!
30//! // Process updates as they arrive
31//! while let Some(price) = stream.next().await {
32//! println!("{}: ${:.2} ({:+.2}%)",
33//! price.id,
34//! price.price,
35//! price.change_percent
36//! );
37//! }
38//! # Ok(())
39//! # }
40//! ```
41
42mod client;
43mod news;
44mod pricing;
45mod source;
46mod subscription;
47mod yahoo;
48
49pub use client::{PriceStream, PriceStreamBuilder, StreamError, StreamResult};
50pub use news::{NewsStream, NewsStreamBuilder};
51pub use pricing::{MarketHoursType, OptionType, PriceUpdate, QuoteType};