Traditional Mean-Variance Optimization (Markowitz) is famous for producing extreme, unstable portfolio weights: tiny changes in expected returns or the covariance matrix move the allocation dramatically. The Black-Litterman model attacks that from an unexpected direction — instead of improving the return estimates, it changes where they come from: start from market equilibrium and treat your own views as noisy Bayesian evidence around it.
In this post we implement Black-Litterman from scratch in NumPy, and verify three things: that naive mean-variance really does collapse onto corner solutions, that Black-Litterman weights survive 200 bootstrapped re-estimations essentially unchanged, and — the part most demos skip — that the Black-Litterman portfolio actually has a higher Sharpe ratio out of sample, verified over 50 fresh simulated years.
Why naive Markowitz fails #
Mean-variance optimization solves:
$$\max_w ; w^T \mu - \frac{\delta}{2} w^T \Sigma w \quad \text{subject to} \quad \sum w_i = 1$$
The problem is upstream of the optimizer. With three years of daily data, the standard error of an annualized mean return is roughly $\sigma / \sqrt{3} \approx 0.12$ — that is, we “know” a 10% expected return to within ±12%. The optimizer then amplifies this noise: it is happy to take a 5% difference between two assets’ estimated means and turn it into a corner solution of 100% vs 0%.
The Black-Litterman framework #
The model has three ingredients:
- Equilibrium prior. Reverse-engineer the returns that make a benchmark portfolio (in practice, cap weights; here, an equal-weight portfolio for simplicity) optimal:
$$\pi = \delta , \Sigma , w_{eq}$$
with $\delta$ the representative investor’s risk aversion. This is a covariance-based quantity — it deliberately avoids using the noisy $\hat{\mu}$.
-
Investor views. $P w = Q + \epsilon$, where $P$ selects assets, $Q$ holds the view targets, and $\epsilon$ is view error with covariance $\Omega$. We use the standard He–Litterman rule $\Omega = \tau , \mathrm{diag}(P , \tau \Sigma , P^T)$.
-
Bayesian update. Combine prior and views:
$$\Pi_{BL} = M\left[(\tau\Sigma)^{-1}\pi + P^T \Omega^{-1} Q\right], \qquad M = \left[(\tau\Sigma)^{-1} + P^T\Omega^{-1}P\right]^{-1}$$
Optimize with the posterior $\Pi_{BL}$ in place of $\hat{\mu}$. ($\tau \approx 0.01$–$0.05$ controls how much the prior trusts equilibrium; we use $0.05$.)
One caution worth its own paragraph: a well-known mistake is to set the “market portfolio” to the tangency portfolio of the estimated returns. That makes $\pi$ circular — the implied returns recreate exactly the estimates you were trying to escape, noise included. The prior must anchor on something exogenous to $\hat{\mu}$: cap weights, a benchmark index, an equal-weight book.
The experiment: a market with known truth #
import numpy as np
from scipy.optimize import minimize
ASSETS = ['A', 'B', 'C', 'D', 'E']
RF = 0.02 # risk-free rate
DELTA = 2.5 # risk-aversion for the equilibrium prior
TAU = 0.05 # prior uncertainty scale
def sharpe(w, mu, cov):
return (w @ mu - RF) / np.sqrt(w @ cov @ w)
def max_sharpe_weights(mu, cov):
n = len(mu)
r = minimize(lambda w: -sharpe(w, mu, cov), x0=np.ones(n) / n, method='SLSQP',
bounds=[(0, 1)] * n,
constraints=[{'type': 'eq', 'fun': lambda w: np.sum(w) - 1}])
return r.x
rng = np.random.default_rng(42)
n_assets, n_days = 5, 252 * 3
true_mu = np.array([0.08, 0.10, 0.06, 0.12, 0.07])
true_cov = np.array([
[0.040, 0.012, 0.008, 0.016, 0.010],
[0.012, 0.036, 0.006, 0.018, 0.009],
[0.008, 0.006, 0.025, 0.010, 0.007],
[0.016, 0.018, 0.010, 0.049, 0.012],
[0.010, 0.009, 0.007, 0.012, 0.030],
])
daily_mu = true_mu / 252.0 # simulate in daily units...
daily_cov = true_cov / 252.0
L = np.linalg.cholesky(daily_cov)
returns = rng.standard_normal((n_days, n_assets)) @ L.T + daily_mu
print("true Sharpe :", np.round(true_mu / np.sqrt(np.diag(true_cov)), 3))
w_true = max_sharpe_weights(true_mu, true_cov)
print("MV on TRUE params:", {k: round(float(v), 4) for k, v in zip(ASSETS, w_true)})Output:
true Sharpe : [0.4 0.527 0.379 0.542 0.404]
MV on TRUE params: {'A': 0.0999, 'B': 0.3196, 'C': 0.1362, 'D': 0.3051, 'E': 0.1393}We know the ground truth — and even with perfect inputs, mean-variance wants a tilted book (14–32% per name, no shorts). Keep that allocation in mind as the “full information” reference.
What history tells us #
est_mu = returns.mean(axis=0) * 252
est_cov = np.cov(returns, rowvar=False, ddof=1) * 252
print("estimated mu :", np.round(est_mu, 4))
print("estimated vol :", np.round(np.sqrt(np.diag(est_cov)), 4))
print("estimated Sharpe:", np.round((est_mu - RF) / np.sqrt(np.diag(est_cov)), 3))
w_mark = max_sharpe_weights(est_mu, est_cov)
print("naive MV weights:", {k: round(float(v), 4) for k, v in zip(ASSETS, w_mark)})Output:
estimated mu : [-0.0916 0.1354 0.0817 0.0338 -0.0572]
estimated vol : [0.2 0.1957 0.1522 0.2302 0.1744]
estimated Sharpe: [-0.558 0.59 0.406 0.06 -0.443]
naive MV weights: {'A': 0.0, 'B': 0.5797, 'C': 0.4203, 'D': 0.0, 'E': 0.0}Look at what estimation noise did. From 756 daily observations:
- Asset A’s true Sharpe is 0.40 — history says −0.56
- Asset D has the best true Sharpe (0.542) — history says 0.06
- The naive optimizer accordingly fires A, D and E entirely and puts 58/42 into B and C
The optimizer did exactly what it was asked to do with wrong inputs. This is the data that “tricked” mean-variance, not a bug.
Black-Litterman: equilibrium + one view #
def bl_posterior(pi, Sigma, view_asset, view_q, tau=TAU):
"""Standard form: M = [(tau*Sigma)^-1 + P' Omega^-1 P]^-1
Pi_post = M [(tau*Sigma)^-1 pi + P' Omega^-1 Q] (He-Litterman Omega rule)"""
n = len(pi)
P = np.zeros((1, n)); P[0, view_asset] = 1.0; Q = np.array([view_q])
Omega = tau * Sigma[view_asset, view_asset] # He-Litterman view variance
ts_inv = np.linalg.inv(tau * Sigma)
M = np.linalg.inv(ts_inv + (P.T @ P) / Omega)
return M @ (ts_inv @ pi + (1 / Omega) * (P.T @ Q))
w_eq = np.ones(n_assets) / n_assets # equal-weight market benchmark
pi = DELTA * est_cov @ w_eq
print("implied pi :", np.round(pi, 4))
pi_post = bl_posterior(pi, est_cov, view_asset=1, view_q=0.12)
w_bl = max_sharpe_weights(pi_post, est_cov)
print("BL posterior :", np.round(pi_post, 4))
print("BL weights :", {k: round(float(v), 4) for k, v in zip(ASSETS, w_bl)})Output:
implied pi : [0.0453 0.0445 0.0263 0.0584 0.0373]
BL posterior : [0.059 0.0822 0.0323 0.0777 0.0482]
BL weights : {'A': 0.1282, 'B': 0.5773, 'C': 0.0, 'D': 0.2331, 'E': 0.0614}Read this against the naive result:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| True Sharpe | 0.40 | 0.53 | 0.38 | 0.54 | 0.40 |
| Naive MV | 0% | 58% | 42% | 0% | 0% |
| Black-Litterman | 13% | 58% | 0% | 23% | 6% |
- The 12% view on B moved its posterior return from the equilibrium 4.45% to 8.22% — partial adoption, since the He–Litterman rule makes the view carry about the same uncertainty as the prior.
- D is back at 23%. Its equilibrium return (5.84%) is the highest of the five, derived from the covariance structure, not from the unlucky mean estimate — the prior refused to fire the asset history happened to undersell.
- BL is not diversification for decoration: it dropped C to zero, where the equilibrium says C is the least attractive asset and the view said nothing in its favor.
Stability: 200 bootstrapped re-estimations #
The classic failure mode of mean-variance is not one bad estimate — it is that the portfolio changes identity every time you re-estimate. Resample 3 years of history (bootstrap) 200 times, re-run both models on each sample, and watch the weights:
n_boot = 200
mark_ws, bl_ws = [], []
for b in range(n_boot):
sample = returns[rng.integers(0, n_days, n_days)]
mu_b = sample.mean(axis=0) * 252
S_b = np.cov(sample, rowvar=False, ddof=1) * 252
mark_ws.append(max_sharpe_weights(mu_b, S_b))
pi_b = DELTA * S_b @ w_eq
bl_ws.append(max_sharpe_weights(bl_posterior(pi_b, S_b, 1, 0.12), S_b))
mark_ws = np.array(mark_ws); bl_ws = np.array(bl_ws)
print("MV weight std:", np.round(mark_ws.std(axis=0), 4), " sum:", round(mark_ws.std(axis=0).sum(), 4))
print("BL weight std:", np.round(bl_ws.std(axis=0), 4), " sum:", round(bl_ws.std(axis=0).sum(), 4))
top_mv = np.argmax(mark_ws, axis=1); top_bl = np.argmax(bl_ws, axis=1)
print("MV dominant asset:", {ASSETS[i]: int((top_mv == i).sum()) for i in range(n_assets)})
print("BL dominant asset:", {ASSETS[i]: int((top_bl == i).sum()) for i in range(n_assets)})Output:
MV weight std: [0.0936 0.3624 0.3514 0.1769 0.0692] sum: 1.0535
BL weight std: [0.0146 0.0207 0.0001 0.0165 0.0194] sum: 0.0712
MV dominant asset: {'A': 2, 'B': 99, 'C': 89, 'D': 9, 'E': 1}
BL dominant asset: {'A': 0, 'B': 200, 'C': 0, 'D': 0, 'E': 0}- Naive mean-variance is 15× more unstable (weight dispersion 1.05 vs 0.071). Its largest position flips wholesale between B and C depending on the resample — 99 vs 89 flips — meaning consecutive quarter-end rebalances would look like an entirely different strategy.
- Black-Litterman returns essentially the same portfolio every time, because its central input ($\pi = \delta \Sigma w_{eq}$) rides on covariance estimates, which 756 observations pin down far more tightly than means.
Out-of-sample: one year can mislead, so try fifty #
def realized_sharpe(w, test_returns):
pr = test_returns @ w
return (pr.mean() - RF / 252) / (pr.std(ddof=1) / np.sqrt(252))
rng2 = np.random.default_rng(123)
test = rng2.standard_normal((252, n_assets)) @ L.T + daily_mu # one fresh year
print("fresh year: MV", round(realized_sharpe(w_mark, test), 4), " BL", round(realized_sharpe(w_bl, test), 4))
sh_mv, sh_bl = [], []
for y in range(50): # 50 fresh years
tr = rng2.standard_normal((252, n_assets)) @ L.T + daily_mu
sh_mv.append(realized_sharpe(w_mark, tr))
sh_bl.append(realized_sharpe(w_bl, tr))
sh_mv = np.array(sh_mv); sh_bl = np.array(sh_bl)
print("50 years: MV mean", round(sh_mv.mean(), 3), " BL mean", round(sh_bl.mean(), 3))
print("mean annual diff (MV - BL):", round((sh_mv - sh_bl).mean(), 3),
"+/-", round((sh_mv - sh_bl).std() / np.sqrt(50), 3))
print("true Sharpe of the two portfolios: MV", round((w_mark @ true_mu - RF) / np.sqrt(w_mark @ true_cov @ w_mark), 3),
" BL", round((w_bl @ true_mu - RF) / np.sqrt(w_bl @ true_cov @ w_bl), 3))Output:
fresh year: MV 1.1748 BL 0.3438
50 years: MV mean 0.404 BL mean 0.588
mean annual diff (MV - BL): -0.184 +/- 0.068
true Sharpe of the two portfolios: MV 0.453 BL 0.516Two honest observations, in order of how often they get misrepresented:
- On the single fresh holdout year, naive MV “won” (1.17 vs 0.34). That is one draw of 252 days for a concentrated bet that happened to land in the best-performing assets — the realized 1.17 against a true portfolio Sharpe of 0.45 is luck, and single-year demos that conclude from this ordering are noise.
- Over 50 fresh years the conclusion reverses convincingly: BL’s realized Sharpe beats naive MV by 0.18 per year, a 2.7σ gap. The mechanism is visible in the true portfolio Sharpe (0.52 vs 0.45): by refusing to zero out D, Black-Litterman keeps the best asset in the book across estimation noise.
Conclusion #
The Black-Litterman model is not a forecasting machine — it is a robustness prior:
- Naive mean-variance turns a ±12%-wide knowledge of expected returns into corner solutions that flip identity on every re-estimation (verified: 1.05 vs 0.071 total weight dispersion across 200 resamples).
- The equilibrium return $\pi = \delta \Sigma w_{cap}$ is anchored on something you can actually estimate well — covariances and benchmark weights — and never re-uses the noisy $\hat{\mu}$.
- Views enter through a clean Bayesian update with explicit strength ($\Omega$); the He–Litterman rule $\Omega = \tau P \tau \Sigma P^T$ is a sensible default.
- Verified out-of-sample benefit in simulation: +0.18 Sharpe per year over 50 fresh years — with the honest caveat that any single holdout year can point the other way.
If you let the “market portfolio” be your own tangency portfolio, the whole machinery collapses back into circular noise — the choice of anchor is the model.
References #
- Black, F. & Litterman, R. (1992). Global Portfolio Optimization — the original paper
- He, G. & Litterman, R. (1999). The Intuition Behind Black-Litterman Portfolios — the clearest derivation-to-practice guide
- Grinold, R. & Kahn, R. Active Portfolio Management — Richard Grinold, Ronald Kahn [Amazon] — covers BL in the context of the fundamental law of active management
What to remember #
- Naive MV on noisy $\hat{\mu}$ produces corner solutions; the fix is structural, not a shrinkage parameter bolted on afterwards
- The equilibrium prior $\pi = \delta \Sigma w_{cap}$ rides on well-estimated quantities and deliberately avoids $\hat{\mu}$
- The posterior $\Pi_{BL}$ blends prior and views; the view’s strength is a choice you make and defend ($\Omega$, $\tau$)
- Stability across re-estimation is a first-class result, not a cosmetic one — in this test it came with a genuine out-of-sample Sharpe improvement