Chapter 31
35 min read
Section 263 of 353

Derivation of the Black-Scholes PDE

The Black-Scholes Equation

Learning Objectives

By the end of this section, you will be able to:

  1. Set up a delta-hedged portfolio of one option and Δ\Delta shares of stock from scratch.
  2. Apply Itô's lemma to the option value V(S,t)V(S,t) and read off every term.
  3. Eliminate the stochastic dWdW term by choosing Δ=V/S\Delta = \partial V / \partial S.
  4. Close the derivation with the no-arbitrage condition dΠ=rΠdtd\Pi = r\,\Pi\,dt to obtain the Black-Scholes partial differential equation.
  5. Interpret each of the four terms physically and verify the result numerically by simulating a hedge.

The Question Black-Scholes Answers

Imagine you have just sold a one-year European call option on a stock currently trading at S0=100S_0 = 100, struck at K=100K = 100. In a year the buyer can demand a share from you for 100100. If the stock has risen to 120120, you lose 2020. If it has fallen to 8080, you keep the premium and owe nothing.

The question: what is a fair premium to charge today, so that — no matter what path the stock takes — you can guarantee you will not lose money?

Naively the answer should depend on the drift μ\mu (will the stock go up?), on your risk appetite, and on the expected payoff. The 1973 result of Black, Scholes, and Merton is far more shocking: if you continuously rebalance a hedge of V/S\partial V / \partial S shares, all stochastic risk disappears, drift drops out entirely, and the fair price is the unique function V(S,t)V(S,t) solving one partial differential equation:

Vt  +  12σ2S22VS2  +  rSVS    rV  =  0\frac{\partial V}{\partial t} \;+\; \tfrac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} \;+\; r\,S\,\frac{\partial V}{\partial S} \;-\; r\,V \;=\; 0

The drift μ\mu is gone. The risk-free rate rr is the only growth term. Our job in this section is to derive that equation from first principles — every step, every Itô correction, every cancellation made visible.


Three Ingredients We Already Have

The derivation rests on three results we built in the previous sections. Keep them at hand — we will quote each one explicitly when we use it.

IngredientWhat it saysFrom
GBM for the stockdS=μSdt+σSdWdS = \mu\,S\,dt + \sigma\,S\,dW§31.2 — Brownian motion · §31.3 — SDEs
Itô's lemmadf=ftdt+fSdS+12fSS(dS)2df = f_t\,dt + f_S\,dS + \tfrac12 f_{SS}\,(dS)^2§31.3 — Itô calculus
The Itô rule(dW)2=dt,(dt)2=dtdW=0(dW)^2 = dt,\quad (dt)^2 = dt\,dW = 0§31.3 — quadratic variation
Quick intuition for (dW)2=dt(dW)^2 = dt: a Brownian increment dWdW has variance dtdt, so its square is, on average, dtdt — and over infinitesimal time the variance of (dW)2(dW)^2 is O(dt2)O(dt^2), hence negligible. So in stochastic calculus, second-order terms in dWdW become first-order in dtdt. This is the reason Itô's lemma has the extra 12σ2S2VSS\tfrac12\sigma^2 S^2 V_{SS} term that ordinary calculus does not.

The Hedging Trick — The Real Insight

Before the algebra, the story. A call option VV is risky because SS is risky. But the option value is a function of SS: if SS wiggles up by dSdS, the option wiggles up by approximately V/SdS\partial V / \partial S \cdot dS.

So: if you hold one option and Δ=V/S\Delta = \partial V / \partial S shares of stock in opposite directions, the small wiggle in the option is cancelled by the equal-and-opposite wiggle in the stock. The portfolio is locally riskless.

That is the entire idea. Everything else — Itô, the PDE, even Nobel prizes — is bookkeeping to make this idea precise.

Analogy. Imagine a wobbly ladder leaning against a wall. The top of the ladder (VV) wobbles because the bottom (SS) does. If you push the bottom with the right force every instant — exactly Δ\Delta times the wobble — you can keep the top perfectly still. That "right force" is the delta hedge. Black-Scholes says: if you can do this continuously, the entire cost of keeping the ladder still is determined, and so is the option price.

Let us watch this cancellation happen with our own eyes before we write the algebra. The simulator below sells one call, continuously rebalances a delta hedge, and plots the seller's P&L against the unhedged P&L on the same path.

