QuantLib icon indicating copy to clipboard operation
QuantLib copied to clipboard

The market convention in Canada is to quote a money market equivalent yield on bonds that are in their last coupon period

Open qiubill opened this issue 2 years ago • 9 comments

image-20220712-192828

The market convention in Canada is to quote a money market equivalent yield on bonds that are in their last coupon period. The formula below converts between price and simple interest yield on a bond with one cash flow remaining:

P + AI = (CP + Cm) / (1 + YME * DSM / 365)

where: P = clean price AI = actual/365 accrued interest CP = 100 or call price Cm = coupon payment at maturity YME = money market equivalent yield DSM = days from settlement date to maturity date

So I am not sure whether QuantLib has this kind of yield calculation support for the ql.FixedRateBond class, or there is a work around on. Please advise, thanks!!!

qiubill avatar Jul 13 '22 18:07 qiubill

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

github-actions[bot] avatar Sep 12 '22 02:09 github-actions[bot]

USD corporate bonds with less than 14 months till maturity are quoted using a similar convention. We use the same formula described in section 10.10.3 of this document (see page 49) -- the only difference being that the daycount used for USD corporate MME-yield is typically Actual/360 rather than Actual/365.

It would be great if QuantLib supported this calculation natively.

@qiubill My workaround for now has been to implement the calculation explicitly in python. If you have access to Bloomberg then you can verify the correctness of your own implementation using YAS <GO> or ME <GO>.

erikhansenwong avatar Nov 10 '22 20:11 erikhansenwong

Thanks Erik for your email,

Yeah, we have implemented the MM yield calculation in our product, since we did not hear from QuantLib.

Sent from Outlookhttp://aka.ms/weboutlook


From: Erik Wong @.> Sent: November 10, 2022 3:00 PM To: lballabio/QuantLib @.> Cc: qiubill @.>; Mention @.> Subject: Re: [lballabio/QuantLib] The market convention in Canada is to quote a money market equivalent yield on bonds that are in their last coupon period (Issue #1430)

USD corporate bonds with less than 14 months till maturity are quoted using a similar convention. We use the same formula described in section 10.10.3 of this documenthttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fiiac.ca%2Fwp-content%2Fuploads%2FCanadian-Conventions-in-FI-Markets-Release-1.3.pdf&data=05%7C01%7C%7Cf8c31c3e801c44e73c8908dac3563e8b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638037072427573733%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=d%2B89%2BvS9Wn3xgTAb%2B7F1yWh7%2BMPeX6kvaB4B2Jt8f4U%3D&reserved=0 (see page 49) -- the only difference being that the daycount used for USD corporate MME-yield is typically Actual/360 rather than Actual/365.

It would be great if QuantLib supported this calculation natively.

@qiubillhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fqiubill&data=05%7C01%7C%7Cf8c31c3e801c44e73c8908dac3563e8b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638037072427573733%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EHvvmraw9owNy78ZNpOq6%2FC6fZqzhdu%2F01jVHaUdImA%3D&reserved=0 My workaround for now has been to implement the calculation explicitly in python. If you have access to Bloomberg then you can verify the correctness of your own implementation using YAS <GO> or ME <GO>.

— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flballabio%2FQuantLib%2Fissues%2F1430%23issuecomment-1310828721&data=05%7C01%7C%7Cf8c31c3e801c44e73c8908dac3563e8b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638037072427729942%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dETaVDV0arRBg%2BIrtmrhF3HgGsmFaoefQsm1AnwUG%2Bs%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFOI7MOAUL3Y5KEKDG4A6DTWHVH6NANCNFSM53PWC3DQ&data=05%7C01%7C%7Cf8c31c3e801c44e73c8908dac3563e8b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638037072427729942%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pnpmn%2BRXCsem3vs2xyVOrOB2pFsa8m9pXEUdrqIKRxM%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

qiubill avatar Nov 11 '22 01:11 qiubill

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

github-actions[bot] avatar Jan 10 '23 02:01 github-actions[bot]

Hi @qiubill or @erikhansenwong could you please post a quick code reproducing the desired behavior? Thanks!

jakeheke75 avatar Jan 25 '23 10:01 jakeheke75

Hello @lballabio, how would you implement this requirement? With a new virtual member function in class Bond that can be eventually re-implemented in derived classes? I see that almost all the calculation functions for bonds are in adapter struct BondFunctions which refers to CashFlows functions. So the new functionality should probably be implemented there? Thanks.

jakeheke75 avatar Feb 19 '23 18:02 jakeheke75

our implementation is fairly simple, basically was divided into two scenario: one cash flow or multiple cash flow remaining.

For the one cash flow remaining, it is super important: maturity_adj = self.quantlib_maturity_date dsm = maturity_adj - self.quantlib_settlement_date bond_yield = ((100.0 + 100.0 * self.get_coupon() / self.frequency) / dirty_price - 1.0) * 365.0 / dsm

But for the multiple remaining cash flow case, it will be more complicated, especially for those quarterly or monthly coupon paid scenario, you need to have root_scalar function, but I cannot give you the implementation details, because I did not have the authorization from my company, the code belongs to the company. I believe you will be able to figure it out, and I don't think QuantLIb will implement it, because it is not generic feature.

qiubill avatar Feb 20 '23 02:02 qiubill

I don't think QuantLIb will implement it, because it is not generic feature. Yes, if it's too specific it probably makes sense to leave the implementation out of the library.

Out of curiosity, if we want to implement a MMY formula which is general enough, could be also this one? MMY or also MMY2 Disclaimer: I am not a quantitative analyst 😃

jakeheke75 avatar Feb 20 '23 21:02 jakeheke75

Canadian-Conventions-in-FI-Markets-Release-1-2-Feb-2015 (1).pdf Please read chapter 10.10 of the canadian convention spec, there is the detailed, as I have said, if there is more than one cash flow remaining, you will need root scalar, especially for those Quarterly or Monthly coupon paid bond

qiubill avatar Feb 21 '23 06:02 qiubill