Module contents
Lesson 11 of 30Core 115 min

Black-Scholes-Merton: hedging, PDE and change of measure

Derive Black-Scholes from self-financing hedging and a change of measure, interpret its probabilities, and connect PDEs with pricing under alternative numeraires.

After this lesson you can

  • Derive the Black-Scholes PDE using Itô's lemma and a self-financing riskless portfolio.
  • Apply Girsanov's theorem and market price of risk to obtain risk-neutral dynamics.
  • Calculate the lognormal Black-Scholes expectation and interpret N(d₁) and N(d₂).
  • Use Feynman-Kac to connect the pricing PDE with risk-neutral expectation.
  • Generalize to continuous dividends, currencies and changes of numeraire.

Before you start

A hedge that removes the noise

In the previous lesson’s tree we replicated two payoffs by adjusting stock and bond at each node. In the continuous limit the same idea gives a differential equation. Assume a costless market with borrowing and short sales at constant rate rr, continuous trading, a positive stock and constant volatility σ>0\sigma>0. Under physical measure PP,

dSt=μSt dt+σSt dWtP,dBt=rBt dt.dS_t=\mu S_t\,dt+\sigma S_t\,dW_t^P,\qquad dB_t=rB_t\,dt.

For now there are no dividends. For a sufficiently regular European derivative V(t,S)V(t,S), Itô’s lemma gives

dV=(Vt+μSVS+12σ2S2VSS)dt+σSVS dWP.dV=\left(V_t+\mu S V_S+\tfrac12\sigma^2S^2V_{SS}\right)dt+\sigma S V_S\,dW^P.

Sell an option and hold Δ=VS\Delta=V_S shares. The random term in Δ dS−dV\Delta\,dS-dV vanishes. The portfolio also includes a financing account; on rebalancing, position changes are paid from that account rather than external contributions. No arbitrage requires its instantaneous return to be r(ΔS−V)dtr(\Delta S-V)dt. Equating terms and canceling μ\mu yields the Black-Scholes PDE:

Vt+12σ2S2VSS+rSVS−rV=0,V(T,S)=g(S).V_t+\tfrac12\sigma^2S^2V_{SS}+rSV_S-rV=0,\qquad V(T,S)=g(S).

The disappearance of μ\mu does not mean beliefs cannot affect stock price or that real risk vanishes. Given SS, rr, σ\sigma and these assumptions, replication fixes price without an additional risk premium. A call payoff g(S)=(S−K)+g(S)=(S-K)^+ has a kink at the strike; under these conditions the solution is smooth for t<Tt<T, though not at maturity.

The account matters. If a replicating portfolio has wealth Xt=ΔtSt+BtcashX_t=\Delta_tS_t+B_t^{\rm cash}, its self-financing condition without dividends is dXt=Δt dSt+rBtcashdtdX_t=\Delta_t\,dS_t+rB_t^{\rm cash}dt. Changing Δ\Delta requires transferring the cost to the account; writing only d(ΔS)d(\Delta S) without that financing introduces terms that do not represent a free strategy. If the asset pays qSdtqSdt, the stock portfolio receives that flow and the PDE changes the coefficient of SVSSV_S from rr to r−qr-q.

InteractiveThe hedge that cancels noise
  • Underlying
  • Call
  • Portfolio minus call
5
0.08
Steps32
Initial price11.3485
Terminal error−1.1259
Hypothetical path generated with a fixed seed and 256 nested normal increments. The portfolio starts with the call price and rebalances without contributions; its difference from the option is shown on an automatically scaled second axis. Changing μ changes the physical path but not the model's initial price. Discrete trading leaves error that need not decrease monotonically on one path.

Change the measure, keep the paths

Let θ=(μ−r)/σ\theta=(\mu-r)/\sigma be the market price of risk per unit of volatility. For constants and a finite horizon, the density

ZT=dQdP=exp⁡(−θWTP−12θ2T)Z_T=\frac{dQ}{dP}=\exp\left(-\theta W_T^P-\tfrac12\theta^2T\right)

is positive and has expectation one. Novikov’s condition holds for constant θ\theta; for general processes it or another sufficient condition must be checked. Girsanov identifies WtQ=WtP+θtW_t^Q=W_t^P+\theta t as Brownian motion under QQ, so

dSt=rSt dt+σSt dWtQ,V0=e−rTEQ[g(ST)]=EP[e−rTZTg(ST)].dS_t=rS_t\,dt+\sigma S_t\,dW_t^Q,\qquad V_0=e^{-rT}\E_Q[g(S_T)]=\E_P[e^{-rT}Z_Tg(S_T)].

