Expand description
Portfolio optimization engine (Rust/nalgebra port, quantwave-a465).
Rust port of the Python-first v1 shipped at
quantwave-py/python/quantwave/portfolio.py (p2k0.5, PR #21). That module
is the numerical SPEC: sample/EWMA/Ledoit-Wolf covariance estimators;
min-variance / max-Sharpe (closed-form) / risk-parity (Spinu fixed-point)
/ HRP (hand-rolled single-linkage) optimizers; capped-simplex projection
for box+budget constraints. This module mirrors that algorithmically,
operating on nalgebra DMatrix<f64> / DVector<f64> instead of numpy
arrays, so it can be embedded in the core engine and driven from Rust
callers (backtests, live sizing) without a Python round-trip. PyO3
bindings in quantwave-py expose it to Python as quantwave._portfolio
(see that crate for the numpy <-> nalgebra bridge).
§Conventions
- Returns matrices are
(rows = time, cols = assets). - Every optimizer returns a weights vector that sums to 1.0.
- Degenerate inputs (singular covariance, a single asset, NaN returns)
return
PortfolioErrorrather than panicking or returning NaN weights (workspace lint:unwrap_used/expect_used= warn,panic= deny).
Enums§
- Portfolio
Error - Errors from the portfolio-optimization engine.
Functions§
- apply_
bounds_ and_ budget - Project raw weights onto the box-constrained, budget=1 feasible set.
- ewma_
cov - Exponentially-weighted covariance matrix (RiskMetrics-style).
- hrp
- Hierarchical Risk Parity (Lopez de Prado) portfolio weights.
- ledoit_
wolf_ cov - Ledoit-Wolf shrinkage covariance estimator (shrinkage target: identity-scaled).
- max_
sharpe - Maximum-Sharpe (tangency) portfolio weights.
- min_
variance - Minimum-variance portfolio weights.
- risk_
parity - Equal risk-contribution (“risk parity”) portfolio weights.
- sample_
cov - Sample covariance matrix of asset returns:
np.cov(returns, rowvar=False, ddof=1).
Type Aliases§
- Bounds
- Per-asset
(low, high)weight bounds.