Build a discrete-time delta-hedging engine, decompose its P&L into theta and gamma, find the cost-optimal rebalancing frequency, then watch the Black-Scholes hedge break under jumps and stochastic volatility. The capstone project for the Stochastic Calculus module.
stochastic-calculus · options · delta-hedging · black-scholes · monte-carlo · risk
Learners placed at Morgan Stanley NYC · Optiver AMS
A working delta-hedging engine, built section by section - hands-on, but never alone. Theory first, then you implement it, and checkpoints confirm each section clicked before the next one opens.
Section 0
The Replication Idea
black_scholes.py
Section 1
Continuous Replication and the Gamma-P&L Identity
greeks.py
Section 2
Discrete Hedging and the 1/N Law
hedge.py
Section 3
Theta-Gamma P&L Decomposition
attribution.py
Section 4
Transaction Costs and the Optimal Hedge
costs.py
Section 5
When Black-Scholes Breaks: Jumps and Stochastic Vol
worlds.py
Section 6
Run the Hedging Desk
desk.py
Never stuck
Reveal a hint when you want a nudge - or the full worked solution when you want the answer. Every exercise ships one.
Theory before code
Each formula is explained step by step before you implement it. Nothing is assumed mid-build.
Yours to keep
Finish with the complete research notebook - keep extending it with your own data.
Section 0The Replication Idea
4 tasks · 4 questions
Section 1Continuous Replication and the Gamma-P&L Identity
3 tasks · 5 questions
Section 2Discrete Hedging and the 1/N Law
2 tasks · 3 questions
Section 3Theta-Gamma P&L Decomposition
3 tasks · 3 questions
Section 4Transaction Costs and the Optimal Hedge
3 tasks · 4 questions
Section 5When Black-Scholes Breaks: Jumps and Stochastic Vol
2 tasks · 4 questions
Section 6Run the Hedging Desk
1 task · 2 questions
FinishProject Complete
Your rewards
Real code from inside the project. Press Run to replicate an option with 4 rebalances, then 52 - and watch the error collapse. Open this page on desktop to run it live in your browser.
import numpy as np
from math import erf, exp, log, sqrt
S0, K, T, sigma = 100.0, 100.0, 0.25, 0.20
N = lambda x: 0.5 * (1 + erf(x / sqrt(2)))
def delta(S, t):
if t <= 1e-9:
return 1.0 if S > K else 0.0
d1 = (log(S / K) + 0.5 * sigma ** 2 * t) / (sigma * sqrt(t))
return N(d1)
rng = np.random.default_rng(5)
def replication_error(steps):
dt = T / steps
S, pos = S0, delta(S0, T)
cash = -pos * S0
for i in range(1, steps + 1):
S *= exp(-0.5 * sigma ** 2 * dt + sigma * sqrt(dt) * rng.standard_normal())
d = delta(S, T - i * dt)
cash -= (d - pos) * S
pos = d
return pos * S + cash - max(S - K, 0)
for n in (4, 52):
errs = [replication_error(n) for _ in range(200)]
print(f"rehedge {n:>2}x over the option's life: error sd {np.std(errs):.2f} per option")
print()
print("hedging more often shrinks the error - but every rebalance costs money")The full build prices the whole trade-off: replication error against real trading costs.
Resume bullets
Copy-paste ready - with the build behind you to back every line.
2 more resume bullets inside the project
Interview ammo
“Why is a delta-hedged long option position long gamma and short theta?”
You answer this with a system you built, not a definition you memorized.
4 more talking points inside the project
Full access to this build and the rest of the pipeline - every project in the vault, plus the lessons, exams and certificates behind them. Guided from the first line to the last.
~12h build · +400 XP · 3 resume bullets · 5 interview answers