27 — Risk Parity and Scenario-Robust Optimization¶
Free learning pack¶
- MIT OCW Portfolio Theory I–III
reference/concepts/risk_parity.md,scenario_robust_optimization.md
Do not search for more material until these are insufficient.
PREDICT¶
Asset A has volatility 20%, Asset B has volatility 10%, uncorrelated. A risk-parity allocation gives each equal risk contribution. Will Asset A or Asset B get the larger capital weight?
Formula¶
Solved via: minimize 0.5*w'*Sigma*w - sum(log(w_i)), then renormalize
w to sum to 1.
import numpy as np
import cvxpy as cp
from pm.risk import component_risk_contribution
Sigma = np.array([[0.04, 0.0], [0.0, 0.01]]) # 20% and 10% vol, uncorrelated
# MANUAL FIRST:
# set up and solve the convex risk-parity problem with cvxpy, then
# renormalize the raw weights to sum to 1. Confirm with
# component_risk_contribution that both assets end up with equal risk
# contribution despite unequal weights.
w_rp = None
print(w_rp)
PREDICT (scenario-robust)¶
Two assets. Scenario A: Asset 1 +10%, Asset 2 -5%. Scenario B: Asset 1 -5%, Asset 2 +10%. By symmetry, what weights maximize the worst-case return across both scenarios?
Formula¶
maximize t subject to R @ w >= t, sum(w) = 1, w >= 0
R = np.array([
[0.10, -0.05],
[-0.05, 0.10],
])
# MANUAL FIRST:
# set up and solve the minimax scenario-robust problem with cvxpy.
# Confirm both scenarios bind at the same worst-case return t at the
# optimal weights (R @ w should give two equal values).
w_robust = None
print(w_robust)
Not implemented here: hierarchical risk parity, regime-aware allocation¶
Both need machinery beyond this repo's scope (clustering + recursive
bisection; regime detection). Read reference/concepts/hierarchical_risk_parity.md
and reference/concepts/regime_aware_allocation.md for what they are and why.
Experiment¶
Break the symmetry in the scenario-robust example (make Scenario A more extreme: Asset 1 +20%, Asset 2 -5%). Does the optimal weight shift toward or away from Asset 1? Why might that feel counterintuitive at first?
Reference¶
reference/concepts/risk_parity.md
reference/concepts/scenario_robust_optimization.md
Promote¶
Use src/pm/robust.py (risk_parity_weights, scenario_robust_weights)
only after your own implementation.
Test¶
pytest tests/test_robust.py
ORAL CHECK¶
Explain to a PM the difference between risk parity (equalizing risk contribution under one covariance estimate) and scenario-robust optimization (maximizing the worst case across several discrete scenarios) - when would you reach for each?
Try /tutor portfolio-construction risk parity for an adaptive walkthrough.