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

Function initial_feasible

crates/openquant/src/portfolio_optimization.rs:224–246  ·  view source on GitHub ↗
(bounds: &[(f64, f64)])

Source from the content-addressed store, hash-verified

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)]
228pub 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///

Callers

nothing calls this directly

Calls 2

lenMethod · 0.80
check_bounds_feasibleFunction · 0.70

Tested by

no test coverage detected