Skip to content

A Python Project Sequence for Learning Financial Mathematics

Original question

Can you recommend a sequence of practical Python projects that gradually introduce more advanced financial mathematics?
Build a returns dashboard, a two-asset portfolio optimiser, a binomial option pricer, a Monte Carlo option pricer, and a discrete delta-hedging experiment. Each project adds one piece of mathematics to tools you already know. Give each project a hand calculation or analytic benchmark so you can distinguish a coding error from a modelling choice.

A sequence with a check at every stage

OrderPython projectNew mathematicsCheck before moving on
1Returns and drawdown dashboardCompounding, sample variance, running peaksReproduce three consecutive returns and a drawdown by hand
2Two-asset efficient frontierCovariance, matrix products, constrained optimisationCompare a grid of weights with the analytic minimum-variance weight
3Binomial European option pricerReplication, discounted expectation, backward inductionMatch a hand-priced one-step call exactly
4Monte Carlo option pricerNormal sampling, geometric Brownian motion, sampling errorCompare a European price and its confidence interval with Black–Scholes
5Discrete delta-hedging experimentOption sensitivities, self-financing accounting, hedging errorTrack stock and cash separately and reproduce one rebalance by hand

The projects are ordered so the tests become more demanding as the models become richer. First use synthetic data to verify arithmetic. Then add a data source or more realistic conditions where relevant. Put the input assumptions and benchmark result near the top of each notebook.

A five-dollar test for the option pricer

In project three, take a stock at 100100 with possible next values of 110110 and 9090, a call strike of 100100, and a zero interest rate over the step. The two call payoffs are 1010 and 00. The replicating portfolio holds half a share and borrows 4545, since 0.5(110)−45=100.5(110)-45=10 and 0.5(90)−45=00.5(90)-45=0. Its initial cost is 0.5(100)−45=50.5(100)-45=5.
Before generalising your tree to hundreds of steps, assert that the one-step model returns 55 for these inputs. Later, when you compare the tree with Black–Scholes, keep the maturity, volatility, rates, and dividend assumptions consistent across methods. Keeping those inputs aligned makes any remaining discrepancy easier to debug.
Reuse your test cases as the projects get bigger. The one-step pricer gives you an exact terminal-payoff test for the tree and a familiar payoff to revisit in Monte Carlo. The continuous-model European call later gives you a benchmark for simulation and a delta for the hedging experiment. Keep the benchmark, the input convention, and the tolerance next to each other. A numerical check tells you much more when you can say whether changing the grid, increasing paths, or changing the model is supposed to affect it.
When you get to the continuous-model benchmark, use the options pricer to check how changing spot or volatility changes the call price.