Skip to content

Fix CDSCurve calibration to honor explicit cash settlement date - #499

Merged
domokane merged 1 commit into
FinancePy-Org:masterfrom
dennis123dennis:fix/cds-curve-cash-settlement
Dec 4, 2026
Merged

domokane merged 1 commit into
FinancePy-Org:masterfrom
dennis123dennis:fix/cds-curve-cash-settlement

Conversation

@dennis123dennis

@dennis123dennis dennis123dennis commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Fix CDSCurve calibration to honor explicit cash settlement date

Problem

The market-curves CDSCurve stores an optional settle_dt, but its bootstrap previously resolved settlement from only the curve anchor. Both O’Kane–Turnbull and ISDA therefore calibrated the accrued coupon rebate at each instrument’s default settlement even when an override was provided. A calibration trade could have a material nonzero clean PV at the requested settlement. Confirmed on ef59d2ad99a707c19fb5e7dc6d216bdf7fa959ed. The published 1.1.2 constructor predates the override.

Reproduction

from financepy.market.curves.cds_curve import CDSCurve
from financepy.market.curves.flat_discount_curve import FlatDiscountCurve
from financepy.products.credit.cds import CDS
from financepy.utils.calendar import CalendarTypes
from financepy.utils.date import Date
from financepy.utils.global_types import CDSModelTypes

anchor = Date(15, 1, 2026)
cash_settle = Date(29, 1, 2026)
discount = FlatDiscountCurve(anchor, 0.05)
quote = CDS(Date(16, 1, 2026), Date(20, 12, 2030), 0.025, 10_000_000.0,
            calendar_type=CalendarTypes.NONE)
for model in CDSModelTypes:
    curve = CDSCurve(anchor, [quote], discount, 0.40, cds_model=model,
                     settle_dt=cash_settle)
    _, clean_pv = quote.value(anchor, curve, 0.40, settle_dt=cash_settle)
    print(model.name, clean_pv)

On the base both models return about −$28.22 at January 29. After the correction the clean values are about $0.0000136 and $0.0000132. On a fixed curve, only the clean accrued rebate changes with cash settlement. Its PV change equals N × c × accrued_fraction × [D(Jan 29) − D(Jan 18)]. Independently discounting $18,750 accrued cash gives −$28.2205486496064. The day-14 calibration target is zero clean PV at the requested date. ISDA Standard CDS examples

Change and compatibility

Pass the curve’s stored override into the existing CDS.get_settle_dt call in CDSCurve.build_curve(). This uses the instrument’s existing date validation and calendar-specific default. Omitted settlement and explicit None still resolve through the instrument calendar. An explicit date before the anchor now raises the existing FinError during nonempty calibration. Spread, rate and recovery sensitivities use the same corrected bootstrap when rebuilding. Pricing signatures, settlement rules and solvers retain their existing contracts.

Validation

The new settlement tests cover both pricing models, default equivalence, same-day settlement, an increasing quote basket, a pre-anchor input, the fixed-curve identity, the zero-rate limit and all three sensitivity rebuilds. The 16-case file yields ten expected failures and six passing controls on the base. All 16 pass with the correction, together with the 755-test focused selection and all 7,164 scenarios in the standalone ISDA grid. The broader Windows/Python 3.12 unit run reported 2,142 passes and two inflation-swap constructor keyword failures that also occur on the unchanged base. The 14 legacy modules reported the same comparator differences before and after. Run the focused regression file with python -m pytest -vv tests/unit/test_cds_curve_cash_settlement.py.

AI assistance

. The Phase 1 evidence was independently reviewed. The Phase 2 patch and outputs are packaged for the submitter’s own review before submission.

@domokane
domokane merged commit 83d89f9 into FinancePy-Org:master Dec 4, 2026
1 of 2 checks passed
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.

2 participants