← Back to blog

Implement Risk Budgeting Portfolios With SGD and Mirror Descent

October 8, 2026
Implement Risk Budgeting Portfolios With SGD and Mirror Descent

A risk budgeting portfolio allocates portfolio risk according to pre-specified risk budgets by solving for weights that make each asset's marginal risk contribution match its budget. This is a solvable numerical problem for volatility and for tail-risk measures such as Expected Shortfall, using algorithms like stochastic gradient descent and Mirror Descent rather than closed-form formulas.


TL;DR:

  • Risk budgeting portfolios generally rely on iterative algorithms like stochastic gradient descent or mirror descent due to the lack of closed-form solutions for tail-risk measures such as Expected Shortfall.
  • Expected Shortfall is preferred over VaR and volatility because it is coherent, convex, and more accurately captures extreme tail risks in the allocation process.
  • Numerical methods converge reliably for positively homogeneous risk measures, but care must be taken to monitor condition numbers and risk contribution ratios to avoid ill-conditioning.
  • Incorporating factor risk analysis helps reveal hidden concentration in common risk exposures, which asset-level budgets alone can mask.
  • Practical implementation requires careful choices of lookback periods, covariance shrinkage, and constraints to prevent drift, high turnover, or model instability during regime shifts.

StockPilot
stockpilot.io
Apply Rules-Based Risk Management
StockPilot combines transparent portfolio construction, position sizing, and ongoing risk management for self-directed investors.
Explore StockPilot

Table of Contents

1. Formal definition and mathematical formulation

Risk budgeting starts with a risk measure R(θ) applied to a portfolio with weights θ. When R is positively homogeneous of degree one, meaning R(λθ) = λR(θ) for any positive scalar λ, Euler's theorem guarantees that total portfolio risk decomposes exactly into the sum of each asset's marginal contribution: R(θ) = Σ θ_i ∂_i R(θ). Each term θ_i ∂_i R(θ) is that asset's risk contribution, and the decomposition holds with no residual or approximation error.

A risk budgeting portfolio is defined by the condition θ_i ∂_i R(θ) = b_i × R(θ) for every asset i, where b_i is the pre-specified budget share and the budgets sum to one. The equal risk contribution portfolio, often called ERC, is the special case where every b_i equals 1/n.

This system of equations is nonlinear because ∂_i R(θ) itself depends on all portfolio weights through covariance or tail dependence. Existence and uniqueness of a solution are not automatic for every risk measure or constraint set, but for a broad class of positively homogeneous measures under long-only constraints with strictly positive budgets, a solution exists and is unique up to scaling, which is what makes the problem tractable for numerical solvers rather than purely theoretical exercises.

2. Volatility vs VaR vs Expected Shortfall: which risk measure fits?

Comparison of three portfolio risk measures

