Skip to content

Fix SimpleThenCompounded NPV for long first coupon period#2473

Open
zippyg wants to merge 1 commit intolballabio: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 intolballabio:masterfrom
zippyg:fix/issue-2172-stc-long-first-period

Conversation

@zippyg
Copy link
Contributor

@zippyg zippyg commented Mar 8, 2026

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

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
Owner

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

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.

SimpleThenCompounded convention applied incorrectly in bond price calculation

3 participants