This site collects notebooks that take a model or method from finance and implement it end to end in Python: pulling the data, solving the problem numerically, and looking at what comes out. Each notebook is self-contained and shows all of its code, so it can be read on its own or used as a starting point for your own work.
Some notebooks use data from WRDS, which requires a subscription to reproduce. The rendered results are stored with the site, so the pages read the same either way.
Portfolio Choice
Implementing the Critical Line Algorithm Trace the mean-variance frontier with short-sales constraints using the Critical Line Algorithm of Markowitz, which builds the frontier from segments joined at corner portfolios, and check it against a numerical solver on real stock data.
Estimation Error in the Tangency Portfolio Simulate investors who estimate the inputs of the tangency portfolio of 100 large U.S. stocks, and see why a structured covariance matrix helps when the alphas are known while estimated alphas are noise that no covariance matrix can fix.
Recursive Utility
Exact Value Function for Recursive Utility Solve the exact nonlinear boundary-value problem for the continuation value in a one-factor Gaussian endowment economy, and measure how far the equilibrium objects are from the local affine approximation.
Option Pricing
Calibrating the Heston Model Implement the Heston closed-form option pricing formula in Python and calibrate the model to AAPL call prices by minimizing the root mean-squared pricing error.