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

Function build_bounds

crates/openquant/src/portfolio_optimization.rs:204–211  ·  view source on GitHub ↗
(
    n: usize,
    bounds: &Option<HashMap<usize, (f64, f64)>>,
    tuple_bounds: Option<(f64, f64)>,
)

Source from the content-addressed store, hash-verified

202}
203
204fn build_bounds(
205 n: usize,
206 bounds: &Option<HashMap<usize, (f64, f64)>>,
207 tuple_bounds: Option<(f64, f64)>,
208) -> Vec<(f64, f64)> {
209 let default = tuple_bounds.unwrap_or((0.0, 1.0));
210 (0..n).map(|i| bounds.as_ref().and_then(|m| m.get(&i)).copied().unwrap_or(default)).collect()
211}
212
213fn check_bounds_feasible(bounds: &[(f64, f64)]) -> Result<(), AllocError> {
214 let lower: f64 = bounds.iter().map(|b| b.0).sum();

Callers 5

allocate_min_vol_withFunction · 0.70
allocate_max_sharpe_withFunction · 0.70
allocate_from_inputsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected