Skip to content

Handle omitted Act/365L reference end date - #259

Open
kadyrbekovhamit-cyber wants to merge 1 commit into
domokane:masterfrom
kadyrbekovhamit-cyber:codex/fix-act365l-missing-reference-date
Open

Handle omitted Act/365L reference end date#259
kadyrbekovhamit-cyber wants to merge 1 commit into
domokane:masterfrom
kadyrbekovhamit-cyber:codex/fix-act365l-missing-reference-date

Conversation

@kadyrbekovhamit-cyber

Copy link
Copy Markdown
Contributor

Summary

DayCount.year_frac() documents dt3 as optional for an ordinary two-date year-fraction calculation. In the annual ACT_365L branch, however, a period that reaches a leap day compares that leap day with dt3 even when dt3 is None. The call then raises AttributeError instead of returning a fraction.

This change treats dt2 as the calculation-period end when no separate reference-period end is supplied. A caller that supplies dt3 for an accrued fraction keeps the existing reference-period behaviour.

Reproducer

DayCount(DayCountTypes.ACT_365L).year_frac(
    Date(1, 12, 2023),
    Date(1, 3, 2024),
    freq_type=FrequencyTypes.ANNUAL,
)

Before this change:

AttributeError: 'NoneType' object has no attribute 'excel_dt'

After this change:

(0.24863387978142076, 91.0, 366)

The regression also distinguishes the ordinary two-date mode from an accrued-fraction call with an explicitly later coupon-period end, so the correction does not erase the existing dt3 semantics.

Validation

  • python -m pytest unit_tests/test_FinDayCount.py -q: 11 passed
  • python -m pytest unit_tests -q: 959 passed, with four pre-existing LSMC RankWarning messages
  • Restoring the previous None handling reproduces the exception above.

The example is synthetic. This PR makes no claim about a downstream system or financial loss.

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.

1 participant