Module contents
Lesson 12 of 30Core 100 min

Greeks, dynamic hedging and option P&L

Derive option Greeks, connect gamma and theta, attribute hedging P&L, and study discretization, jumps and transaction costs.

After this lesson you can

  • Derive Black-Scholes delta, gamma, vega, theta and rho and their relationships.
  • Show how the PDE links theta and gamma for a delta-neutral portfolio.
  • Decompose hedging P&L into the gamma-weighted realized versus implied variance difference.
  • Measure how rebalancing frequency, jumps and heavy tails affect hedging error.
  • Apply Leland's adjustment and compare time-based and delta-band rebalancing with costs.

Before you start

Portfolio sensitivities

A trader selling a call can buy shares to reduce exposure to small movements. That hedge does not remove curvature or guarantee a path-independent result. The Greeks are local derivatives of value V(t,S,σ,r)V(t,S,\sigma,r), not guaranteed profits:

Δ=VS,Γ=VSS,V=Vσ,Θ=Vt,ρ=Vr.\Delta=V_S,\quad \Gamma=V_{SS},\quad \mathcal V=V_\sigma,\quad \Theta=V_t,\quad \rho=V_r.

Theta uses calendar time: time remaining decreases as tt increases. With τ=T−t\tau=T-t, zero dividend and Black-Scholes notation d1,d2d_1,d_2, a European call has

Δ=N(d1),Γ=ϕ(d1)Sστ,V=Sϕ(d1)τ,\Delta=N(d_1),\quad \Gamma=\frac{\phi(d_1)}{S\sigma\sqrt\tau},\quad \mathcal V=S\phi(d_1)\sqrt\tau, Θ=−Sϕ(d1)σ2τ−rKe−rτN(d2),ρ=Kτe−rτN(d2).\Theta=-\frac{S\phi(d_1)\sigma}{2\sqrt\tau}-rKe^{-r\tau}N(d_2),\quad \rho=K\tau e^{-r\tau}N(d_2).

Here ϕ\phi is the normal density. Vega measures a volatility change of 1.0; divide by 100 for one percentage point. Theta is per year, not per day. Position Greeks add with sign and quantity, using the same units and dates. Vanna VSσV_{S\sigma} and volga VσσV_{\sigma\sigma} describe second-order interactions that matter when price and implied volatility move together.

These expressions follow by differentiating the call formula using Sϕ(d1)=Ke−rτϕ(d2)S\phi(d_1)=Ke^{-r\tau}\phi(d_2). That identity cancels terms from derivatives of d1d_1 and d2d_2 in delta and rho. Also V=S2στΓ\mathcal V=S^2\sigma\tau\Gamma: vega and gamma are different exposures but related in Black-Scholes. A portfolio with small net gamma can retain vega if it mixes maturities. For example, if vega is 40 per unit change, raising implied volatility from 20% to 21% adds approximately 0.4 per option before cross effects.

InteractiveThe Greeks landscape
  • T = 0.1
  • T = 0.5
  • T = 1
Portfolio
Value at S=100, T=0.50.0222
Call or short butterfly formed by −1 call with K = 90, +2 with K = 100 and −1 with K = 110; r = 3% and σ = 25%. Three times remaining and S prices from 60 to 140 are compared. Greeks use an approximate normal CDF and sum positions; no contracts or multipliers are applied.

Gamma of a long call concentrates around the strike as maturity approaches and can grow without bound there; far from the strike it tends to zero. A short butterfly sums gammas of opposite signs and may have positive gamma at the center and negative gamma at the sides. A large price or volatility change requires terms beyond the local Taylor expansion.

Gamma, theta and financing

The previous lesson’s PDE implies the gamma-theta relationship

Θ+12σi2S2Γ+rSΔ−rV=0.\Theta+\tfrac12\sigma_i^2S^2\Gamma+rS\Delta-rV=0.

For a long option, short Δ\Delta shares and self-financing cash, the wealth change after subtracting financing return is approximately Θdt+12Γ(dS)2+r(ΔS−V)dt\Theta dt+\tfrac12\Gamma(dS)^2+r(\Delta S-V)dt. If the underlying’s instantaneous variance is σr2dt\sigma_r^2dt, this gives

dΠ−rΠ dt=12ΓS2(σr2−σi2) dt.d\Pi-r\Pi\,dt=\tfrac12\Gamma S^2(\sigma_r^2-\sigma_i^2)\,dt.

