Skip to content

Credit coupons in Bond.forward_price the way the dirty prices and calc_ror do - #487

Merged
domokane merged 1 commit into
FinancePy-Org:masterfrom
QuantIntellect:fix/bond-forward-price-coupons
Nov 30, 2026
Merged

domokane merged 1 commit into
FinancePy-Org:masterfrom
QuantIntellect:fix/bond-forward-price-coupons

Conversation

@QuantIntellect

Copy link
Copy Markdown
Contributor

The other item from #484. forward_price subtracts the coupons paid between the settlement and forward dates, picked by payment date. The dirty prices and calc_ror decide who gets a coupon by its coupon date and ex-dividend date. They also treat the maturity date as part of the final coupon period. Because the rules differ, the forward clean price jumps by a whole coupon in three places. For the bond from #484's tests, settled on 1 Mar 2027 at a clean price of 100 with a 3% repo rate:

Forward date master this PR Neighbouring days
15 Jul 2029, a Sunday coupon date paid on the Monday 99.4548 97.4550 97.4582 / 97.4517
5 Jan 2030, in the final ex-dividend period (7 ex-dividend days) 98.8759 96.8776 96.8792 on 4 Jan
15 Jan 2030, the maturity date 94.8426 96.8426 96.8459 on 14 Jan

The cause of each jump:

  • Sunday coupon date: accrued interest has restarted, but the coupon isn't paid until the Monday, so it wasn't subtracted.
  • Ex-dividend period: the seller keeps the next coupon, but it's paid after the forward date, so it wasn't subtracted either.
  • Maturity date: accrued_interest includes the final coupon since Fix Bond settlement on the maturity date and coupon attribution in calc_ror #484, and the coupon was also subtracted as paid.

Change

  • Shared rule: _cpns_held(begin_dt, end_dt) returns the coupons that a holder from begin_dt to end_dt receives. It uses the rule calc_ror already had, moved out of calc_ror, which now calls it.
  • Forward price: forward_price subtracts those coupons, each carried from its payment date to the forward date, as before. A coupon kept in an ex-dividend period is paid after the forward date, so its carry time is negative.

BondFuture.implied_repo_rate picks coupons with the same kind of window. test_implied_repo_inverts_forward_price still passes, because its dates avoid these cases. I can align it in a follow-up if you like.

Tests

test_forward_price_moves_smoothly walks the forward date a day at a time:

  • through the Sunday coupon date and the final coupon period;
  • with and without ex-dividend days.

It checks that no day moves the price by 0.01 or more. On master all 4 cases fail, each with a move of 2.003. The 16 tests from #484 still pass, including the calc_ror ones.

I also walked the forward date through the whole life of this bond, and of a quarterly bond with weekend coupon dates, with and without ex-dividend days. The largest one-day move is now 0.0075, against 2.004 and 1.257 on master.

pytest tests/unit gives 2073 passed, including the new cases. scripts/run_all_regression_tests.py gives the same error counts as master in all 129 modules. The warning counts differ by one only in the equity barrier, FX barrier and FX lookback Monte Carlo modules, which vary from run to run and don't use bonds. The branch merges cleanly with #486, and the bond tests pass on the merge.

…c_ror do

forward_price subtracted the coupons whose payment date falls after the
settlement date and on or before the forward date. The dirty prices and
calc_ror decide who gets a coupon by its coupon date, its ex-dividend date
and, on the maturity date, the final coupon period. So the forward clean
price jumped by a whole coupon when the forward date was a coupon date
whose payment is business-day adjusted, inside an ex-dividend period, or
the maturity date, where accrued_interest already includes the final
coupon.

Move calc_ror's rule into _cpns_held, which returns the coupons a holder
from one date to another receives, and use it in both. forward_price
carries each of those coupons from its payment date to the forward date
as before. One kept in an ex-dividend period is paid after the forward
date, so its time is negative.
@domokane
domokane merged commit 2813409 into FinancePy-Org:master Nov 30, 2026
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