use polars::prelude::*;
pub fn calculate_hma(df: &DataFrame, column: &str, period: usize) -> PolarsResult<Series> {
let half_period = period / 2;
let wma_full = super::wma::calculate_wma(df, column, period)?;
let wma_half = super::wma::calculate_wma(df, column, half_period)?;
let raw_hma = wma_half
.multiply(&Series::new("mult".into(), &[2.0f64]))?
.subtract(&wma_full)?;
let temp_df = DataFrame::new(vec![raw_hma.clone().into()])?;
let sqrt_period = (period as f64).sqrt().round() as usize;
super::wma::calculate_wma(&temp_df, raw_hma.name(), sqrt_period)
}