This realized versus implied volatility identity assumes continuous paths and hedging, fixed implied volatility and no costs; Γ\Gamma uses σi\sigma_i. For the short position the sign changes. Over time, integrate the difference weighted by ΓS2\Gamma S^2; comparing two unweighted annualized volatilities is insufficient. If implied volatility changes, vega exposure and cross and higher-order terms appear.

Long-option delta hedging rebalances by selling shares when they rise and buying them back when they fall. Local convexity gain competes with time passage and financing; calling it gamma scalping does not make every trade profitable or guarantee a positive result on a discrete path.

On a grid, for the long call and r=0r=0, the per-step approximation is 12Γi(ΔSi)2+ΘiΔt\tfrac12\Gamma_i(\Delta S_i)^2+\Theta_i\Delta t. Substituting the PDE gives 12Γi[(ΔSi)2−σi2Si2Δt]\tfrac12\Gamma_i[(\Delta S_i)^2-\sigma_i^2S_i^2\Delta t]. The first term uses the movement actually observed, not annual volatility estimated afterward. Exact cash-and-stock P&L differs from this sum through gamma changes during the step and higher-order terms, especially near the end or with jumps.

InteractiveGamma scalping along a path
  • Portfolio P&L
  • Cumulative gamma
  • Cumulative theta
  • Gamma + theta
30.0 %
20.0 %
Terminal S60.84
Exact P&L1.830
Approximate gamma + theta1.884
Long call hedged with short stock, S₀ = K = 100, r = 0 and 64 steps. The path uses normals with seed 281201. Self-financing P&L and the approximate gamma-theta sum are shown with explicit scales and annual volatilities. One realized path does not guarantee the expected sign.

Discretization, tails and costs

Discrete rebalancing leaves hedging error: between dates delta ceases to be the current sensitivity. Under regular diffusion and appropriate conditions, its standard deviation often falls as Δt\sqrt{\Delta t}; quadrupling steps approximately halves it, not as an exact equality for every grid. A jump leaves a convexity residual V(S+ΔS)−V(S)−ΔΔSV(S+\Delta S)-V(S)-\Delta\Delta S that delta fixed before the jump cannot remove.

InteractiveThe hedging-error distribution
  • Daily: 252
  • Weekly: 52
  • Monthly: 12
Innovations
0
SimulationCalculating 30,000 paths
For each frequency, 10,000 paths of a short call are simulated with S₀ = K = 100, implied and diffusion σ of 20%, r = 0 and seeds 281210 + number of steps. Symmetric log-price jumps are ±0.15 with approximate annual intensity 0.5 and mean compensation; Student t₅ is standardized to unit variance. Histograms cover [−15,15] with exclusions counted; statistics use all results.

The Student case uses t innovations in log return as a synthetic physical experiment: the t distribution lacks a finite exponential moment, so it is not presented as finite-mean risk-neutral price dynamics. Simulations with finitely many paths do not prove population P&L moments exist. Adding costs changes mean and dispersion; more trades reduce some discretization error while accumulating costs. The frequency minimizing a particular metric depends on its definition.

If κ\kappa is proportional cost per trade on traded notional, a Leland approximation for a positive-gamma call and fixed grid replaces variance, under this convention, by

σL2=σ2+2κσ2πΔt.\sigma_L^2=\sigma^2+2\kappa\sigma\sqrt{\frac{2}{\pi\Delta t}}.

The intuition is that ∣ΔΔ∣≈∣ΓΔS∣|\Delta\Delta|\approx|\Gamma\Delta S| and the mean absolute value of a normal is 2/π\sqrt{2/\pi} standard deviations. Another convention defining cost as round-trip introduces a different factor of two. The adjustment approximates price and strategy under specific assumptions, not a perfect hedge or universal prescription. A delta band avoids trading when deviation from target is small and changes the cost-risk tradeoff. See Leland (1985).

To see the scale, expected cost per interval is approximately κS2∣Γ∣σ2Δt/π\kappa S^2|\Gamma|\sigma\sqrt{2\Delta t/\pi}. Dividing by Δt\Delta t makes it grow as 1/Δt1/\sqrt{\Delta t}, while diffusion error falls on that scale. With positive cost, formally moving to continuous trading is not free. The figure also compares P&L RMSE against zero; its three points do not ensure a U-shaped curve or identify the optimum among all frequencies.

