Skip to content

Skip degenerate periods in OvernightLeg when adjusted dates collapse#2515

Open
javierdejesusda wants to merge 1 commit intolballabio:masterfrom
javierdejesusda:fix/overnight-leg-degenerate-period
Open

Skip degenerate periods in OvernightLeg when adjusted dates collapse#2515
javierdejesusda wants to merge 1 commit intolballabio:masterfrom
javierdejesusda:fix/overnight-leg-degenerate-period

Conversation

@javierdejesusda
Copy link
Copy Markdown

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 OvernightIndexedCoupon to 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 periods
whose adjusted start date is on or past the adjusted end date.

Test plan

  • Added test constructing a schedule with a Saturday-to-Monday degenerate
    stub and verifying the period is skipped without crashing

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
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 28, 2026

CLA assistant check
All committers have signed the CLA.

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Mar 28, 2026

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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OvernightLeg segfault on degenerate 1-day weekend stub period

3 participants