Skip to main content

YahooFinanceClient

Struct YahooFinanceClient 

Source
pub struct YahooFinanceClient { /* private fields */ }
Expand description

Main client for Yahoo Finance API requests.

This client handles authenticated requests to Yahoo Finance, automatically managing crumb tokens and retrying on auth failures.

Implementations§

Source§

impl YahooFinanceClient

Source

pub fn new( auth_manager: Arc<YahooAuthManager>, fetch_client: Arc<FetchClient>, ) -> Self

Create a new YahooFinanceClient.

§Arguments
  • auth_manager - Shared authentication manager
  • fetch_client - Shared HTTP client
Source

pub fn fetch_client(&self) -> Arc<FetchClient> ⓘ

Expose the underlying fetch client for auxiliary HTTP calls (e.g., logo fetching).

Source

pub async fn get_quote(&self, symbol: &str) -> Result<Value, YahooError>

Get detailed quote data for a symbol.

Source

pub async fn get_simple_quotes( &self, symbols: &[&str], ) -> Result<Value, YahooError>

Get simple quote data for multiple symbols.

Source

pub async fn get_chart( &self, symbol: &str, interval: &str, range: &str, ) -> Result<Value, YahooError>

Get chart data for a symbol.

Source

pub async fn get_chart_with_periods( &self, symbol: &str, interval: &str, period1: i64, period2: i64, ) -> Result<Value, YahooError>

Get chart data using period1 and period2 (Unix timestamps) instead of range.

Source

pub async fn search( &self, query: &str, hits: usize, ) -> Result<Value, YahooError>

Search for symbols.

Source

pub async fn get_similar_quotes( &self, symbol: &str, limit: usize, ) -> Result<Value, YahooError>

Get similar/recommended quotes for a symbol.

Source

pub async fn get_fundamentals_timeseries( &self, symbol: &str, period1: i64, period2: i64, types: &[&str], ) -> Result<Value, YahooError>

Get fundamentals timeseries data.

Source

pub async fn get_quote_summary( &self, symbol: &str, modules: &[&str], ) -> Result<Value, YahooError>

Get quote summary with specified modules.

Source

pub async fn get_quote_type(&self, symbol: &str) -> Result<Value, YahooError>

Get quote type information.

Source

pub async fn get_earnings_transcript( &self, event_id: &str, company_id: &str, ) -> Result<Value, YahooError>

Get earnings transcript.

Source

pub async fn make_request( &self, url: &str, params: Option<&[(&str, &str)]>, ) -> Result<Response, YahooError>

Make a Yahoo Finance API request and return the raw response. This is useful for endpoints that need custom handling.

Source

pub async fn get_actions( &self, symbol: &str, period: &str, ) -> Result<ActionsResponse, YahooError>

Get stock actions (dividends, splits, capital gains) for a symbol

§Arguments
  • symbol - The stock symbol
  • period - Time period (e.g., “max”, “5y”, “1y”)
§Example
ⓘ
let actions = client.get_actions("AAPL", "max").await?;
println!("Total dividends: {}", actions.total_dividends());
Source

pub async fn get_dividends( &self, symbol: &str, period: &str, ) -> Result<Vec<Dividend>, YahooError>

Get only dividends for a symbol

Source

pub async fn get_splits( &self, symbol: &str, period: &str, ) -> Result<Vec<StockSplit>, YahooError>

Get only stock splits for a symbol

Source

pub async fn get_capital_gains( &self, symbol: &str, period: &str, ) -> Result<Vec<CapitalGain>, YahooError>

Get only capital gains for a symbol

Source

pub async fn get_option_chain( &self, symbol: &str, date: Option<&str>, ) -> Result<OptionChain, YahooError>

Get option chain for a symbol and expiration date

§Arguments
  • symbol - The stock symbol
  • date - Optional expiration date (YYYY-MM-DD). If None, returns nearest expiration
§Example
ⓘ
let chain = client.get_option_chain("AAPL", Some("2025-12-19")).await?;
println!("Calls: {}, Puts: {}", chain.calls.len(), chain.puts.len());
Source

pub async fn get_option_expirations( &self, symbol: &str, ) -> Result<OptionExpirations, YahooError>

Get all available option expiration dates for a symbol

§Example
ⓘ
let expirations = client.get_option_expirations("AAPL").await?;
for exp in &expirations.expirations {
    println!("Expiration: {}", exp);
}
Source

pub async fn get_calendar(&self, symbol: &str) -> Result<Calendar, YahooError>

Get calendar events (earnings dates, dividend dates) for a symbol

§Example
ⓘ
let calendar = client.get_calendar("AAPL").await?;
if let Some(date) = calendar.earnings_date {
    println!("Next earnings: {}", date);
}
Source

pub async fn get_sec_filings( &self, symbol: &str, ) -> Result<SecFilingsResponse, YahooError>

Get SEC filings for a symbol

§Example
ⓘ
let filings = client.get_sec_filings("AAPL").await?;
for filing in &filings.filings {
    println!("{}: {} - {}", filing.date, filing.filing_type, filing.title);
}
Source

pub async fn get_sustainability( &self, symbol: &str, ) -> Result<SustainabilityScores, YahooError>

Get ESG/Sustainability scores for a symbol

§Example
ⓘ
let esg = client.get_sustainability("AAPL").await?;
if let Some(score) = esg.total_esg {
    println!("ESG Score: {:.1} (Rating: {})", score, esg.rating().unwrap_or("N/A"));
}
Source

pub async fn get_industry( &self, industry_key: &str, ) -> Result<Industry, YahooError>

Get industry data including top performing and growth companies

§Arguments
  • industry_key - The industry key (e.g., “technology-hardware”)
§Example
ⓘ
let industry = client.get_industry("technology-hardware").await?;
println!("Industry: {} (Sector: {:?})", industry.name, industry.sector_name);
Source

pub async fn get_market_status( &self, market: &str, ) -> Result<MarketStatus, YahooError>

Get market status (open/closed/pre/post)

§Arguments
  • market - Market identifier (e.g., “us_market”, “gb_market”)
§Example
ⓘ
let status = client.get_market_status("us_market").await?;
println!("Market is {}", if status.is_open() { "open" } else { "closed" });
Source

pub async fn get_market_summary( &self, market: &str, ) -> Result<MarketSummaryResponse, YahooError>

Get market summary with major indices

§Arguments
  • market - Market identifier (e.g., “us_market”)
§Example
ⓘ
let summary = client.get_market_summary("us_market").await?;
for index in &summary.indices {
    println!("{}: {} ({:+.2}%)", index.short_name, index.price, index.percent_change);
}
Source

pub async fn get_movers( &self, count: MoverCount, ) -> Result<(Vec<MarketMover>, Vec<MarketMover>, Vec<MarketMover>), YahooError>

Get market movers (most active, gainers, losers)

§Arguments
  • count - Number of movers to return (25, 50, or 100)
§Example
ⓘ
use finance_query_core::MoverCount;

let (actives, gainers, losers) = client.get_movers(MoverCount::Fifty).await?;
println!("Top gainer: {} ({:+})", gainers[0].name, gainers[0].percent_change);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more