finance-query 3.0.0

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

// line 58
#[rustfmt::skip]
#[test]
fn doc_block_line_58() {
    use finance_query::Ticker;
    use finance_query::format::Both;

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

        if let Some(price) = quote.regular_market_price.as_ref().and_then(|v| v.raw) {
            println!("AAPL: ${:.2}", price);
        }
        Ok(())
    }
    main();
}

// line 76
#[rustfmt::skip]
#[test]
fn doc_block_line_76() {
    use finance_query::{Tickers, Interval, TimeRange};

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        // Fetch quotes for multiple symbols in one request
        let tickers = Tickers::builder(vec!["AAPL", "MSFT", "GOOGL"]).logo().build().await?;
        let response = tickers.quotes().await?;

        for (symbol, quote) in &response.quotes {
            if let Some(price) = quote.regular_market_price.as_ref().and_then(|v| v.raw) {
                println!("{}: ${:.2}", symbol, price);
            }
        }
        Ok(())
    }
    main();
}

// line 96
#[rustfmt::skip]
#[test]
fn doc_block_line_96() {
    use finance_query::edgar;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        edgar::init("your.email@example.com")?;

        // Resolve ticker to CIK
        let cik = edgar::resolve_cik("AAPL").await?;

        // Get filing history
        let submissions = edgar::submissions(cik).await?;
        if let Some(name) = &submissions.name {
            println!("Company: {}", name);
        }

        // Get XBRL financial data
        let facts = edgar::company_facts(cik).await?;
        if let Some(us_gaap) = facts.facts.get("us-gaap")
            && let Some(revenue) = us_gaap.0.get("Revenues")
            && let Some(usd) = revenue.units.get("USD")
        {
            for point in usd.iter().take(3) {
                if let (Some(fy), Some(val)) = (point.fy, point.val) {
                    println!("FY {}: ${}", fy, val);
                }
            }
        }
        Ok(())
    }
    main();
}