RQuantLib FixedRateBondYield close to maturity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RQuantLib FixedRateBondYield close to maturity

Charles Duranceau

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

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RQuantLib FixedRateBondYield close to maturity

terry leitch
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 <[hidden email]> on behalf of Charles Duranceau <[hidden email]>
Sent: Friday, May 26, 2017 11:33:33 AM
To: [hidden email]
Subject: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity


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

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RQuantLib FixedRateBondYield close to maturity

Charles Duranceau
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.

Regards


From: Terry Leitch [mailto:[hidden email]]
Sent: Friday, May 26, 2017 1:52 PM
To: Charles Duranceau; [hidden email]
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 <[hidden email]<mailto:[hidden email]>> on behalf of Charles Duranceau <[hidden email]<mailto:[hidden email]>>
Sent: Friday, May 26, 2017 11:33:33 AM
To: [hidden email]<mailto:[hidden email]>
Subject: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity


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

_______________________________________________
[hidden email]<mailto:[hidden email]> mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance<https://stat.ethz.ch/mailman/listinfo/r-sig-finance>
-- 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]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RQuantLib FixedRateBondYield close to maturity

terry leitch
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 <[hidden email]>
Sent: Friday, May 26, 2017 7:14:42 PM
To: Terry Leitch; [hidden email]
Subject: RE: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity

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.

Regards


From: Terry Leitch [mailto:[hidden email]]
Sent: Friday, May 26, 2017 1:52 PM
To: Charles Duranceau; [hidden email]
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 <[hidden email]<mailto:[hidden email]>> on behalf of Charles Duranceau <[hidden email]<mailto:[hidden email]>>
Sent: Friday, May 26, 2017 11:33:33 AM
To: [hidden email]<mailto:[hidden email]>
Subject: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity


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

_______________________________________________
[hidden email]<mailto:[hidden email]> mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RQuantLib FixedRateBondYield close to maturity

Charles Duranceau
Hi Terry,
The settlement delay drives the accruals calculation, not the (clean) bond price.
In practical term, if you possess that bond the day before it matures you need to mark it as of that date (value date= Dec-30) and so it need to return a price (coupon + redemption amount) and so a yield.

I will then conclude it is not an error in the bond configuration  from my part. I just need to control for that type of case.
Thank you for your feedback.
Regards


From: Terry Leitch [mailto:[hidden email]]
Sent: Saturday, May 27, 2017 11:43 AM
To: Charles Duranceau; [hidden email]
Subject: Re: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity


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 <[hidden email]<mailto:[hidden email]>>
Sent: Friday, May 26, 2017 7:14:42 PM
To: Terry Leitch; [hidden email]<mailto:[hidden email]>
Subject: RE: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity

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.

Regards


From: Terry Leitch [mailto:[hidden email]]
Sent: Friday, May 26, 2017 1:52 PM
To: Charles Duranceau; [hidden email]<mailto:[hidden email]>
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 <[hidden email]<mailto:[hidden email]>> on behalf of Charles Duranceau <[hidden email]<mailto:[hidden email]>>
Sent: Friday, May 26, 2017 11:33:33 AM
To: [hidden email]<mailto:[hidden email]>
Subject: [R-SIG-Finance] RQuantLib FixedRateBondYield close to maturity


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

_______________________________________________
[hidden email]<mailto:[hidden email]> mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance<https://stat.ethz.ch/mailman/listinfo/r-sig-finance>
-- 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]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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.
Loading...