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

Function resample_prices

crates/openquant/src/hrp.rs:130–147  ·  view source on GitHub ↗
(prices: &DMatrix<f64>, step: usize)

Source from the content-addressed store, hash-verified

128}
129
130fn resample_prices(prices: &DMatrix<f64>, step: usize) -> DMatrix<f64> {
131 if step <= 1 {
132 return prices.clone_owned();
133 }
134 let mut flat = Vec::new();
135 let mut out_rows = 0;
136 for r in (step - 1..prices.nrows()).step_by(step) {
137 for c in 0..prices.ncols() {
138 flat.push(prices[(r, c)]);
139 }
140 out_rows += 1;
141 }
142 if out_rows == 0 {
143 prices.clone_owned()
144 } else {
145 DMatrix::from_vec(out_rows, prices.ncols(), flat)
146 }
147}
148
149fn returns_from_prices(prices: &DMatrix<f64>) -> Result<DMatrix<f64>, HrpError> {
150 if prices.nrows() < 2 {

Callers 1

allocateMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected