FA-61221 / Bond day-count conventions / Open access
Irregular final coupon amount: the extension beyond q1 is measured against the first notional period · case 01
Long final coupons are misstated when consecutive notional periods have different lengths.
ROOT CAUSE
The extension fraction divides by days(prev, q1) instead of days(q1, q2).
VERIFIED REPAIR
Divide the extension by the length of the second notional period.
Unsuccessful approach: Dividing by the whole irregular period mixes the regular and extension parts.
Case contract
Inputs the last regular coupon date prev, maturity (prev < maturity <= prev + 2 periods), months per period and annual rate. Quasi dates are prev shifted forward k*months with the prev day clamped to month length. c = 100*rate/freq. Short final period (maturity <= q1): c*days(prev,mat)/days(prev,q1). Long final period: c*(1 + days(q1,mat)/days(q1,q2)). Round to 6 decimals.
Why this case matters
Bond accrual and pricing systems depend on exact day-count arithmetic; a single-day error changes settlement cash.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
from fractions import Fraction
N = 1
observations = []
def solve(prev, maturity, months, rate):
def mlen(y, m):
if m == 2:
return 29 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 else 28
return 30 if m in (4, 6, 9, 11) else 31
P = datetime.date(*prev)
M = datetime.date(*maturity)
freq = 12 // months
def fwd(k):
t = P.year * 12 + P.month - 1 + k * months
y, m = t // 12, t % 12 + 1
return datetime.date(y, m, min(P.day, mlen(y, m)))
c = 100 * Fraction(str(rate)) / freq
q1 = fwd(1)
if M <= q1:
frac = Fraction((M - P).days, (q1 - P).days)
else:
q2 = fwd(2)
frac = 1 + Fraction((M - q1).days, (q1 - P).days)
return round(float(c * frac), 6)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression long stub extension denominator 1', [[2015, 5, 30], [2017, 1, 1], 12, 0.05], 7.958904], ['regression long stub extension denominator 2', [[2017, 7, 31], [2017, 9, 30], 1, 0.045], 0.75], ['partial repair probe 1', [[2033, 2, 28], [2034, 11, 6], 12, 0.03], 5.063014], ['partial repair probe 2', [[2017, 11, 30], [2019, 10, 26], 12, 0.045], 8.568493], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2042, 3, 31], [2042, 7, 7], 6, 0.0725], 1.941257], ['normal control 2', [[2014, 4, 7], [2014, 10, 7], 6, 0.045], 2.25]], [['regression long stub extension denominator 1', [[2016, 10, 30], [2017, 8, 24], 6, 0.045], 3.67623], ['regression long stub extension denominator 2', [[2045, 9, 30], [2046, 9, 30], 6, 0.05], 5.0], ['partial repair probe 1', [[2023, 9, 30], [2024, 3, 27], 3, 0.045], 2.212912], ['partial repair probe 2', [[2034, 7, 4], [2034, 10, 5], 3, 0.045], 1.137228], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2013, 4, 3], [2013, 11, 23], 12, 0.03], 1.923288], ['normal control 2', [[2018, 6, 30], [2018, 9, 30], 3, 0.05], 1.25]], [['regression long stub extension denominator 1', [[2019, 2, 28], [2019, 8, 29], 6, 0.05], 2.513587], ['regression long stub extension denominator 2', [[2017, 12, 1], [2018, 3, 30], 3, 0.03], 0.986413], ['partial repair probe 1', [[2039, 6, 30], [2040, 3, 13], 6, 0.05], 3.510929], ['partial repair probe 2', [[2013, 10, 29], [2014, 12, 28], 12, 0.03], 3.493151], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2026, 7, 31], [2026, 8, 27], 1, 0.0725], 0.52621], ['normal control 2', [[2018, 7, 21], [2018, 8, 3], 6, 0.03], 0.105978]], [['regression long stub extension denominator 1', [[2020, 9, 7], [2021, 7, 20], 6, 0.0725], 6.284647], ['regression long stub extension denominator 2', [[2034, 11, 18], [2035, 11, 10], 6, 0.03], 2.934783], ['partial repair probe 1', [[2005, 6, 30], [2007, 6, 30], 12, 0.045], 9.0], ['partial repair probe 2', [[2037, 5, 26], [2038, 8, 20], 12, 0.03], 3.706849], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2014, 4, 29], [2014, 5, 3], 1, 0.0725], 0.080556], ['normal control 2', [[2006, 1, 11], [2006, 7, 11], 6, 0.03], 1.5]], [['regression long stub extension denominator 1', [[2009, 2, 28], [2009, 4, 5], 1, 0.05], 0.524194], ['regression long stub extension denominator 2', [[2005, 11, 30], [2006, 1, 5], 1, 0.03], 0.298387], ['partial repair probe 1', [[2023, 4, 28], [2024, 1, 14], 6, 0.05], 3.565574], ['partial repair probe 2', [[2023, 6, 20], [2024, 6, 20], 6, 0.045], 4.5], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2042, 12, 1], [2043, 3, 10], 12, 0.03], 0.813699], ['normal control 2', [[2030, 6, 29], [2030, 8, 27], 3, 0.03], 0.480978]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression long stub extension denominator 1 | 7.95082 | 7.958904 | Failed |
| regression long stub extension denominator 2 | 0.737903 | 0.75 | Failed |
| partial repair probe 1 | 5.063014 | 5.063014 | Passed |
| partial repair probe 2 | 8.568493 | 8.568493 | Passed |
| boundary control 1 | 1.236264 | 1.236264 | Passed |
| boundary control 2 | 2.5 | 2.5 | Passed |
| normal control 1 | 1.941257 | 1.941257 | Passed |
| normal control 2 | 2.25 | 2.25 | Passed |
SHA-256 / d2e5c02a33dee78ea70833ef35f0ebdfea7b980a29bde6560c928b4d4cc118f9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
from fractions import Fraction
N = 1
observations = []
def solve(prev, maturity, months, rate):
def mlen(y, m):
if m == 2:
return 29 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 else 28
return 30 if m in (4, 6, 9, 11) else 31
P = datetime.date(*prev)
M = datetime.date(*maturity)
freq = 12 // months
def fwd(k):
t = P.year * 12 + P.month - 1 + k * months
y, m = t // 12, t % 12 + 1
return datetime.date(y, m, min(P.day, mlen(y, m)))
c = 100 * Fraction(str(rate)) / freq
q1 = fwd(1)
if M <= q1:
frac = Fraction((M - P).days, (q1 - P).days)
else:
q2 = fwd(2)
frac = 1 + Fraction((M - q1).days, (M - P).days)
return round(float(c * frac), 6)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression long stub extension denominator 1', [[2015, 5, 30], [2017, 1, 1], 12, 0.05], 7.958904], ['regression long stub extension denominator 2', [[2017, 7, 31], [2017, 9, 30], 1, 0.045], 0.75], ['partial repair probe 1', [[2033, 2, 28], [2034, 11, 6], 12, 0.03], 5.063014], ['partial repair probe 2', [[2017, 11, 30], [2019, 10, 26], 12, 0.045], 8.568493], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2042, 3, 31], [2042, 7, 7], 6, 0.0725], 1.941257], ['normal control 2', [[2014, 4, 7], [2014, 10, 7], 6, 0.045], 2.25]], [['regression long stub extension denominator 1', [[2016, 10, 30], [2017, 8, 24], 6, 0.045], 3.67623], ['regression long stub extension denominator 2', [[2045, 9, 30], [2046, 9, 30], 6, 0.05], 5.0], ['partial repair probe 1', [[2023, 9, 30], [2024, 3, 27], 3, 0.045], 2.212912], ['partial repair probe 2', [[2034, 7, 4], [2034, 10, 5], 3, 0.045], 1.137228], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2013, 4, 3], [2013, 11, 23], 12, 0.03], 1.923288], ['normal control 2', [[2018, 6, 30], [2018, 9, 30], 3, 0.05], 1.25]], [['regression long stub extension denominator 1', [[2019, 2, 28], [2019, 8, 29], 6, 0.05], 2.513587], ['regression long stub extension denominator 2', [[2017, 12, 1], [2018, 3, 30], 3, 0.03], 0.986413], ['partial repair probe 1', [[2039, 6, 30], [2040, 3, 13], 6, 0.05], 3.510929], ['partial repair probe 2', [[2013, 10, 29], [2014, 12, 28], 12, 0.03], 3.493151], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2026, 7, 31], [2026, 8, 27], 1, 0.0725], 0.52621], ['normal control 2', [[2018, 7, 21], [2018, 8, 3], 6, 0.03], 0.105978]], [['regression long stub extension denominator 1', [[2020, 9, 7], [2021, 7, 20], 6, 0.0725], 6.284647], ['regression long stub extension denominator 2', [[2034, 11, 18], [2035, 11, 10], 6, 0.03], 2.934783], ['partial repair probe 1', [[2005, 6, 30], [2007, 6, 30], 12, 0.045], 9.0], ['partial repair probe 2', [[2037, 5, 26], [2038, 8, 20], 12, 0.03], 3.706849], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2014, 4, 29], [2014, 5, 3], 1, 0.0725], 0.080556], ['normal control 2', [[2006, 1, 11], [2006, 7, 11], 6, 0.03], 1.5]], [['regression long stub extension denominator 1', [[2009, 2, 28], [2009, 4, 5], 1, 0.05], 0.524194], ['regression long stub extension denominator 2', [[2005, 11, 30], [2006, 1, 5], 1, 0.03], 0.298387], ['partial repair probe 1', [[2023, 4, 28], [2024, 1, 14], 6, 0.05], 3.565574], ['partial repair probe 2', [[2023, 6, 20], [2024, 6, 20], 6, 0.045], 4.5], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2042, 12, 1], [2043, 3, 10], 12, 0.03], 0.813699], ['normal control 2', [[2030, 6, 29], [2030, 8, 27], 3, 0.03], 0.480978]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression long stub extension denominator 1 | 6.85567 | 7.958904 | Failed |
| regression long stub extension denominator 2 | 0.559426 | 0.75 | Failed |
| partial repair probe 1 | 4.222403 | 5.063014 | Failed |
| partial repair probe 2 | 6.636691 | 8.568493 | Failed |
| boundary control 1 | 1.236264 | 1.236264 | Passed |
| boundary control 2 | 2.5 | 2.5 | Passed |
| normal control 1 | 1.941257 | 1.941257 | Passed |
| normal control 2 | 2.25 | 2.25 | Passed |
SHA-256 / c9d71f236290460fd4e13edbab68557b1b4cff33da1a0dc3547f582db3c3922d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
from fractions import Fraction
N = 1
observations = []
def solve(prev, maturity, months, rate):
def mlen(y, m):
if m == 2:
return 29 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 else 28
return 30 if m in (4, 6, 9, 11) else 31
P = datetime.date(*prev)
M = datetime.date(*maturity)
freq = 12 // months
def fwd(k):
t = P.year * 12 + P.month - 1 + k * months
y, m = t // 12, t % 12 + 1
return datetime.date(y, m, min(P.day, mlen(y, m)))
c = 100 * Fraction(str(rate)) / freq
q1 = fwd(1)
if M <= q1:
frac = Fraction((M - P).days, (q1 - P).days)
else:
q2 = fwd(2)
frac = 1 + Fraction((M - q1).days, (q2 - q1).days)
return round(float(c * frac), 6)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression long stub extension denominator 1', [[2015, 5, 30], [2017, 1, 1], 12, 0.05], 7.958904], ['regression long stub extension denominator 2', [[2017, 7, 31], [2017, 9, 30], 1, 0.045], 0.75], ['partial repair probe 1', [[2033, 2, 28], [2034, 11, 6], 12, 0.03], 5.063014], ['partial repair probe 2', [[2017, 11, 30], [2019, 10, 26], 12, 0.045], 8.568493], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2042, 3, 31], [2042, 7, 7], 6, 0.0725], 1.941257], ['normal control 2', [[2014, 4, 7], [2014, 10, 7], 6, 0.045], 2.25]], [['regression long stub extension denominator 1', [[2016, 10, 30], [2017, 8, 24], 6, 0.045], 3.67623], ['regression long stub extension denominator 2', [[2045, 9, 30], [2046, 9, 30], 6, 0.05], 5.0], ['partial repair probe 1', [[2023, 9, 30], [2024, 3, 27], 3, 0.045], 2.212912], ['partial repair probe 2', [[2034, 7, 4], [2034, 10, 5], 3, 0.045], 1.137228], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2013, 4, 3], [2013, 11, 23], 12, 0.03], 1.923288], ['normal control 2', [[2018, 6, 30], [2018, 9, 30], 3, 0.05], 1.25]], [['regression long stub extension denominator 1', [[2019, 2, 28], [2019, 8, 29], 6, 0.05], 2.513587], ['regression long stub extension denominator 2', [[2017, 12, 1], [2018, 3, 30], 3, 0.03], 0.986413], ['partial repair probe 1', [[2039, 6, 30], [2040, 3, 13], 6, 0.05], 3.510929], ['partial repair probe 2', [[2013, 10, 29], [2014, 12, 28], 12, 0.03], 3.493151], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2026, 7, 31], [2026, 8, 27], 1, 0.0725], 0.52621], ['normal control 2', [[2018, 7, 21], [2018, 8, 3], 6, 0.03], 0.105978]], [['regression long stub extension denominator 1', [[2020, 9, 7], [2021, 7, 20], 6, 0.0725], 6.284647], ['regression long stub extension denominator 2', [[2034, 11, 18], [2035, 11, 10], 6, 0.03], 2.934783], ['partial repair probe 1', [[2005, 6, 30], [2007, 6, 30], 12, 0.045], 9.0], ['partial repair probe 2', [[2037, 5, 26], [2038, 8, 20], 12, 0.03], 3.706849], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2014, 4, 29], [2014, 5, 3], 1, 0.0725], 0.080556], ['normal control 2', [[2006, 1, 11], [2006, 7, 11], 6, 0.03], 1.5]], [['regression long stub extension denominator 1', [[2009, 2, 28], [2009, 4, 5], 1, 0.05], 0.524194], ['regression long stub extension denominator 2', [[2005, 11, 30], [2006, 1, 5], 1, 0.03], 0.298387], ['partial repair probe 1', [[2023, 4, 28], [2024, 1, 14], 6, 0.05], 3.565574], ['partial repair probe 2', [[2023, 6, 20], [2024, 6, 20], 6, 0.045], 4.5], ['boundary control 1', [[2024, 1, 31], [2024, 4, 30], 6, 0.05], 1.236264], ['boundary control 2', [[2024, 1, 31], [2024, 7, 31], 6, 0.05], 2.5], ['normal control 1', [[2042, 12, 1], [2043, 3, 10], 12, 0.03], 0.813699], ['normal control 2', [[2030, 6, 29], [2030, 8, 27], 3, 0.03], 0.480978]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression long stub extension denominator 1 | 7.958904 | 7.958904 | Passed |
| regression long stub extension denominator 2 | 0.75 | 0.75 | Passed |
| partial repair probe 1 | 5.063014 | 5.063014 | Passed |
| partial repair probe 2 | 8.568493 | 8.568493 | Passed |
| boundary control 1 | 1.236264 | 1.236264 | Passed |
| boundary control 2 | 2.5 | 2.5 | Passed |
| normal control 1 | 1.941257 | 1.941257 | Passed |
| normal control 2 | 2.25 | 2.25 | Passed |
SHA-256 / 8f2df7963fea6a07f8f6a26e94888b004daeba053dcc3603cfbb69ee57d1040e
Verification & scope
A deterministic toy contract stated explicitly in the contract field; no claim of conformance to any published convention text. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:46:53.136774+00:00.
Case digest / fd1ed0f15569c60fa4ace03a432f70e87d861c8ee395b9e3764a5469210b87d4