The orange line is what happens if you collect the premium and do nothing: your terminal wealth depends entirely on where the stock ended up — pure gambling. The green line is the same trade with a continuously rebalanced Δ\Delta-hedge: it hugs zero regardless of whether the path went up, down, or sideways. The hedge has converted randomness into determinism. That is what the Black-Scholes PDE encodes.


Step 1: Itô's Lemma on V(S,t)

Let V(S,t)V(S,t) be the price of the option as a function of the underlying stock price SS and time tt. We do not yet know what VV is — that is what we are trying to find. But it is at least a smooth function of two variables, and the stock follows dS=μSdt+σSdWdS = \mu S\,dt + \sigma S\,dW. So Itô's lemma gives us:

dV  =  Vtdt  +  VSdS  +  122VS2(dS)2dV \;=\; \frac{\partial V}{\partial t}\,dt \;+\; \frac{\partial V}{\partial S}\,dS \;+\; \tfrac12\,\frac{\partial^2 V}{\partial S^2}\,(dS)^2

Now substitute. First the easy piece — (dS)2(dS)^2:

(dS)2=(μSdt+σSdW)2(dS)^2 = (\mu S\,dt + \sigma S\,dW)^2
=μ2S2(dt)2+2μσS2dtdW+σ2S2(dW)2\quad\quad = \mu^2 S^2 (dt)^2 + 2\mu\sigma S^2\,dt\,dW + \sigma^2 S^2 (dW)^2
=0+0+σ2S2dt\quad\quad = 0 + 0 + \sigma^2 S^2\,dt (by Itô's rule: (dt)2=0(dt)^2 = 0, dtdW=0dt\,dW = 0, (dW)2=dt(dW)^2 = dt)
=σ2S2dt\quad\quad = \sigma^2 S^2\,dt

Plug that back into dVdV along with dS=μSdt+σSdWdS = \mu S\,dt + \sigma S\,dW and collect terms:

  dV  =  (Vt  +  μSVS  +  12σ2S2VSS)dt  +  σSVSdW  \boxed{\; dV \;=\; \Bigl(\, V_t \;+\; \mu\,S\,V_S \;+\; \tfrac12\,\sigma^2 S^2\,V_{SS}\,\Bigr)\,dt \;+\; \sigma\,S\,V_S\,dW \;}

Two parts. A drift piece (the dtdt-bracket) and a diffusion piece (the dWdW-term). The diffusion piece carries the Brownian risk — and it is exactly proportional to VSV_S. That is our hook.

Where ordinary calculus would have stopped: a beginner not aware of Itô would have written dV=Vtdt+VSdSdV = V_t\,dt + V_S\,dS, missing the 12σ2S2VSS\tfrac12\sigma^2 S^2 V_{SS} term. That term —gamma in disguise — is the entire reason the BS PDE has a second derivative in it. Without volatility there would be no gamma, no second derivative, no PDE — just an ordinary bond.

Step 2: Build the Hedged Portfolio

Define a portfolio with one option long and hh shares short:

Π(t)  =  V(S,t)    hS\Pi(t) \;=\; V(S,t) \;-\; h\,S

We have not yet decided what hh is — we will choose it cleverly in one step. The change in value over an infinitesimal dtdt is:

dΠ  =  dV    hdSd\Pi \;=\; dV \;-\; h\,dS
Self-financing assumption. When we change hh during a rebalance, the difference is absorbed by a cash account that grows at the risk-free rate rr. So hh itself does not contribute a dhSdh\cdot S term in dΠd\Pi. (This is the source of subtle technical machinery that we will gloss over here; in continuous time it is consistent.)

Substitute dVdV from Step 1 and dS=μSdt+σSdWdS = \mu S\,dt + \sigma S\,dW:

dΠ=(Vt+μSVS+12σ2S2VSS)dt+σSVSdWh(μSdt+σSdW)d\Pi = \bigl( V_t + \mu S V_S + \tfrac12 \sigma^2 S^2 V_{SS} \bigr)\,dt + \sigma S V_S\,dW - h\,(\mu S\,dt + \sigma S\,dW)

Group the dtdt and dWdW terms:

dΠ  =  [Vt+μSVS+12σ2S2VSShμS]dt  +  [σSVShσS]dWd\Pi \;=\; \Bigl[\,V_t + \mu S V_S + \tfrac12 \sigma^2 S^2 V_{SS} - h\,\mu S\,\Bigr]\,dt \;+\; \Bigl[\,\sigma S V_S - h\,\sigma S\,\Bigr]\,dW
      =  [Vt+12σ2S2VSS  +  μS(VSh)]dt  +  σS(VSh)dW\quad\;\;\; =\; \Bigl[\,V_t + \tfrac12 \sigma^2 S^2 V_{SS} \;+\; \mu S\,(V_S - h)\,\Bigr]\,dt \;+\; \sigma S\,(V_S - h)\,dW

Look at the dWdW coefficient. It is σS(VSh)\sigma S (V_S - h). The drift μ\mu appears only multiplied by the same factor (VSh)(V_S - h). Both pieces of risky future are controlled by one knob: hh.


Step 3: Kill the dW Term

Choose hh to make the random part disappear. The only way:

  h  =  VS  =  Δ  \boxed{\;h \;=\; \frac{\partial V}{\partial S} \;=\; \Delta\;}

With h=VSh = V_S the factor (VSh)=0(V_S - h) = 0, and both the dWdW term and the μ\mu term vanish in one stroke:

dΠ  =  [Vt  +  12σ2S2VSS]dtd\Pi \;=\; \Bigl[\, V_t \;+\; \tfrac12\,\sigma^2 S^2\,V_{SS} \,\Bigr]\,dt

Stop and read this. The portfolio has no dWdW — it is deterministic. It also has no μ\mu — it does not matter whether the stock drifts up or down. Whatever the path, this hedged portfolio earns the same return over any short interval. That is what we hoped for from the analogy of the wobbly ladder, now expressed in algebra.

Use the interactive view below to watch this happen term by term. Move the hedge ratio hh away from VSV_S and the red "RISK" bar — the dWdW coefficient — grows. Snap hh back to VSV_S and it collapses to exactly zero.


Step 4: No-Arbitrage Closes the Loop

We now have a portfolio whose return over dtdt is guaranteed, no randomness. In financial markets, any guaranteed-return portfolio must earn exactly the risk-free rate rr — otherwise, you could borrow at rr, buy the portfolio, and pocket the difference forever (arbitrage). So:

dΠ  =  rΠdt  =  r(VVSS)dtd\Pi \;=\; r\,\Pi\,dt \;=\; r\,(V - V_S\,S)\,dt

Set our two expressions for dΠd\Pi equal and divide out the common dtdt:

Vt  +  12σ2S2VSS  =  rV    rSVSV_t \;+\; \tfrac12\,\sigma^2 S^2\,V_{SS} \;=\; r\,V \;-\; r\,S\,V_S

Rearrange so the right-hand side is zero, and we are done.


The Black-Scholes PDE

Vt  +  12σ2S22VS2  +  rSVS    rV  =  0\frac{\partial V}{\partial t} \;+\; \tfrac12\,\sigma^2 S^2\,\frac{\partial^2 V}{\partial S^2} \;+\; r\,S\,\frac{\partial V}{\partial S} \;-\; r\,V \;=\; 0
The fair price of any European-style derivative satisfies this equation, with payoff baked in via the terminal condition.

A second-order linear parabolic PDE in two variables (S,t)(S, t). Backward in time (we know the payoff at t=Tt = T and solve toward t=0t = 0). The boundary/terminal conditions determine which contract it is:

ContractTerminal condition at t = TBoundary at S = 0
European callV(S,T)=max(SK,0)V(S, T) = \max(S - K, 0)V(0,t)=0V(0, t) = 0
European putV(S,T)=max(KS,0)V(S, T) = \max(K - S, 0)V(0,t)=Ker(Tt)V(0, t) = K e^{-r(T-t)}
Cash-or-nothing callV(S,T)=1S>KV(S, T) = \mathbf{1}_{S > K}V(0,t)=0V(0, t) = 0
Forward contractV(S,T)=SKV(S, T) = S - KV(0,t)=Ker(Tt)V(0, t) = -K e^{-r(T-t)}
The same PDE for everything. The PDE itself is identical across these contracts — only the terminal payoff differs. That is what makes Black-Scholes universal: solve once, plug in the payoff that interests you, and read off the price.

Reading the PDE Term by Term

Each of the four terms has a financial meaning. Read them out loud.

TermGreek nameWhat it represents
V/t\partial V / \partial tTheta (Θ)Time decay. How much value the option loses per unit of time, all else equal.
12σ2S22V/S2\tfrac12\sigma^2 S^2\,\partial^2 V / \partial S^2Gamma (Γ) × ½σ²S²Convexity bonus. The hedger profits from realised volatility — proportional to gamma and the square of σS.
rSV/Sr\,S\,\partial V / \partial SDelta (Δ) × rSCost of carry on the stock position you hold to hedge. You borrow rS·dt every interval to finance the hedge.
rV-\,r\,V−rV (discounting)Discounting the option's own value back at the risk-free rate.
In words: The option loses time-value (theta) at exactly the rate at which it gains convexity from realised volatility (gamma), net of the carry on the hedge and the discounting on its own value. That sentence is the Black-Scholes PDE in English.

Look once more at the equation: Vt+12σ2S2VSS+rSVSrV=0V_t + \tfrac12\sigma^2 S^2 V_{SS} + rS V_S - rV = 0. Notice what is not there:

  • No μ\mu. The actual drift of the stock is irrelevant. A bullish trader and a bearish trader must agree on the same fair price.
  • No expected payoff. We never computed E[max(STK,0)]E[\max(S_T - K, 0)]. The price is the deterministic cost of running a hedge, not a probability-weighted expectation.
  • No risk preferences. There is no utility function, no risk aversion, no "market price of risk" here. Two investors who disagree on μ\mu still agree on VV.

Worked Example: Hedging a One-Year Call

Time to do this by hand. We will price a one-year at-the-money call, set up the hedge, take one step forward, watch the cancellation, then verify our PDE term by term. Try each step yourself first; the full hand-worked solution is hidden in the box below.

Setup: S0=100,  K=100,  r=0.04,  σ=0.25,  T=1S_0 = 100, \; K = 100, \; r = 0.04, \; \sigma = 0.25, \; T = 1. Take one step of size dt=0.01dt = 0.01 (about 2.5 trading days). Assume a Brownian increment dW=+0.05dW = +0.05.

▶ Show full hand-worked solution (8 steps)

Step 1 — Compute the BS quantities at t = 0

With v=σT=0.25v = \sigma\sqrt{T} = 0.25,

QuantityFormulaValue
d1d_1ln(S/K)+(r+12σ2)Tv\frac{\ln(S/K) + (r + \tfrac12\sigma^2)T}{v}0+0.071250.25=0.285\frac{0 + 0.07125}{0.25} = 0.285
d2d_2d1vd_1 - v0.0350.035
V=SN(d1)KerTN(d2)V = S\,N(d_1) - K e^{-rT}\,N(d_2)1000.61296.080.514100\cdot 0.612 - 96.08\cdot 0.51411.78\approx 11.78
VS=N(d1)V_S = N(d_1)0.6120.612
VSS=φ(d1)SvV_{SS} = \frac{\varphi(d_1)}{S\,v}0.3831000.25\frac{0.383}{100\cdot 0.25}0.01530.0153

Step 2 — Set up the hedged portfolio

Sell one call, collect V=11.78V = 11.78. Buy Δ=VS=0.612\Delta = V_S = 0.612 shares for 0.612100=61.200.612 \cdot 100 = 61.20. Net cash: 11.7861.20=49.4211.78 - 61.20 = -49.42 (borrowed at rate r). Define the seller's position as Π=VSSV\Pi = V_S\,S - V (he is long stock and short option — equivalent to (Πbook)-(\Pi_{\text{book}}) from the algebra above; signs don't change the conclusion).

