| 77 | //! assert!(matches!( |
| 78 | //! allocate_from_inputs(&mu, &cov, "min_volatility", &impossible), |
| 79 | //! Err(AllocError::InfeasibleBounds { .. }) |
| 80 | //! )); |
| 81 | //! # Ok(()) |
| 82 | //! # } |
| 83 | //! ``` |
| 84 | |
| 85 | use nalgebra::{DMatrix, DVector}; |
| 86 | |
| 87 | use crate::util::qp::{solve_qp, QpError}; |
| 88 | use crate::util::resample::{freq_step, resample_prices}; |
| 89 | use crate::util::stats; |
| 90 | use std::collections::HashMap; |
| 91 | |
| 92 | /// Errors returned by the allocation functions. |
| 93 | #[derive(Debug, PartialEq, thiserror::Error)] |
| 94 | pub enum AllocError { |
| 95 | /// The price matrix has fewer than two rows (after resampling), so no return can be formed. |
| 96 | #[error("no data: supply asset prices, or expected returns and a covariance matrix")] |
| 97 | NoData, |
| 98 | /// `solution` is not one of `"inverse_variance"`, `"min_volatility"`, `"max_sharpe"`, |
| 99 | /// `"efficient_risk"`. |
| 100 | #[error("unknown solution: {0}")] |