Expand description
§finance-query
A Rust library for querying financial data. 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::FinanceError;pub use error::Result;pub use finance::LookupOptions;pub use finance::LookupType;pub use finance::SearchOptions;pub use indicators::AroonData;pub use indicators::BollingerBands;pub use indicators::BollingerBandsData;pub use indicators::BullBearPowerData;pub use indicators::CandlePattern;pub use indicators::DonchianChannelsData;pub use indicators::ElderRayData;pub use indicators::IchimokuData;pub use indicators::Indicator;pub use indicators::IndicatorError;pub use indicators::IndicatorResult;pub use indicators::IndicatorsSummary;pub use indicators::KeltnerChannelsData;pub use indicators::MacdData;pub use indicators::MacdResult;pub use indicators::PatternSentiment;pub use indicators::StochasticData;pub use indicators::SuperTrendData;pub use indicators::atr;pub use indicators::patterns;
Modules§
- backtesting
- Backtesting engine for trading strategy simulation.
- crypto
- CoinGecko cryptocurrency data (requires
cryptofeature). - edgar
- SEC EDGAR API client for filing history, XBRL data, and full-text search. SEC EDGAR API client.
- error
- Error types and result definitions.
- feeds
- RSS/Atom news feed aggregation.
- finance
- Non-symbol-specific operations (search, lookup, screeners, market data, etc.). Non-symbol-specific Yahoo Finance operations
- fred
- Macro-economic data sources: FRED API and US Treasury yield curve.
- indicators
- Technical analysis indicators for financial data.
- risk
- Standalone risk analytics.
- streaming
- Real-time price streaming from Yahoo Finance WebSocket
Structs§
- Batch
Capital Gains Response - Response containing capital gains for multiple symbols.
- Batch
Charts Response - Response containing charts for multiple symbols.
- Batch
Dividends Response - Response containing dividends for multiple symbols.
- Batch
Financials Response - Response containing financial statements for multiple symbols.
- Batch
Indicators Response - Response containing technical indicators for multiple symbols.
- Batch
News Response - Response containing news articles for multiple symbols.
- Batch
Options Response - Response containing options chains for multiple symbols.
- Batch
Quotes Response - Response containing quotes for multiple symbols.
- Batch
Recommendations Response - Response containing recommendations for multiple symbols.
- Batch
Sparks Response - Response containing spark data 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
- CikEntry
- An entry from the SEC ticker-to-CIK mapping.
- Client
Handle - Opaque handle to a shared Yahoo Finance client session.
- Company
Facts - Complete company facts response containing all XBRL financial data.
- Contracts
- A collection of option contracts with DataFrame support.
- Currency
- A single currency with its properties
- Dividend
- Public dividend data
- Dividend
Analytics - Computed analytics derived from a symbol’s dividend history.
- Edgar
Filing - A single SEC filing with metadata.
- Edgar
Filing File - Reference to an additional filing history file for older filings.
- Edgar
Filing Index - Filing index response for a specific EDGAR accession.
- Edgar
Filing Index Item - Single file entry within an EDGAR filing index.
- Edgar
Filing Recent - Recent filings data stored as parallel arrays.
- Edgar
Filings - Container for recent filings and links to older filing history files.
- Edgar
Search Hit - A single search result hit from EDGAR full-text search (Elasticsearch format).
- Edgar
Search Hits Container - Container for search hits with metadata.
- Edgar
Search Results - Full-text search results from SEC EDGAR.
- Edgar
Search Source - Source data for a search hit containing the actual filing information.
- Edgar
Search Total - Total count information for search results.
- Edgar
Submissions - Full submissions response for a company from SEC EDGAR.
- Exchange
- Information about a supported exchange.
- Fact
Concept - A single XBRL concept (e.g., “Revenue”) with all reported values.
- Fact
Unit - A single data point for an XBRL fact.
- Facts
ByTaxonomy - Facts within a single taxonomy (e.g., “us-gaap”).
- Fear
AndGreed - The current CNN Fear & Greed Index reading from Alternative.me.
- Financial
Statement - A flattened, user-friendly financial statement
- Formatted
Value - A generic type representing Yahoo Finance’s formatted value pattern
- Industry
Data - 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 typed filter condition for a screener query.
- 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 typed 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
Data - Complete sector data with all available information
- Similar
Symbol - A similar/recommended symbol with score
- Spark
- Sparkline data for a single symbol.
- 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§
- Condition
Value - The value portion of a typed screener condition.
- Equity
Field - Typed field names for equity custom screener queries.
- Exchange
Code - Typed exchange code for screener queries.
- Fear
Greed Label - Classification label for the Fear & Greed Index value.
- Frequency
- Frequency for financial data (annual or quarterly)
- Fund
Field - Typed field names for mutual fund custom screener queries.
- Indices
Region - Region categories for world indices
- Industry
- Typed industry identifier for the industry endpoint and custom screener queries.
- Interval
- Chart intervals
- Logical
Operator - Logical operator for combining multiple screener conditions.
- Operator
- Comparison operator for screener query conditions.
- Query
Operand - An operand within a query group — either a leaf condition or a nested group.
- Quote
Type - Quote type for custom screener queries.
- Region
- Supported regions for Yahoo Finance regional APIs
- Screener
- Predefined Yahoo Finance screener selector
- Screener
Fund Category - Morningstar fund category for mutual fund screener queries.
- Screener
Peer Group - Equity peer group for screener queries.
- Sector
- Market sector types available on Yahoo Finance
- Sort
Type - Sort direction for screener results.
- Statement
Type - Statement types for financial data
- Time
Range - Time ranges for chart data
- Value
Format - Value format for API responses
Traits§
- Screener
Field - A typed screener field usable in custom query conditions, sorting, and response field selection.
- Screener
Field Ext - Fluent condition-building methods on any
ScreenerFieldtype.
Type Aliases§
- Equity
Screener Query - Type alias for equity (stock) screener queries.
- Fund
Screener Query - Type alias for mutual fund screener queries.
Derive Macros§
- ToData
Frame - Derive macro for automatic DataFrame conversion.