[R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity
tleitch1 at jhu.edu
Sat May 27 18:43:05 CEST 2017
You don't accrue because you haven't settled. Accruel begins when possess the bond. You possess it the day it matures. It can happen but makes no sense as it's just an exchange of cash for cash in practical terms.
From: Charles Duranceau <cduranceau at nial.ky>
Sent: Friday, May 26, 2017 7:14:42 PM
To: Terry Leitch; r-sig-finance at r-project.org
Subject: RE: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity
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)?
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)
businessDayConvention=abusinessDayConvention ,compound = acompound ,redemption=aredemption,issueDate=aissueDate))
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
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
 LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
 LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
 stats graphics grDevices utils datasets methods base
other attached packages:
loaded via a namespace (and not attached):
 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