Companion code for the Medium article: https://medium.com/@moukarzeljoseph/from-scratch-a-python-safe-haven-odyssey-179e929e69d0
This repository contains the Jupyter notebook and analysis behind my exploration of tail risk hedging and the safe haven investment strategy as described by Mark Spitznagel in his book Safe Haven. The core question: Can a small allocation to "insurance" against market crashes actually improve long-term returns, not just reduce risk?
The answer, backed by 98 years of S&P 500 data and 10,000 Monte Carlo simulations, is a resounding yes.
Markets don't follow normal distributions. The left tail, i.e. catastrophic years where the S&P 500 drops 20%, 30%, or even 40% has a disproportionate impact on returns.
A 50% loss requires a 100% gain to recover. This asymmetry means that avoiding the worst years matters more than capturing the best years for longterm wealth accumulation.
By the way, the historical returns do not actually reflect the real statistical properties of returns: the tail is likely fatter than what we have seen, we just need to wait longer.
The notebook explores a simple insurance mechanism:
- 98% of the portfolio in S&P 500 (passive exposure)
- 2% allocated to "crash insurance" (e.g., deep OTM puts)
- If the market drops ≥15%, the insurance pays 15x (turning 2% into 30%)
- If the market doesn't crash, the 2% is lost (cost of insurance)
- Finally, we perform a grid paramter search over multiple thresholds and payment multiplers.
From 10,000 bootstrap simulations over 25 year horizons:
| Metric | Uninsured | Insured |
|---|---|---|
| Median Final Wealth | Lower | Higher |
| 5th Percentile (Worst Cases) | Much Lower | Significantly Better |
| Probability of Outperformance | - | ~60% of trials |
The insured portfolio doesn't just reduce risk, it often increases terminal wealth by avoiding the devastating drawdowns that cripple compounding.
jupyter notebook installed
numpy, matplotlib, scipy, seaborn
jupyter notebook Safe-Haven-Medium.ipynbThe notebook is self-contained with:
- Historical S&P 500 data (1928-2025)
- Distribution analysis with left tail visualization
- Bootstrap Monte Carlo simulation engine
- Side-by-side comparison of hedged vs. unhedged portfolios
The notebook generates:
- Return Distribution Plot: Histogram + KDE showing the fat left tail
- Monte Carlo Fan Charts: 10,000 wealth trajectories with percentile bands
- Comparative Analysis: Insured vs. uninsured portfolio outcomes
The insurance payoff structure:
If S&P return < -15%:
Portfolio return = 0.98 × SPX_return + 0.02 × 15 = 0.98 × SPX_return + 0.30
Else:
Portfolio return = 0.98 × SPX_return - 0.02
This creates convex payoff in the left tail—exactly when you need it most.
- Medium Article: [PLACEHOLDER - Coming Soon]
- Spitznagel, M. - Safe Haven: Investing for Financial Storms
- Taleb, N.N. - Antifragile & The Black Swan
MIT License - Feel free to use, modify, and build upon this work.
For business: joseph.moukarzel@jmclarity.com
Personal: moukarzeljoseph@gmail.com