A compact, reproducible quantitative research project that connects covariance estimation, constrained numerical optimization, transaction-aware rebalancing, bootstrap stability, and factor stress testing.
The experiment uses deterministic synthetic returns from a transparent three-factor model whose true covariance is known. It contains no private data and makes no claim about real investment performance.
- Sample covariance versus Ledoit–Wolf shrinkage.
- Long-only, fully invested global minimum-variance optimization with a 35% cap.
- A smooth L1 turnover penalty relative to a predeclared current portfolio.
- Evaluation against the generator's true covariance, not the matrix optimized.
- A stronger first-factor stress applied to both variances and covariances.
- Bootstrap weight stability and true-risk dispersion across resamples.
- Feasibility, positive-semidefinite, hand-calculation, turnover, and stability tests.
For weights w, covariance Sigma, current weights w0, and penalty lambda,
the solver minimizes
w' Sigma w + lambda * sum(sqrt((w_i - w0_i)^2 + epsilon^2) - epsilon)
subject to sum(w) = 1, 0 <= w_i <= 0.35. The smoothing constant is 1e-6.
The documented run sets the turnover penalty to 1e-5.
The reported one-way turnover is 0.5 * sum(abs(w - w0)); it is not the smoothed
quantity used by the numerical objective.
Requires Python 3.10 or newer.
python -m venv .venv source .venv/bin/activate python -m pip install -e ".[dev]" pytest python -m robust_portfolio_optimization_lab \ --output-dir artifacts \ --observations 160 \ --assets 8 \ --bootstrap 120 \ --seed 20260916
The command writes portfolio weights and metrics, bootstrap results, stressed risk contributions, a JSON summary, and three diagnostic charts.
The checked-in artifacts use the command above. Results describe only this synthetic generator, sample size, constraints, solver settings, and seed.
| Portfolio | True annual volatility | Stressed annual volatility | One-way turnover | Maximum weight |
|---|---|---|---|---|
| Current | 13.13% | 19.87% | 0.00% | 30.00% |
| Equal weight | 14.84% | 22.54% | 27.50% | 12.50% |
| Sample-covariance GMV | 13.03% | 19.49% | 16.58% | 35.00% |
| Shrinkage-covariance GMV | 13.06% | 19.59% | 16.00% | 35.00% |
| Turnover-aware shrinkage | 13.06% | 19.74% | 3.82% | 30.47% |
In this single seeded experiment, sample-covariance GMV has marginally lower true risk than shrinkage GMV; the shrinkage benefit is instead visible in the better-conditioned estimate (condition number 10.30 versus 13.35) and slightly lower median bootstrap weight distance (0.237 versus 0.242). The turnover-aware portfolio retains the shrinkage solution's true risk to the reported precision while reducing one-way turnover from 16.00% to 3.82%. The factor stress raises annualized volatility by roughly 49.7% to 51.9% across the five portfolios.
The true covariance is available only because this is a simulation. In real data, out-of-sample risk is unknown and nonstationary. Shrinkage can improve conditioning and stability but does not guarantee lower realized risk. Bootstrap dispersion is an estimation-sensitivity diagnostic, not a probability distribution for future returns. The factor stress is a transparent scenario, not a forecast.
This project deliberately omits expected-return estimation, leverage, shorting, taxes, market impact, liquidity, nonlinear costs, and dynamic rebalancing. SLSQP success and constraint checks establish numerical feasibility, not global economic optimality under a different objective.
Educational use only. This repository is not investment advice.
src/robust_portfolio_optimization_lab/
simulation.py # known factor covariance and stressed covariance
estimation.py # sample and Ledoit–Wolf estimates
optimization.py # capped long-only SLSQP optimizer
evaluation.py # risk metrics, bootstrap, and stress contributions
reporting.py # CSV/JSON outputs and charts
cli.py # reproducible command-line workflow
tests/ # estimator, optimizer, risk, and stability tests
artifacts/ # checked-in outputs from the documented run
MIT


