Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com
Robust Portfolio
Classical mean-variance optimization is notoriously sensitive to estimation error in expected returns. A small change in the mean vector can produce wildly different portfolio weights. Robust optimization addresses this by assuming the true mean lies within an uncertainty set and optimizing for the worst case. Horizon implements ellipsoidal uncertainty sets and worst-case return computation in Rust.Robust Optimize
hz.robust_optimize() finds weights that maximize worst-case return over an ellipsoidal uncertainty set.Worst-Case Return
hz.worst_case_return() computes the minimum expected return for given weights under parameter uncertainty.Robust Frontier
hz.robust_efficient_frontier() traces the robust efficient frontier across risk targets.Pipeline Integration
hz.robust_allocator() rebalances portfolio weights each cycle using robust optimization.hz.robust_optimize
Find portfolio weights that maximize the worst-case expected return subject to a volatility constraint, where the true mean vector lies within an ellipsoidal uncertainty set centered on the sample mean.| Parameter | Type | Description |
|---|---|---|
mu | list[float] | Estimated expected returns, length N |
covariance | list[list[float]] | N x N covariance matrix |
kappa | float | Uncertainty set radius. Controls how conservative the optimization is. Higher values shrink toward equal weight |
max_volatility | float | Maximum portfolio volatility (standard deviation) constraint |
RobustPortfolioResult Type
| Field | Type | Description |
|---|---|---|
weights | list[float] | Optimal portfolio weights, length N, summing to 1.0 |
worst_case_return | float | Minimum expected return over the uncertainty set |
volatility | float | Portfolio standard deviation at the optimal weights |
kappa | float | Uncertainty radius used in the optimization |
iterations | int | Number of iterations for convergence |
The uncertainty set is an ellipsoid centered on the sample mean, with radius controlled by kappa. When kappa = 0, this reduces to standard mean-variance optimization. As kappa increases, the optimizer hedges more against estimation error.
hz.worst_case_return
For a given set of portfolio weights, compute the worst-case expected return over the uncertainty set.| Parameter | Type | Description |
|---|---|---|
mu | list[float] | Estimated expected returns, length N |
covariance | list[list[float]] | N x N covariance matrix |
weights | list[float] | Portfolio weights, length N |
kappa | float | Uncertainty set radius |
float: the worst-case expected return.
hz.robust_efficient_frontier
Trace the robust efficient frontier by solving the robust optimization problem at multiple volatility targets.| Parameter | Type | Description |
|---|---|---|
mu | list[float] | Estimated expected returns, length N |
covariance | list[list[float]] | N x N covariance matrix |
kappa | float | Uncertainty set radius |
n_points | int | Number of points to compute on the frontier |
min_volatility | float | Minimum volatility target |
max_volatility | float | Maximum volatility target |
list[RobustPortfolioResult]: one result per frontier point, sorted by volatility.
Choosing Kappa
The uncertainty radius kappa controls how conservative the portfolio is. Larger kappa means the optimizer assumes more parameter uncertainty and tilts toward diversification.| Kappa | Behavior |
|---|---|
| 0.0 | Standard mean-variance (no robustness) |
| 0.1 - 0.3 | Mild robustness, slight tilt toward diversification |
| 0.5 - 1.0 | Moderate robustness, recommended starting range |
| > 1.0 | Aggressive hedging, approaches equal-weight or minimum-variance |
Pipeline Integration
Thehz.robust_allocator() pipeline function recomputes robust portfolio weights each cycle and injects them into ctx.params["robust_weights"].
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
feed | str | required | Feed name to compute returns from |
kappa | float | 0.5 | Uncertainty set radius |
max_volatility | float | 0.15 | Maximum portfolio volatility constraint |
lookback | int | 100 | Number of historical observations for mean/covariance estimation |
rebalance_every | int | 50 | Recompute weights every N cycles |
Mathematical Background
Ellipsoidal Uncertainty Sets
Ellipsoidal Uncertainty Sets
The true mean vector mu is assumed to lie within an ellipsoid centered on the sample estimate mu_hat. The ellipsoid is defined as all mu_hat + delta such that
delta' * Sigma_inv * delta is at most kappa^2. This is a natural choice because the sampling distribution of the mean is approximately elliptical (via the CLT), with shape governed by the covariance matrix. The radius kappa controls the confidence level.Worst-Case Optimization
Worst-Case Optimization
The robust optimization problem maximizes the worst-case expected return
w' * mu over all mu in the uncertainty set, subject to a volatility constraint w' * Sigma * w at most sigma_max^2, weights summing to 1, and non-negativity. The inner minimization has a closed-form solution: the worst-case return for weights w is w' * mu_hat - kappa * sqrt(w' * Sigma * w). So the robust problem reduces to a second-order cone program that can be solved efficiently.Connection to Shrinkage
Connection to Shrinkage
Robust optimization with ellipsoidal uncertainty is closely related to Bayesian shrinkage. As kappa increases, the optimal portfolio shrinks toward the minimum-variance portfolio (which does not depend on the mean). This provides a smooth interpolation between the aggressive mean-variance portfolio and the conservative minimum-variance portfolio.