From 48fe8db61eddaa0dc9fc5d5c670b05aef157f1d7 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sun, 6 Apr 2025 05:14:00 +0100 Subject: [PATCH] Add Python wrappers for `get_bdates_from_col_hv` and `get_period_indices_hv` functions --- src/_py/mod.rs | 1 - src/_py/panel.rs | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/_py/mod.rs b/src/_py/mod.rs index 7da3188..4b37399 100644 --- a/src/_py/mod.rs +++ b/src/_py/mod.rs @@ -1,4 +1,3 @@ - /// Python wrapper for [`crate::utils::qdf`]. pub mod qdf; diff --git a/src/_py/panel.rs b/src/_py/panel.rs index 1e0ebfe..a332677 100644 --- a/src/_py/panel.rs +++ b/src/_py/panel.rs @@ -1,11 +1,13 @@ use pyo3::prelude::*; -use pyo3_polars::PyDataFrame; +use pyo3_polars::{PyDataFrame, PySeries}; /// Python wrapper for [`crate::panel`] module. #[allow(deprecated)] #[pymodule] pub fn panel(_py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(historic_vol, m)?)?; + m.add_function(wrap_pyfunction!(get_bdates_from_col_hv, m)?)?; + m.add_function(wrap_pyfunction!(get_period_indices_hv, m)?)?; Ok(()) } @@ -44,3 +46,18 @@ pub fn historic_vol( .unwrap(), )) } + +#[pyfunction] +pub fn get_bdates_from_col_hv(dfw: PyDataFrame, est_freq: &str) -> PyResult { + Ok(PySeries( + crate::panel::historic_vol::get_bdates_from_col_hv(&dfw.into(), est_freq) + .unwrap() + .into(), + )) +} + + +#[pyfunction] +pub fn get_period_indices_hv(dfw: PyDataFrame, est_freq: &str) -> PyResult> { + Ok(crate::panel::historic_vol::get_period_indices_hv(&dfw.into(), est_freq).unwrap()) +}