FAILURE MAP
← Case archive

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

Discount-basis bill price and bond-equivalent yield: the 366-day basis is chosen by the settlement calendar year · case 01

Bills settling late in a leap year after 29 February, or before a coming leap day, get the wrong basis.

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

ROOT CAUSE

Basis selection tests whether the settlement year is a leap year instead of whether a leap day lies in the following year window.

VERIFIED REPAIR

Use 366 only when a 29 February falls in (settle, settle+365 days].

Unsuccessful approach: Testing the maturity year still ignores where the leap day falls relative to the window.

Case contract

Inputs settlement and maturity [y,m,d] (1 to 364 days apart) and discount rate d. t = days. Price = 100*(1 - d*t/360). Year basis B is 366 if a 29 February lies in (settle, settle+365 days], else 365. For t <= B/2, BEY = B*d/(360 - d*t); otherwise BEY solves the quadratic with a = t/(2B) - 0.25, b = t/B, c = (price-100)/price, taking (-b + sqrt(b^2 - 4ac))/(2a). Return [price rounded 6, BEY rounded 8].

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
import math
N = 1
observations = []
def solve(settle, maturity, d):
    S = datetime.date(*settle)
    M = datetime.date(*maturity)
    t = (M - S).days
    def leap(y):
        return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0
    horizon = S + datetime.timedelta(days=365)
    basis = 366 if leap(S.year) else 365
    price = 100 * (1 - d * t / 360)
    if t <= basis / 2:
        bey = basis * d / (360 - d * t)
    else:
        a = t / (2 * basis) - 0.25
        b = t / basis
        c = (price - 100) / price
        bey = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
    return [round(price, 6), round(bey, 8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression leap basis window 1', [[2063, 9, 25], [2064, 3, 25], 0.001], [99.949444, 0.00101718]], ['regression leap basis window 2', [[2003, 12, 27], [2004, 6, 25], 0.0435], [97.812917, 0.04521386]], ['partial repair probe 1', [[2076, 1, 28], [2077, 1, 26], 0.025], [97.472222, 0.02590891]], ['partial repair probe 2', [[2067, 1, 16], [2068, 1, 15], 0.001], [99.898889, 0.00101466]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2003, 1, 31], [2003, 8, 2], 0.01], [99.491667, 0.01019055]], ['normal control 2', [[2100, 3, 1], [2100, 8, 31], 0.01], [99.491667, 0.01019055]], ['normal control 3', [[2053, 8, 30], [2054, 2, 27], 0.0435], [97.812917, 0.04509033]]], [['regression leap basis window 1', [[2084, 3, 30], [2084, 9, 29], 0.08], [95.933333, 0.08453969]], ['regression leap basis window 2', [[2068, 10, 31], [2069, 10, 30], 0.001], [99.898889, 0.00101466]], ['partial repair probe 1', [[2036, 2, 28], [2037, 2, 10], 0.08], [92.266667, 0.08638134]], ['partial repair probe 2', [[2023, 1, 28], [2024, 1, 27], 0.01], [98.988889, 0.01021643]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2045, 1, 30], [2045, 7, 31], 0.0435], [97.800833, 0.0450959]], ['normal control 2', [[1999, 1, 16], [1999, 7, 18], 0.08], [95.933333, 0.08453969]], ['normal control 3', [[2001, 9, 2], [2002, 2, 17], 0.01], [99.533333, 0.01018643]]], [['regression leap basis window 1', [[2020, 11, 28], [2021, 5, 29], 0.025], [98.736111, 0.02567168]], ['regression leap basis window 2', [[2023, 12, 1], [2024, 11, 29], 0.025], [97.472222, 0.02590891]], ['partial repair probe 1', [[2067, 2, 28], [2068, 2, 27], 0.01], [98.988889, 0.01021643]], ['partial repair probe 2', [[2027, 1, 28], [2028, 1, 27], 0.08], [91.911111, 0.08638888]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2100, 6, 28], [2100, 12, 26], 0.001], [99.949722, 0.0010144]], ['normal control 2', [[2101, 1, 1], [2101, 7, 2], 0.08], [95.955556, 0.08452987]], ['normal control 3', [[2101, 10, 25], [2102, 5, 2], 0.0525], [97.24375, 0.05468645]]], [['regression leap basis window 1', [[2020, 11, 1], [2021, 5, 3], 0.0525], [97.33125, 0.05468459]], ['regression leap basis window 2', [[2052, 9, 4], [2053, 3, 6], 0.0525], [97.33125, 0.05468459]], ['partial repair probe 1', [[2023, 1, 28], [2024, 1, 27], 0.025], [97.472222, 0.02583812]], ['partial repair probe 2', [[2028, 2, 28], [2029, 2, 26], 0.08], [91.911111, 0.0866256]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2100, 12, 15], [2101, 6, 15], 0.0435], [97.800833, 0.0450959]], ['normal control 2', [[2006, 3, 28], [2006, 9, 26], 0.025], [98.736111, 0.02567168]], ['normal control 3', [[2077, 7, 28], [2077, 12, 12], 0.025], [99.048611, 0.02559069]]], [['regression leap basis window 1', [[2036, 3, 24], [2036, 6, 23], 0.08], [97.977778, 0.08278521]], ['regression leap basis window 2', [[2023, 6, 1], [2023, 12, 1], 0.0525], [97.33125, 0.0548385]], ['partial repair probe 1', [[2023, 1, 15], [2024, 1, 14], 0.0435], [95.601667, 0.04561452]], ['partial repair probe 2', [[2088, 2, 27], [2089, 2, 25], 0.0525], [94.691667, 0.0555986]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2051, 2, 7], [2051, 8, 7], 0.001], [99.949722, 0.0010144]], ['normal control 2', [[2028, 2, 15], [2028, 8, 14], 0.001], [99.949722, 0.00101718]], ['normal control 3', [[2058, 4, 13], [2058, 10, 11], 0.0525], [97.360417, 0.05467229]]]]
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 leap basis window 1[99.949444, 0.0010144][99.949444, 0.00101718]Failed
regression leap basis window 2[97.812917, 0.04509033][97.812917, 0.04521386]Failed
partial repair probe 1[97.472222, 0.02590891][97.472222, 0.02590891]Passed
partial repair probe 2[99.898889, 0.00101466][99.898889, 0.00101466]Passed
boundary control 1[99.986111, 0.05070149][99.986111, 0.05070149]Passed
normal control 1[99.491667, 0.01019055][99.491667, 0.01019055]Passed
normal control 2[99.491667, 0.01019055][99.491667, 0.01019055]Passed
normal control 3[97.812917, 0.04509033][97.812917, 0.04509033]Passed

SHA-256 / 61945dfac03e85ddfbbe427d22de9fcad6213686fa227a25401c444dbd5b6303

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import math
N = 1
observations = []
def solve(settle, maturity, d):
    S = datetime.date(*settle)
    M = datetime.date(*maturity)
    t = (M - S).days
    def leap(y):
        return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0
    horizon = S + datetime.timedelta(days=365)
    basis = 366 if leap(M.year) else 365
    price = 100 * (1 - d * t / 360)
    if t <= basis / 2:
        bey = basis * d / (360 - d * t)
    else:
        a = t / (2 * basis) - 0.25
        b = t / basis
        c = (price - 100) / price
        bey = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
    return [round(price, 6), round(bey, 8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression leap basis window 1', [[2063, 9, 25], [2064, 3, 25], 0.001], [99.949444, 0.00101718]], ['regression leap basis window 2', [[2003, 12, 27], [2004, 6, 25], 0.0435], [97.812917, 0.04521386]], ['partial repair probe 1', [[2076, 1, 28], [2077, 1, 26], 0.025], [97.472222, 0.02590891]], ['partial repair probe 2', [[2067, 1, 16], [2068, 1, 15], 0.001], [99.898889, 0.00101466]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2003, 1, 31], [2003, 8, 2], 0.01], [99.491667, 0.01019055]], ['normal control 2', [[2100, 3, 1], [2100, 8, 31], 0.01], [99.491667, 0.01019055]], ['normal control 3', [[2053, 8, 30], [2054, 2, 27], 0.0435], [97.812917, 0.04509033]]], [['regression leap basis window 1', [[2084, 3, 30], [2084, 9, 29], 0.08], [95.933333, 0.08453969]], ['regression leap basis window 2', [[2068, 10, 31], [2069, 10, 30], 0.001], [99.898889, 0.00101466]], ['partial repair probe 1', [[2036, 2, 28], [2037, 2, 10], 0.08], [92.266667, 0.08638134]], ['partial repair probe 2', [[2023, 1, 28], [2024, 1, 27], 0.01], [98.988889, 0.01021643]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2045, 1, 30], [2045, 7, 31], 0.0435], [97.800833, 0.0450959]], ['normal control 2', [[1999, 1, 16], [1999, 7, 18], 0.08], [95.933333, 0.08453969]], ['normal control 3', [[2001, 9, 2], [2002, 2, 17], 0.01], [99.533333, 0.01018643]]], [['regression leap basis window 1', [[2020, 11, 28], [2021, 5, 29], 0.025], [98.736111, 0.02567168]], ['regression leap basis window 2', [[2023, 12, 1], [2024, 11, 29], 0.025], [97.472222, 0.02590891]], ['partial repair probe 1', [[2067, 2, 28], [2068, 2, 27], 0.01], [98.988889, 0.01021643]], ['partial repair probe 2', [[2027, 1, 28], [2028, 1, 27], 0.08], [91.911111, 0.08638888]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2100, 6, 28], [2100, 12, 26], 0.001], [99.949722, 0.0010144]], ['normal control 2', [[2101, 1, 1], [2101, 7, 2], 0.08], [95.955556, 0.08452987]], ['normal control 3', [[2101, 10, 25], [2102, 5, 2], 0.0525], [97.24375, 0.05468645]]], [['regression leap basis window 1', [[2020, 11, 1], [2021, 5, 3], 0.0525], [97.33125, 0.05468459]], ['regression leap basis window 2', [[2052, 9, 4], [2053, 3, 6], 0.0525], [97.33125, 0.05468459]], ['partial repair probe 1', [[2023, 1, 28], [2024, 1, 27], 0.025], [97.472222, 0.02583812]], ['partial repair probe 2', [[2028, 2, 28], [2029, 2, 26], 0.08], [91.911111, 0.0866256]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2100, 12, 15], [2101, 6, 15], 0.0435], [97.800833, 0.0450959]], ['normal control 2', [[2006, 3, 28], [2006, 9, 26], 0.025], [98.736111, 0.02567168]], ['normal control 3', [[2077, 7, 28], [2077, 12, 12], 0.025], [99.048611, 0.02559069]]], [['regression leap basis window 1', [[2036, 3, 24], [2036, 6, 23], 0.08], [97.977778, 0.08278521]], ['regression leap basis window 2', [[2023, 6, 1], [2023, 12, 1], 0.0525], [97.33125, 0.0548385]], ['partial repair probe 1', [[2023, 1, 15], [2024, 1, 14], 0.0435], [95.601667, 0.04561452]], ['partial repair probe 2', [[2088, 2, 27], [2089, 2, 25], 0.0525], [94.691667, 0.0555986]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2051, 2, 7], [2051, 8, 7], 0.001], [99.949722, 0.0010144]], ['normal control 2', [[2028, 2, 15], [2028, 8, 14], 0.001], [99.949722, 0.00101718]], ['normal control 3', [[2058, 4, 13], [2058, 10, 11], 0.0525], [97.360417, 0.05467229]]]]
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 leap basis window 1[99.949444, 0.00101718][99.949444, 0.00101718]Passed
regression leap basis window 2[97.812917, 0.04521386][97.812917, 0.04521386]Passed
partial repair probe 1[97.472222, 0.02583812][97.472222, 0.02590891]Failed
partial repair probe 2[99.898889, 0.00101744][99.898889, 0.00101466]Failed
boundary control 1[99.986111, 0.05070149][99.986111, 0.05070149]Passed
normal control 1[99.491667, 0.01019055][99.491667, 0.01019055]Passed
normal control 2[99.491667, 0.01019055][99.491667, 0.01019055]Passed
normal control 3[97.812917, 0.04509033][97.812917, 0.04509033]Passed

SHA-256 / fcf7c8719f9fcd214586c96ad6a952e7ff7bb271f068a337c4752b9ce9710a18

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import math
N = 1
observations = []
def solve(settle, maturity, d):
    S = datetime.date(*settle)
    M = datetime.date(*maturity)
    t = (M - S).days
    def leap(y):
        return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0
    horizon = S + datetime.timedelta(days=365)
    basis = 366 if any(leap(y) and S < datetime.date(y, 2, 29) <= horizon for y in (S.year, S.year + 1)) else 365
    price = 100 * (1 - d * t / 360)
    if t <= basis / 2:
        bey = basis * d / (360 - d * t)
    else:
        a = t / (2 * basis) - 0.25
        b = t / basis
        c = (price - 100) / price
        bey = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
    return [round(price, 6), round(bey, 8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression leap basis window 1', [[2063, 9, 25], [2064, 3, 25], 0.001], [99.949444, 0.00101718]], ['regression leap basis window 2', [[2003, 12, 27], [2004, 6, 25], 0.0435], [97.812917, 0.04521386]], ['partial repair probe 1', [[2076, 1, 28], [2077, 1, 26], 0.025], [97.472222, 0.02590891]], ['partial repair probe 2', [[2067, 1, 16], [2068, 1, 15], 0.001], [99.898889, 0.00101466]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2003, 1, 31], [2003, 8, 2], 0.01], [99.491667, 0.01019055]], ['normal control 2', [[2100, 3, 1], [2100, 8, 31], 0.01], [99.491667, 0.01019055]], ['normal control 3', [[2053, 8, 30], [2054, 2, 27], 0.0435], [97.812917, 0.04509033]]], [['regression leap basis window 1', [[2084, 3, 30], [2084, 9, 29], 0.08], [95.933333, 0.08453969]], ['regression leap basis window 2', [[2068, 10, 31], [2069, 10, 30], 0.001], [99.898889, 0.00101466]], ['partial repair probe 1', [[2036, 2, 28], [2037, 2, 10], 0.08], [92.266667, 0.08638134]], ['partial repair probe 2', [[2023, 1, 28], [2024, 1, 27], 0.01], [98.988889, 0.01021643]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2045, 1, 30], [2045, 7, 31], 0.0435], [97.800833, 0.0450959]], ['normal control 2', [[1999, 1, 16], [1999, 7, 18], 0.08], [95.933333, 0.08453969]], ['normal control 3', [[2001, 9, 2], [2002, 2, 17], 0.01], [99.533333, 0.01018643]]], [['regression leap basis window 1', [[2020, 11, 28], [2021, 5, 29], 0.025], [98.736111, 0.02567168]], ['regression leap basis window 2', [[2023, 12, 1], [2024, 11, 29], 0.025], [97.472222, 0.02590891]], ['partial repair probe 1', [[2067, 2, 28], [2068, 2, 27], 0.01], [98.988889, 0.01021643]], ['partial repair probe 2', [[2027, 1, 28], [2028, 1, 27], 0.08], [91.911111, 0.08638888]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2100, 6, 28], [2100, 12, 26], 0.001], [99.949722, 0.0010144]], ['normal control 2', [[2101, 1, 1], [2101, 7, 2], 0.08], [95.955556, 0.08452987]], ['normal control 3', [[2101, 10, 25], [2102, 5, 2], 0.0525], [97.24375, 0.05468645]]], [['regression leap basis window 1', [[2020, 11, 1], [2021, 5, 3], 0.0525], [97.33125, 0.05468459]], ['regression leap basis window 2', [[2052, 9, 4], [2053, 3, 6], 0.0525], [97.33125, 0.05468459]], ['partial repair probe 1', [[2023, 1, 28], [2024, 1, 27], 0.025], [97.472222, 0.02583812]], ['partial repair probe 2', [[2028, 2, 28], [2029, 2, 26], 0.08], [91.911111, 0.0866256]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2100, 12, 15], [2101, 6, 15], 0.0435], [97.800833, 0.0450959]], ['normal control 2', [[2006, 3, 28], [2006, 9, 26], 0.025], [98.736111, 0.02567168]], ['normal control 3', [[2077, 7, 28], [2077, 12, 12], 0.025], [99.048611, 0.02559069]]], [['regression leap basis window 1', [[2036, 3, 24], [2036, 6, 23], 0.08], [97.977778, 0.08278521]], ['regression leap basis window 2', [[2023, 6, 1], [2023, 12, 1], 0.0525], [97.33125, 0.0548385]], ['partial repair probe 1', [[2023, 1, 15], [2024, 1, 14], 0.0435], [95.601667, 0.04561452]], ['partial repair probe 2', [[2088, 2, 27], [2089, 2, 25], 0.0525], [94.691667, 0.0555986]], ['boundary control 1', [[2023, 1, 1], [2023, 1, 2], 0.05], [99.986111, 0.05070149]], ['normal control 1', [[2051, 2, 7], [2051, 8, 7], 0.001], [99.949722, 0.0010144]], ['normal control 2', [[2028, 2, 15], [2028, 8, 14], 0.001], [99.949722, 0.00101718]], ['normal control 3', [[2058, 4, 13], [2058, 10, 11], 0.0525], [97.360417, 0.05467229]]]]
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 leap basis window 1[99.949444, 0.00101718][99.949444, 0.00101718]Passed
regression leap basis window 2[97.812917, 0.04521386][97.812917, 0.04521386]Passed
partial repair probe 1[97.472222, 0.02590891][97.472222, 0.02590891]Passed
partial repair probe 2[99.898889, 0.00101466][99.898889, 0.00101466]Passed
boundary control 1[99.986111, 0.05070149][99.986111, 0.05070149]Passed
normal control 1[99.491667, 0.01019055][99.491667, 0.01019055]Passed
normal control 2[99.491667, 0.01019055][99.491667, 0.01019055]Passed
normal control 3[97.812917, 0.04509033][97.812917, 0.04509033]Passed

SHA-256 / 22b6ee06eff6a0cd88bef72e30f016f5ebb11a2bb930fca3e53de70306e87587

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

Case digest / 364bf24ebba4c8de13d095816499be6e483fce2bf02dc4ea0805480c512e71a7