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 jupyterlab

02 · The core environment

Needed by every notebook.

PackageVersionUsed for
Python3.11+3.10 works; 3.11 is what we QA against
NumPy≥ 1.26array engine used by everything below
Pandas≥ 2.1time-series handling, CSV/parquet IO
SciPy≥ 1.11optimisers, distributions, stats tests
Matplotlib≥ 3.8every notebook figure
yfinance≥ 0.2market data download (Yahoo Finance)
statsmodels≥ 0.14regressions & econometrics
Jupyterlab or notebookor 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.

PackageVersionUsed in
PyPortfolioOpt1.6+MVO, Black–Litterman (T05, T06)
Riskfolio-Lib7+risk-parity & CVaR validation (T07, T10)
Polars1.xthe modern DataFrame example in T09
DuckDB1.xthe SQL VaR example in T09
vectorbt1.xbacktest engine (T13)
seaborn0.13+statistical plots (T11)

04 · Per-tutorial stack

#TutorialLibrariesData
01GBM: Simulating Price PathsNumPy · Pandas · Matplotlib · yfinance · SciPySPY (S&P 500 ETF, State Street)
02Black–Scholes & the GreeksNumPy · SciPy · MatplotlibQQQ options (Nasdaq 100 ETF, Invesco)
03Bond Pricing, Duration & ConvexityNumPy · Pandas · Matplotlib · yfinanceUS Treasuries (2y–30y) + SHY / IEF / TLT (iShares)
05MVO & the Efficient FrontierPyPortfolioOpt · Pandas · MatplotlibSPY · TLT · GLD · VNQ · VEA · VWO
06Black–Litterman: Equilibrium + ViewsPyPortfolioOpt (BL) · NumPyEWJ · EWG · EWU · EWA · EWC (iShares country ETFs)
07Risk Parity from ScratchSciPy (build) · Riskfolio-Lib (validate)SPY · TLT · GLD · DBC
09VaR Three WaysNumPy · SciPy · Pandas · Polars · DuckDBDAX (^GDAXI)
10CVaR / Expected ShortfallSciPy · Riskfolio-LibHYG + VWO (fat-tailed assets)
11Copulas & Tail DependenceSciPy · statsmodels · seabornS&P 500 vs FTSE 100 vs Nikkei 225
13SMA Crossover Backtestvectorbt · Pandas · PyfolioQQQ + BTC-USD (trend behaves differently per asset)
14Kalman Filters: Dynamic Hedge RatiosNumPy (build the filter) · statsmodels · PandasEWA / 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.