finance-query 3.0.0

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

// line 30: compile-only (no_run)
#[cfg(feature = "translation")]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_30() {
    use finance_query::Ticker;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let ticker = Ticker::builder("7203.T").lang("ja").build().await?;
        let quote = ticker.quote::<finance_query::format::Raw>().await?;
        // quote.sector_disp / long_business_summary are now Japanese.
        Ok(())
    }
}

// line 44: compile-only (no_run)
#[cfg(feature = "translation")]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_44() {
    use finance_query::Tickers;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let tickers = Tickers::builder(["AAPL", "NVDA"]).lang("de").build().await?;
        let news = tickers.news().await?; // titles translated to German
        Ok(())
    }
}

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

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let providers = Providers::builder()
            .route(Capability::QUOTE, [Provider::Yahoo])
            .lang("ja")
            .build().await?;

        let ticker = providers.ticker("7203.T").build().await?;
        let quote = ticker.quote::<finance_query::format::Raw>().await?; // Japanese

        // Override per handle if needed:
        let en = providers.ticker("AAPL").lang("en-US").build().await?;
        Ok(())
    }
}

// line 87: compile-only (no_run)
#[cfg(feature = "translation")]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_87() {
    use finance_query::{SearchOptions, finance, translation};

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let mut results = finance::search("toyota", &SearchOptions::default()).await?;
        translation::translate(&mut results, "ja").await?;
        Ok(())
    }
}

// line 106
#[cfg(feature = "translation")]
#[rustfmt::skip]
#[test]
fn doc_block_line_106() {
    use finance_query::translation::{self, Lang};

    #[tokio::main]
    async fn main() {
        let lang = Lang::parse("es").unwrap();
        let translated = translation::translate_texts(
            ["Technology", "Healthcare", "Chief Executive Officer"],
            &lang,
        )
        .await
        .unwrap();
        assert_eq!(translated, ["TecnologĂ­a", "Salud", "Director ejecutivo"]);
    }
    main();
}

// line 182: compile-only (no_run)
#[cfg(feature = "translation-offline")]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_182() {
    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        finance_query::translation::preload().await?;
        Ok(())
    }
}