QQ changes path weights, not possible paths. In this complete model without dividends, St/BtS_t/B_t is a martingale under QQ and the stochastic discount factor is e−rTZTe^{-rT}Z_T under PP. The change does not say that expected physical return is rr.

Equivalence matters: ZT>0Z_T>0 almost surely, so an event impossible under one measure remains impossible under the other. The bond Bt=ertB_t=e^{rt} acts as numeraire. In a market with untraded risk sources, hedging may not exist and no arbitrage may allow multiple risk-neutral measures; this construction alone then does not determine a unique price.

InteractiveTilt the measure
  • Physical-measure histogram
  • Weighted histogram
  • P density
  • Q density
0.12
Market price of risk θ0.360
Sample ESS / sample size0.877
Asymptotic ESS / sample size0.878
6000 paths simulated under P with seed 281103, unweighted and weighted by dQ/dP, and theoretical densities with S₀ = 100, r = 3%, σ = 25% and T = 1. Only the range 30 to 250 is plotted. The Q density is the P density times the weight; finite histograms fluctuate. Asymptotic ESS is the limiting effective-size proportion.

With independent weights, EP[ZT2]=eθ2T\E_P[Z_T^2]=e^{\theta^2T}, so the asymptotic effective-size ratio Neff/NN_{\rm eff}/N is e−θ2Te^{-\theta^2T}. Physical drift far from risk-neutral drift concentrates weights: the expectation identity remains true, but naive simulation may have high variance. The lab quantifies that difference without treating approximate agreement as exact sample equality.

The formula and its probabilities

With continuous dividend qq and time remaining τ=T−t\tau=T-t, ex-dividend dynamics under QQ have drift r−qr-q. Write

d1=log⁡(S/K)+(r−q+σ2/2)τστ,d2=d1−στ.d_1=\frac{\log(S/K)+(r-q+\sigma^2/2)\tau}{\sigma\sqrt\tau},\qquad d_2=d_1-\sigma\sqrt\tau.

The Black-Scholes-Merton formula for European calls and puts is

C=Se−qτN(d1)−Ke−rτN(d2),P=C−Se−qτ+Ke−rτ.C=Se^{-q\tau}N(d_1)-Ke^{-r\tau}N(d_2),\qquad P=C-Se^{-q\tau}+Ke^{-r\tau}.

To obtain it, separate EQ[e−rτST1ST>K]\E_Q[e^{-r\tau}S_T\mathbf 1_{S_T>K}] from Ke−rτQ(ST>K)Ke^{-r\tau}Q(S_T>K). The logarithm of STS_T is normal; completing the square in the first integral shifts its mean by σ2τ\sigma^2\tau. Thus the second term contains N(d2)N(d_2) and the first N(d1)N(d_1). The first is a stock-weighted expectation, not merely a probability under QQ.

More explicitly, for Z∼N(0,1)Z\sim N(0,1), ST=Sexp⁡((r−q−σ2/2)τ+στZ)S_T=S\exp((r-q-\sigma^2/2)\tau+\sigma\sqrt\tau Z) and exercise is equivalent to Z>−d2Z>-d_2. The identity eazϕ(z)=ea2/2ϕ(z−a)e^{az}\phi(z)=e^{a^2/2}\phi(z-a) transforms the weighted integral to Se(r−q)τN(d1)Se^{(r-q)\tau}N(d_1). Discounting gives Se−qτN(d1)Se^{-q\tau}N(d_1). The put follows from parity, which can also be constructed with stock, bond and both options.

With q=0q=0, N(d2)=Q(ST>K)N(d_2)=Q(S_T>K) and N(d1)N(d_1) is the probability of the same event under the measure whose numeraire is the stock. It is also call delta. With continuous dividends, delta is e−qτN(d1)e^{-q\tau}N(d_1); the appropriate numeraire is the total-return portfolio reinvesting dividends, not the unadjusted ex-dividend stock.

InteractiveWhat N(d₁) and N(d₂) mean
  • Q density
  • Stock-measure density
  • Strike
100
Q: N(d₂)0.4980
Stock measure: N(d₁)0.5968
Theoretical densities under Q and the stock measure, with q = 0. Mass to the right of K is N(d₂) and N(d₁), respectively; shading reaches 250 and numerical values approximate the full tail using a normal CDF. The second density incorporates weighting by terminal stock value.

Use annual σ\sigma and τ\tau in years. At maturity return the payoff directly; for σ=0\sigma=0 return the discounted deterministic payoff max⁡(Se−qτ−Ke−rτ,0)\max(Se^{-q\tau}-Ke^{-r\tau},0) without dividing by zero. The formula should not price an American option with early exercise without checking its conditions.

From the PDE to expectation and other numeraires

