按平均价格支付
普通看涨期权只取决于一天的价格,即最后一天。亚式期权取决于一组日期上的平均价格:亚式看涨期权支付 max(平均价 - K, 0)。公司用它来对冲持续发生的成本,比如每月采购石油,而且到期日很难被操纵。它是*路径依赖*的,算术平均没有简单的布莱克-斯科尔斯公式,通常的工具是蒙特卡洛模拟。
import numpy as np
# Two simulated paths: the starting price, then monthly prices; the last column is expiry
paths = np.array([[100.0, 90.0, 110.0, 130.0],
[100.0, 70.0, 80.0, 90.0]])
average = paths[:, 1:].mean(axis=1) # the monitoring dates only, not the starting price
print(average) # [110. 80.]
print(np.maximum(average - 100.0, 0.0)) # Asian call payoffs: [10. 0.]
print(np.maximum(paths[:, -1] - 100.0, 0.0)) # European call payoffs on the same paths: [30. 0.]模拟路径
路径来自几何布朗运动,使用风险中性漂移:用利率 r 代替 mu。抽取一个标准正态矩阵,每条路径一行、每个观察日一列,把它转换成对数价格的变动,再沿每一行做累积和。这样一个数组就装下了所有路径,之后每一步(平均、收益)都是沿行方向的一次向量化操作,不需要对路径循环。
import numpy as np
def simulate_paths(s0, rate, sigma, t, steps, n_paths, rng):
dt = t / steps
z = rng.standard_normal((n_paths, steps))
log_moves = (rate - 0.5 * sigma ** 2) * dt + sigma * np.sqrt(dt) * z
return s0 * np.exp(np.hstack([np.zeros((n_paths, 1)), np.cumsum(log_moves, axis=1)]))
rng = np.random.default_rng(1)
paths = simulate_paths(100.0, 0.05, 0.2, 1.0, 12, 50000, rng) # monthly monitoring for a year
print(paths.shape) # (50000, 13)
print(round(float(paths[:, -1].mean()), 2), round(100 * np.exp(0.05), 2)) # the risk-neutral mean of the final price价格及其误差
期权价格是折现后的平均收益:exp(-r * T) * mean(payoffs)。蒙特卡洛价格只是一个估计,所以务必同时报告它的标准误 std(payoffs) / sqrt(路径数)(折现后),它说明这个数可能离真值多远:路径数变为 4 倍,误差减半。同一只股票上,亚式看涨期权比欧式便宜,因为平均使价格变平滑,降低了有效波动率。
import numpy as np
def simulate_paths(s0, rate, sigma, t, steps, n_paths, rng):
dt = t / steps
z = rng.standard_normal((n_paths, steps))
log_moves = (rate - 0.5 * sigma ** 2) * dt + sigma * np.sqrt(dt) * z
return s0 * np.exp(np.hstack([np.zeros((n_paths, 1)), np.cumsum(log_moves, axis=1)]))
def asian_price(paths, strike, rate, t):
payoff = np.maximum(paths[:, 1:].mean(axis=1) - strike, 0.0)
discount = np.exp(-rate * t)
return discount * payoff.mean(), discount * payoff.std(ddof=1) / np.sqrt(len(payoff))
rng = np.random.default_rng(1)
paths = simulate_paths(100.0, 0.05, 0.2, 1.0, 12, 100000, rng)
price, error = asian_price(paths, 100.0, 0.05, 1.0)
european = np.exp(-0.05) * np.maximum(paths[:, -1] - 100.0, 0.0).mean()
print(round(float(price), 3), "+/-", round(float(error), 3))
print(round(float(european), 3), "European call on the same paths")# Geometric and arithmetic averages of the same monitoring prices
import numpy as np
prices = np.array([90.0, 110.0, 130.0])
arithmetic = prices.mean()
geometric = np.exp(np.log(prices).mean())
print(round(float(arithmetic), 3), round(float(geometric), 3)) # 110.0 108.774: the geometric average is never larger几何平均有公式对数正态变量的乘积仍是对数正态,所以几何平均的亚式期权可以用布莱克-斯科尔斯式公式定价。这使它适合作检验,更适合作算术平均版本的控制变量:两种收益高度相关,因而已知的几何期权精确价格可以抵消大部分蒙特卡洛噪声。后面讲控制变量的一节用的正是这个思路。
- 亚式期权按观察日的平均价支付:
max(平均价 - K, 0);路径依赖,没有简单公式,工具是蒙特卡洛。 - 把全部路径放进一个数组(行 = 路径,列 = 日期),用风险中性漂移模拟;平均与收益沿行向量化。
- 价格 =
exp(-r * T) * mean(payoffs),标准误为std / sqrt(paths);平均化使它比欧式看涨便宜,几何版本可作控制变量。
下一节:障碍期权,价格触及某一水平时生效或失效的期权。
实验:评分内容
- 用
average_price沿每条路径求平均25 分 - 用
geometric_average试试几何平均25 分 - 用
asian_call_payoff按平均价格支付25 分 - 用
asian_price定价并给出误差25 分