Skip degenerate periods in OvernightLeg when adjusted dates collapse#2515
Skip degenerate periods in OvernightLeg when adjusted dates collapse#2515javierdejesusda wants to merge 1 commit intolballabio:masterfrom
Conversation
A 1-day stub spanning e.g. Saturday-Sunday collapses to the same business day under the overnight index fixing calendar, causing OvernightIndexedCoupon to throw on the degenerate schedule. Skip such periods in OvernightLeg::operator Leg() by checking whether the adjusted start date is on or past the adjusted end date. Closes lballabio#2496
|
Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it. |
| // same business day under the overnight index's fixing calendar | ||
| // (e.g. a 1-day stub spanning Saturday-Sunday). | ||
| if (fixCal.adjust(start, fixConv) >= fixCal.adjust(end, fixConv)) | ||
| continue; |
There was a problem hiding this comment.
I'm not sure that I would skip the period silently. With this change, in the test case you added we would end up with two coupons, the first accruing up to March 28th and the second accruing starting from March 30th. However, the short period between the 28th and the 30th is in the schedule and should give an accrual somehow (most likely by accruing Friday's fixing for the two days between Saturday and Monday). Do you have more info on the actual bond that's causing this?
There was a problem hiding this comment.
I don't have the bond details — I came across the issue and put together a PR based on the proposed fix. @UnitedMarsupials, could you share more about the bond that triggered this?
You're right that silently skipping the period isn't ideal. Happy to take a different approach if you'd prefer handling this inside OvernightIndexedCoupon so the degenerate period produces a valid coupon using the previous business day's fixing, or some other way.
Closes #2496
Summary
A 1-day stub spanning a weekend (e.g. Saturday to Sunday) can collapse
to the same business day under the overnight index's fixing calendar.
This causes
OvernightIndexedCouponto throw on the degenerate schedule,and the exception unwind triggers use-after-free in
~FloatingRateCoupon(partially constructed coupon still registered as observer).
The fix adds a guard in
OvernightLeg::operator Leg()that skips periodswhose adjusted start date is on or past the adjusted end date.
Test plan
stub and verifying the period is skipped without crashing