R语言中进行期权定价的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}

#Initial stock priceS0 <- 100# Number of simulations (feel free to reduce this)n <- 100000# Sampling frequencyfreq <- "monthly"# volatility mean-reversion speedkappa <- 0.003# volatility of volatilityvolvol <- 0.009# Correlation between stoch. vol and spot pricesrho <- -0.5# Initial varianceV0 <- 0.04# long-term variancetheta <- 0.04#Initial short rater0 <- 0.015# Options maturitieshorizon <- 15# Options' exercise pricesstrikes <- c(140, 100, 60)

#  Stochastic volatility  simulationsim.vol <- simdiff(n =  n, horizon =  horizon,frequency =  freq, model = "CIR", x0 =  V0,theta1 =  kappa*theta, theta2 =  kappa,theta3 =  volvol, eps =  shocks[[1]])# Stock prices simulationsim.price <- simdiff(n = n, horizon = horizon,frequency = freq, model = "GBM", x0 = S0,theta1 = r0, theta2 = sqrt(sim.vol),eps = shocks[[2]])

# Stock price at maturity (15 years)print(results)strikes mcprices  lower95  upper95 pricesAnalytic1     140 25.59181 25.18569 25.99793         25.961742     100 37.78455 37.32418 38.24493         38.178513      60 56.53187 56.02380 57.03995         56.91809