Free lesson · Stochastic calc
Black–Scholes and delta hedging in production
Open interactive lessonPractice calculationsExplore labs
Start with the idea
Black–Scholes prices a replicable payoff under a set of idealised assumptions. The drift of the real-world stock forecast disappears from the price because replication replaces a directional forecast with no-arbitrage financing.
Symbols, units & horizon
- C: European call value with no dividends in the displayed BS equation
- S or S₀: spot
- K: strike
- r: continuously compounded annual risk-free rate
- T: years remaining
- σ: annualised return volatility
- E_Q: expectation under the risk-neutral probability measure, not physical expected return
- Z,Z₁,Z₂: standard normal draws
- (x)⁺: max(x,0)
- N or Φ: standard normal cumulative probability
- φ: standard normal density
- d₁,d₂: dimensionless normal thresholds
- μ: price drift in the physical-measure Heston model
- v: instantaneous return variance per year
- κ: variance mean-reversion speed per year
- θ: long-run variance
- ξ: volatility of variance parameter
- W_S,W_v: correlated Brownian motions
- ρ: shock correlation
- ⟨ ⟩: quadratic covariation
- v⁺: max(v,0) in the numerical scheme
- Δ: call delta, sensitivity to spot
- Γ: gamma, second spot derivative
- Vega: option value change per unit decimal volatility
- m(t): expected variance at time t in the ODE
- v₀: initial variance
When and why to use this
Use the formula as a baseline for implied volatility, scenario sensitivities and option-price checks. The Heston extension explains how allowing variance to move introduces skew and additional risks.
Integrate the risk-neutral call payoff
- For a European call without dividends, risk-neutral pricing gives , with .
- The exercise condition Sₜ>K is Z>−d₂, where . Split the payoff expectation into a stock term and K times the exercise probability.
- Use (complete the square). The stock term becomes ; the strike term is . Subtract.
- Differentiate the result, using the normal-density cancellation, to get and . Vega per 1.00 volatility is .
S=K=100, r=.05, T=1, σ=.20: d₁=.35, d₂=.15; N≈.63683,.55962; C≈10.4506. These are risk-neutral pricing quantities.
is the risk-neutral probability of finishing in the money; is the delta. The formula is the solution of the PDE you get by plugging Itô's lemma into a hedged portfolio and insisting it earn the risk-free rate — which is why does not appear: the hedge removed it.
Delta hedging uses the option model's local stock sensitivity to choose the hedge. With discrete rebalancing there is residual error. Under suitable diffusion, regularity and fine-grid assumptions, the standard deviation of the discretisation component can scale approximately with ; in that regime, a quarter of the interval gives about half that component's standard deviation. This is not a universal scaling law for total trading P&L. Jumps, near-expiry payoff kinks, changing parameters and transaction costs can materially change the result.
| Greek | definition | what it tells the desk |
|---|---|---|
| Δ delta | shares to hold against one option | |
| Γ gamma | how fast delta changes; convexity; peaks at the money near expiry | |
| Θ theta | daily decay; the bill for gamma | |
| ν vega | exposure to implied vol; largest at the money, long-dated |
At-the-money call, T → 0. Gamma goes…
. As at the money, the denominator vanishes. Delta flips from 0 to 1 across the strike in an instant; hedging it is impossible. This is "pin risk", and it is why expiry days are dangerous for short-gamma books.
Heston: volatility is itself random
Discretise stochastic variance and correlated shocks
- Heston specifies variance rather than deriving it from price. Over Δt, a full-truncation Euler update is , with .
- For independent unit-normal Z₁,Z₂, set and . Variance is ρ²+(1−ρ²)=1 and covariance with Zₛ is ρ.
- Taking expectation of the variance equation removes the shock. Solving gives .
ρ=−.7, Z₁=1,Z₂=0 gives Zᵥ=−.7. With κ=2, θ=.04, v₀=.09, T=1, expected variance=.04+.05e⁻²≈.04677.
Black–Scholes prices every strike with one σ; the market does not. Plot implied vol against strike and you get a smile (or, in equities, a skew — puts are dearer). Heston generates the smile from two extra ingredients: vol-of-vol fattens both tails, and correlation between price and vol tilts it. (crashes come with vol spikes) produces the equity skew.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
from math import log, exp, sqrt
from statistics import NormalDist
def black_scholes_call(spot, strike, rate, volatility, years):
if min(spot,strike,volatility,years) <= 0:
raise ValueError("Positive S, K, sigma and T required")
d1 = (log(spot/strike)+(rate+.5*volatility**2)*years)/(volatility*sqrt(years))
d2 = d1-volatility*sqrt(years)
normal = NormalDist()
return spot*normal.cdf(d1)-strike*exp(-rate*years)*normal.cdf(d2)
def heston_step(spot, raw_variance, mu, kappa, theta, xi, rho, dt, z1, z2):
"""Full-truncation Euler variance; independent standard-normal z1, z2.
Preserve raw variance for the next step; positive part is used in coefficients.
Spot uses a log step. Discretisation has bias; this is not an exact sampler.
"""
if not -1 <= rho <= 1 or dt < 0:
raise ValueError("Invalid correlation or time step")
v = max(raw_variance, 0)
shock_s = sqrt(dt)*z1
shock_v = sqrt(dt)*(rho*z1+sqrt(1-rho*rho)*z2)
next_v = raw_variance+kappa*(theta-v)*dt+xi*sqrt(v)*shock_v
next_s = spot*exp((mu-.5*v)*dt+sqrt(v)*shock_s)
return next_s, next_v
print(black_scholes_call(100,100,.05,.2,1))
def bs_spot_vol_greeks(spot, strike, rate, volatility, years):
d1 = (log(spot/strike)+(rate+.5*volatility**2)*years)/(volatility*sqrt(years))
density = NormalDist().pdf(d1)
return {"delta":NormalDist().cdf(d1),
"gamma":density/(spot*volatility*sqrt(years)),
"vega_per_unit":spot*density*sqrt(years)}
def heston_expected_variance(initial_variance, long_run_variance, speed, years):
return long_run_variance+(initial_variance-long_run_variance)*exp(-speed*years)
Continue learning
Stochastic Calculus — all lessons- Start with one random step before continuous noise
- Before Itô: random walks, Brownian motion and information
- Itô integration and quadratic variation
- SDEs, Euler–Maruyama and an Ornstein–Uhlenbeck example
- Geometric Brownian motion: the model under Black–Scholes
- Itô's lemma: why gamma exists
- Black–Scholes and delta hedging in production
- Put–call parity and a full Greek P&L budget
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations