mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 07:20:01 +00:00
added py-bindings for panel/hist_vol
This commit is contained in:
parent
8f3ffa6298
commit
6599f265b6
3
src/panel/mod.rs
Normal file
3
src/panel/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod historic_vol;
|
||||
|
||||
|
@ -5,6 +5,9 @@ pub mod qdf;
|
||||
/// Python API for [`crate::download`].
|
||||
pub mod download;
|
||||
|
||||
/// Python API for [`crate::panel`].
|
||||
pub mod panel;
|
||||
|
||||
use pyo3::{prelude::*, wrap_pymodule};
|
||||
// use pyo3_polars::PyDataFrame;
|
||||
|
||||
@ -13,5 +16,6 @@ use pyo3::{prelude::*, wrap_pymodule};
|
||||
pub fn msyrs(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_wrapped(wrap_pymodule!(qdf::qdf))?;
|
||||
m.add_wrapped(wrap_pymodule!(download::download))?;
|
||||
m.add_wrapped(wrap_pymodule!(panel::panel))?;
|
||||
Ok(())
|
||||
}
|
||||
|
46
src/py/panel.rs
Normal file
46
src/py/panel.rs
Normal file
@ -0,0 +1,46 @@
|
||||
use pyo3::prelude::*;
|
||||
use pyo3_polars::PyDataFrame;
|
||||
|
||||
/// 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)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Python wrapper for calculating historic volatility.
|
||||
/// See [`crate::panel::historic_vol`] for full documentation.
|
||||
#[pyfunction]
|
||||
pub fn historic_vol(
|
||||
df: PyDataFrame,
|
||||
xcat: String,
|
||||
cids: Option<Vec<String>>,
|
||||
lback_periods: Option<usize>,
|
||||
lback_method: Option<String>,
|
||||
half_life: Option<f64>,
|
||||
start: Option<String>,
|
||||
end: Option<String>,
|
||||
est_freq: Option<String>,
|
||||
remove_zeros: Option<bool>,
|
||||
postfix: Option<String>,
|
||||
nan_tolerance: Option<f64>,
|
||||
) -> PyResult<PyDataFrame> {
|
||||
Ok(PyDataFrame(
|
||||
crate::panel::historic_vol::historic_vol(
|
||||
df.into(),
|
||||
xcat,
|
||||
cids,
|
||||
lback_periods,
|
||||
lback_method,
|
||||
half_life,
|
||||
start,
|
||||
end,
|
||||
est_freq,
|
||||
remove_zeros,
|
||||
postfix,
|
||||
nan_tolerance,
|
||||
)
|
||||
.unwrap(),
|
||||
))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user