Skip to main content

Crate finance_query

Crate finance_query 

Source
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 crypto feature).
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§

BatchCapitalGainsResponse
Response containing capital gains for multiple symbols.
BatchChartsResponse
Response containing charts for multiple symbols.
BatchDividendsResponse
Response containing dividends for multiple symbols.
BatchFinancialsResponse
Response containing financial statements for multiple symbols.
BatchIndicatorsResponse
Response containing technical indicators for multiple symbols.
BatchNewsResponse
Response containing news articles for multiple symbols.
BatchOptionsResponse
Response containing options chains for multiple symbols.
BatchQuotesResponse
Response containing quotes for multiple symbols.
BatchRecommendationsResponse
Response containing recommendations for multiple symbols.
BatchSparksResponse
Response containing spark data for multiple symbols.
Candle
A single OHLCV candle/bar
CapitalGain
Public capital gain data
Chart
Fully typed chart data
ChartMeta
Metadata for chart data
CikEntry
An entry from the SEC ticker-to-CIK mapping.
ClientHandle
Opaque handle to a shared Yahoo Finance client session.
CompanyFacts
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
DividendAnalytics
Computed analytics derived from a symbol’s dividend history.
EdgarFiling
A single SEC filing with metadata.
EdgarFilingFile
Reference to an additional filing history file for older filings.
EdgarFilingIndex
Filing index response for a specific EDGAR accession.
EdgarFilingIndexItem
Single file entry within an EDGAR filing index.
EdgarFilingRecent
Recent filings data stored as parallel arrays.
EdgarFilings
Container for recent filings and links to older filing history files.
EdgarSearchHit
A single search result hit from EDGAR full-text search (Elasticsearch format).
EdgarSearchHitsContainer
Container for search hits with metadata.
EdgarSearchResults
Full-text search results from SEC EDGAR.
EdgarSearchSource
Source data for a search hit containing the actual filing information.
EdgarSearchTotal
Total count information for search results.
EdgarSubmissions
Full submissions response for a company from SEC EDGAR.
Exchange
Information about a supported exchange.
FactConcept
A single XBRL concept (e.g., “Revenue”) with all reported values.
FactUnit
A single data point for an XBRL fact.
FactsByTaxonomy
Facts within a single taxonomy (e.g., “us-gaap”).
FearAndGreed
The current CNN Fear & Greed Index reading from Alternative.me.
FinancialStatement
A flattened, user-friendly financial statement
FormattedValue
A generic type representing Yahoo Finance’s formatted value pattern
IndustryData
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 typed filter condition for a screener query.
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 typed 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
SectorData
Complete sector data with all available information
SimilarSymbol
A similar/recommended symbol with score
Spark
Sparkline data for a single symbol.
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§

ConditionValue
The value portion of a typed screener condition.
EquityField
Typed field names for equity custom screener queries.
ExchangeCode
Typed exchange code for screener queries.
FearGreedLabel
Classification label for the Fear & Greed Index value.
Frequency
Frequency for financial data (annual or quarterly)
FundField
Typed field names for mutual fund custom screener queries.
IndicesRegion
Region categories for world indices
Industry
Typed industry identifier for the industry endpoint and custom screener queries.
Interval
Chart intervals
LogicalOperator
Logical operator for combining multiple screener conditions.
Operator
Comparison operator for screener query conditions.
QueryOperand
An operand within a query group — either a leaf condition or a nested group.
QuoteType
Quote type for custom screener queries.
Region
Supported regions for Yahoo Finance regional APIs
Screener
Predefined Yahoo Finance screener selector
ScreenerFundCategory
Morningstar fund category for mutual fund screener queries.
ScreenerPeerGroup
Equity peer group for screener queries.
Sector
Market sector types available on Yahoo Finance
SortType
Sort direction for screener results.
StatementType
Statement types for financial data
TimeRange
Time ranges for chart data
ValueFormat
Value format for API responses

Traits§

ScreenerField
A typed screener field usable in custom query conditions, sorting, and response field selection.
ScreenerFieldExt
Fluent condition-building methods on any ScreenerField type.

Type Aliases§

EquityScreenerQuery
Type alias for equity (stock) screener queries.
FundScreenerQuery
Type alias for mutual fund screener queries.

Derive Macros§

ToDataFrame
Derive macro for automatic DataFrame conversion.