原文鏈接:http://tecdat.cn/?p=12111
在本文中,我將向您展示如何模擬股票價格的Heston隨機波動率模型。
Heston模型是針對具有隨機波動性的期權,並於1993年申請了債券的貨幣期權。對於固定的無風險利率,其描述爲:
通過使用這種模型,可以得出歐洲看漲期權的價格 。
這是函數的描述。
callHestoncf(S, X, tau, r, v0, vT, rho, k, sigma){
# S = Spot, X = Strike, tau = time to maturity
# r = risk-free rate, q = dividend yield
# v0 = initial variance, vT = long run variance (theta)
# rho = correlation, k = speed of mean reversion (kappa)
# sigma = volatility of volatility
}
現在,進行蒙特卡洛定價。我們將爲3個歐洲看漲期權定價,具有3種不同的執行價格。我們在15年中使用100000個模擬,每個月進行一次。以下是對仿真有用的參數:
#Initial stock price
S0 <- 100
# Number of simulations (feel free to reduce this)
n <- 100000
# Sampling frequency
freq <- "monthly"
# volatility mean-reversion speed
kappa <- 0.003
# volatility of volatility
volvol <- 0.009
# Correlation between stoch. vol and spot prices
rho <- -0.5
# Initial variance
V0 <- 0.04
# long-term variance
theta <- 0.04
#Initial short rate
r0 <- 0.015
# Options maturities
horizon <- 15
# Options' exercise prices
strikes <- c(140, 100, 60)
爲了使用模擬Heston模型,我們首先需要定義如何進行模擬。
此函數提供一個包含2個成分的列表,每個成分包含模擬的隨機高斯增量。
# Stochastic volatility simulation
sim.vol <- simdiff(n = n, horizon = horizon,
frequency = freq, model = "CIR", x0 = V0,
theta1 = kappa*theta, theta2 = kappa,
theta3 = volvol, eps = shocks[[1]])
# Stock prices simulation
sim.price <- simdiff(n = n, horizon = horizon,
frequency = freq, model = "GBM", x0 = S0,
theta1 = r0, theta2 = sqrt(sim.vol),
eps = shocks[[2]])
現在,我們可以使用3種不同的
計算期權價格。
# Stock price at maturity (15 years)
print(results)
strikes mcprices lower95 upper95 pricesAnalytic
1 140 25.59181 25.18569 25.99793 25.96174
2 100 37.78455 37.32418 38.24493 38.17851
3 60 56.53187 56.02380 57.03995 56.91809
從這些結果中,我們看到這三個選項的蒙特卡洛價格與使用函數(直接使用公式來計算價格)計算出的價格相當接近。95%的置信區間包含理論價格。
下面是期權價格,作爲模擬次數的函數。計算出的理論價格用藍色繪製,蒙特卡洛平均價格用紅色繪製,陰影區域表示均值(蒙特卡洛價格)周圍的95%置信區間。