Notebooks · Technical requirements
Run every notebook, anywhere.
Every article ships a runnable companion notebook. They are written against one pinned environment, download their own data, and seed every random draw — so the numbers you get match the numbers in the article, on Windows, Linux, or macOS.
01 · Setup in two commands
Create an isolated environment, then install the full stack. The same commands work in PowerShell (Windows) and any POSIX shell (Linux / macOS) — only the activation line differs.
terminal
python -m venv .venv
# Windows: .venv\Scripts\activate
# Linux / macOS: source .venv/bin/activate
pip install numpy pandas scipy matplotlib yfinance statsmodels \
PyPortfolioOpt Riskfolio-Lib polars duckdb vectorbt seaborn jupyterlab02 · The core environment
Needed by every notebook.
| Package | Version | Used for |
|---|---|---|
| Python | 3.11+ | 3.10 works; 3.11 is what we QA against |
| NumPy | ≥ 1.26 | array engine used by everything below |
| Pandas | ≥ 2.1 | time-series handling, CSV/parquet IO |
| SciPy | ≥ 1.11 | optimisers, distributions, stats tests |
| Matplotlib | ≥ 3.8 | every notebook figure |
| yfinance | ≥ 0.2 | market data download (Yahoo Finance) |
| statsmodels | ≥ 0.14 | regressions & econometrics |
| Jupyter | lab or notebook | or VS Code's built-in notebook UI |
03 · Specialist libraries
Only needed for the tutorials that use them — each article's header lists its exact stack.
| Package | Version | Used in |
|---|---|---|
| PyPortfolioOpt | 1.6+ | MVO, Black–Litterman (T05, T06) |
| Riskfolio-Lib | 7+ | risk-parity & CVaR validation (T07, T10) |
| Polars | 1.x | the modern DataFrame example in T09 |
| DuckDB | 1.x | the SQL VaR example in T09 |
| vectorbt | 1.x | backtest engine (T13) |
| seaborn | 0.13+ | statistical plots (T11) |
04 · Per-tutorial stack
| # | Tutorial | Libraries | Data |
|---|---|---|---|
| 01 | GBM: Simulating Price Paths | NumPy · Pandas · Matplotlib · yfinance · SciPy | SPY (S&P 500 ETF, State Street) |
| 02 | Black–Scholes & the Greeks | NumPy · SciPy · Matplotlib | QQQ options (Nasdaq 100 ETF, Invesco) |
| 03 | Bond Pricing, Duration & Convexity | NumPy · Pandas · Matplotlib · yfinance | US Treasuries (2y–30y) + SHY / IEF / TLT (iShares) |
| 05 | MVO & the Efficient Frontier | PyPortfolioOpt · Pandas · Matplotlib | SPY · TLT · GLD · VNQ · VEA · VWO |
| 06 | Black–Litterman: Equilibrium + Views | PyPortfolioOpt (BL) · NumPy | EWJ · EWG · EWU · EWA · EWC (iShares country ETFs) |
| 07 | Risk Parity from Scratch | SciPy (build) · Riskfolio-Lib (validate) | SPY · TLT · GLD · DBC |
| 09 | VaR Three Ways | NumPy · SciPy · Pandas · Polars · DuckDB | DAX (^GDAXI) |
| 10 | CVaR / Expected Shortfall | SciPy · Riskfolio-Lib | HYG + VWO (fat-tailed assets) |
| 11 | Copulas & Tail Dependence | SciPy · statsmodels · seaborn | S&P 500 vs FTSE 100 vs Nikkei 225 |
| 13 | SMA Crossover Backtest | vectorbt · Pandas · Pyfolio | QQQ + BTC-USD (trend behaves differently per asset) |
| 14 | Kalman Filters: Dynamic Hedge Ratios | NumPy (build the filter) · statsmodels · Pandas | EWA / EWC pair (Australia / Canada) |
05 · Reproducibility notes
- Data downloads itself. Every notebook pulls its own data from Yahoo Finance via yfinance — no files to place, no paths to edit. An internet connection is required on first run.
- Randomness is seeded. Simulations use np.random.default_rng(42), so Monte-Carlo numbers match the article to the digit on any OS.
- Data revisions happen. Yahoo occasionally restates adjusted closes (dividends, splits). If a third decimal differs from the article, that is the data vendor, not your environment.
- Windows note. vectorbt compiles via numba on first import — the first run takes a minute; subsequent runs are instant.
- No paid data anywhere. Every tutorial runs end-to-end on free data. Nothing to license, nothing to subscribe to.