I am trying to use RQuantLib to price bonds but the version I am using will not work with negative interest rates. See example below. Does anyone know a work around? I thought that QuantLib was able to accept negative rates?
require(RQuantLib)
today <- as.Date("2014-10-27")
setEvaluationDate(today)
times <- seq(today+2,as.Date("2024-12-30"),by=1)
maturity <- yearFraction(rep(today,length(times)),times,rep(2,length(times)))
zerorates <- seq(-.0001,.01,length.out=length(maturity))
curve <- list(table = data.frame(date=times, zeroRates=zerorates))
attr(curve,"class") <- "DiscountCurve"
FixedRateBond(
bond =list(issueDate=as.Date("2005-11-24"), maturityDate=as.Date("2016-01-03")),
rates=.035, discountCurve= curve,
dateparams=list(settlementDays=2,dayCounter=2,period=1))
Error: invalid value (-0.0001) at index 0
sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RQuantLib_0.3.12 rJava_0.9-6
loaded via a namespace (and not attached):
[1] Rcpp_0.11.3 tools_3.1.1