Step 3 — Compute dS over one step

dS=μSdt+σSdW=0.081000.01+0.251000.05dS = \mu S\,dt + \sigma S\,dW = 0.08\cdot 100\cdot 0.01 + 0.25\cdot 100\cdot 0.05
              =0.08+1.25=1.33\;\;\;\;\;\;\;= 0.08 + 1.25 = 1.33

So S0+dt101.33S_{0+dt} \approx 101.33. The drift contributes only 0.080.08; the Brownian shock contributes 1.251.25. Randomness dominates, as expected.

Step 4 — Compute dV via Itô

First (dS)2=σ2S2dt=0.0625100000.01=6.25(dS)^2 = \sigma^2 S^2 dt = 0.0625\cdot 10000\cdot 0.01 = 6.25. Then

dV=Vtdt+VSdS+12VSS(dS)2dV = V_t\,dt + V_S\,dS + \tfrac12 V_{SS}\,(dS)^2

Theta at our state is (BS theta) Vt6.45V_t \approx -6.45 (per year). So Vtdt0.0645V_t\,dt \approx -0.0645.

VSdS=0.6121.33=0.8140V_S\,dS = 0.612 \cdot 1.33 = 0.8140
12VSS(dS)2=0.50.01536.25=0.0478\tfrac12 V_{SS}(dS)^2 = 0.5\cdot 0.0153\cdot 6.25 = 0.0478
dV0.0645+0.8140+0.0478=0.7973dV \approx -0.0645 + 0.8140 + 0.0478 = 0.7973

