Skip to content

Fix SimpleThenCompounded NPV for long first coupon period#2473

Open
zippyg wants to merge 1 commit into
lballabio:masterfrom
zippyg:fix/issue-2172-stc-long-first-period
Open

Fix SimpleThenCompounded NPV for long first coupon period#2473
zippyg wants to merge 1 commit into
lballabio:masterfrom
zippyg:fix/issue-2172-stc-long-first-period

Conversation

@zippyg

@zippyg zippyg commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

For bonds with a long irregular first coupon period, CashFlows::npv() and the related duration and convexity functions incorrectly applied compound discounting to the first period when the yield convention is SimpleThenCompounded. The ICMA specification requires simple discounting for the first period unconditionally; the time-magnitude threshold in InterestRate::compoundFactor() only diverges from this when the first stub exceeds one frequency period. This patch moves the period-position logic into the affected functions using a firstCoupon flag and, for modifiedDuration and convexity, running alpha/beta accumulators that correctly represent the mixed simple-then-compound derivative. Fixes #2172.

For bonds with a long irregular first coupon period, CashFlows::npv()
and the related duration and convexity functions incorrectly applied
compound discounting to the first period when the yield convention is
SimpleThenCompounded.  The ICMA specification requires simple discounting
for the first period unconditionally; the time-magnitude threshold in
InterestRate::compoundFactor() only diverges from this when the first
stub exceeds one frequency period.

The fix moves the period-position logic into the affected functions using
a firstCoupon flag and, for modifiedDuration and convexity, running
alpha/beta accumulators that correctly represent the mixed
simple-then-compound derivative.  Normal bonds (all periods equal to
exactly 1/frequency) are numerically unaffected.

Fixes lballabio#2172.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 74.239% (-0.003%) from 74.242%
when pulling a1eba15 on zippyg:fix/issue-2172-stc-long-first-period
into 81d819d on lballabio:master.

@lballabio

Copy link
Copy Markdown
Owner

@pcaspers, you had done some analysis and had some test cases, if I recall correctly. May you have a look? Thanks!

@lballabio

Copy link
Copy Markdown
Owner

@pcaspers ☝️ — thanks! (Just nudging in case you missed, ignore me if you saw this but don't have time now)

@pcaspers

Copy link
Copy Markdown
Contributor

sorry, yes, I'll come back to this, just swamped right now with other things

@github-actions

Copy link
Copy Markdown
Contributor

This PR was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

@github-actions github-actions Bot added the stale label Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SimpleThenCompounded convention applied incorrectly in bond price calculation

4 participants