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§
- Batch
Charts Response - Response containing charts for multiple symbols.
- Batch
Quotes Response - Response containing quotes for multiple symbols.
- Candle
- A single OHLCV candle/bar
- Capital
Gain - Public capital gain data
- Chart
- Fully typed chart data
- Chart
Meta - 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.
- Financial
Statement - A flattened, user-friendly financial statement
- Formatted
Value - A generic type representing Yahoo Finance’s formatted value pattern
- Indicators
Summary - Summary of all calculated technical indicators
- Industry
- Industry data from Yahoo Finance
- Lookup
Quote - A quote/document result from symbol lookup
- Lookup
Results - Response wrapper for lookup endpoint
- Market
Hours - Flattened response for market hours
- Market
Summary Quote - A single market summary quote (index, currency, commodity, etc.)
- Market
Time - Market time information for a specific market
- News
- A news article
- Option
Chain - Options chain data for a specific expiration
- Option
Contract - An options contract (call or put)
- Options
- Response wrapper for options endpoint
- Options
Quote - Quote data included with options response
- Query
Condition - A single filter condition
- Query
Group - A group of query operands combined with a logical operator
- Quote
- Flattened quote data with deduplicated fields
- Recommendation
- Fully typed recommendation data
- Research
Report - A research report result from search
- Research
Reports - A collection of research reports with DataFrame support.
- Screener
Query - A custom screener query for Yahoo Finance
- Screener
Quote - Quote data from a Yahoo Finance screener
- Screener
Results - Flattened, user-friendly response for screener results
- Search
News - A news result from search
- Search
News List - A collection of search news with DataFrame support.
- Search
Quote - A quote result from symbol search
- Search
Quotes - A collection of search quotes with DataFrame support.
- Search
Results - Response wrapper for search endpoint
- Sector
- Complete sector data with all available information
- Similar
Symbol - A similar/recommended symbol with score
- Spark
Data - Spark chart mini-data for market summary
- Split
- Public stock split data
- Ticker
- Ticker for fetching symbol-specific data.
- Ticker
Builder - Builder for Ticker
- Tickers
- Multi-symbol ticker for efficient batch operations.
- Tickers
Builder - Builder for Tickers
- Transcript
- Full transcript response from Yahoo Finance.
- Transcript
With Meta - Transcript with metadata from the earnings call list.
- Trending
Quote - A trending stock/symbol quote
Enums§
- Frequency
- Frequency for financial data (annual or quarterly)
- Indices
Region - Region categories for world indices
- Interval
- Chart intervals
- Query
Operand - An operand in a query - either a condition or a nested group
- Query
Value - A value in a query condition (can be string or number)
- Region
- Supported regions for Yahoo Finance regional APIs
- Screener
Type - Enum of all predefined Yahoo Finance screeners
- Sector
Type - Market sector types available on Yahoo Finance
- Statement
Type - Statement types for financial data
- Time
Range - Time ranges for chart data
- Value
Format - Value format for API responses
Derive Macros§
- ToData
Frame - Derive macro for automatic DataFrame conversion.