Step 5 — Compute dΠ for the unhedged seller

If we did not hedge, the seller's short-call P&L change would be approximately dV0.7973-dV \approx -0.7973 (he loses what the option gained). Plus interest on his cash of 11.78rdt=11.780.040.01=0.004711.78\cdot r\cdot dt = 11.78\cdot 0.04\cdot 0.01 = 0.0047. Net: 0.7973+0.0047=0.7926-0.7973 + 0.0047 = -0.7926. A $0.80 loss on a $1.33 stock move — pure exposure to dWdW.

Step 6 — Compute dΠ for the delta-hedged seller

Now include the hedge: hold Δ=0.612\Delta = 0.612 shares (long). Stock gain from hedge: 0.6121.33=0.81400.612\cdot 1.33 = 0.8140. Interest on cash of 49.420.040.01=0.0198-49.42\cdot 0.04\cdot 0.01 = -0.0198. Plus option P&L of 0.7973-0.7973 (from Step 4).

dΠhedged=0.7973+0.81400.0198=0.0031d\Pi_{\text{hedged}} = -0.7973 + 0.8140 - 0.0198 = -0.0031

The risky $0.80 swing has collapsed to $0.003. That residue is the discretisation error from taking a finite step dt=0.01dt = 0.01: it scales like (dt)3/2(dt)^{3/2}. In the continuous-hedging limit it is exactly zero, which is precisely the BS PDE.

