pub struct IndexStream;Expand description
A stream that yields market index updates at regular intervals.
Implementations§
Source§impl IndexStream
impl IndexStream
Sourcepub fn create(
client: Arc<YahooFinanceClient>,
index_symbols: Vec<String>,
poll_interval: Duration,
) -> Pin<Box<dyn Stream<Item = Result<Vec<MarketIndex>, YahooError>> + Send>>
pub fn create( client: Arc<YahooFinanceClient>, index_symbols: Vec<String>, poll_interval: Duration, ) -> Pin<Box<dyn Stream<Item = Result<Vec<MarketIndex>, YahooError>> + Send>>
Create a new index stream that fetches index data at the specified interval.
§Arguments
client- The Yahoo Finance client to use for fetching dataindex_symbols- List of index symbols to track (e.g., “^GSPC”, “^DJI”, “^IXIC”)poll_interval- How often to fetch new data
§Example
ⓘ
use finance_query_core::{IndexStream, YahooFinanceClient};
use std::time::Duration;
use futures_util::StreamExt;
// Stream S&P 500, Dow Jones, and NASDAQ
let symbols = vec!["^GSPC".to_string(), "^DJI".to_string(), "^IXIC".to_string()];
let stream = IndexStream::create(&client, symbols, Duration::from_secs(5));
while let Some(result) = stream.next().await {
match result {
Ok(indices) => {
for index in indices {
println!("{}: {} ({:+})", index.name, index.value, index.percent_change);
}
}
Err(e) => eprintln!("Error: {}", e),
}
}Sourcepub fn with_default_interval(
client: Arc<YahooFinanceClient>,
index_symbols: Vec<String>,
) -> Pin<Box<dyn Stream<Item = Result<Vec<MarketIndex>, YahooError>> + Send>>
pub fn with_default_interval( client: Arc<YahooFinanceClient>, index_symbols: Vec<String>, ) -> Pin<Box<dyn Stream<Item = Result<Vec<MarketIndex>, YahooError>> + Send>>
Create an index stream with a default 5-second interval.
Sourcepub fn us_major_indices(
client: Arc<YahooFinanceClient>,
poll_interval: Duration,
) -> Pin<Box<dyn Stream<Item = Result<Vec<MarketIndex>, YahooError>> + Send>>
pub fn us_major_indices( client: Arc<YahooFinanceClient>, poll_interval: Duration, ) -> Pin<Box<dyn Stream<Item = Result<Vec<MarketIndex>, YahooError>> + Send>>
Create a stream for major US indices (S&P 500, Dow Jones, NASDAQ).
Auto Trait Implementations§
impl Freeze for IndexStream
impl RefUnwindSafe for IndexStream
impl Send for IndexStream
impl Sync for IndexStream
impl Unpin for IndexStream
impl UnsafeUnpin for IndexStream
impl UnwindSafe for IndexStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more