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` trait abstracts the provider-specific transport and wire
9//! protocol. Yahoo (`YahooStreamSource`) is the reference implementation,
10//! with additional providers (e.g. Polygon) supported through the same
11//! 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 alerts;
43mod batch;
44#[cfg(feature = "polygon")]
45mod book;
46mod client;
47#[cfg(feature = "fred")]
48mod economic;
49mod handle;
50mod news;
51#[cfg(feature = "polygon")]
52mod options;
53#[cfg(feature = "polygon")]
54mod polygon;
55mod pricing;
56mod source;
57mod subscription;
58#[cfg(feature = "polygon")]
59mod trades;
60mod yahoo;
61
62pub use alerts::{
63 AlertCondition, AlertConditionKind, AlertEvaluator, AlertEvent, AlertExt, AlertRule,
64 AlertStream,
65};
66pub use batch::{Batched, StreamBatchExt};
67#[cfg(feature = "polygon")]
68pub use book::{BookLevel, DepthStream, DepthStreamBuilder, OrderBookUpdate};
69pub use client::{PriceSource, PriceStream, PriceStreamBuilder, StreamError, StreamResult};
70#[cfg(feature = "fred")]
71pub use economic::{EconomicStream, EconomicStreamBuilder, SeriesUpdate};
72pub use news::{NewsStream, NewsStreamBuilder};
73#[cfg(feature = "polygon")]
74pub use options::{Greeks, OptionContractUpdate, OptionsChainStream, OptionsChainStreamBuilder};
75#[cfg(feature = "polygon")]
76pub use polygon::AssetClass;
77pub use pricing::{MarketHoursType, OptionType, PriceUpdate, QuoteType};
78#[cfg(feature = "polygon")]
79pub use trades::{TradeStream, TradeStreamBuilder, TradeTick};