Step 7 — Verify the PDE numerically

Plug our numbers into the LHS of the PDE:

Vt+12σ2S2VSS+rSVSrVV_t + \tfrac12\sigma^2 S^2 V_{SS} + rSV_S - rV
=6.45+0.50.0625100000.0153+0.041000.6120.0411.78= -6.45 + 0.5\cdot 0.0625\cdot 10000\cdot 0.0153 + 0.04\cdot 100\cdot 0.612 - 0.04\cdot 11.78
=6.45+4.78+2.4480.471= -6.45 + 4.78 + 2.448 - 0.471
0.31\approx 0.31 (would be exactly 0 if we used the exact BS theta; our rounded values produced a small residual)

Step 8 — Interpret the four terms

  • Vt=6.45V_t = -6.45: option bleeds 6.45/yr in time value.
  • 12σ2S2VSS=+4.78\tfrac12\sigma^2 S^2 V_{SS} = +4.78: gamma earns 4.78/yr from realised volatility — partial compensation for theta.
  • rSVS=+2.45rSV_S = +2.45: financing the long stock hedge costs 2.45/yr — but it shows up as a positive term in the PDE because we are summing the parts to zero.
  • rV=0.47-rV = -0.47: discounting the option itself.

They sum to zero (modulo rounding). That is the PDE in action — balance of forces: theta is paid for by gamma plus carry plus discounting.


Code: Simulating the Hedged Portfolio

Algebra is one thing — but you should not believe the derivation until you have run it on a computer and watched the residual P&L distribution collapse. The script below simulates 2000 paths, rebalances daily, and prints the distribution of the seller's terminal P&L. Read each line; the explanation panel walks through the BS formula, the GBM step, the self-financing rebalance, and how to check the PDE numerically.

Continuously-rebalanced Black-Scholes hedge — numerical proof of the PDE
🐍delta_hedge.py
1NumPy + scipy.stats

We need a random number generator for the Brownian increments (numpy) and the cumulative normal distribution N(·) for the Black-Scholes formula (scipy.stats.norm).

5bs_call(S, K, r, σ, τ) — the option price and delta

This is the closed-form Black-Scholes formula for a European call, with the bonus that the function also returns Δ = V_S = N(d₁). We will derive this formula in the next section; for now treat it as the analytical 'true price' an arbitrage-free market would charge.

EXAMPLE
bs_call(100, 100, 0.04, 0.25, 1.0)  →  price ≈ 11.78, delta ≈ 0.620
6Boundary case: tau = 0 means expiry

