问题
I'm trying to use the RQuantLib
package to calculate greeks for some options but getting NAs
for all the output values except price.
I'm getting the same results when I copy the examples from the package user manual:
> AmericanOption("put", strike=100, volatility=0.4, 100, 0.02, 0.03, 0.5)
Concise summary of valuation for AmericanOption
value delta gamma vega theta rho divRho
10.9174 NA NA NA NA NA NA
> AmericanOption("call", 100, 100, 0.02, 0.03, 0.5, 0.4)
Concise summary of valuation for AmericanOption
value delta gamma vega theta rho divRho
11.3648 NA NA NA NA NA NA
Any suggestions?
回答1:
That has been discussed before e.g. in this thread on the r-sig-finance mailing list: the stubs are there because QL used to provided (numerical) greeks for American options, but stopped doing so many years ago.
So you have to approximate them numerically by shifting inputs; see the post referenced above for details. Consider subscribing to r-sig-finance as well.
回答2:
All you have to do is to include the engine CrankNicolson as follows:
# simple call with unnamed parameters, using Crank-Nicolons
AmericanOption("put", strike=100, volatility=0.4, 100, 0.02, 0.03, 0.5, engine="CrankNicolson")
来源:https://stackoverflow.com/questions/10074480/r-rquantlib-not-calculating-greeks