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 , not guaranteed profits:
Theta uses calendar time: time remaining decreases as increases. With , zero dividend and Black-Scholes notation , a European call has
Here 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 and volga describe second-order interactions that matter when price and implied volatility move together.
These expressions follow by differentiating the call formula using . That identity cancels terms from derivatives of and in delta and rho. Also : 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.
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
For a long option, short shares and self-financing cash, the wealth change after subtracting financing return is approximately . If the underlying’s instantaneous variance is , this gives
This realized versus implied volatility identity assumes continuous paths and hedging, fixed implied volatility and no costs; uses . For the short position the sign changes. Over time, integrate the difference weighted by ; 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 , the per-step approximation is . Substituting the PDE gives . 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.
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 ; quadrupling steps approximately halves it, not as an exact equality for every grid. A jump leaves a convexity residual that delta fixed before the jump cannot remove.
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 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
The intuition is that and the mean absolute value of a normal is 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 . Dividing by makes it grow as , 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 so cash earns no interest. The call is sold at initial value, the hedge bought and 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.
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,partsTo 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.
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 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.
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 , 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
Step 1 of 3. What equation does the option satisfy?
Step 1 of 3. What does the short position in Δ shares cancel?
def hedge_call(path,K,sigma):
raise NotImplementedError()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.