joshriang
← Back to portfolio

Quant research & trading·Python·Published

Options Hedging Simulator

I wanted to see, in numbers, why delta-hedging a short option is not the riskless trade it looks like on a whiteboard, so I built a simulator that hedges one short European call through time and splits the final P&L into premium, payoff, trading residual and transaction costs. The pricer is plain Black-Scholes with delta, gamma, vega, theta and implied vol by bisection; paths come from GBM or a Merton jump-diffusion, and the hedge loop goes long delta shares, funds them from a cash account accruing at e^(r·dt) and re-hedges every k steps. The attribution satisfies an exact additive identity that a test checksums, so no P&L can hide in an unexplained residual. Running 2000 paths over 63 steps, hedging at vol 0.35 against a true 0.25 earned +1.98 on average while hedging at 0.15 lost -1.99, and at the true vol the mean was -0.0027. Coarsening rebalancing from every step to every 21 steps kept the mean near zero but pushed RMSE from 0.576 to 2.294, and adding downside jumps moved the mean to -0.56, roughly tripled the std to 1.59 and fattened the 5th percentile to -3.57. The suite is 12 pytest tests with no network dependency.

Date
2026
Main stack
Python
Code
github ↗
01
02
  • With the correct volatility the hedge is unbiased but not safe: RMSE went from 0.576 to 2.294 as rebalancing moved from every step to every 21, so discrete gamma bleed is a variance problem, not a bias problem.
  • Volatility misspecification shifts the mean almost linearly (about 0.2 per vol point between 0.15 and 0.35), which is the volatility risk premium showing up as a P&L number rather than a story.
  • A P&L attribution is only trustworthy if it is an identity with a checksum; without that, jump losses quietly land in the residual and the model looks better than it is.
03

Scale 0–100: how much this project relied on each skill.