mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 04:20:00 +00:00
Add Python wrapper for utils module and update msyrs.pyi to include utils functions
This commit is contained in:
parent
4df2d4147d
commit
c0f7299643
@ -7,6 +7,9 @@ pub mod download;
|
||||
/// Python wrapper for [`crate::panel`].
|
||||
pub mod panel;
|
||||
|
||||
/// Python wrapper for [`crate::utils`].
|
||||
pub mod utils;
|
||||
|
||||
use pyo3::{prelude::*, wrap_pymodule};
|
||||
|
||||
/// PyO3 bindings for the `msyrs` Python wrapper.
|
||||
@ -16,5 +19,6 @@ 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))?;
|
||||
m.add_wrapped(wrap_pymodule!(utils::utils))?;
|
||||
Ok(())
|
||||
}
|
||||
|
22
src/_py/utils.rs
Normal file
22
src/_py/utils.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use pyo3::prelude::*;
|
||||
use pyo3_polars::{PyDataFrame, PySeries};
|
||||
|
||||
/// Python wrapper for [`crate::utils::qdf`] module.
|
||||
#[allow(deprecated)]
|
||||
#[pymodule]
|
||||
pub fn utils(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(get_bdates_series_default, m)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
pub fn get_bdates_series_default(
|
||||
start_date: String,
|
||||
end_date: String,
|
||||
freq: Option<String>,
|
||||
) -> PyResult<PySeries> {
|
||||
Ok(PySeries(
|
||||
crate::utils::dateutils::get_bdates_series_default(start_date, end_date, freq)
|
||||
.map_err(|e| PyErr::new::<pyo3::exceptions::PyValueError, _>(format!("{}", e)))?,
|
||||
))
|
||||
}
|
@ -34,16 +34,23 @@ class qdf:
|
||||
def pivot_dataframe_by_ticker(*args, **kwargs) -> DataFrame: ...
|
||||
|
||||
class panel:
|
||||
__all__ = ["historic_vol"]
|
||||
__all__ = [
|
||||
"historic_vol",
|
||||
"get_bdates_from_col_hv",
|
||||
"get_period_indices_hv",
|
||||
"linear_composite",
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def historic_vol(*args, **kwargs) -> DataFrame: ...
|
||||
|
||||
@staticmethod
|
||||
def get_bdates_from_col_hv(*args, **kwargs) -> Series: ...
|
||||
|
||||
@staticmethod
|
||||
def get_period_indices_hv(*args, **kwargs) -> Series: ...
|
||||
|
||||
@staticmethod
|
||||
def linear_composite(*args, **kwargs) -> DataFrame: ...
|
||||
|
||||
class utils:
|
||||
__all__ = ["get_bdates_series_default"]
|
||||
@staticmethod
|
||||
def get_bdates_series_default(*args, **kwargs) -> Series: ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user