covariance-and-risk-modelslisted
Install: claude install-skill howard-lynn-ye/fin-skills
# Covariance and risk models
Verification scope: section 5's import-order probe was re-run on 2026-09-14 in both
environments below. The numerical DGP tables retain their 2026-09-09 measurement provenance.
**`np.cov(returns.T)` is an unbiased estimate of every entry and a bad estimate of the matrix.**
The optimizer does not consume entries; it consumes the inverse, and the inverse is where the
estimation error concentrates. Two failures follow, and both look like success in-sample: with
N > T the matrix is singular and the optimizer finds its null space, and even with N < T the
variance it predicts for its own portfolio is biased low.
Every number below is printed by `scripts/risk_model.py` (numpy / pandas, fixed seeds, about
10 s). The data is a k-factor DGP whose true covariance is known, so "predicted", "true" and
"out-of-sample realized" are three separate columns rather than two.
## 1. 🚨 N > T: the optimizer reports 0.00 % risk and delivers 243 %
✅ Measured: 100 assets from a 3-factor DGP, minimum-variance weights `Sigma^-1 1 / 1'Sigma^-1 1`,
volatilities annualized at sqrt(252), `true` from the DGP covariance:
| T | estimator | rank | cond | gross lev | max abs w | pred vol | true vol | true/pred var |
|---|---|---|---|---|---|---|---|---|
| **60** | 🚨 sample | **59** | 2.25e+20 | **92.5** | 2.92 | **0.00 %** | **243.44 %** | **-9.0e+15** |
| 60 | Ledoit-Wolf identity | 100 | 1.82e+02 | 3.2 | 0.09 | 4.92 % | 10.67 % | 4.69 |
| 250 | sample | 100 | 5.39e+02 | 3.5