At expiry there is no time left for randomness. The call is worth its intrinsic payoff max(S − K, 0). Delta is 1 if in-the-money, 0 otherwise.

8v = σ√τ — the total uncertainty scale

Brownian motion accumulates variance linearly: Var(W_τ) = τ. So the standard deviation of log-returns over τ is σ√τ. This v is the 'lever arm' that all of d₁, d₂ depend on.

EXAMPLE
σ = 0.25, τ = 1.0  →  v = 0.25.  σ = 0.4, τ = 0.25  →  v = 0.2.
9d₁: the standardised log-moneyness, drift-adjusted

d₁ is how many standard deviations the log-stock has to rise above log K to land in-the-money at expiry, after correcting for the risk-free drift and Itô's −½σ²τ term. When d₁ is large, the call is deep ITM and Δ ≈ 1. When d₁ is very negative, Δ ≈ 0.

EXAMPLE
S=K, r=0.04, σ=0.25, τ=1  →  d₁ = (0.04 + 0.03125) / 0.25 = 0.285
11Price = S·N(d₁) − K·e^{−rτ}·N(d₂)

Two pieces. S·N(d₁) is the expected stock you receive if you exercise. K·e^{−rτ}·N(d₂) is the present value of the strike you pay, weighted by the risk-neutral probability of exercising. Subtract to get the net.

12Delta = N(d₁) — derivative of price w.r.t. S

This is the magic number for hedging. If you hold Δ = N(d₁) shares of stock against one short call, a small move in S changes your stock position by Δ·dS, which exactly matches V_S·dS in the option's first-order change. The dW term cancels. This is the entire idea of Black-Scholes.

EXAMPLE
N(0.285) ≈ 0.612 — hold 0.612 shares per call sold.
16simulate_hedged_short_call — one Monte Carlo path

We pretend to be a market-maker who sold one call for the BS premium and now must hedge for T years using N rebalances of size dt = T/N. The function returns the final P&L (should be ≈ 0) and the terminal stock price (random).

22dt = T / N — one rebalancing step

Black-Scholes assumes *continuous* hedging (dt → 0). In code we approximate with N discrete steps. The smaller dt, the more perfect the cancellation. With N=252 we rebalance daily for one year.

EXAMPLE
T = 1.0, N = 252  →  dt ≈ 0.00397 years (~1 trading day).
25premium, delta = bs_call(S0, K, r, σ, T)

At t=0 we collect the option premium and compute the initial hedge ratio. Premium becomes our starting cash; we will spend most of it buying Δ shares of stock.

EXAMPLE
At S0 = K = 100, σ = 0.25, r = 0.04, T = 1:  premium ≈ 11.78, Δ ≈ 0.620.
EXECUTION STATE
premium = 11.78
delta = 0.620
26shares = delta — the hedge position

Buy Δ shares right now. From this moment on, the seller's exposure to small moves in S is approximately neutral — that is the whole point of the Black-Scholes construction.

27bank = premium − shares · S₀ — the leftover cash

With S₀ = 100 and Δ ≈ 0.62, buying the hedge costs 62. We only collected 11.78 in premium, so bank starts at −50.22 — we are borrowing 50.22 dollars at rate r. This negative cash balance is normal and expected.

EXAMPLE
bank = 11.78 − 0.620 · 100 = −50.22
29Begin the rebalancing loop — N iterations

Each iteration: roll the stock forward by one Brownian step, accrue interest on the cash, recompute Δ at the new state, and adjust shares to match.

30z = rng.standard_normal() — one Brownian increment

Sample z ~ N(0, 1). Then dW = √dt · z is the Brownian motion increment over one step. This is the *only* source of randomness in the model.

EXAMPLE
z = 0.43  →  dW ≈ 0.43 · √0.00397 ≈ 0.0271 over one day.
31S_next = S · exp((μ − ½σ²)·dt + σ·√dt·z)

This is the exact one-step Geometric Brownian Motion update. The −½σ² is the Itô convexity correction that ensures E[S_t] = S_0·e^{μt}. Without it, log-returns would have a drift bias.

EXAMPLE
S = 100, μ=0.08, σ=0.25, dt=0.004, z=0.43  →  S_next ≈ 100·exp(−0.000175 + 0.00679) ≈ 100.66.
33bank *= exp(r · dt) — interest on cash position

