FinancePy icon indicating copy to clipboard operation
FinancePy copied to clipboard

Potential issues for CDS pricing

Open YimingZhang07 opened this issue 2 years ago • 4 comments

Hello,

I really like this package, and have been taking a very close look to the implementation. I spot two potential things that may not be reasonable based on my knowledge from a couple of references (including your book).

  1. In protection leg calculation, the integral step is set to be dt = (tmat - teff) / num_steps_per_year, and num_steps_per_year is 25 by default. I assume this should mean dt = 1 / nums_steps_per_year and total steps are math.ceil((tmat-teff) * nums_steps_per_year). Or else, a long enough term could make dt detours from our target.

  2. The treatment for the last payment date is moved one day forward from the maturity date (usually 20th), which seems off at least when 20th itself is Saturday.

To replicate a given example from markit, use the following example.

CDS(Date(20, 2, 2009, 2, 20), Date(20, 3, 2010), 0.01). The last payment date given by the pricer is March 21st Sunday, which is still a weekend.

The same setup can be found at https://www.cdsmodel.com/assets/cds-model/docs/Standard%20CDS%20Examples.pdf

where the last payment date is adjusted to March 22nd Monday.

Let me know your thoughts.

Thanks,

YimingZhang07 avatar Jun 29 '23 17:06 YimingZhang07

Hi - Thanks for the comments. Let me look at this over the weekend. Best D

domokane avatar Jun 29 '23 17:06 domokane

For the second point, this change should adjust the dates correctly: here This still needs to be properly tested (especially for DateGenRuleTypes.FORWARD). You can checkout the change with:

git remote add FergalOK https://github.com/FergalOK/FinancePy.git
git fetch FergalOK
git checkout --track FergalOK/cds

Also, you're right that dt = (tmat - teff) / num_steps_per_year is wrong. I can make the change once I create a good example to test.

FergalOK avatar Jul 02 '23 13:07 FergalOK

We have almost completed addressing these issues. I will push a new version asap.

domokane avatar Jul 03 '23 09:07 domokane

Thanks for looking into this! Will continue to look at other modules as well.

YimingZhang07 avatar Jul 03 '23 17:07 YimingZhang07