Feynman-Kac connects both routes: under suitable regularity and growth, discounted expectation solves the PDE with terminal condition. Conversely, applying Itô to e−rtV(t,St)e^{-rt}V(t,S_t) under QQ removes drift if VV satisfies the PDE; with integrability, the resulting martingale recovers the expectation. With qq, replace rSVSrS V_S by (r−q)SVS(r-q)SV_S.

The change x=log⁡(S/K)x=\log(S/K) and τ=T−t\tau=T-t converts S2VSSS^2V_{SS} into a second derivative with constant coefficient. A translation of xx removes drift and an exponential factor removes the discount term, leaving the heat equation. Gaussian convolution smooths the payoff for τ>0\tau>0; it does not remove the kink at τ=0\tau=0.

Specifically, if v(τ,x)=V(T−τ,Kex)v(\tau,x)=V(T-\tau,Ke^x), then vτ=12σ2vxx+(r−q−12σ2)vx−rvv_\tau=\tfrac12\sigma^2v_{xx}+(r-q-\tfrac12\sigma^2)v_x-rv. With a=r−q−σ2/2a=r-q-\sigma^2/2 and v=e−rτu(τ,x+aτ)v=e^{-r\tau}u(\tau,x+a\tau), uτ=12σ2uxxu_\tau=\tfrac12\sigma^2u_{xx}. For the call, the relevant boundary is C(t,0)=0C(t,0)=0 and, as S→∞S\to\infty, C(t,S)∼Se−qτ−Ke−rτC(t,S)\sim Se^{-q\tau}-Ke^{-r\tau}. The finite surface window does not literally represent those infinite limits.

InteractivePrice as a surface
0.25
Call S=K=100, T=111.3485
Call with K = 100, r = 3%, q = 0 and an approximate normal CDF. The plane spans S from 50 to 150 and time remaining from 0 to 1 year; height is price divided by 25. Show payoff and finite-end slices. Rotate the surface and change σ to observe smoothing.

Numeraire pricing uses a positive traded asset NtN_t: Vt/Nt=EtQN[g(ST)/NT]V_t/N_t=\E^{Q^N}_t[g(S_T)/N_T]. Discount and measure must change together. For currencies, treating the foreign rate as q=rfq=r_f gives Garman-Kohlhagen, with domestic rr. For forward FF lognormal under the maturity-bond measure, Black gives C=B(t,T)[FN(d1)−KN(d2)]C=B(t,T)[F N(d_1)-K N(d_2)] with d1=[log⁡(F/K)+σ2τ/2]/(στ)d_1=[\log(F/K)+\sigma^2\tau/2]/(\sigma\sqrt\tau). These are dynamics assumptions, not automatic substitution of every futures contract by a forward.

To exchange one asset for another without dividends, Margrabe’s (1978) formula uses the second asset as numeraire: V=S1N(d1)−S2N(d2)V=S_1N(d_1)-S_2N(d_2), with relative volatility σ12=σ12+σ22−2ρσ1σ2\sigma_{12}=\sqrt{\sigma_1^2+\sigma_2^2-2\rho\sigma_1\sigma_2} and d1=[log⁡(S1/S2)+σ122τ/2]/(σ12τ)d_1=[\log(S_1/S_2)+\sigma_{12}^2\tau/2]/(\sigma_{12}\sqrt\tau). If relative volatility is zero take the deterministic limit. These formulas share replication logic, but not the same units of account.

Lab: three routes to price

The formula uses SciPy’s normal CDF, the tree is CRR and Monte Carlo simulates directly under QQ. Seed and path count make the comparison reproducible; the interval measures only sampling error in this model.

[ ]Formula, tree and Monte CarloBrowser
import numpy as np
from scipy.special import ndtr
def bs_price(S,K,r,q,sigma,T,kind='call'):
    S,K,r,q,sigma,T=np.broadcast_arrays(*[np.asarray(x,dtype=float) for x in (S,K,r,q,sigma,T)])
    if np.any(S<=0) or np.any(K<=0) or np.any(T<0) or np.any(sigma<0) or kind not in ('call','put'): raise ValueError('Parámetros inválidos')
    a=sigma*np.sqrt(T); safe=np.where(a>0,a,1.); d1=(np.log(S/K)+(r-q+.5*sigma*sigma)*T)/safe; d2=d1-a
    c=np.where(a>0,S*np.exp(-q*T)*ndtr(d1)-K*np.exp(-r*T)*ndtr(d2),np.maximum(S*np.exp(-q*T)-K*np.exp(-r*T),0))
    return c if kind=='call' else c-S*np.exp(-q*T)+K*np.exp(-r*T)
