Crate finance_query

Crate finance_query 

Source
Expand description

§finance-query

A Rust library for fetching financial data from Yahoo Finance. Inspired by yfinance, with smart lazy loading for efficient data fetching.

§Quick Start

use finance_query::Ticker;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Simple: Create a ticker with default configuration
    let ticker = Ticker::new("AAPL").await?;

    // First access to any quote property fetches ALL quote modules in one request
    if let Some(financials) = ticker.financial_data().await? {
        println!("Financial data: {:?}", financials);
    }

    // Subsequent accesses use cached data (no additional network calls)
    if let Some(profile) = ticker.asset_profile().await? {
        println!("Company profile: {:?}", profile);
    }

    // Chart data is fetched separately and cached by interval/range
    let chart = ticker.chart(
        finance_query::Interval::OneDay,
        finance_query::TimeRange::OneMonth
    ).await?;
    println!("Candles: {}", chart.candles.len());

    // Builder pattern: Fluent configuration
    let ticker_jp = Ticker::builder("7203.T")
        .lang("ja-JP")
        .region_code("JP")
        .timeout(std::time::Duration::from_secs(30))
        .build()
        .await?;

    Ok(())
}

§Lazy Loading

The library uses lazy loading:

  • Quote data: All ~30 quote modules fetched together on first property access
  • Chart data: Fetched per (interval, range) combination and cached
  • Recommendations: Fetched once and cached

This approach minimizes network requests while keeping memory usage efficient.

Re-exports§

pub use error::Result;
pub use error::YahooError;
pub use finance::LookupOptions;
pub use finance::LookupType;
pub use finance::SearchOptions;

Modules§

error
Error types and result definitions.
finance
Non-symbol-specific operations (search, lookup, screeners, market data, etc.). Non-symbol-specific Yahoo Finance operations
screener_query
Custom screener query types and operators
streaming
Real-time price streaming from Yahoo Finance WebSocket

Structs§

BatchChartsResponse
Response containing charts for multiple symbols.
BatchQuotesResponse
Response containing quotes for multiple symbols.
Candle
A single OHLCV candle/bar
CapitalGain
Public capital gain data
Chart
Fully typed chart data
ChartMeta
Metadata for chart data
Contracts
A collection of option contracts with DataFrame support.
Currency
A single currency with its properties
Dividend
Public dividend data
Exchange
Information about a supported exchange.
FinancialStatement
A flattened, user-friendly financial statement
FormattedValue
A generic type representing Yahoo Finance’s formatted value pattern
IndicatorsSummary
Summary of all calculated technical indicators
Industry
Industry data from Yahoo Finance
LookupQuote
A quote/document result from symbol lookup
LookupResults
Response wrapper for lookup endpoint
MarketHours
Flattened response for market hours
MarketSummaryQuote
A single market summary quote (index, currency, commodity, etc.)
MarketTime
Market time information for a specific market
News
A news article
OptionChain
Options chain data for a specific expiration
OptionContract
An options contract (call or put)
Options
Response wrapper for options endpoint
OptionsQuote
Quote data included with options response
QueryCondition
A single filter condition
QueryGroup
A group of query operands combined with a logical operator
Quote
Flattened quote data with deduplicated fields
Recommendation
Fully typed recommendation data
ResearchReport
A research report result from search
ResearchReports
A collection of research reports with DataFrame support.
ScreenerQuery
A custom screener query for Yahoo Finance
ScreenerQuote
Quote data from a Yahoo Finance screener
ScreenerResults
Flattened, user-friendly response for screener results
SearchNews
A news result from search
SearchNewsList
A collection of search news with DataFrame support.
SearchQuote
A quote result from symbol search
SearchQuotes
A collection of search quotes with DataFrame support.
SearchResults
Response wrapper for search endpoint
Sector
Complete sector data with all available information
SimilarSymbol
A similar/recommended symbol with score
SparkData
Spark chart mini-data for market summary
Split
Public stock split data
Ticker
Ticker for fetching symbol-specific data.
TickerBuilder
Builder for Ticker
Tickers
Multi-symbol ticker for efficient batch operations.
TickersBuilder
Builder for Tickers
Transcript
Full transcript response from Yahoo Finance.
TranscriptWithMeta
Transcript with metadata from the earnings call list.
TrendingQuote
A trending stock/symbol quote

Enums§

Frequency
Frequency for financial data (annual or quarterly)
IndicesRegion
Region categories for world indices
Interval
Chart intervals
QueryOperand
An operand in a query - either a condition or a nested group
QueryValue
A value in a query condition (can be string or number)
Region
Supported regions for Yahoo Finance regional APIs
ScreenerType
Enum of all predefined Yahoo Finance screeners
SectorType
Market sector types available on Yahoo Finance
StatementType
Statement types for financial data
TimeRange
Time ranges for chart data
ValueFormat
Value format for API responses

Derive Macros§

ToDataFrame
Derive macro for automatic DataFrame conversion.