Volatility is the default choice because it is smooth, twice differentiable, and gives risk contributions a closed analytical form through the covariance matrix: ∂_i R(θ) = (Σθ)_i / sqrt(θ'Σθ). That tractability comes at a cost: volatility treats upside and downside moves symmetrically and says nothing about the shape of the tail.

Value-at-Risk measures the loss threshold not exceeded at a given confidence level, but it is not subadditive, meaning diversification can mechanically increase a portfolio's reported VaR. That noncoherence, along with VaR's nonsmoothness at the quantile boundary, makes it a poor target for gradient-based optimization.

Expected Shortfall, also called CVaR, averages losses beyond the VaR threshold and is coherent: subadditive, monotonic, and convex. Its practical advantage is the Rockafellar-Uryasev variational formulation, which rewrites ES as the solution to a convex auxiliary optimization rather than requiring direct quantile estimation. That reformulation preserves convexity in the risk-budgeting problem and is why Expected Shortfall is implementable in the same numerical pipelines built for volatility, while giving a far more honest picture of extreme tail risk.

3. Numerical solution methods and algorithmic trade-offs

Closed-form weights only exist for the volatility-based ERC case under simplifying assumptions. Everything else, including ES-based budgeting and constrained problems, requires iterative solvers.

  • Stochastic gradient descent treats the risk-budgeting equations as a loss function penalizing deviation of θ_i ∂_i R(θ) from b_i R(θ), updating weights with mini-batched return samples and a decaying learning rate.
  • Mirror Descent and tamed Mirror Descent replace the Euclidean update with a geometry suited to the simplex constraint, which avoids repeated projection steps and improves stability when gradients are noisy or budgets are extreme.
  • Semidefinite relaxations bound nonconvex formulations, such as generalized risk budgeting with overlapping asset partitions, giving a certified lower bound even when the exact problem is intractable.
  • Multiplicative update rules preserve the sign and positivity of weights by construction, which is useful when long-only constraints must hold at every iteration rather than only at convergence.

For a wide range of positively homogeneous measures, stochastic algorithms converge reliably in practice, though numerical conditioning of the covariance or tail-risk estimate matters as much as the choice of optimizer. Mirror Descent variants with tamed gradients offer non-asymptotic convergence rates and tend to be more stable than plain SGD in constrained budgeting problems, particularly when budgets are uneven across assets.

Pro Tip: Track the ratio of realized to target risk contributions at every iteration rather than only the loss value: a loss near zero with contributions still off-budget usually signals an ill-conditioned covariance matrix.

4. Factor risk budgeting and the asset-factor hybrid

Asset-level budgets can hide risk that is concentrated in a handful of common factors. Two assets with low correlation to each other can still share the same factor exposure, such as duration or credit spread, so an ERC portfolio built purely on asset weights may look diversified while carrying one dominant factor risk.

Factor risk budgeting addresses this by defining risk contributions at the factor level: given a factor model θ = Bf, where B holds factor loadings, the same Euler decomposition applies to the factor-mapped risk measure, splitting total risk across the underlying factors rather than the assets themselves.

A practical workflow estimates factor loadings from a multi-factor model, sets budget targets for each factor based on an investor's macro view or risk tolerance, and then checks whether those factor budgets are consistent with the original asset-level budgets. When they conflict, which happens often in practice, an Asset-Factor Risk Budgeting framework blends both objectives into a single optimization that balances asset-level and factor-level contributions simultaneously. That combined objective is rarely convex in both weight sets at once, which is another reason stochastic algorithms rather than closed-form solvers are the standard implementation path.

5. Practical implementation checklist and common pitfalls

Building a risk-budgeting portfolio that holds up outside a backtest requires a short list of deliberate choices, each with a failure mode attached.

  1. Choose a lookback window and frequency that match the risk measure. A short window reacts fast but adds noise to the covariance estimate; a long window is stable but lags regime shifts.
  2. Shrink the covariance matrix toward a structured target, such as a single-factor or constant-correlation model, to control estimation error when the asset count approaches the sample size.
  3. Set liquidity, sector, and position limits before optimizing, not after, so the solver never converges to a theoretically optimal but practically untradeable allocation.
  4. Cap turnover explicitly in the objective or as a constraint, since risk-budgeting weights can shift meaningfully between rebalances purely from covariance re-estimation.
  5. Account for financing costs on any leveraged sleeve. During periods of higher policy rates, financing costs materially erode the net benefit of levered risk-based strategies, so backtests that ignore borrowing cost overstate performance.
  6. Verify ex-post risk contributions against targets on a rolling basis, since a solver that converges numerically can still drift from budget as realized correlations diverge from the estimation sample.

Volatility targeting that mechanically cuts exposure in high-volatility regimes and re-levers in calm ones has been shown to improve realized Sharpe ratios across a range of risk assets, which is one reason many risk-budgeting implementations pair a budgeting layer with a volatility-scaling overlay rather than relying on static budgets alone.

6. StockPilot perspective: applying risk-budgeting mechanics in a rules-based system

We built our system around the same principle that drives formal risk budgeting: risk exposure should follow a predefined rule set, not a discretionary call made under pressure. The model portfolio combines income-producing positions with AI-selected growth positions, and position sizing follows fixed criteria rather than ad hoc judgment.

When our predefined risk criteria flag unfavorable market conditions, we reduce growth exposure and shift capital toward Treasury ETFs, which mirrors the de-risking behavior that volatility-targeting and risk-budgeting overlays are designed to produce. Changes are issued as after-hours buy or sell alerts, allowing users to execute trades in their own brokerage accounts, maintaining transparency.

8. Comparing risk budgeting with mean-variance and minimum-variance portfolios

Mean-variance optimization, the Markowitz framework, maximizes expected return for a given level of risk, which makes it highly sensitive to estimation error in expected returns. Small changes in forecast inputs can produce large, unstable swings in optimal weights, a well-documented weakness that has pushed many practitioners toward return-agnostic alternatives.

Minimum-variance portfolios sidestep the return-forecasting problem entirely by minimizing portfolio variance directly, but they tend to concentrate heavily in low-volatility assets, which can mean large uncompensated bets on a narrow sector or factor.

The equal risk contribution special case is often described as a diversification-first alternative to both approaches, since it guarantees no single position dominates total portfolio risk by construction. The trade-off is that risk budgeting ignores expected returns as an input, so it can hold assets with weak return prospects simply because they help balance the risk profile, a limitation mean-variance optimization does not share even as it suffers from the opposite problem of overreacting to noisy return estimates.

9. Backtesting risk budgeting portfolios: what the evidence shows

Backtesting a risk-budgeting portfolio requires checking two separate things: whether realized risk contributions actually tracked the target budgets, and whether the resulting return and drawdown profile was attractive relative to simpler benchmarks.

The first check is often skipped, but it matters most. A portfolio can report reasonable historical returns while its realized risk contributions drift far from the specified budgets whenever the covariance structure used at rebalance time diverges from what actually occurred afterward, which is common during regime changes. Rolling comparison of ex-post contributions against targets is the only way to catch this.

On the return side, risk-budgeted and equal risk contribution portfolios have tended to show smoother drawdown profiles than concentrated mean-variance portfolios in periods of market stress, largely because no single position or factor can dominate losses by design. That smoother profile does not guarantee higher absolute returns. A backtest that excludes transaction costs, financing costs on any leveraged overlay, and realistic rebalancing frequency will systematically overstate performance, which is why the financing-cost point raised earlier in implementation deserves equal weight in any backtest design.

10. Common challenges and pitfalls in risk budgeting

Model risk is the central challenge: every risk contribution calculation depends on an estimated covariance matrix or tail-risk model, and that estimate is never the true underlying process. Small sample sizes relative to the number of assets inflate estimation error, producing risk-budgeting weights that look precise but are statistically unstable.

Nonstationarity compounds the problem. Correlations and volatilities shift across regimes, so a budgeting solution calibrated on a calm period can misallocate risk substantially once volatility spikes, exactly when accurate risk control matters most.

Numerical convergence failures are a separate, more mechanical pitfall: an optimizer can report convergence while actual risk contributions remain meaningfully off-budget, particularly with ill-conditioned covariance matrices or overly aggressive learning rates in SGD-based solvers. Constraint conflicts, where liquidity, sector, or turnover limits make the exact budget vector infeasible, are common in practice and require an explicit decision about which constraint takes priority rather than letting the solver silently approximate a compromise.

11. Choosing a risk measure based on investor tolerance

The choice of risk measure should follow how an investor actually experiences loss, not which measure is easiest to optimize. An investor primarily concerned with day-to-day fluctuation and comfortable assuming roughly symmetric return behavior is well served by volatility-based budgeting, since it is computationally simple and the contributions are easy to interpret.

An investor more concerned with rare, severe drawdowns, such as someone managing a near-retirement portfolio or a fund with strict drawdown mandates, is better served by Expected Shortfall budgeting, since it directly targets the average loss in the worst outcomes rather than treating all deviations symmetrically. The computational cost is higher and the Rockafellar-Uryasev formulation requires more careful tail-sample estimation, but the resulting budget allocation reflects the risk investors actually fear.

VaR-based budgeting is rarely the right default given its lack of subadditivity, though it can still serve as a secondary monitoring metric alongside a primary ES or volatility target.

12. Applications across market environments and asset classes

Equity-only risk budgeting is the most common application, typically built as an ERC overlay across sectors or individual names to avoid the concentration that market-cap weighting produces. Multi-asset risk budgeting extends the same logic across equities, bonds, and commodities, where volatility differences between asset classes are large enough that naive capital weighting would let equities dominate total portfolio risk even at a modest capital allocation.

In fixed income, factor risk budgeting is particularly relevant because duration and credit spread exposure cut across instruments that look diversified by issuer but are not diversified by risk driver. Allocating budgets across these factor exposures rather than individual bonds surfaces concentration that asset-level budgeting alone would miss.

During high-volatility regimes, risk-budgeting portfolios paired with a volatility-scaling overlay tend to reduce exposure mechanically, which has shown improved left-tail behavior relative to static-weight benchmarks. For candidate asset screening within any of these frameworks, cross-referencing valuation and fair-value metrics can help filter the universe before risk budgets are applied, since a risk-balanced allocation to an overvalued asset is still a risk-balanced allocation to a poor investment.

12. Applications across market environments and asset classes — overview diagram

13. What the research actually supports about risk budgeting

The strongest result in this literature is narrow but important: for a broad class of positively homogeneous risk measures, a risk-budgeting solution exists and is computable with stochastic algorithms. That is a real, useful guarantee. It is not a guarantee that the resulting portfolio will outperform anything, and treating risk budgeting as a performance strategy rather than a risk-control discipline is the most common misreading of the method.

Conventional advice tends to stop at ERC and volatility, when the more defensible position is that Expected Shortfall deserves to be the default tail-risk measure for anyone managing drawdown-sensitive capital, given its coherence properties and its tractable variational form. The bigger blind spot is factor concentration: an asset-level budget that looks diversified on paper can still be a concentrated factor bet underneath. Readers implementing this for the first time should prioritize covariance conditioning and factor-level checks before tuning optimizer hyperparameters, since a well-converged solver applied to a badly estimated covariance matrix is precision applied to the wrong target.

— David Elliot

14. A simpler path to risk-aware portfolio management

Everything covered here, Euler decomposition, Expected Shortfall budgeting, Mirror Descent solvers, factor reconciliation, is the machinery professional risk managers use to keep portfolio risk deliberate rather than accidental. Most self-directed investors do not have the time or infrastructure to run that machinery themselves, which is the gap we built StockPilot to close.

StockPilot

Our model portfolio applies rules-based risk management without requiring you to estimate a covariance matrix or tune a solver. It combines income-producing positions with AI-selected growth positions, and when predefined risk criteria signal unfavorable conditions, it shifts capital toward Treasury ETFs automatically rather than leaving that decision to discretion in the moment. Users receive clear after-hours buy and sell alerts and execute every trade themselves, in their own brokerage accounts, with full visibility into every position.

If the quantitative discipline in this guide is what you want for your own portfolio without building it from scratch, subscribe to StockPilot Premium for $147 per month, or review our risk disclosures first if you want the formal terms before you start.

FAQ

What is a risk budgeting portfolio?

A risk budgeting portfolio is one where weights are chosen so each asset's share of total portfolio risk matches a pre-specified target, rather than each asset receiving an equal dollar weight. The allocation is typically solved numerically using the Euler risk decomposition and an iterative algorithm such as stochastic gradient descent.

What is risk budgeting?

Risk budgeting is the practice of allocating a portfolio's total risk, rather than its capital, across assets or factors according to predefined shares called budgets. It contrasts with capital-weighted allocation, which can leave risk concentrated in a few volatile positions even when dollar amounts look evenly spread.

What is an optimal risk portfolio?

An optimal risk portfolio generally refers to the allocation that maximizes risk-adjusted return for a given risk tolerance, most commonly derived from mean-variance optimization rather than risk budgeting itself. Risk budgeting pursues a different objective: matching risk contributions to predefined shares rather than maximizing a return-to-risk ratio.

What is the —/20/20 rule for portfolios?

There is no single standardized "—/20/20 rule" with an established definition in the portfolio construction literature. Allocation splits like this vary by advisor and goal, so a reader encountering this term should ask the source to define the exact split and its intended risk and return assumptions before applying it.

Sources

Working implementations are the fastest way to validate the mathematics before deploying real capital. Two toolchains dominate current practice.

In Python, the open-source skfolio library provides runnable notebooks that demonstrate both variance-based risk parity and CVaR-based risk-budgeting variants, letting a practitioner swap the risk measure and budget vector without rebuilding the optimizer from scratch. These examples are useful precisely because they expose the covariance or tail-risk input and the budget constraint as separate, inspectable objects, which makes it straightforward to test sensitivity to estimation error.

MATLAB's Financial Toolbox documents a riskBudgetingPortfolio example that walks through specifying a covariance matrix and a target budget vector, then solving for weights using an internal iterative routine. It is a reasonable starting point for practitioners already working in MATLAB for portfolio analytics, though it covers the volatility case more thoroughly than tail-risk measures.

For practitioners prototyping constrained or leveraged implementations, especially where strict drawdown discipline matters, reviewing how futures evaluation programs structure end-of-day drawdown rules offers a useful comparison point for how risk limits get enforced mechanically outside a pure optimization framework. Either toolchain should be treated as a starting scaffold: production systems typically replace the default covariance estimator with a shrinkage or robust variant and add the liquidity and turnover constraints discussed earlier before any capital is committed.