A chain rule with a catch
If S were a smooth function of time, the change of f(S) would be f'(S) * dS, the ordinary chain rule. But dS contains dW, and (dW)^2 = dt is not negligible: it is of the same order as dt. Expanding f(S + dS) to second order, the term 0.5 * f''(S) * (dS)^2 survives, and (dS)^2 = sigma^2 * S^2 * dt. That extra term is Itô's lemma, the main tool for deriving option prices.
def ito_drift(s, mu, sigma, f_t, f_s, f_ss):
return f_t + mu * s * f_s + 0.5 * sigma ** 2 * s ** 2 * f_ss
# f(S) = S: the drift is just mu * S (no curvature, no extra term)
print(ito_drift(100.0, 0.08, 0.2, 0.0, 1.0, 0.0)) # 8.0
# f(S) = S squared: f_S = 2 S and f_SS = 2, so the curvature term appears
print(ito_drift(100.0, 0.08, 0.2, 0.0, 2 * 100.0, 2.0)) # 1600 + 400 = 2000.0# The drift for several functions of the price, S = 100, mu = 8%, sigma = 20%
def ito_drift(s, mu, sigma, f_t, f_s, f_ss):
return f_t + mu * s * f_s + 0.5 * sigma ** 2 * s ** 2 * f_ss
s, mu, sigma = 100.0, 0.08, 0.2
print("S ", ito_drift(s, mu, sigma, 0.0, 1.0, 0.0)) # 8.0
print("S^2 ", ito_drift(s, mu, sigma, 0.0, 2 * s, 2.0)) # 2000.0
print("S^3 ", ito_drift(s, mu, sigma, 0.0, 3 * s ** 2, 6 * s)) # 240000 + 120000 = 360000.0
print("sqrt(S)", round(ito_drift(s, mu, sigma, 0.0, 0.5 / s ** 0.5, -0.25 / s ** 1.5), 4)) # 0.35 : curvature pulls it downThe log price and the sigma squared over two
Apply the lemma to f = ln S. Here f_t = 0, f_S = 1/S and f_SS = -1/S^2, so the drift is mu - 0.5 * sigma^2 and the diffusion sigma: d ln S = (mu - sigma^2/2) dt + sigma dW. The log price is an arithmetic Brownian motion, which is exactly why the solution of GBM has mu - sigma^2/2 in the exponent. The convexity of exp and the concavity of ln are two sides of the same fact.
def ito_drift(s, mu, sigma, f_t, f_s, f_ss):
return f_t + mu * s * f_s + 0.5 * sigma ** 2 * s ** 2 * f_ss
def log_drift(mu, sigma):
s = 1.0 # the answer does not depend on s
return ito_drift(s, mu, sigma, 0.0, 1.0 / s, -1.0 / s ** 2)
print(log_drift(0.08, 0.20)) # 0.06 = 0.08 - 0.5 * 0.2**2
print(round(log_drift(0.08, 0.60), 4)) # -0.1 a high volatility makes the typical growth negativeChecking the lemma by simulation
You do not have to take the lemma on trust. Take many random one-step moves s_new = s + mu * s * dt + sigma * s * sqrt(dt) * z, compute f(s_new) - f(s) for a function f, average and divide by dt. The result converges to the drift from the lemma. With f = S^2 and the curvature term left out, the simulation visibly disagrees, which is the best way to see that the extra term is real.
import numpy as np
def mean_change_estimate(f, s, mu, sigma, dt, z):
s_new = s + mu * s * dt + sigma * s * np.sqrt(dt) * z
return float(np.mean(f(s_new) - f(s)) / dt)
half = np.random.default_rng(1).standard_normal(200_000)
z = np.concatenate([half, -half]) # pairs of opposite draws: the noise at first order cancels
estimate = mean_change_estimate(lambda x: x ** 2, 100.0, 0.08, 0.2, 0.001, z)
print(round(estimate)) # about 2000
print(round(0.08 * 100.0 * 2 * 100.0)) # 1600 the ordinary chain rule alone: the curvature term (400) is missingV(S, t). The drift contains V_t, mu * S * V_S and 0.5 * sigma^2 * S^2 * V_SS; delta-hedging removes the dW term, and the result is the Black–Scholes equation, which has the Greeks of the earlier topics in it: theta, delta and gamma. The risk-free rate replaces mu, and the stock's expected return drops out of the price.- Ito's lemma: the drift of
f(S, t)isf_t + mu * S * f_S + 0.5 * sigma^2 * S^2 * f_SSand the noise coefficientsigma * S * f_S. - The curvature term exists because
(dW)^2 = dt; forln Sit gives the driftmu - sigma^2 / 2of the GBM solution. - Verify by simulation: the average of
f(s_new) - f(s)overdtmatches the lemma; applied to an option value it yields Black–Scholes.
Next up: Asian options, whose payoff depends on the average price over the life of the option.
Lab · what's graded
- Find the drift of a function with
ito_drift25 pts - Find the noise coefficient with
ito_diffusion25 pts - Apply it to the log price with
log_drift25 pts - Check it by simulation with
mean_change_estimate25 pts