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

Charles Duranceau cduranceau at nial.ky
Sat May 27 01:14:42 CEST 2017

Hi Terry,
you are right, the last settlement day of the bond is on Dec 30th as the bond redeems on a week end so the next business day as you point out fall after the redemption.
However, the day before you still have 1 day of accrual and still have a discount (and the price may deviate from par).
I agree this is an extreme case but possible (you held that bond to maturity) and you would not expect the function to return an error message unless the setup is wrong which is my question.
I find a work around by calculating a simple discount in such case but I thought it could be useful to know.


From: Terry Leitch [mailto:tleitch1 at jhu.edu]
Sent: Friday, May 26, 2017 1:52 PM
To: Charles Duranceau; r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity

Not sure, but maturity=effectivedate+1 . Since setllementDays=1, the bond matures on the same day you pay for it. Was that your intention?

From: R-SIG-Finance <r-sig-finance-bounces at r-project.org<mailto:r-sig-finance-bounces at r-project.org>> on behalf of Charles Duranceau <cduranceau at nial.ky<mailto:cduranceau at nial.ky>>
Sent: Friday, May 26, 2017 11:33:33 AM
To: r-sig-finance at r-project.org<mailto:r-sig-finance at r-project.org>
Subject: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity

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

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



# 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)


[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]]

R-SIG-Finance at r-project.org<mailto:R-SIG-Finance at r-project.org> mailing list
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.

	[[alternative HTML version deleted]]

More information about the R-SIG-Finance mailing list