polars-ta 0.1.0

Polars Series interface for technical indicators — native Polars integration, aligned with ta-lib
Documentation
use polars_core::prelude::*;
use polars_ta_core::oscillator::willr as willr_core;

fn series_to_f64(s: &Series) -> PolarsResult<Vec<f64>> {
    Ok(s.cast(&DataType::Float64)?
        .f64()?
        .into_iter()
        .map(|v| v.unwrap_or(f64::NAN))
        .collect())
}

pub fn willr_series(
    high: &Series,
    low: &Series,
    close: &Series,
    period: usize,
) -> PolarsResult<Series> {
    let h = series_to_f64(high)?;
    let l = series_to_f64(low)?;
    let c = series_to_f64(close)?;
    let result = willr_core(&h, &l, &c, period);
    Ok(Float64Chunked::from_vec("willr".into(), result).into_series())
}