[R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity

Charles Duranceau cduranceau at nial.ky
Fri May 26 17:33:33 CEST 2017


Hi,
I try to back-out the yield from a US Treasury note giving clean price using the function "FixedRateBondYield".
The procedure generate an error (See below).

Is this a structural problem or could it be correct by changing the bond settings ( I tried several changes already)?
Thank you
Charles


In this reproducible example, I try to back-out the yield for a bond maturing on 31-Dec-2016 as of (value date) 30-Dec-2016 (Friday).

library("RQuantLib")

dateValue<-as.Date("2016-12-30")

setEvaluationDate(dateValue)
# US Treasury note fixed attributes
gen_bond_UST =list(asettlementDays=1,afaceAmount= 100,aperiod=3,acalendar="UnitedStates/GovernmentBond",adayCounter=2,
                   abusinessDayConvention=2 ,acompound = 1 ,aredemption=100 ,aissueDate=as.Date("2014-01-31"),aendOfMonth=0)

# Function
with(gen_bond_UST,FixedRateBondYield(price=100.0078,effectiveDate=dateValue,maturityDate=as.Date("2016-12-31") ,rates=0.00625,
                   calendar=acalendar,settlementDays=asettlementDays,faceAmount= afaceAmount,period=aperiod,dayCounter=adayCounter,
                   businessDayConvention=abusinessDayConvention ,compound = acompound ,redemption=aredemption,issueDate=aissueDate))

# output
Error in fixedRateBondYieldByPriceEngine(settlementDays, price, calendar,  :
  degenerate single date (December 30th, 2016) schedule
seed date: December 31st, 2016
exit date: December 30th, 2016
effective date: December 30th, 2016
first date: null date
next to last date: null date
termination date: December 31st, 2016
generation rule: Backward
end of month: 0


> sessionInfo()

R version 3.3.2 (2016-10-31)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows >= 8 x64 (build 9200)



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.4.3



loaded via a namespace (and not attached):

[1] zoo_1.8-0       tools_3.3.2     Rcpp_0.12.10    grid_3.3.2      lattice_0.20-34



	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list