pub struct Tickers { /* private fields */ }Expand description
Multi-symbol ticker for efficient batch operations.
Tickers optimizes data fetching for multiple symbols by:
- Using batch endpoints where available (e.g., /v7/finance/quote)
- Fetching concurrently when batch endpoints don’t exist
- Sharing a single authenticated client across all symbols
- Caching results per symbol
§Example
use finance_query::Tickers;
// Create tickers for multiple symbols
let tickers = Tickers::new(["AAPL", "MSFT", "GOOGL"]).await?;
// Batch fetch all quotes (single API call)
let quotes = tickers.quotes(false).await?;
for (symbol, quote) in "es.quotes {
let price = quote.regular_market_price.as_ref().and_then(|v| v.raw).unwrap_or(0.0);
println!("{}: ${:.2}", symbol, price);
}
// Fetch charts concurrently
use finance_query::{Interval, TimeRange};
let charts = tickers.charts(Interval::OneDay, TimeRange::OneMonth).await?;Implementations§
Source§impl Tickers
impl Tickers
Sourcepub fn builder<S, I>(symbols: I) -> TickersBuilder
pub fn builder<S, I>(symbols: I) -> TickersBuilder
Creates a new builder for Tickers
Sourcepub async fn quotes(&self, include_logo: bool) -> Result<BatchQuotesResponse>
pub async fn quotes(&self, include_logo: bool) -> Result<BatchQuotesResponse>
Batch fetch quotes for all symbols
Uses /v7/finance/quote endpoint - fetches all symbols in a single API call.
When include_logo is true, makes a parallel call for logo URLs.
§Arguments
include_logo- Whether to fetch company logo URLs
Sourcepub async fn quote(&self, symbol: &str, include_logo: bool) -> Result<Quote>
pub async fn quote(&self, symbol: &str, include_logo: bool) -> Result<Quote>
Get a specific quote by symbol (from cache or fetch all)
Sourcepub async fn charts(
&self,
interval: Interval,
range: TimeRange,
) -> Result<BatchChartsResponse>
pub async fn charts( &self, interval: Interval, range: TimeRange, ) -> Result<BatchChartsResponse>
Batch fetch charts for all symbols concurrently
Chart data cannot be batched in a single request, so this fetches all charts concurrently using tokio for maximum performance.
Sourcepub async fn chart(
&self,
symbol: &str,
interval: Interval,
range: TimeRange,
) -> Result<Chart>
pub async fn chart( &self, symbol: &str, interval: Interval, range: TimeRange, ) -> Result<Chart>
Get a specific chart by symbol
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear all caches
Auto Trait Implementations§
impl Freeze for Tickers
impl !RefUnwindSafe for Tickers
impl Send for Tickers
impl Sync for Tickers
impl Unpin for Tickers
impl !UnwindSafe for Tickers
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more