The cash account (whether positive or negative) compounds continuously at the risk-free rate r. This is the 'r' that appears in the BS PDE — it is *not* μ. The drift μ never appears in the final PDE; it only governs the realised path here so we can simulate.

EXAMPLE
bank=−50.22, r=0.04, dt=0.00397  →  bank ← −50.22·e^{0.000159} ≈ −50.228.
34tau_next = T − (i+1)·dt — remaining time to expiry

τ shrinks every step. At i=N−1 we have τ_next = 0, i.e. we are computing Δ at expiry — which is exactly 1 if S>K and 0 otherwise. That step is the moment all uncertainty resolves.

35_, delta_next = bs_call(...) — the new hedge ratio

We do not care about the new option price for the simulation — only the new Δ. We recompute it at the freshly updated (S_next, τ_next) and prepare to adjust our share count.

37bank -= (delta_next − shares) · S_next — pay to rebalance

If Δ rose, we need to *buy* more stock at the new price S_next, draining cash. If Δ fell, we sell some shares back, raising cash. This trade is *self-financing*: no money enters or leaves the portfolio, the bank account simply absorbs the cost of every adjustment.

EXAMPLE
delta_next = 0.625, shares = 0.620, S_next = 100.66  →  bank -= 0.005 · 100.66 ≈ 0.5
38shares = delta_next — update bookkeeping

Now we are holding exactly delta_next shares for the next sub-interval. Repeat.

LOOP TRACE · 3 iterations
Iter 1 (t=0→dt)
S = 100.00 → 100.66
shares = 0.620 → 0.625
bank = −50.22 → −50.73
Iter 126 (t≈0.5)
S = ≈ 104
shares = ≈ 0.71
bank = ≈ −62.5
Iter 252 (t=T)
S = ≈ 108 (random)
shares = → 1.0 (ITM)
bank = ≈ −96.2
portfolio = bank + shares·S = ≈ +11.8
41portfolio_value = bank + shares · S — terminal wealth

Mark everything to market at t=T. The bank account plus the value of the stock we hold equals our total wealth. We owe max(S − K, 0) to the option buyer.

42payoff_owed = max(S − K, 0) — what the option costs us

If S > K, we owe (S − K) to the buyer. If S ≤ K, we owe nothing — the call expires worthless. Either way, we already hold ~Δ shares to offset this.

43pnl = portfolio_value − payoff_owed

The whole point of Black-Scholes: under continuous hedging with the right Δ, this number is 0 — independent of the path the stock took. The premium we collected at t=0 was *exactly* the deterministic cost of running this hedge to expiry.

47Run 2000 paths and look at the distribution

Each call to simulate_hedged_short_call has a different random seed, so each produces a different stock path. We collect 2000 P&L outcomes.

48Print mean and standard deviation of P&L

The expected output is something like: mean P&L = +0.002 std P&L = +0.150 The mean is essentially zero — that's the BS PDE in action. The std is small but nonzero because we hedge discretely (N=252) rather than continuously. Push N higher and watch the std shrink toward zero.

EXAMPLE
N=252:   std ≈ 0.15
N=2520:  std ≈ 0.05
N=∞:     std = 0 exactly (the PDE limit)
22 lines without explanation
1import numpy as np
2from math import log, sqrt, exp
3from scipy.stats import norm
4
5def bs_call(S, K, r, sigma, tau):
6    if tau <= 0:
7        return max(S - K, 0.0), 1.0 if S > K else 0.0
8    v = sigma * sqrt(tau)
9    d1 = (log(S / K) + (r + 0.5 * sigma**2) * tau) / v
10    d2 = d1 - v
11    price = S * norm.cdf(d1) - K * exp(-r * tau) * norm.cdf(d2)
12    delta = norm.cdf(d1)
13    return price, delta
14
15def simulate_hedged_short_call(S0=100, K=100, mu=0.08, sigma=0.25,
16                               r=0.04, T=1.0, N=252, seed=0):
17    """Sell one call. Continuously rebalance to hold Delta shares.
18    Return the seller's terminal P&L vs. the call payoff."""
19    rng = np.random.default_rng(seed)
20    dt = T / N
21    S = S0
22
23    premium, delta = bs_call(S0, K, r, sigma, T)   # received at t=0
24    shares = delta                                  # buy Delta shares immediately
25    bank   = premium - shares * S0                  # what's left in cash (may be negative = borrowed)
26
27    for i in range(N):
28        z = rng.standard_normal()
29        S_next = S * np.exp((mu - 0.5 * sigma**2) * dt + sigma * sqrt(dt) * z)
30
31        bank *= np.exp(r * dt)                      # cash grows at r over dt
32        tau_next = T - (i + 1) * dt
33        _, delta_next = bs_call(S_next, K, r, sigma, tau_next)
34
35        bank -= (delta_next - shares) * S_next      # pay to rebalance
36        shares = delta_next
37        S = S_next
38
39    portfolio_value = bank + shares * S
40    payoff_owed     = max(S - K, 0.0)
41    pnl             = portfolio_value - payoff_owed
42    return pnl, S
43
44# Repeat over many seeds — the histogram should collapse around 0
45pnls = [simulate_hedged_short_call(seed=k)[0] for k in range(2000)]
46print(f"mean P&L  = {np.mean(pnls):+.4f}")
47print(f"std  P&L  = {np.std(pnls):+.4f}")