def tree(S,K,r,q,sigma,T,n):
    dt=T/n; u=np.exp(sigma*np.sqrt(dt)); d=1/u; p=(np.exp((r-q)*dt)-d)/(u-d)
    if not 0<p<1: raise ValueError('Árbol con arbitraje')
    j=np.arange(n+1); v=np.maximum(S*u**(2*j-n)-K,0)
    for i in range(n-1,-1,-1): v=np.exp(-r*dt)*((1-p)*v[:-1]+p*v[1:])
    return v[0]
S,K,r,q,sigma,T=100.,105.,.03,0.,.25,.5
exact=bs_price(S,K,r,q,sigma,T); put=bs_price(S,K,r,q,sigma,T,'put')
g=np.random.default_rng(281101); z=g.standard_normal(200000); terminal=S*np.exp((r-q-.5*sigma*sigma)*T+sigma*np.sqrt(T)*z)
pay=np.exp(-r*T)*np.maximum(terminal-K,0); mc=pay.mean(); se=pay.std(ddof=1)/np.sqrt(len(pay))
print('BS call',float(exact),'put',float(put),'residuo paridad',float(exact-put-S*np.exp(-q*T)+K*np.exp(-r*T)))
print('CRR 100 y 500',[tree(S,K,r,q,sigma,T,n) for n in (100,500)])
print('MC',mc,'intervalo normal 95 %', (mc-1.96*se,mc+1.96*se))

In this run, the formula gives 5.575977, CRR with 100 and 500 steps gives 5.590523 and 5.574481, and Monte Carlo gives 5.626326 with approximate interval [5.580827, 5.671824]. Here the interval misses the reference: a 95% interval can fail in a particular sample. The tree also oscillates with step count. Parity is an identity of formulas with the same units and inputs; a near-zero residual checks implementation, not whether the model describes the market.

[ ]Girsanov through weightsBrowser
S,K,r,sigma,T=100.,100.,.03,.25,1.; g=np.random.default_rng(281102); z=g.standard_normal(200000)
for mu in (.03,.13,.33):
    theta=(mu-r)/sigma; wt=np.sqrt(T)*z; weight=np.exp(-theta*wt-.5*theta*theta*T)
    st=S*np.exp((mu-.5*sigma*sigma)*T+sigma*wt); sample=np.exp(-r*T)*weight*np.maximum(st-K,0)
    ess=weight.sum()**2/np.sum(weight**2); se=sample.std(ddof=1)/np.sqrt(len(sample))
    print('mu',mu,'valor',round(sample.mean(),5),'EE',round(se,5),'media peso',round(weight.mean(),5),'ESS/N',round(ess/len(sample),4),'límite',round(np.exp(-theta*theta*T),4))
print('referencia BS',float(bs_price(S,K,r,0,sigma,T)))

Weights are the exact density and are not renormalized to calculate expectation. ESS uses normalized weights only as a diagnostic; as θ\theta grows, a few observations can dominate and sample mean weight can move away from one. In this run relative ESS moves from 1 to 0.2423 as μ\mu varies from 0.03 to 0.33; the call reference is 11.34848. Variance of a particular weighted payoff need not increase with weight variance: in this example payoff standard error decreases. Comparing with the formula and standard error helps detect weight deterioration but does not correct variance.

Exercises

ProofEliminate the Brownian term
Prove: Derive the PDE with a short option and Δ\Delta shares, without dividends.
0
Assume dS=μSdt+σSdWdS=\mu Sdt+\sigma SdW and a risk-free account at rate rr.

Step 1 of 3. What number of shares eliminates dW?

ProofSeparate the payoff
Prove: Obtain the European call formula as a discounted lognormal expectation.
0
Under QQ, log⁡ST\log S_T is normal with mean log⁡S+(r−q−σ2/2)T\log S+(r-q-\sigma^2/2)T and variance σ2T\sigma^2T.

Step 1 of 3. How is the payoff separated?

NumericEuropean call
Calculate the call with S = 100, K = 105, r = 3%, q = 0, annual σ = 25% and T = 0.5 years.
QuizTwo investors
Two investors disagree about μ. Why do they agree on the model price?
CodeFormula with limits
Implement bs_price(S,K,r,q,sigma,T,kind), vectorized with NumPy, for calls and puts; handle T=0 and σ=0 without invalid division.
def bs_price(S,K,r,q,sigma,T,kind):
  raise NotImplementedError()
Shift+Enter to run

Ideas to remember

Hedging and change of measure yield the same price under common assumptions. The PDE describes local evolution; risk-neutral expectation describes terminal payoff. The numeraire changes both measure and units. With real data, discrete trading, costs, jumps and variable volatility limit the ideal replication of Black and Scholes (1973).