finance-query 3.0.0

A Rust library for querying financial data
Documentation
// @generated by `cargo soothfast docs gen-tests`
// source: docs/library/tickers.md
#![allow(unused)]

// line 122: compile-only (no_run)
#[cfg(feature = "polygon")]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_122() {
    use finance_query::{Capability, Fetch, Provider, Providers};

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let providers = Providers::builder()
            .route(Capability::QUOTE, [Provider::Polygon, Provider::Yahoo])
            .fetch(Fetch::Sequential)
            .build()
            .await?;
        let tickers = providers.tickers(["AAPL", "NVDA"]).build().await?;
        Ok(())
    }
}

// line 931: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_931() {
        use finance_query::{Interval, Tickers, TimeRange};

        #[tokio::main]
        async fn main() -> Result<(), Box<dyn std::error::Error>> {
            // Good: Reuse Tickers instance for multiple operations
            let tickers = Tickers::builder(vec!["AAPL", "GOOGL", "INVALID", "MSFT"]).logo().build().await?;

            // First operation - fetches data
            let quotes_response = tickers.quotes().await?;

            // Handle partial failures - check which symbols failed
            for (symbol, error) in &quotes_response.errors {
                println!("Failed to fetch {}: {}", symbol, error);
            }

            // Process successful results
            for (symbol, quote) in &quotes_response.quotes {
                let price = quote.regular_market_price.as_ref().and_then(|v| v.raw).unwrap_or(0.0);
                println!("{}: ${:.2}", symbol, price);
            }

            // Second operation - uses cached data (no network request)
            let charts_response = tickers.charts(Interval::OneDay, TimeRange::OneMonth).await?;
            Ok(())
        }
}