Implementing Heston–Nandi Volatility and Option Pricing
Summary
The document presents a question about iteratively estimating volatility under the Heston–Nandi model from simulated price data. The author simulates a price process using a separate GARCH-generated volatility series, then applies a proposed recursion to update volatility from prior estimates and price observations. The question is whether this procedure correctly extracts volatility associated with Heston–Nandi, and asks for implementation guidance.
The response suggests two routes: use the Heston–Nandi option-pricing implementation directly with model parameters, or, when building an option price calculation from GARCH parameters, simulate both the spot-price and volatility processes. It points to a book as an implementation reference. The exchange does not derive the recursion, validate the supplied code, or clarify whether the simulated dynamics match Heston–Nandi assumptions. It therefore gives directional modeling advice rather than a verified algorithm or empirical result.
Key ideas
- The example combines a GARCH-generated volatility series with a separate simulated price process.
- The proposed recursion is intended to estimate volatility from observed prices, but the response does not verify it.
- An existing Heston–Nandi option-pricing implementation is offered as one practical route.
- A custom option-pricing calculation requires simulating both spot prices and volatility.
- The document gives implementation pointers but no derivation or validation of the code.
Tags
Full text
# Volatility updating rule using r
# Volatility updating rule using r
I'm trying to program a volatility updating rule using iteration. I start with the well know Heston-Nandi model where the returns dynamics are :
with is iid standard normal randome variable, where is time-varying squared volatility, , and .
I want to do is to write the code associate to the volatility updating rule, explain in this algorithm :
- Define equals the given unconditional variance which is constant,
- Iteration for :
to obtain the returns based proxy for spot variances . Which yields an updating function that exclusively involves observation :
My program (r-code) is the following:
```
library(fGarch)
T=3000
# For the example I simulate a GARCH
#process parameters
eta = 0.2 #eta = 0 is equivalent to Geometric Brownian Motion
mu = 100 #the mean of the process
#GARCH volatility model
specs = garchSpec(model = list(omega = 0.000001, alpha = 0.5, beta = 0.4))
sigma = garchSim(spec = specs, n = T)
P_0 = mu #starting price, known
P = rep(P_0,T)
for(i in 2:T){
P[i] = P[i-1] + eta * (mu - P[i-1]) + sigma[i] * P[i-1]
}
# Set the parameters :
para<-c(0.1,0.2,0.3,0.4,0.5,0.7) # (beta_0,beta_1, beta_2, beta_3, r, gamma)
# Iteration to obtain the volatility associate to the model :
vol = c()
vol[1]=sd(P)
for (i in 2:length(P)){
para_vol <- para[1:6]
vol[i]=para_vol[1]+ (para_vol[2]*vol[i-1])+ (para_vol[3]/vol[i-1])*(P[i-1]-para_vol[5]-(para_vol[4]+para_vol[6])*vol[i-1])
}
vol
```
This is an example where I simulate a GARCH (as data set), the I am trying to extract the volatility associate to the Heston-Nandi model.
I known, I´m using a lot of bad things for r, but I could not figure out a better solution. So my question is it correct?
Any correction and suggestion to improve this process! please feel free to share your extant code in R.
Huge thanks!
## Answer by JulianRCook (score 2)
https://quant.stackexchange.com/a/17298
There are two answers to your question
- If you want to use the Neston-Nandi model, you can use it directly with the parameters that you already show above:
`model = list(omega = 0.000001, alpha = 0.5, beta = 0.4)`
In r, the fOptions package has an HN model that can use them:
`HNGOption(TypeFlag, model, S, X, Time.inDays, r.daily)`
- If you want to calculate your own option price using garch params, you need to simulate the spot (or stock) price process as well as the volatility process. Your first set of equations show how the Return (the change in the spot price) is updated for each period.
The best book or reference I have seen that explains the implementation of the HN model is 'Option Pricing Models and Volatility' by Rouah and Vainberg. The code is VBA, but the explanation is very good..Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.