MCPcopy Create free account
hub / github.com/Open-Quant/openquant / freq_step

Function freq_step

crates/openquant/src/portfolio_optimization.rs:66–77  ·  view source on GitHub ↗
(resample_by: Option<&str>)

Source from the content-addressed store, hash-verified

64
65pub fn returns_method_from_str(name: &str) -> Result<ReturnsMethod, AllocError> {
66 match name.to_lowercase().as_str() {
67 "mean" | "mean_historical" => Ok(ReturnsMethod::Mean),
68 "exponential" | "exponential_historical" => Ok(ReturnsMethod::Exponential { span: 500 }),
69 other => Err(AllocError::UnknownReturns(other.to_string())),
70 }
71}
72
73fn returns_from_prices(prices: &DMatrix<f64>) -> Result<DMatrix<f64>, AllocError> {
74 let rows = prices.nrows();
75 let cols = prices.ncols();
76 if rows < 2 {
77 return Err(AllocError::NoData);
78 }
79 let mut out = DMatrix::<f64>::zeros(rows - 1, cols);
80 for r in 1..rows {

Callers 1

returns_and_meansFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected