有陷阱的链式法则
如果 S 是时间的光滑函数,f(S) 的变化就是 f'(S) * dS,即普通的链式法则。但 dS 含有 dW,而 (dW)^2 = dt 不能忽略:它和 dt 是同一量级。把 f(S + dS) 展开到二阶,0.5 * f''(S) * (dS)^2 这一项会保留下来,且 (dS)^2 = sigma^2 * S^2 * dt。这个额外项就是伊藤引理,推导期权价格的主要工具。
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 down对数价格与 σ 平方的一半
把引理用于 f = ln S。这里 f_t = 0,f_S = 1/S,f_SS = -1/S^2,所以漂移是 mu - 0.5 * sigma^2,扩散是 sigma:d ln S = (mu - sigma^2/2) dt + sigma dW。对数价格是算术布朗运动,这正是 GBM 的解在指数里带有 mu - sigma^2/2 的原因。exp 的凸性和 ln 的凹性,是同一个事实的两面。
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 negative通过模拟检验引理
不必盲目相信引理。取许多随机的一步变动 s_new = s + mu * s * dt + sigma * s * sqrt(dt) * z,对函数 f 计算 f(s_new) - f(s),求平均再除以 dt。结果会收敛到引理给出的漂移。对 f = S^2 若漏掉曲率项,模拟结果会明显不符,这是看清额外项真实存在的最好办法。
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 missing为什么对期权重要给期权定价时,把引理用于它的价值
V(S, t)。漂移包含 V_t、mu * S * V_S 和 0.5 * sigma^2 * S^2 * V_SS;用 delta 对冲消去 dW 项后,得到布莱克-斯科尔斯方程,其中含有前面各节的希腊字母:theta、delta 和 gamma。无风险利率取代了 mu,股票的预期收益从价格中消失。- 伊藤引理:
f(S, t)的漂移是f_t + mu * S * f_S + 0.5 * sigma^2 * S^2 * f_SS,噪声系数是sigma * S * f_S。 - 曲率项的存在是因为
(dW)^2 = dt;对ln S它给出 GBM 解的漂移mu - sigma^2 / 2。 - 用模拟验证:
f(s_new) - f(s)的均值除以dt与引理一致;用于期权价值就得到布莱克-斯科尔斯。
下一节:亚式期权,其收益取决于期权存续期内的平均价格。
实验:评分内容
- 用
ito_drift求函数的漂移25 分 - 用
ito_diffusion求噪声系数25 分 - 用
log_drift应用于对数价格25 分 - 用
mean_change_estimate通过模拟验证25 分