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 line 878
use finance_query::Tickers;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Bound reuse to a 30-second TTL
    let tickers = Tickers::builder(vec!["AAPL", "MSFT"])
        .cache(Duration::from_secs(30))
        .build()
        .await?;

    // First call: Network request, result cached for 30s
    let response1 = tickers.quotes().await?;

    // Second call within TTL: Returns cached data (no network request)
    let response2 = tickers.quotes().await?;

    // Clear all caches to force fresh data
    tickers.clear_cache().await;
    let response3 = tickers.quotes().await?; // Network request

    // Or clear selectively:
    tickers.clear_quote_cache().await; // Quotes only
    tickers.clear_chart_cache().await; // Charts, sparks, and events

    println!(
        "response1={} response2={} response3={}",
        response1.quotes.len(),
        response2.quotes.len(),
        response3.quotes.len(),
    );
    Ok(())
}