Skip to content

Repository files navigation

Computational Finance

Derivative pricing implemented from the mathematics in Python — an analytical Black-Scholes model with the full Greeks and a delta-hedging simulation, and a binomial tree pricer checked for convergence against the closed-form solution.

Most models in quantitative finance have no tractable closed form, so the practical question is always how a numerical method behaves: whether it converges, how fast, and to what. These two notebooks are a paired answer — one model that has an exact solution, and one numerical method measured against it.

Black-Scholes with Greeks

Black-Scholes Option Pricing Model.ipynb implements the closed-form European option price and all five first- and second-order sensitivities, derived directly rather than differenced numerically:

Greek Measures
Delta sensitivity to the underlying price
Gamma rate of change of delta — the convexity that makes hedging non-trivial
Theta time decay
Rho sensitivity to the risk-free rate
Vega sensitivity to volatility

Gamma is the one that matters operationally: because delta itself moves as the underlying moves, a delta-hedged position stops being hedged the moment the price does anything. The notebook includes a hedging simulation that rebalances over the life of the option to show that drift in practice.

Worked exampleS₀ = 100, K = 110, r = 0.04, σ = 0.30, T = 1:

Value Delta
Call 9.6254 0.4863
Put 15.3122 −0.5137

The two deltas summing to exactly −1 is put-call parity holding, which is the cheapest available sanity check that the implementation is right.

Binomial tree, and whether it converges

Binomial Tree Option Pricing Model.ipynb builds the Cox-Ross-Rubinstein lattice: model the underlying as discrete up/down moves, then work backwards from expiry through risk-neutral valuation.

The reason to implement it when a closed form exists is that the lattice generalises where Black-Scholes does not — early exercise, American options, path dependence. So the useful measurement isn't the price, it's the convergence: how many steps until the tree agrees with the analytical result, and whether it approaches smoothly or oscillates. The notebook plots tree price against step count with the Black-Scholes value as a horizontal reference.

Worked exampleS₀ = 100, K = 99, r = 0.06, σ = 0.20, T = 1, N = 50 steps:

Value
Call 11.5464
Put 4.7811

Run it

pip install -r requirements.txt
jupyter notebook

Both notebooks are self-contained — no data files, no external feeds. All parameters are set in the first cell of each so they can be varied directly.

Stack

Python, NumPy, SciPy (scipy.stats for the normal CDF and PDF), pandas, matplotlib, Jupyter.

About

Derivative pricing in Python — Black-Scholes with the full Greeks and delta hedging, plus binomial tree pricing with convergence analysis against the closed form.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages