(prices: &DMatrix<f64>)
| 377 | } |
| 378 | self.efficient_frontier_means.clear(); |
| 379 | self.efficient_frontier_sigma.clear(); |
| 380 | |
| 381 | // `lambdas`, `gammas` and `free_weights` always describe the turning points. `weights` |
| 382 | // holds the requested solution, which for "cla_turning_points" is those same points. |
| 383 | let turning_points = self.weights.clone(); |
| 384 | match solution.unwrap_or("cla_turning_points") { |
| 385 | "cla_turning_points" => {} |
| 386 | "min_volatility" => { |
| 387 | let best = turning_points |
| 388 | .iter() |
| 389 | .min_by(|a, b| { |
| 390 | quad_risk(&self.cov_matrix, a).total_cmp(&quad_risk(&self.cov_matrix, b)) |
| 391 | }) |
| 392 | .ok_or(ClaError::NoTurningPoints)?; |
| 393 | self.weights = vec![best.clone()]; |
| 394 | } |
| 395 | "max_sharpe" => { |
| 396 | self.weights = |
| 397 | vec![max_sharpe_on_frontier(&turning_points, &mean, &self.cov_matrix)?]; |
| 398 | } |
| 399 | "efficient_frontier" => { |
no outgoing calls
no test coverage detected