Lab: attributing P&L

The following functions use r=q=0r=q=0 so cash earns no interest. The call is sold at initial value, the hedge bought and κ\kappa paid for each position change. Marked price uses a quote volatility that can change; hedge delta can use another forecast. The residual contains Taylor error, including cross and higher-order terms, not a new profit.

[ ]Vectorized hedging simulatorBrowser
import numpy as np
from scipy.special import ndtr
def price_greeks(S,K,sigma,tau):
    S,sigma,tau=np.broadcast_arrays(np.asarray(S,float),np.asarray(sigma,float),np.asarray(tau,float))
    safe=np.maximum(tau,1e-12); a=np.maximum(sigma*np.sqrt(safe),1e-12); d1=(np.log(S/K)+.5*sigma*sigma*safe)/a; d2=d1-a
    phi=np.exp(-d1*d1/2)/np.sqrt(2*np.pi); c=S*ndtr(d1)-K*ndtr(d2)
    return (np.where(tau>0,c,np.maximum(S-K,0)),np.where(tau>0,ndtr(d1),(S>K).astype(float)),
            np.where(tau>0,phi/(S*a),0),np.where(tau>0,-S*phi*sigma/(2*np.sqrt(safe)),0),np.where(tau>0,S*phi*np.sqrt(safe),0))
def hedge(logreturns,quote,hedge_vol=None,cost=0.,band=0.):
    paths,n=logreturns.shape; dt=1/n; S=np.full(paths,100.); quote=np.broadcast_to(quote,(n+1,)); K=100.
    vol=quote[0] if hedge_vol is None else np.broadcast_to(hedge_vol,(n,))[0]
    V,delta,gamma,theta,vega=price_greeks(S,K,quote[0],1.); h=price_greeks(S,K,vol,1.)[1]
    cash=V-h*S-cost*np.abs(h)*S; pnl=-cost*np.abs(h)*S
    parts={name:np.zeros(paths) for name in ('delta','gamma','theta','vega','residuo','coste')}; parts['coste']-=cost*np.abs(h)*S
    for i in range(n):
        newS=S*np.exp(logreturns[:,i]); ds=newS-S; newV=price_greeks(newS,K,quote[i+1],1-(i+1)*dt)[0]
        raw=-(newV-V)+h*ds
        terms={'delta':(h-delta)*ds,'gamma':-.5*gamma*ds*ds,'theta':-theta*dt,'vega':-vega*(quote[i+1]-quote[i])}
        for name,val in terms.items(): parts[name]+=val
        parts['residuo']+=raw-sum(terms.values()); pnl+=raw
        if i<n-1:
            hv=quote[i+1] if hedge_vol is None else np.broadcast_to(hedge_vol,(n,))[i+1]
            target=price_greeks(newS,K,hv,1-(i+1)*dt)[1]; newh=np.where(np.abs(target-h)>band,target,h)
        else: newh=np.zeros(paths)
        trade=newh-h; fee=cost*np.abs(trade)*newS; cash-=trade*newS+fee; pnl-=fee; parts['coste']-=fee
        S,V,h=newS,newV,newh
        _,delta,gamma,theta,vega=price_greeks(S,K,quote[i+1],1-(i+1)*dt)
    assert np.allclose(pnl,cash-V,atol=1e-9)
    assert np.allclose(pnl,sum(parts.values()),atol=1e-9)
    return pnl,parts

To verify convergence order we generate exact diffusions with volatility equal to implied volatility. Samples are independent for each frequency and the result is a statistical check, not an identity of sample standard deviations.

[ ]Discretization scalingBrowser
g=np.random.default_rng(281202); sig=.2; count=3000
for n in (16,64,256,1024):
    dt=1/n; returns=-.5*sig**2*dt+sig*np.sqrt(dt)*g.standard_normal((count,n)); p,parts=hedge(returns,np.full(n+1,sig))
    print('pasos',n,'media',round(p.mean(),5),'desviación',round(p.std(ddof=1),5),'sd*sqrt(n)',round(p.std(ddof=1)*np.sqrt(n),5),'residuo medio',round(parts['residuo'].mean(),5))

In this run standard deviations for 16, 64, 256 and 1024 steps were 1.71050, 0.92708, 0.42415 and 0.22218. Their products by n\sqrt n were between 6.79 and 7.42. The pattern is compatible with that scale, although sampling variation prevents expecting ratios exactly equal to two.

