FAILURE MAP
← Case archive

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

Irregular first coupon accrued by quasi-coupon periods: older quasi periods are accrued in full regardless of settlement · case 01

Early settlements in a long first period are charged for quasi periods not yet elapsed.

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

ROOT CAUSE

Only the latest quasi period clips its end at the settlement date.

THE FAILURE

Only the latest quasi period clips its end at the settlement date.

Unsuccessful approach: Clipping the two latest periods still fails when three or more quasi periods exist.

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 j == 0 else end
        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 settlement clipping 1', [[2037, 12, 17], [2038, 8, 31], [2038, 4, 9], 0.08, 3], 2.491787], ['regression settlement clipping 2', [[2042, 11, 10], [2043, 8, 31], [2042, 12, 3], 0.03, 6], 0.190608], ['partial repair probe 1', [[2039, 3, 14], [2040, 10, 23], [2039, 3, 14], 0.045, 6], 0.0], ['partial repair probe 2', [[2043, 10, 16], [2045, 4, 30], [2043, 11, 25], 0.03, 6], 0.327869], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['boundary control 2', [[2024, 3, 15], [2024, 9, 15], [2024, 6, 15], 0.05, 6], 1.25], ['normal control 1', [[2029, 10, 4], [2031, 3, 15], [2031, 3, 1], 0.0675, 6], 9.509669], ['normal control 2', [[2027, 11, 10], [2029, 9, 29], [2027, 11, 7], 0.045, 12], 'settlement outside first period']], [['regression settlement clipping 1', [[2018, 3, 16], [2018, 5, 5], [2018, 3, 16], 0.045, 1], 0.0], ['regression settlement clipping 2', [[2035, 7, 24], [2035, 10, 5], [2035, 8, 15], 0.0675, 1], 0.399194], ['partial repair probe 1', [[2037, 2, 2], [2038, 3, 25], [2037, 2, 2], 0.045, 6], 0.0], ['partial repair probe 2', [[2014, 11, 11], [2015, 1, 31], [2014, 11, 27], 0.05, 1], 0.222222], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['boundary control 2', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['normal control 1', [[2029, 11, 15], [2030, 5, 4], [2030, 5, 4], 0.08, 6], 3.756906], ['normal control 2', [[2027, 7, 20], [2028, 1, 29], [2027, 7, 17], 0.03, 3], 'settlement outside first period']], [['regression settlement clipping 1', [[2038, 6, 26], [2038, 9, 19], [2038, 6, 27], 0.08, 1], 0.022222], ['regression settlement clipping 2', [[2034, 9, 8], [2035, 3, 31], [2034, 9, 8], 0.045, 3], 0.0], ['partial repair probe 1', [[2037, 3, 25], [2037, 11, 1], [2037, 3, 25], 0.08, 3], 0.0], ['partial repair probe 2', [[2010, 1, 19], [2010, 11, 1], [2010, 1, 19], 0.03, 3], 0.0], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['boundary control 2', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['normal control 1', [[2043, 11, 1], [2043, 11, 12], [2043, 11, 4], 0.0675, 3], 0.055027], ['normal control 2', [[2031, 2, 12], [2031, 2, 28], [2031, 2, 28], 0.0675, 1], 0.290323]], [['regression settlement clipping 1', [[2039, 4, 11], [2039, 10, 15], [2039, 7, 14], 0.03, 3], 0.775092], ['regression settlement clipping 2', [[2032, 12, 15], [2034, 1, 28], [2033, 1, 8], 0.05, 12], 0.327869], ['partial repair probe 1', [[2028, 1, 11], [2028, 11, 18], [2028, 4, 15], 0.045, 3], 1.177174], ['partial repair probe 2', [[2026, 2, 6], [2028, 10, 12], [2026, 9, 29], 0.03, 12], 1.931507], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['boundary control 2', [[2024, 3, 15], [2024, 9, 15], [2024, 6, 15], 0.05, 6], 1.25], ['normal control 1', [[2012, 12, 25], [2013, 2, 15], [2013, 2, 15], 0.02, 1], 0.27957], ['normal control 2', [[2001, 2, 18], [2001, 5, 28], [2001, 2, 18], 0.03, 6], 0.0]], [['regression settlement clipping 1', [[2005, 11, 20], [2007, 1, 31], [2006, 3, 21], 0.05, 6], 1.655056], ['regression settlement clipping 2', [[2016, 10, 4], [2018, 4, 26], [2016, 10, 4], 0.045, 12], 0.0], ['partial repair probe 1', [[2001, 1, 21], [2001, 3, 31], [2001, 1, 23], 0.045, 1], 0.024194], ['partial repair probe 2', [[2028, 8, 30], [2030, 2, 28], [2028, 12, 17], 0.05, 6], 1.480978], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['boundary control 2', [[2024, 3, 15], [2024, 9, 15], [2024, 6, 15], 0.05, 6], 1.25], ['normal control 1', [[2021, 5, 19], [2021, 5, 31], [2021, 5, 16], 0.05, 3], 'settlement outside first period'], ['normal control 2', [[2040, 1, 11], [2040, 5, 31], [2040, 1, 11], 0.02, 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 settlement clipping 13.6222222.491787Failed
regression settlement clipping 20.9116020.190608Failed
partial repair probe 14.9945050.0Failed
partial repair probe 23.1147540.327869Failed
boundary control 11.5314441.531444Passed
boundary control 21.251.25Passed
normal control 19.5096699.509669Passed
normal control 2settlement outside first periodsettlement outside first periodPassed

