FinancePy
FinancePy copied to clipboard
Potential issues for CDS pricing
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).
-
In protection leg calculation, the integral step is set to be
dt = (tmat - teff) / num_steps_per_year, andnum_steps_per_yearis 25 by default. I assume this should meandt = 1 / nums_steps_per_yearand total steps aremath.ceil((tmat-teff) * nums_steps_per_year). Or else, a long enough term could makedtdetours from our target. -
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,
Hi - Thanks for the comments. Let me look at this over the weekend. Best D
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.
We have almost completed addressing these issues. I will push a new version asap.
Thanks for looking into this! Will continue to look at other modules as well.