finance-query 3.0.0

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

// line 866: compile-only (no_run)
#[cfg(feature = "dataframe")]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_866() {
        use finance_query::{Interval, Ticker, TimeRange};
        use polars::prelude::*;

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

            // Convert to DataFrame for analysis
            let df = chart.to_dataframe()?;

            // Reuse the same chart data for different analyses
            let high_volume = df
                .clone()
                .lazy()
                .filter(col("volume").gt(lit(50_000_000i64)))
                .collect()?;
            let recent = df.tail(Some(5));

            // No additional API calls - data is cached in the Ticker
            println!("{} high-volume days, recent:\n{}", high_volume.height(), recent);
            Ok(())
        }
}