lballabio / QuantLib

The QuantLib C++ library
http://quantlib.org
Other
5.35k stars 1.79k forks source link

Credit Default Swap - Last period day counter is not used when there is only one period #2105

Open capitolis-stephen opened 1 week ago

capitolis-stephen commented 1 week ago

When creating a CreditDefaultSwap, setting the last period day counter to include the final date has no effect on the calculation of the final coupon. Creating a single period CDS and setting the day counter to include the last date does change the coupon calculation.

Examples:

trade date = October 9th 2024 notional = 70mm fixed rate = 100bps

CDS expiring December 20th 2024 with last period day counter set to NOT include last day => coupon 176,944 CDS expiring December 20th 2024 with last period day counter set to include last day => coupon 176,944 CDS expiring December 20th 2024 with main day counter set to include last day => coupon 178,888

The issue appears to be related to the last period being the same as the first period:

CDS expiring March 20th 2024 with last period day counter set to NOT include last day => coupon 174,999 CDS expiring March 20th 2024 with last period day counter set to include last day => coupon 176,944

boring-cyborg[bot] commented 1 week ago

Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.

lballabio commented 1 week ago

Hi—may you post some code to reproduce this? It would make it a lot easier to fix the issue.