callHestoncf {NMOF} | R Documentation |
Price of a European Call under the Heston Model
Description
Computes the price of a European Call under the Heston model (and the equivalent Black–Scholes–Merton volatility)
Usage
callHestoncf(S, X, tau, r, q, v0, vT, rho, k, sigma, implVol = FALSE,
...,
uniroot.control = list(), uniroot.info = FALSE)
Arguments
S |
current stock price |
X |
strike price |
tau |
time to maturity |
r |
risk-free rate |
q |
dividend rate |
v0 |
current variance |
vT |
long-run variance (theta in Heston's paper) |
rho |
correlation between spot and variance |
k |
speed of mean-reversion (kappa in Heston's paper) |
sigma |
volatility of variance. A value smaller than 0.01 is replaced with 0.01. |
implVol |
compute equivalent Black–Scholes–Merton
volatility? Default is |
... |
named arguments, passed to |
uniroot.control |
A list. If there are elements named
|
uniroot.info |
logical; default is |
Details
The function computes the value of a plain vanilla European call under the Heston model. Put values can be computed through put–call-parity.
If implVol
is TRUE
, the function will
compute the implied volatility necessary to obtain the
same price under Black–Scholes–Merton. The implied
volatility is computed with uniroot
from
the stats package (the default search interval is
c(0.00001, 2)
; it can be changed through
uniroot.control
).
Note that the function takes variances as inputs (not volatilities).
Value
Returns the value of the call (numeric) under the Heston
model or, if implVol
is TRUE
, a list of the
value and the implied volatility. If uniroot.info
is TRUE
, then instead of only the computed
volatility, the complete output of uniroot
is included in the result.
Note
If implVol
is TRUE
, the function will
return a list with elements named value
and
impliedVol
. Prior to version 0.26-3, the first
element was named callPrice
.
Author(s)
Enrico Schumann
References
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. doi:10.1016/C2017-0-01621-X
Heston, S.L. (1993) A Closed-Form Solution for Options with Stochastic Volatility with Applications to Bonds and Currency options. Review of Financial Studies 6(2), 327–343.
Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual
See Also
Examples
S <- 100; X <- 100; tau <- 1; r <- 0.02; q <- 0.01
v0 <- 0.2^2 ## variance, not volatility
vT <- 0.2^2 ## variance, not volatility
rho <- -0.7; k <- 0.2; sigma <- 0.5
## get Heston price and BSM implied volatility
result <- callHestoncf(S = S, X = X, tau = tau, r = r, q = q,
v0 = v0, vT = vT, rho = rho, k = k,
sigma = sigma, implVol = TRUE)
## Heston price
result[[1L]]
## price BSM with implied volatility
vol <- result[[2L]]
d1 <- (log(S/X) + (r - q + vol^2 / 2)*tau) / (vol*sqrt(tau))
d2 <- d1 - vol*sqrt(tau)
callBSM <- S * exp(-q * tau) * pnorm(d1) -
X * exp(-r * tau) * pnorm(d2)
callBSM ## should be (about) the same as result[[1L]]