finance-query 3.0.0

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

// line 16: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_16() {
    use finance_query::{Ticker, Region};

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        // French stock with France locale
        let ticker = Ticker::builder("MC.PA")
            .region(Region::France)
            .build()
            .await?;

        // German stock with German locale
        let ticker = Ticker::builder("SAP.DE")
            .region(Region::Germany)
            .build()
            .await?;

        // UK stock with UK locale
        let ticker = Ticker::builder("HSBA.L")
            .region(Region::UnitedKingdom)
            .build()
            .await?;
        Ok(())
    }
}

// line 87: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_87() {
    use finance_query::Ticker;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let ticker = Ticker::builder("AAPL")
            .lang("en-US")
            .region_code("US")
            .build()
            .await?;
        Ok(())
    }
}

// line 109: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_109() {
    use finance_query::Ticker;
    use std::time::Duration;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let ticker = Ticker::builder("AAPL")
            .timeout(Duration::from_secs(60))  // 60 second timeout
            .build()
            .await?;
        Ok(())
    }
}

// line 127: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_127() {
    use finance_query::Ticker;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let ticker = Ticker::builder("AAPL")
            .proxy("http://proxy.example.com:8080")
            .build()
            .await?;

        // With authentication
        let ticker = Ticker::builder("AAPL")
            .proxy("http://user:pass@proxy.example.com:8080")
            .build()
            .await?;
        Ok(())
    }
}

// line 156: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_156() {
    use finance_query::{Tickers, Region};
    use std::time::Duration;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let tickers = Tickers::builder(vec!["2330.TW", "2317.TW", "2454.TW"])
            .region(Region::Taiwan)
            .timeout(Duration::from_secs(60))
            .build()
            .await?;
        Ok(())
    }
}

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

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

        // Valid
        let daily = ticker.chart(Interval::OneDay, TimeRange::OneYear).await?;
        let intraday = ticker.chart(Interval::FiveMinutes, TimeRange::OneDay).await?;

        // Invalid - will return error
        // let invalid = ticker.chart(Interval::OneMinute, TimeRange::OneMonth).await?;
        Ok(())
    }
}

// line 281: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_281() {
    use finance_query::{Frequency, StatementType, Ticker};

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

        // Annual statements (default)
        let income_annual = ticker.financials(
            StatementType::Income,
            Frequency::Annual
        ).await?;

        // Quarterly statements
        let income_quarterly = ticker.financials(
            StatementType::Income,
            Frequency::Quarterly
        ).await?;
        Ok(())
    }
}

// line 307: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_307() {
    use finance_query::Ticker;
    use finance_query::format::{Both, Pretty, Raw};

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

        let raw = ticker.quote::<Raw>().await?;       // numeric fields (Option<f64>, Option<i64>)
        let pretty = ticker.quote::<Pretty>().await?; // formatted strings (Option<String>)
        let both = ticker.quote::<Both>().await?;     // raw + formatted pair
        Ok(())
    }
}

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

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        // Default: Yahoo Finance only
        let ticker = Ticker::new("AAPL").await?;

        // Route specific capabilities to preferred providers (routing lives on Providers::builder)
        // (requires the `polygon` and `fmp` features)
        let providers = Providers::builder()
            .route(Capability::QUOTE, [Provider::Polygon, Provider::Yahoo])
            .route(Capability::FUNDAMENTALS, [Provider::Fmp, Provider::Yahoo])
            .fetch(Fetch::Sequential)
            .build()
            .await?;
        let ticker = providers.ticker("AAPL").build().await?;
        Ok(())
    }
}

// line 382: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_382() {
        use finance_query::{Region, Ticker, format::Raw};

        #[tokio::main]
        async fn main() -> Result<(), Box<dyn std::error::Error>> {
            // US stock
            let apple = Ticker::builder("AAPL")
                .region(Region::UnitedStates)
                .logo()
                .build()
                .await?;

            // Taiwan stock
            let tsmc = Ticker::builder("2330.TW")
                .region(Region::Taiwan)
                .logo()
                .build()
                .await?;

            // German stock
            let sap = Ticker::builder("SAP.DE")
                .region(Region::Germany)
                .logo()
                .build()
                .await?;

            // Fetch quotes in parallel
            let (apple_quote, tsmc_quote, sap_quote) = tokio::join!(
                apple.quote::<Raw>(),
                tsmc.quote::<Raw>(),
                sap.quote::<Raw>()
            );
            println!("{:?} {:?} {:?}", apple_quote?.symbol, tsmc_quote?.symbol, sap_quote?.symbol);
            Ok(())
        }
}

// line 427: compile-only (no_run)
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_427() {
        use finance_query::Ticker;
        use std::time::Duration;

        #[tokio::main]
        async fn main() -> Result<(), Box<dyn std::error::Error>> {
            // Configure for corporate network with proxy and longer timeout
            let ticker = Ticker::builder("AAPL")
                .proxy("http://corporate-proxy.company.com:8080")
                .timeout(Duration::from_secs(45))
                .build()
                .await?;
            Ok(())
        }
}