The next experiment uses GARCH returns with standardized t innovations and simulated jumps. The volatility forecast uses only previous returns, not future path volatility. Quote volatility is constant and vega attribution is zero by construction. A separate test also covers an exogenous quote change.

[ ]GARCH-t, jumps and bandsBrowser
g=np.random.default_rng(281203); paths,n=4000,252; h=np.full(paths,.2**2/252); returns=np.empty((paths,n)); predictions=[]; history=[]
for i in range(n):
    predictions.append(.2 if i<20 else float(np.clip(np.std(np.concatenate(history[-20:]))*np.sqrt(252),.05,.8)))
    z=g.standard_t(6,paths)*np.sqrt(4/6); innovation=np.sqrt(h)*z; jump=(g.random(paths)<.5/252)*g.normal(0,.08,paths)
    returns[:,i]=-.5*h+innovation+jump; history.append(returns[:,i].copy()); h=.0000008+.08*innovation**2+.90*h
quote=np.full(n+1,.2); cost=.001
def report(name,p):
    ordered=np.sort(p); tail=ordered[:int(.05*len(p))]
    print(name,'media',round(p.mean(),4),'desviación',round(p.std(ddof=1),4),'pérdida media del peor 5 %',round(-tail.mean(),4))
for name,vol,band in [('delta implícita',None,0),('delta previsión',np.array(predictions),0),('banda 0.05',None,.05)]:
    p,parts=hedge(returns,quote,vol,cost,band); report(name,p)
    print('atribución media', {k:round(v.mean(),4) for k,v in parts.items()})
moving=np.linspace(.2,.25,n+1); p,parts=hedge(returns,moving,None,cost,0)
print('cotización creciente: vega media',round(parts['vega'].mean(),4),'residuo medio',round(parts['residuo'].mean(),4))

The example forecasts aggregate synthetic paths available at each date across the cross-section; they are a laboratory device, not a predictor calibrated to market data. GARCH variance has persistence 0.98 and unconditional daily level 0.0000008/(1−0.98)=0.000040.0000008/(1-0.98)=0.00004, equivalent to approximately 10% annual volatility before jumps; the 20% quote does not represent the same generating model. Jumps and the GARCH-t mixture are compared across strategies on the same sample. Mean loss in the worst 5% is a tail measure for this sample, not a future-risk guarantee; t innovations in log returns do not guarantee finite population exponential moments either.

With this seed, mean P&L for implied, forecast and band strategies is 2.2505, 2.2008 and 2.4272; their mean losses in the worst 5% are 3.9172, 4.3289 and 3.7909. The band reduced mean cost from 0.4253 to 0.2486, but these numbers do not establish dominance in other distributions or samples. With rising quote volatility, mean vega attribution was −1.1248 and mean residual 0.0298, calculated on the same sample.

Exercises

ProofTheta pays for gamma
Prove: Derive the relationship between Θ\Theta and Γ\Gamma from the PDE without dividends.
0
Use Δ=VS\Delta=V_S, Γ=VSS\Gamma=V_{SS} and Θ=Vt\Theta=V_t.

Step 1 of 3. What equation does the option satisfy?

ProofVariance differential
Prove: Obtain financed P&L for a long, hedged option with fixed σi\sigma_i and realized instantaneous variance σr2\sigma_r^2.
0
Assume continuous diffusion and costless continuous hedging.

Step 1 of 3. What does the short position in Δ shares cancel?

NumericDelta near the money
For a call with S = K = 100, r = 0, annual σ = 20% and T = 0.25 years, calculate delta.
NumericGamma near the money
With the same parameters, calculate gamma per unit of price.
QuizHedged straddle
Total realized volatility equals implied volatility, but the largest movements occurred near the strike just before maturity. Why can a short, hedged straddle lose money?
CodeA hedged path
Implement hedge_call(path,K,sigma) for a short call, r = 0 and equally spaced times. The vector contains prices from t=0 to T=1; receive the premium, buy delta initially and rebalance at each interior date. Return cash after settling the option and stock, without costs.
def hedge_call(path,K,sigma):
  raise NotImplementedError()
Shift+Enter to run

Ideas to remember

Delta removes local linear exposure; gamma, theta, vega and financing explain the remainder only within an approximation. P&L-relevant variance is weighted by gamma and path. In markets with jumps or costs, increasing frequency does not eliminate every risk.