mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 04:20:00 +00:00
Add linear_composite function to panel module with appropriate signature
This commit is contained in:
parent
e37b4c19cb
commit
8a9b6bc88f
@ -8,6 +8,7 @@ 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)?)?;
|
||||
m.add_function(wrap_pyfunction!(linear_composite, m)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -56,8 +57,60 @@ pub fn get_bdates_from_col_hv(dfw: PyDataFrame, est_freq: &str) -> PyResult<PySe
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
#[pyfunction]
|
||||
pub fn get_period_indices_hv(dfw: PyDataFrame, est_freq: &str) -> PyResult<Vec<usize>> {
|
||||
Ok(crate::panel::historic_vol::get_period_indices_hv(&dfw.into(), est_freq).unwrap())
|
||||
}
|
||||
|
||||
#[pyfunction(signature = (
|
||||
df,
|
||||
xcats,
|
||||
cids,
|
||||
weights = None,
|
||||
signs = None,
|
||||
weight_xcats = None,
|
||||
normalize_weights = false,
|
||||
start = None,
|
||||
end = None,
|
||||
blacklist = None,
|
||||
complete_xcats = false,
|
||||
complete_cids = false,
|
||||
new_xcat = None,
|
||||
new_cid = None
|
||||
))]
|
||||
pub fn linear_composite(
|
||||
df: PyDataFrame,
|
||||
xcats: Vec<String>,
|
||||
cids: Vec<String>,
|
||||
weights: Option<Vec<f64>>,
|
||||
signs: Option<Vec<f64>>,
|
||||
weight_xcats: Option<Vec<String>>,
|
||||
normalize_weights: bool,
|
||||
start: Option<String>,
|
||||
end: Option<String>,
|
||||
blacklist: Option<std::collections::HashMap<String, Vec<String>>>,
|
||||
complete_xcats: bool,
|
||||
complete_cids: bool,
|
||||
new_xcat: Option<String>,
|
||||
new_cid: Option<String>,
|
||||
) -> PyResult<PyDataFrame> {
|
||||
Ok(PyDataFrame(
|
||||
crate::panel::linear_composite::linear_composite(
|
||||
&df.into(),
|
||||
xcats,
|
||||
cids,
|
||||
weights,
|
||||
signs,
|
||||
weight_xcats,
|
||||
normalize_weights,
|
||||
start,
|
||||
end,
|
||||
blacklist,
|
||||
complete_xcats,
|
||||
complete_cids,
|
||||
new_xcat,
|
||||
new_cid,
|
||||
)
|
||||
.unwrap(),
|
||||
))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user