if (.Platform$OS.type != "windows" && .Platform$r_arch != "i386") {
if (FALSE) {
# This data was generated to match the original quantlib example for Bermudan Swaption
params <- list(tradeDate=as.Date('2016-2-15'),
settleDate=as.Date('2016-2-17'),
startDate=as.Date('2017-2-17'),
maturity=as.Date('2022-2-17'),
payFixed=TRUE,
european=FALSE,
dt=.25,
strike=.06,
method="G2Analytic",
interpWhat="discount",
interpHow="loglinear")
# Market data used to construct the term structure of interest rates
tsQuotes <- list(d1w =0.0382,
d1m =0.0372,
fut1=96.2875,
fut2=96.7875,
fut3=96.9875,
fut4=96.6875,
fut5=96.4875,
fut6=96.3875,
fut7=96.2875,
fut8=96.0875,
s3y =0.0398,
s5y =0.0443,
s10y =0.05165,
s15y =0.055175)
# Swaption volatility matrix with corresponding maturities and tenors
swaptionMaturities <- c(1,2,3,4,5)
swapTenors <- c(1,2,3,4,5)
volMatrix <- matrix(
c(0.1490, 0.1340, 0.1228, 0.1189, 0.1148,
0.1290, 0.1201, 0.1146, 0.1108, 0.1040,
0.1149, 0.1112, 0.1070, 0.1010, 0.0957,
0.1047, 0.1021, 0.0980, 0.0951, 0.1270,
0.1000, 0.0950, 0.0900, 0.1230, 0.1160),
ncol=5, byrow=TRUE)
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual")
setEvaluationDate(as.Date("2016-2-16"))
times<-times <- seq(0,14.75,.25)
dcurve <- DiscountCurve(params, tsQuotes, times=times,legparams)
# Price the Bermudan swaption
pricing <- AffineSwaption(params, dcurve,swaptionMaturities, swapTenors, volMatrix,legparams)
summary(pricing)
}
}
Run the code above in your browser using DataLab