require(ggplot2)
## Loading required package: ggplot2
require(RQuantLib)
## Loading required package: RQuantLib
spot <- 1:200
time <- seq(from = 1, to = 150, by = 1)
inputs <- expand.grid(spot, time)
names(inputs) <- c("spot", "time")
optionPrice <- mapply(function(...) {
x <- AmericanOption(..., engine = "CrankNicolson")
cbind(x$value, x$delta, x$gamma)
}, underlying = inputs$spot, maturity = inputs$time, MoreArgs = list(type = "call",
strike = 100, dividendYield = 0, riskFreeRate = 0.01, volatility = 0.3))
DAT <- cbind(inputs, t(optionPrice))
names(DAT) <- c("spot", "time", "value", "delta", "gamma")
qplot(spot, value, data = DAT, geom = "point", color = time, main = "Option Price vs Spot for diff maturities")
qplot(spot, delta, data = DAT, geom = "point", color = time, main = "Option Delta vs Spot for diff maturities")
qplot(spot, gamma, data = DAT, geom = "point", color = time, main = "Option Gamma vs Spot for diff maturities")