if (interactive()) { # the example is too computationally expensive for normal checks
#set-up a HullWhite according to example from QuantLib
HullWhite <- list(term = 0.055, alpha = 0.03, sigma = 0.01, gridIntervals = 40)
#callability schedule dataframe
Price <- rep(as.double(100),24)
Type <- rep(as.character("C"), 24)
Date <- seq(as.Date("2006-09-15"), by = '3 months', length = 24)
callSch <- data.frame(Price, Type, Date)
callSch$Type <- as.character(callSch$Type)
bondparams <- list(faceAmount=100, issueDate = as.Date("2004-09-16"),
maturityDate=as.Date("2012-09-16"), redemption=100,
callSch = callSch)
dateparams <- list(settlementDays=3, calendar="UnitedStates/GovernmentBond",
dayCounter = "ActualActual",
period="Quarterly",
businessDayConvention = "Unadjusted",
terminationDateConvention= "Unadjusted")
coupon <- c(0.0465)
setEvaluationDate(as.Date("2004-11-22"))
CallableBond(bondparams, HullWhite, coupon, dateparams)
#examples using default values
CallableBond(bondparams, HullWhite, coupon)
dateparams <- list(period="Quarterly",
businessDayConvention = "Unadjusted",
terminationDateConvention= "Unadjusted")
CallableBond(bondparams, HullWhite, coupon, dateparams)
bondparams <- list(issueDate = as.Date("2004-09-16"),
maturityDate=as.Date("2012-09-16"))
CallableBond(bondparams, HullWhite, coupon, dateparams)
}
Run the code above in your browser using DataLab