Run it. With N=252N = 252 you should see mean P&L within a few cents of zero and a standard deviation of order $0.15. Double NN and the std-dev roughly halves. The convergence rate is O(1/N)O(1/\sqrt{N}) — the exact rate at which Itô's lemma promises continuous-time hedging is risk-free.

Tweak μ. Set μ=0.5\mu = -0.5 (extreme crash). Set μ=+1.0\mu = +1.0 (extreme bull). The std of P&L should not move — only individual path outcomes change, not the hedger's overall risk. That is the drift invariance the PDE predicts.

Common Confusions, Cleared Up

What students often thinkWhat is actually going on
"VV = expected discounted payoff under the real-world measure."Wrong. V is the deterministic cost of running a continuous-time hedge. The 'real' probabilities never appear. (Under a special risk-neutral measure ℚ — discussed later — V IS an expectation, but with μ replaced by r.)
"The drift μ\mu must matter — bull and bear markets price calls differently."In Black-Scholes they don't. The hedge absorbs the drift entirely: every dt, you earn μS·V_S on stock and lose μS·V_S on the short option position. The μ exactly cancels.
"Why is there a second derivative? Surely a first derivative is enough to react to S."Because realised volatility is a second-order effect: it is the variance of S, which is encoded in V_SS via Itô's lemma. Without volatility (σ=0) the PDE degenerates to V_t + rS V_S − rV = 0 — a simple ODE for a forward contract.
"The hedge has to be perfect — surely real markets are not continuous."Correct concern. Discrete hedging leaves a residual std-dev of O(1/√N). Transaction costs make N=∞ impossible. Real desks accept a small variance and add a margin. The PDE is the idealised limit.
"Why is the PDE solved backward in time?"Because we know the payoff at t=T (the contract spec) and we want the price today, t=0. We diffuse the terminal condition backward — exactly like solving the heat equation with a final temperature distribution.

Summary

The whole derivation in one breath: write Itô on V(S,t)V(S,t), build the portfolio Π=VVSS\Pi = V - V_S\,S to cancel the dWdW, observe that dΠd\Pi is now deterministic, demand it earn rΠdtr\,\Pi\,dt by no-arbitrage, equate coefficients — and out drops Vt+12σ2S2VSS+rSVSrV=0V_t + \tfrac12 \sigma^2 S^2 V_{SS} + rS V_S - rV = 0.
  1. Itô's lemma gives the chain rule for stochastic functions: the extra 12VSS(dS)2=12σ2S2VSSdt\tfrac12 V_{SS} (dS)^2 = \tfrac12\sigma^2 S^2 V_{SS}\,dt term is the source of everything new.
  2. The delta hedge h=VSh = V_S simultaneously kills the dWdW noise and the drift μ\mu. One coefficient, two cancellations.
  3. No-arbitrage (dΠ=rΠdtd\Pi = r\Pi\,dt) is the final ingredient — it converts "riskless" into "earns rr".
  4. The PDE is universal: same equation, different terminal condition for each derivative.
  5. The four PDE terms have clean financial meaning: theta + gamma·½σ²S² + delta·rS − rV = 0. Theta is paid for by gamma and carry, net of discounting.
  6. Numerical simulation confirms it: hedged P&L collapses to zero as dt0dt \to 0.

In the next section we will solve this PDE for a European call, recover the famous closed-form Black-Scholes formula, and meet the Greeks for the first time as honest derivatives of VV.

Loading comments...