(bounds: &[(f64, f64)])
| 222 | /// `sqrt(w' Sigma w)` with `Sigma` the annualised covariance, and `portfolio_sharpe` is |
| 223 | /// `(portfolio_return - risk_free_rate) / portfolio_risk`, so `risk_free_rate` is an annual rate. |
| 224 | /// From `allocate_from_inputs` the units are the caller's. `portfolio_sharpe` is computed for |
| 225 | /// every solution. It is forced to 0 when risk is 0; with positive risk it is also 0 when |
| 226 | /// expected excess return is 0. |
| 227 | #[derive(Debug, Clone)] |
| 228 | pub struct MeanVariance { |
| 229 | /// Portfolio weights, one per asset in column order, summing to 1. |
| 230 | pub weights: Vec<f64>, |
| 231 | /// Portfolio volatility `sqrt(w' Sigma w)`. |
| 232 | pub portfolio_risk: f64, |
| 233 | /// Portfolio expected return `mu' w`. |
| 234 | pub portfolio_return: f64, |
| 235 | /// `(portfolio_return - risk_free_rate) / portfolio_risk`, or 0 when the risk is 0. |
| 236 | pub portfolio_sharpe: f64, |
| 237 | } |
| 238 | |
| 239 | /// Parse an expected-returns method name (case-insensitive): `"mean"` or `"mean_historical"` |
| 240 | /// give [`ReturnsMethod::Mean`]; `"exponential"` or `"exponential_historical"` give |
| 241 | /// [`ReturnsMethod::Exponential`] with `span = 500`. |
| 242 | /// |
| 243 | /// # Errors |
| 244 | /// |
| 245 | /// [`AllocError::UnknownReturns`] for any other name. |
| 246 | /// |
| 247 | /// ``` |
| 248 | /// use openquant::portfolio_optimization::{returns_method_from_str, AllocError, ReturnsMethod}; |
| 249 | /// |
nothing calls this directly
no test coverage detected