finance_query/streaming/mod.rs
1//! Real-time price streaming from Yahoo Finance WebSocket
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//! Yahoo Finance provides a WebSocket endpoint that streams real-time price data
9//! in protobuf format. This module handles:
10//!
11//! - WebSocket connection and reconnection
12//! - Protobuf message decoding
13//! - Subscription management with automatic heartbeats
14//! - A clean Stream API for consuming updates
15//!
16//! # Example
17//!
18//! ```no_run
19//! use finance_query::streaming::PriceStream;
20//! use futures::StreamExt;
21//!
22//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
23//! // Subscribe to symbols
24//! let mut stream = PriceStream::subscribe(&["AAPL", "NVDA", "TSLA"]).await?;
25//!
26//! // Process updates as they arrive
27//! while let Some(price) = stream.next().await {
28//! println!("{}: ${:.2} ({:+.2}%)",
29//! price.id,
30//! price.price,
31//! price.change_percent
32//! );
33//! }
34//! # Ok(())
35//! # }
36//! ```
37
38mod client;
39mod pricing;
40
41pub use client::{PriceStream, PriceStreamBuilder, StreamError, StreamResult};
42pub use pricing::{MarketHoursType, OptionType, PriceUpdate, QuoteType};