FAILURE MAP
← Case archive

FA-61071 / Bond day-count conventions / Open access

Irregular first coupon accrued by quasi-coupon periods: every quasi period is measured with the latest period length · case 01

Accruals drift when earlier quasi periods have a different number of days.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The denominator for each quasi fraction reuses the length of the quasi period ending at the first coupon.

VERIFIED REPAIR

Divide each quasi period's accrued days by that same quasi period's length.

Unsuccessful approach: Adding one day to each own-period length double counts an endpoint.

Case contract

Inputs issue, first coupon and settlement [y,m,d], annual rate and months per period. Settlement must lie in [issue, first] else return "settlement outside first period". Quasi-coupon dates are generated back from the first coupon in steps of months (day clamped to month length) until one is on or before issue. For each quasi period [start, end), accrued days are those in [max(start, issue), min(end, settle)) and are divided by that quasi period length. Accrued = 100*rate/freq*sum, rounded 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(issue, first, settle, rate, months):
    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
    I = datetime.date(*issue)
    Fc = datetime.date(*first)
    S = datetime.date(*settle)
    if not (I <= S <= Fc):
        return 'settlement outside first period'
    freq = 12 // months
    def back(k):
        t = Fc.year * 12 + Fc.month - 1 - k * months
        y, m = t // 12, t % 12 + 1
        return datetime.date(y, m, min(Fc.day, mlen(y, m)))
    q = [Fc]
    k = 1
    while q[-1] > I:
        q.append(back(k))
        k += 1
    frac = Fraction(0)
    for j in range(len(q) - 1):
        end, start = q[j], q[j + 1]
        lo = max(start, I)
        hi = min(end, S)
        if hi > lo:
            frac += Fraction((hi - lo).days, (Fc - q[1]).days)
    return round(float(100 * Fraction(str(rate)) / freq * frac), 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression quasi period length 1', [[2023, 6, 29], [2024, 2, 29], [2023, 11, 21], 0.03, 6], 1.18753], ['regression quasi period length 2', [[2011, 7, 11], [2012, 11, 30], [2012, 2, 10], 0.0675, 12], 3.953896], ['partial repair probe 1', [[2033, 12, 28], [2034, 1, 30], [2034, 1, 27], 0.0675, 3], 0.550272], ['partial repair probe 2', [[2030, 10, 2], [2030, 10, 30], [2030, 10, 15], 0.08, 6], 0.284153], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2039, 9, 21], [2039, 10, 14], [2039, 9, 21], 0.02, 1], 0.0], ['normal control 2', [[2000, 8, 4], [2001, 7, 12], [2000, 8, 4], 0.03, 6], 0.0], ['normal control 3', [[2000, 11, 4], [2001, 4, 30], [2000, 11, 1], 0.03, 3], 'settlement outside first period']], [['regression quasi period length 1', [[2002, 5, 28], [2003, 8, 22], [2003, 6, 19], 0.0675, 6], 7.160221], ['regression quasi period length 2', [[2010, 9, 29], [2010, 11, 30], [2010, 10, 30], 0.045, 1], 0.387097], ['partial repair probe 1', [[2015, 8, 19], [2015, 9, 30], [2015, 9, 28], 0.045, 12], 0.493151], ['partial repair probe 2', [[2042, 11, 10], [2043, 2, 18], [2042, 11, 30], 0.03, 6], 0.163043], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2040, 2, 3], [2040, 2, 24], [2040, 2, 3], 0.05, 3], 0.0], ['normal control 2', [[2015, 3, 1], [2015, 6, 30], [2015, 3, 1], 0.02, 3], 0.0], ['normal control 3', [[2006, 1, 23], [2006, 1, 31], [2006, 1, 23], 0.02, 3], 0.0]], [['regression quasi period length 1', [[2035, 3, 6], [2035, 8, 30], [2035, 8, 26], 0.0675, 3], 3.190367], ['regression quasi period length 2', [[2008, 5, 29], [2008, 7, 29], [2008, 6, 2], 0.08, 1], 0.086022], ['partial repair probe 1', [[2008, 8, 6], [2008, 9, 3], [2008, 8, 7], 0.0675, 1], 0.018145], ['partial repair probe 2', [[2003, 5, 22], [2003, 6, 30], [2003, 6, 6], 0.03, 3], 0.122283], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2036, 3, 22], [2036, 6, 30], [2036, 3, 19], 0.05, 6], 'settlement outside first period'], ['normal control 2', [[2020, 3, 26], [2020, 9, 14], [2020, 3, 23], 0.05, 6], 'settlement outside first period'], ['normal control 3', [[2027, 2, 9], [2028, 8, 31], [2027, 2, 6], 0.08, 6], 'settlement outside first period']], [['regression quasi period length 1', [[2018, 9, 4], [2018, 10, 31], [2018, 9, 18], 0.03, 1], 0.116667], ['regression quasi period length 2', [[2022, 8, 27], [2023, 4, 29], [2023, 3, 1], 0.03, 6], 1.53013], ['partial repair probe 1', [[2032, 4, 24], [2032, 5, 7], [2032, 5, 1], 0.045, 3], 0.0875], ['partial repair probe 2', [[2004, 3, 2], [2004, 7, 13], [2004, 4, 27], 0.0675, 3], 1.038462], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2026, 11, 19], [2027, 5, 1], [2026, 11, 16], 0.0675, 6], 'settlement outside first period'], ['normal control 2', [[2006, 4, 26], [2006, 5, 30], [2006, 4, 26], 0.045, 3], 0.0], ['normal control 3', [[2010, 6, 26], [2010, 9, 30], [2010, 6, 23], 0.045, 1], 'settlement outside first period']], [['regression quasi period length 1', [[2040, 3, 19], [2040, 9, 24], [2040, 5, 13], 0.02, 3], 0.299212], ['regression quasi period length 2', [[2044, 3, 15], [2045, 3, 1], [2044, 9, 15], 0.02, 6], 1.001261], ['partial repair probe 1', [[2023, 12, 3], [2024, 1, 17], [2024, 1, 17], 0.045, 6], 0.550272], ['partial repair probe 2', [[2044, 5, 5], [2044, 7, 14], [2044, 5, 22], 0.02, 3], 0.093407], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2029, 3, 18], [2029, 4, 9], [2029, 3, 15], 0.08, 1], 'settlement outside first period'], ['normal control 2', [[2015, 6, 22], [2015, 8, 22], [2015, 6, 22], 0.02, 3], 0.0], ['normal control 3', [[2005, 6, 4], [2006, 1, 31], [2005, 6, 4], 0.03, 12], 0.0]]]
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 fixtureActualExpectedOutcome
regression quasi period length 11.1820651.18753Failed
regression quasi period length 23.9467213.953896Failed
partial repair probe 10.5502720.550272Passed
partial repair probe 20.2841530.284153Passed
boundary control 1settlement outside first periodsettlement outside first periodPassed
normal control 10.00.0Passed
normal control 20.00.0Passed
normal control 3settlement outside first periodsettlement outside first periodPassed

SHA-256 / 77f3f1cf8062c67f4e967c2b9c92943ebece102145a55c5ffa7f808634dda9a1

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(issue, first, settle, rate, months):
    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
    I = datetime.date(*issue)
    Fc = datetime.date(*first)
    S = datetime.date(*settle)
    if not (I <= S <= Fc):
        return 'settlement outside first period'
    freq = 12 // months
    def back(k):
        t = Fc.year * 12 + Fc.month - 1 - k * months
        y, m = t // 12, t % 12 + 1
        return datetime.date(y, m, min(Fc.day, mlen(y, m)))
    q = [Fc]
    k = 1
    while q[-1] > I:
        q.append(back(k))
        k += 1
    frac = Fraction(0)
    for j in range(len(q) - 1):
        end, start = q[j], q[j + 1]
        lo = max(start, I)
        hi = min(end, S)
        if hi > lo:
            frac += Fraction((hi - lo).days, (end - start).days + 1)
    return round(float(100 * Fraction(str(rate)) / freq * frac), 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression quasi period length 1', [[2023, 6, 29], [2024, 2, 29], [2023, 11, 21], 0.03, 6], 1.18753], ['regression quasi period length 2', [[2011, 7, 11], [2012, 11, 30], [2012, 2, 10], 0.0675, 12], 3.953896], ['partial repair probe 1', [[2033, 12, 28], [2034, 1, 30], [2034, 1, 27], 0.0675, 3], 0.550272], ['partial repair probe 2', [[2030, 10, 2], [2030, 10, 30], [2030, 10, 15], 0.08, 6], 0.284153], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2039, 9, 21], [2039, 10, 14], [2039, 9, 21], 0.02, 1], 0.0], ['normal control 2', [[2000, 8, 4], [2001, 7, 12], [2000, 8, 4], 0.03, 6], 0.0], ['normal control 3', [[2000, 11, 4], [2001, 4, 30], [2000, 11, 1], 0.03, 3], 'settlement outside first period']], [['regression quasi period length 1', [[2002, 5, 28], [2003, 8, 22], [2003, 6, 19], 0.0675, 6], 7.160221], ['regression quasi period length 2', [[2010, 9, 29], [2010, 11, 30], [2010, 10, 30], 0.045, 1], 0.387097], ['partial repair probe 1', [[2015, 8, 19], [2015, 9, 30], [2015, 9, 28], 0.045, 12], 0.493151], ['partial repair probe 2', [[2042, 11, 10], [2043, 2, 18], [2042, 11, 30], 0.03, 6], 0.163043], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2040, 2, 3], [2040, 2, 24], [2040, 2, 3], 0.05, 3], 0.0], ['normal control 2', [[2015, 3, 1], [2015, 6, 30], [2015, 3, 1], 0.02, 3], 0.0], ['normal control 3', [[2006, 1, 23], [2006, 1, 31], [2006, 1, 23], 0.02, 3], 0.0]], [['regression quasi period length 1', [[2035, 3, 6], [2035, 8, 30], [2035, 8, 26], 0.0675, 3], 3.190367], ['regression quasi period length 2', [[2008, 5, 29], [2008, 7, 29], [2008, 6, 2], 0.08, 1], 0.086022], ['partial repair probe 1', [[2008, 8, 6], [2008, 9, 3], [2008, 8, 7], 0.0675, 1], 0.018145], ['partial repair probe 2', [[2003, 5, 22], [2003, 6, 30], [2003, 6, 6], 0.03, 3], 0.122283], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2036, 3, 22], [2036, 6, 30], [2036, 3, 19], 0.05, 6], 'settlement outside first period'], ['normal control 2', [[2020, 3, 26], [2020, 9, 14], [2020, 3, 23], 0.05, 6], 'settlement outside first period'], ['normal control 3', [[2027, 2, 9], [2028, 8, 31], [2027, 2, 6], 0.08, 6], 'settlement outside first period']], [['regression quasi period length 1', [[2018, 9, 4], [2018, 10, 31], [2018, 9, 18], 0.03, 1], 0.116667], ['regression quasi period length 2', [[2022, 8, 27], [2023, 4, 29], [2023, 3, 1], 0.03, 6], 1.53013], ['partial repair probe 1', [[2032, 4, 24], [2032, 5, 7], [2032, 5, 1], 0.045, 3], 0.0875], ['partial repair probe 2', [[2004, 3, 2], [2004, 7, 13], [2004, 4, 27], 0.0675, 3], 1.038462], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2026, 11, 19], [2027, 5, 1], [2026, 11, 16], 0.0675, 6], 'settlement outside first period'], ['normal control 2', [[2006, 4, 26], [2006, 5, 30], [2006, 4, 26], 0.045, 3], 0.0], ['normal control 3', [[2010, 6, 26], [2010, 9, 30], [2010, 6, 23], 0.045, 1], 'settlement outside first period']], [['regression quasi period length 1', [[2040, 3, 19], [2040, 9, 24], [2040, 5, 13], 0.02, 3], 0.299212], ['regression quasi period length 2', [[2044, 3, 15], [2045, 3, 1], [2044, 9, 15], 0.02, 6], 1.001261], ['partial repair probe 1', [[2023, 12, 3], [2024, 1, 17], [2024, 1, 17], 0.045, 6], 0.550272], ['partial repair probe 2', [[2044, 5, 5], [2044, 7, 14], [2044, 5, 22], 0.02, 3], 0.093407], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2029, 3, 18], [2029, 4, 9], [2029, 3, 15], 0.08, 1], 'settlement outside first period'], ['normal control 2', [[2015, 6, 22], [2015, 8, 22], [2015, 6, 22], 0.02, 3], 0.0], ['normal control 3', [[2005, 6, 4], [2006, 1, 31], [2005, 6, 4], 0.03, 12], 0.0]]]
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 fixtureActualExpectedOutcome
regression quasi period length 11.1810811.18753Failed
regression quasi period length 23.9431033.953896Failed
partial repair probe 10.5443550.550272Failed
partial repair probe 20.2826090.284153Failed
boundary control 1settlement outside first periodsettlement outside first periodPassed
normal control 10.00.0Passed
normal control 20.00.0Passed
normal control 3settlement outside first periodsettlement outside first periodPassed

SHA-256 / a5420cd9086fdf251dbed07d2fbef8d2aea02ac97d333ca2b34776177fb3ea2c

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(issue, first, settle, rate, months):
    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
    I = datetime.date(*issue)
    Fc = datetime.date(*first)
    S = datetime.date(*settle)
    if not (I <= S <= Fc):
        return 'settlement outside first period'
    freq = 12 // months
    def back(k):
        t = Fc.year * 12 + Fc.month - 1 - k * months
        y, m = t // 12, t % 12 + 1
        return datetime.date(y, m, min(Fc.day, mlen(y, m)))
    q = [Fc]
    k = 1
    while q[-1] > I:
        q.append(back(k))
        k += 1
    frac = Fraction(0)
    for j in range(len(q) - 1):
        end, start = q[j], q[j + 1]
        lo = max(start, I)
        hi = min(end, S)
        if hi > lo:
            frac += Fraction((hi - lo).days, (end - start).days)
    return round(float(100 * Fraction(str(rate)) / freq * frac), 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression quasi period length 1', [[2023, 6, 29], [2024, 2, 29], [2023, 11, 21], 0.03, 6], 1.18753], ['regression quasi period length 2', [[2011, 7, 11], [2012, 11, 30], [2012, 2, 10], 0.0675, 12], 3.953896], ['partial repair probe 1', [[2033, 12, 28], [2034, 1, 30], [2034, 1, 27], 0.0675, 3], 0.550272], ['partial repair probe 2', [[2030, 10, 2], [2030, 10, 30], [2030, 10, 15], 0.08, 6], 0.284153], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2039, 9, 21], [2039, 10, 14], [2039, 9, 21], 0.02, 1], 0.0], ['normal control 2', [[2000, 8, 4], [2001, 7, 12], [2000, 8, 4], 0.03, 6], 0.0], ['normal control 3', [[2000, 11, 4], [2001, 4, 30], [2000, 11, 1], 0.03, 3], 'settlement outside first period']], [['regression quasi period length 1', [[2002, 5, 28], [2003, 8, 22], [2003, 6, 19], 0.0675, 6], 7.160221], ['regression quasi period length 2', [[2010, 9, 29], [2010, 11, 30], [2010, 10, 30], 0.045, 1], 0.387097], ['partial repair probe 1', [[2015, 8, 19], [2015, 9, 30], [2015, 9, 28], 0.045, 12], 0.493151], ['partial repair probe 2', [[2042, 11, 10], [2043, 2, 18], [2042, 11, 30], 0.03, 6], 0.163043], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2040, 2, 3], [2040, 2, 24], [2040, 2, 3], 0.05, 3], 0.0], ['normal control 2', [[2015, 3, 1], [2015, 6, 30], [2015, 3, 1], 0.02, 3], 0.0], ['normal control 3', [[2006, 1, 23], [2006, 1, 31], [2006, 1, 23], 0.02, 3], 0.0]], [['regression quasi period length 1', [[2035, 3, 6], [2035, 8, 30], [2035, 8, 26], 0.0675, 3], 3.190367], ['regression quasi period length 2', [[2008, 5, 29], [2008, 7, 29], [2008, 6, 2], 0.08, 1], 0.086022], ['partial repair probe 1', [[2008, 8, 6], [2008, 9, 3], [2008, 8, 7], 0.0675, 1], 0.018145], ['partial repair probe 2', [[2003, 5, 22], [2003, 6, 30], [2003, 6, 6], 0.03, 3], 0.122283], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2036, 3, 22], [2036, 6, 30], [2036, 3, 19], 0.05, 6], 'settlement outside first period'], ['normal control 2', [[2020, 3, 26], [2020, 9, 14], [2020, 3, 23], 0.05, 6], 'settlement outside first period'], ['normal control 3', [[2027, 2, 9], [2028, 8, 31], [2027, 2, 6], 0.08, 6], 'settlement outside first period']], [['regression quasi period length 1', [[2018, 9, 4], [2018, 10, 31], [2018, 9, 18], 0.03, 1], 0.116667], ['regression quasi period length 2', [[2022, 8, 27], [2023, 4, 29], [2023, 3, 1], 0.03, 6], 1.53013], ['partial repair probe 1', [[2032, 4, 24], [2032, 5, 7], [2032, 5, 1], 0.045, 3], 0.0875], ['partial repair probe 2', [[2004, 3, 2], [2004, 7, 13], [2004, 4, 27], 0.0675, 3], 1.038462], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2026, 11, 19], [2027, 5, 1], [2026, 11, 16], 0.0675, 6], 'settlement outside first period'], ['normal control 2', [[2006, 4, 26], [2006, 5, 30], [2006, 4, 26], 0.045, 3], 0.0], ['normal control 3', [[2010, 6, 26], [2010, 9, 30], [2010, 6, 23], 0.045, 1], 'settlement outside first period']], [['regression quasi period length 1', [[2040, 3, 19], [2040, 9, 24], [2040, 5, 13], 0.02, 3], 0.299212], ['regression quasi period length 2', [[2044, 3, 15], [2045, 3, 1], [2044, 9, 15], 0.02, 6], 1.001261], ['partial repair probe 1', [[2023, 12, 3], [2024, 1, 17], [2024, 1, 17], 0.045, 6], 0.550272], ['partial repair probe 2', [[2044, 5, 5], [2044, 7, 14], [2044, 5, 22], 0.02, 3], 0.093407], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['normal control 1', [[2029, 3, 18], [2029, 4, 9], [2029, 3, 15], 0.08, 1], 'settlement outside first period'], ['normal control 2', [[2015, 6, 22], [2015, 8, 22], [2015, 6, 22], 0.02, 3], 0.0], ['normal control 3', [[2005, 6, 4], [2006, 1, 31], [2005, 6, 4], 0.03, 12], 0.0]]]
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 fixtureActualExpectedOutcome
regression quasi period length 11.187531.18753Passed
regression quasi period length 23.9538963.953896Passed
partial repair probe 10.5502720.550272Passed
partial repair probe 20.2841530.284153Passed
boundary control 1settlement outside first periodsettlement outside first periodPassed
normal control 10.00.0Passed
normal control 20.00.0Passed
normal control 3settlement outside first periodsettlement outside first periodPassed

SHA-256 / c2eb04a5f4150754c1648f215783c9eee795c766766fcaa4b4ed00bc832d86e9

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:51.684592+00:00.

Case digest / 2f76babac63c3cb5d5d7f555822431f85bcb65e72e138aa4dcfc9fde927aa66e