SHA-256 / 46be8519456aeadf8babda4d86119ffaccf46179e129a17643b206414aa34d1a

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 j <= 1 else end
        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 settlement clipping 1', [[2037, 12, 17], [2038, 8, 31], [2038, 4, 9], 0.08, 3], 2.491787], ['regression settlement clipping 2', [[2042, 11, 10], [2043, 8, 31], [2042, 12, 3], 0.03, 6], 0.190608], ['partial repair probe 1', [[2039, 3, 14], [2040, 10, 23], [2039, 3, 14], 0.045, 6], 0.0], ['partial repair probe 2', [[2043, 10, 16], [2045, 4, 30], [2043, 11, 25], 0.03, 6], 0.327869], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['boundary control 2', [[2024, 3, 15], [2024, 9, 15], [2024, 6, 15], 0.05, 6], 1.25], ['normal control 1', [[2029, 10, 4], [2031, 3, 15], [2031, 3, 1], 0.0675, 6], 9.509669], ['normal control 2', [[2027, 11, 10], [2029, 9, 29], [2027, 11, 7], 0.045, 12], 'settlement outside first period']], [['regression settlement clipping 1', [[2018, 3, 16], [2018, 5, 5], [2018, 3, 16], 0.045, 1], 0.0], ['regression settlement clipping 2', [[2035, 7, 24], [2035, 10, 5], [2035, 8, 15], 0.0675, 1], 0.399194], ['partial repair probe 1', [[2037, 2, 2], [2038, 3, 25], [2037, 2, 2], 0.045, 6], 0.0], ['partial repair probe 2', [[2014, 11, 11], [2015, 1, 31], [2014, 11, 27], 0.05, 1], 0.222222], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['boundary control 2', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['normal control 1', [[2029, 11, 15], [2030, 5, 4], [2030, 5, 4], 0.08, 6], 3.756906], ['normal control 2', [[2027, 7, 20], [2028, 1, 29], [2027, 7, 17], 0.03, 3], 'settlement outside first period']], [['regression settlement clipping 1', [[2038, 6, 26], [2038, 9, 19], [2038, 6, 27], 0.08, 1], 0.022222], ['regression settlement clipping 2', [[2034, 9, 8], [2035, 3, 31], [2034, 9, 8], 0.045, 3], 0.0], ['partial repair probe 1', [[2037, 3, 25], [2037, 11, 1], [2037, 3, 25], 0.08, 3], 0.0], ['partial repair probe 2', [[2010, 1, 19], [2010, 11, 1], [2010, 1, 19], 0.03, 3], 0.0], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['boundary control 2', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['normal control 1', [[2043, 11, 1], [2043, 11, 12], [2043, 11, 4], 0.0675, 3], 0.055027], ['normal control 2', [[2031, 2, 12], [2031, 2, 28], [2031, 2, 28], 0.0675, 1], 0.290323]], [['regression settlement clipping 1', [[2039, 4, 11], [2039, 10, 15], [2039, 7, 14], 0.03, 3], 0.775092], ['regression settlement clipping 2', [[2032, 12, 15], [2034, 1, 28], [2033, 1, 8], 0.05, 12], 0.327869], ['partial repair probe 1', [[2028, 1, 11], [2028, 11, 18], [2028, 4, 15], 0.045, 3], 1.177174], ['partial repair probe 2', [[2026, 2, 6], [2028, 10, 12], [2026, 9, 29], 0.03, 12], 1.931507], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 9, 16], 0.05, 6], 'settlement outside first period'], ['boundary control 2', [[2024, 3, 15], [2024, 9, 15], [2024, 6, 15], 0.05, 6], 1.25], ['normal control 1', [[2012, 12, 25], [2013, 2, 15], [2013, 2, 15], 0.02, 1], 0.27957], ['normal control 2', [[2001, 2, 18], [2001, 5, 28], [2001, 2, 18], 0.03, 6], 0.0]], [['regression settlement clipping 1', [[2005, 11, 20], [2007, 1, 31], [2006, 3, 21], 0.05, 6], 1.655056], ['regression settlement clipping 2', [[2016, 10, 4], [2018, 4, 26], [2016, 10, 4], 0.045, 12], 0.0], ['partial repair probe 1', [[2001, 1, 21], [2001, 3, 31], [2001, 1, 23], 0.045, 1], 0.024194], ['partial repair probe 2', [[2028, 8, 30], [2030, 2, 28], [2028, 12, 17], 0.05, 6], 1.480978], ['boundary control 1', [[2024, 1, 10], [2024, 9, 15], [2024, 5, 1], 0.05, 6], 1.531444], ['boundary control 2', [[2024, 3, 15], [2024, 9, 15], [2024, 6, 15], 0.05, 6], 1.25], ['normal control 1', [[2021, 5, 19], [2021, 5, 31], [2021, 5, 16], 0.05, 3], 'settlement outside first period'], ['normal control 2', [[2040, 1, 11], [2040, 5, 31], [2040, 1, 11], 0.02, 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 settlement clipping 12.4917872.491787Passed
regression settlement clipping 20.1906080.190608Passed
partial repair probe 12.7445050.0Failed
partial repair probe 21.6147540.327869Failed
boundary control 11.5314441.531444Passed
boundary control 21.251.25Passed
normal control 19.5096699.509669Passed
normal control 2settlement outside first periodsettlement outside first periodPassed

SHA-256 / 9bc311dee32aa366a6334f04a76ed7cc5bc203c5e9fa29de0ac1f4be2b90bec0

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / efdd9795aa76866e04853674c7f7362c740c4e0753da5d7578fece2aa2accab1