Skip to main content
Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com
What is this? Classical portfolio optimization is fragile - small errors in expected returns produce wildly different weights. Robust optimization assumes the true expected returns lie within an uncertainty set and optimizes for the worst case. The result is a portfolio that performs well even when your return estimates are wrong, which they always are.

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.

RobustPortfolioResult Type

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.
Returns 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.
Returns 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.
A practical calibration: set kappa proportional to sqrt(N / T) where N is the number of markets and T is the number of observations used to estimate the mean. This scales the uncertainty set to match the statistical uncertainty in the sample mean.

Pipeline Integration

The hz.robust_allocator() pipeline function recomputes robust portfolio weights each cycle and injects them into ctx.params["robust_weights"].

Parameters


Mathematical Background

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.
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.
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.
The covariance matrix must be positive definite. If you have fewer observations than markets (T less than N), the sample covariance will be singular. Use hz.denoise_covariance() or hz.hrp_weights() as alternatives when data is scarce.