FA-61211 / Bond day-count conventions / Open access
Settlement date from a business-day lag across two calendars: the trade date counts as the first business day · case 01
Settlement is one business day early.
ROOT CAUSE
The loop tests the current day before advancing, so the trade date is counted.
VERIFIED REPAIR
Advance first, then count business days strictly after the trade date.
Unsuccessful approach: Skipping the trade date but still advancing after counting returns the day after the n-th business day.
Case contract
Inputs a trade date (a business day), a lag n and two holiday lists. A business day is a weekday that is a holiday in neither calendar. Settlement is the n-th business day strictly after trade (trade date for n=0). Return [y,m,d].
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
N = 1
observations = []
def solve(trade, n, hol_a, hol_b):
T = datetime.date(*trade)
HA = {datetime.date(*h) for h in hol_a}
HB = {datetime.date(*h) for h in hol_b}
def biz(x):
return x.weekday() < 5 and x not in HA and x not in HB
x = T
k = 0
while k < n:
if biz(x):
k += 1
if k < n:
x += datetime.timedelta(days=1)
return [x.year, x.month, x.day]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression trade date counted 1', [[2028, 3, 31], 5, [[2028, 4, 3], [2028, 4, 6]], [[2028, 4, 4], [2028, 4, 7]]], [2028, 4, 13]], ['regression trade date counted 2', [[2027, 8, 5], 2, [], [[2027, 8, 7]]], [2027, 8, 9]], ['partial repair probe 1', [[2027, 9, 30], 2, [], [[2027, 10, 3]]], [2027, 10, 4]], ['partial repair probe 2', [[2021, 1, 18], 2, [[2021, 1, 27]], [[2021, 1, 27], [2021, 1, 19]]], [2021, 1, 21]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2029, 3, 5], 0, [], [[2029, 3, 8], [2029, 3, 13]]], [2029, 3, 5]], ['normal control 2', [[2020, 6, 30], 0, [], []], [2020, 6, 30]], ['normal control 3', [[2022, 7, 21], 0, [[2022, 7, 30], [2022, 7, 25]], []], [2022, 7, 21]]], [['regression trade date counted 1', [[2030, 2, 28], 2, [], [[2030, 3, 4], [2030, 3, 1]]], [2030, 3, 6]], ['regression trade date counted 2', [[2027, 2, 5], 1, [[2027, 2, 10]], [[2027, 2, 13], [2027, 2, 8]]], [2027, 2, 9]], ['partial repair probe 1', [[2019, 5, 31], 3, [[2019, 6, 8]], []], [2019, 6, 5]], ['partial repair probe 2', [[2024, 7, 31], 1, [], [[2024, 8, 9], [2024, 8, 4]]], [2024, 8, 1]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2020, 2, 28], 0, [[2020, 3, 1]], []], [2020, 2, 28]], ['normal control 2', [[2024, 4, 22], 0, [], []], [2024, 4, 22]], ['normal control 3', [[2021, 1, 25], 0, [[2021, 2, 3], [2021, 2, 1]], [[2021, 1, 29], [2021, 1, 30]]], [2021, 1, 25]]], [['regression trade date counted 1', [[2027, 7, 21], 2, [[2027, 7, 23], [2027, 7, 30]], [[2027, 7, 28], [2027, 7, 26]]], [2027, 7, 27]], ['regression trade date counted 2', [[2026, 6, 30], 1, [[2026, 7, 1], [2026, 7, 6]], [[2026, 7, 2], [2026, 7, 5]]], [2026, 7, 3]], ['partial repair probe 1', [[2021, 10, 15], 3, [], [[2021, 10, 24]]], [2021, 10, 20]], ['partial repair probe 2', [[2025, 10, 31], 2, [[2025, 11, 1]], [[2025, 11, 9]]], [2025, 11, 4]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2022, 1, 21], 0, [[2022, 1, 23], [2022, 1, 22]], [[2022, 1, 26], [2022, 1, 29]]], [2022, 1, 21]], ['normal control 2', [[2025, 9, 22], 0, [[2025, 9, 26]], [[2025, 9, 27], [2025, 9, 26]]], [2025, 9, 22]], ['normal control 3', [[2023, 2, 28], 0, [[2023, 3, 8]], [[2023, 3, 4]]], [2023, 2, 28]]], [['regression trade date counted 1', [[2019, 7, 31], 2, [[2019, 8, 2]], []], [2019, 8, 5]], ['regression trade date counted 2', [[2026, 1, 5], 2, [], [[2026, 1, 11]]], [2026, 1, 7]], ['partial repair probe 1', [[2030, 5, 31], 3, [[2030, 6, 2]], []], [2030, 6, 5]], ['partial repair probe 2', [[2023, 10, 31], 2, [[2023, 11, 7], [2023, 11, 2]], [[2023, 11, 3], [2023, 11, 2]]], [2023, 11, 6]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2020, 4, 30], 0, [[2020, 5, 7]], [[2020, 5, 5], [2020, 5, 1]]], [2020, 4, 30]], ['normal control 2', [[2019, 8, 6], 0, [[2019, 8, 12]], []], [2019, 8, 6]], ['normal control 3', [[2019, 7, 31], 0, [], []], [2019, 7, 31]]], [['regression trade date counted 1', [[2026, 12, 31], 2, [], []], [2027, 1, 4]], ['regression trade date counted 2', [[2026, 11, 9], 2, [[2026, 11, 16]], [[2026, 11, 18], [2026, 11, 12]]], [2026, 11, 11]], ['partial repair probe 1', [[2019, 7, 1], 5, [], []], [2019, 7, 8]], ['partial repair probe 2', [[2029, 5, 28], 2, [], [[2029, 6, 1]]], [2029, 5, 30]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2025, 6, 2], 0, [[2025, 6, 8]], [[2025, 6, 5], [2025, 6, 9]]], [2025, 6, 2]], ['normal control 2', [[2021, 9, 10], 0, [], [[2021, 9, 19]]], [2021, 9, 10]], ['normal control 3', [[2020, 10, 26], 0, [[2020, 10, 28], [2020, 10, 31]], [[2020, 11, 3], [2020, 11, 4]]], [2020, 10, 26]]]]
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 trade date counted 1 | [2028, 4, 12] | [2028, 4, 13] | Failed |
| regression trade date counted 2 | [2027, 8, 6] | [2027, 8, 9] | Failed |
| partial repair probe 1 | [2027, 10, 1] | [2027, 10, 4] | Failed |
| partial repair probe 2 | [2021, 1, 20] | [2021, 1, 21] | Failed |
| boundary control 1 | [2024, 5, 3] | [2024, 5, 3] | Passed |
| normal control 1 | [2029, 3, 5] | [2029, 3, 5] | Passed |
| normal control 2 | [2020, 6, 30] | [2020, 6, 30] | Passed |
| normal control 3 | [2022, 7, 21] | [2022, 7, 21] | Passed |
SHA-256 / 89bc1e1e389568aa935255f34867287f1a388b644778e298b693c41314d88c88
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(trade, n, hol_a, hol_b):
T = datetime.date(*trade)
HA = {datetime.date(*h) for h in hol_a}
HB = {datetime.date(*h) for h in hol_b}
def biz(x):
return x.weekday() < 5 and x not in HA and x not in HB
x = T
k = 0
while k < n:
if biz(x) and x != T:
k += 1
x += datetime.timedelta(days=1)
return [x.year, x.month, x.day]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression trade date counted 1', [[2028, 3, 31], 5, [[2028, 4, 3], [2028, 4, 6]], [[2028, 4, 4], [2028, 4, 7]]], [2028, 4, 13]], ['regression trade date counted 2', [[2027, 8, 5], 2, [], [[2027, 8, 7]]], [2027, 8, 9]], ['partial repair probe 1', [[2027, 9, 30], 2, [], [[2027, 10, 3]]], [2027, 10, 4]], ['partial repair probe 2', [[2021, 1, 18], 2, [[2021, 1, 27]], [[2021, 1, 27], [2021, 1, 19]]], [2021, 1, 21]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2029, 3, 5], 0, [], [[2029, 3, 8], [2029, 3, 13]]], [2029, 3, 5]], ['normal control 2', [[2020, 6, 30], 0, [], []], [2020, 6, 30]], ['normal control 3', [[2022, 7, 21], 0, [[2022, 7, 30], [2022, 7, 25]], []], [2022, 7, 21]]], [['regression trade date counted 1', [[2030, 2, 28], 2, [], [[2030, 3, 4], [2030, 3, 1]]], [2030, 3, 6]], ['regression trade date counted 2', [[2027, 2, 5], 1, [[2027, 2, 10]], [[2027, 2, 13], [2027, 2, 8]]], [2027, 2, 9]], ['partial repair probe 1', [[2019, 5, 31], 3, [[2019, 6, 8]], []], [2019, 6, 5]], ['partial repair probe 2', [[2024, 7, 31], 1, [], [[2024, 8, 9], [2024, 8, 4]]], [2024, 8, 1]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2020, 2, 28], 0, [[2020, 3, 1]], []], [2020, 2, 28]], ['normal control 2', [[2024, 4, 22], 0, [], []], [2024, 4, 22]], ['normal control 3', [[2021, 1, 25], 0, [[2021, 2, 3], [2021, 2, 1]], [[2021, 1, 29], [2021, 1, 30]]], [2021, 1, 25]]], [['regression trade date counted 1', [[2027, 7, 21], 2, [[2027, 7, 23], [2027, 7, 30]], [[2027, 7, 28], [2027, 7, 26]]], [2027, 7, 27]], ['regression trade date counted 2', [[2026, 6, 30], 1, [[2026, 7, 1], [2026, 7, 6]], [[2026, 7, 2], [2026, 7, 5]]], [2026, 7, 3]], ['partial repair probe 1', [[2021, 10, 15], 3, [], [[2021, 10, 24]]], [2021, 10, 20]], ['partial repair probe 2', [[2025, 10, 31], 2, [[2025, 11, 1]], [[2025, 11, 9]]], [2025, 11, 4]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2022, 1, 21], 0, [[2022, 1, 23], [2022, 1, 22]], [[2022, 1, 26], [2022, 1, 29]]], [2022, 1, 21]], ['normal control 2', [[2025, 9, 22], 0, [[2025, 9, 26]], [[2025, 9, 27], [2025, 9, 26]]], [2025, 9, 22]], ['normal control 3', [[2023, 2, 28], 0, [[2023, 3, 8]], [[2023, 3, 4]]], [2023, 2, 28]]], [['regression trade date counted 1', [[2019, 7, 31], 2, [[2019, 8, 2]], []], [2019, 8, 5]], ['regression trade date counted 2', [[2026, 1, 5], 2, [], [[2026, 1, 11]]], [2026, 1, 7]], ['partial repair probe 1', [[2030, 5, 31], 3, [[2030, 6, 2]], []], [2030, 6, 5]], ['partial repair probe 2', [[2023, 10, 31], 2, [[2023, 11, 7], [2023, 11, 2]], [[2023, 11, 3], [2023, 11, 2]]], [2023, 11, 6]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2020, 4, 30], 0, [[2020, 5, 7]], [[2020, 5, 5], [2020, 5, 1]]], [2020, 4, 30]], ['normal control 2', [[2019, 8, 6], 0, [[2019, 8, 12]], []], [2019, 8, 6]], ['normal control 3', [[2019, 7, 31], 0, [], []], [2019, 7, 31]]], [['regression trade date counted 1', [[2026, 12, 31], 2, [], []], [2027, 1, 4]], ['regression trade date counted 2', [[2026, 11, 9], 2, [[2026, 11, 16]], [[2026, 11, 18], [2026, 11, 12]]], [2026, 11, 11]], ['partial repair probe 1', [[2019, 7, 1], 5, [], []], [2019, 7, 8]], ['partial repair probe 2', [[2029, 5, 28], 2, [], [[2029, 6, 1]]], [2029, 5, 30]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2025, 6, 2], 0, [[2025, 6, 8]], [[2025, 6, 5], [2025, 6, 9]]], [2025, 6, 2]], ['normal control 2', [[2021, 9, 10], 0, [], [[2021, 9, 19]]], [2021, 9, 10]], ['normal control 3', [[2020, 10, 26], 0, [[2020, 10, 28], [2020, 10, 31]], [[2020, 11, 3], [2020, 11, 4]]], [2020, 10, 26]]]]
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 trade date counted 1 | [2028, 4, 14] | [2028, 4, 13] | Failed |
| regression trade date counted 2 | [2027, 8, 10] | [2027, 8, 9] | Failed |
| partial repair probe 1 | [2027, 10, 5] | [2027, 10, 4] | Failed |
| partial repair probe 2 | [2021, 1, 22] | [2021, 1, 21] | Failed |
| boundary control 1 | [2024, 5, 3] | [2024, 5, 3] | Passed |
| normal control 1 | [2029, 3, 5] | [2029, 3, 5] | Passed |
| normal control 2 | [2020, 6, 30] | [2020, 6, 30] | Passed |
| normal control 3 | [2022, 7, 21] | [2022, 7, 21] | Passed |
SHA-256 / 89d8b6dbf6349fbceb17a8a577d38af7be419390edfc220912865990a9e5b65e
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(trade, n, hol_a, hol_b):
T = datetime.date(*trade)
HA = {datetime.date(*h) for h in hol_a}
HB = {datetime.date(*h) for h in hol_b}
def biz(x):
return x.weekday() < 5 and x not in HA and x not in HB
x = T
k = 0
while k < n:
x += datetime.timedelta(days=1)
if biz(x):
k += 1
return [x.year, x.month, x.day]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression trade date counted 1', [[2028, 3, 31], 5, [[2028, 4, 3], [2028, 4, 6]], [[2028, 4, 4], [2028, 4, 7]]], [2028, 4, 13]], ['regression trade date counted 2', [[2027, 8, 5], 2, [], [[2027, 8, 7]]], [2027, 8, 9]], ['partial repair probe 1', [[2027, 9, 30], 2, [], [[2027, 10, 3]]], [2027, 10, 4]], ['partial repair probe 2', [[2021, 1, 18], 2, [[2021, 1, 27]], [[2021, 1, 27], [2021, 1, 19]]], [2021, 1, 21]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2029, 3, 5], 0, [], [[2029, 3, 8], [2029, 3, 13]]], [2029, 3, 5]], ['normal control 2', [[2020, 6, 30], 0, [], []], [2020, 6, 30]], ['normal control 3', [[2022, 7, 21], 0, [[2022, 7, 30], [2022, 7, 25]], []], [2022, 7, 21]]], [['regression trade date counted 1', [[2030, 2, 28], 2, [], [[2030, 3, 4], [2030, 3, 1]]], [2030, 3, 6]], ['regression trade date counted 2', [[2027, 2, 5], 1, [[2027, 2, 10]], [[2027, 2, 13], [2027, 2, 8]]], [2027, 2, 9]], ['partial repair probe 1', [[2019, 5, 31], 3, [[2019, 6, 8]], []], [2019, 6, 5]], ['partial repair probe 2', [[2024, 7, 31], 1, [], [[2024, 8, 9], [2024, 8, 4]]], [2024, 8, 1]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2020, 2, 28], 0, [[2020, 3, 1]], []], [2020, 2, 28]], ['normal control 2', [[2024, 4, 22], 0, [], []], [2024, 4, 22]], ['normal control 3', [[2021, 1, 25], 0, [[2021, 2, 3], [2021, 2, 1]], [[2021, 1, 29], [2021, 1, 30]]], [2021, 1, 25]]], [['regression trade date counted 1', [[2027, 7, 21], 2, [[2027, 7, 23], [2027, 7, 30]], [[2027, 7, 28], [2027, 7, 26]]], [2027, 7, 27]], ['regression trade date counted 2', [[2026, 6, 30], 1, [[2026, 7, 1], [2026, 7, 6]], [[2026, 7, 2], [2026, 7, 5]]], [2026, 7, 3]], ['partial repair probe 1', [[2021, 10, 15], 3, [], [[2021, 10, 24]]], [2021, 10, 20]], ['partial repair probe 2', [[2025, 10, 31], 2, [[2025, 11, 1]], [[2025, 11, 9]]], [2025, 11, 4]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2022, 1, 21], 0, [[2022, 1, 23], [2022, 1, 22]], [[2022, 1, 26], [2022, 1, 29]]], [2022, 1, 21]], ['normal control 2', [[2025, 9, 22], 0, [[2025, 9, 26]], [[2025, 9, 27], [2025, 9, 26]]], [2025, 9, 22]], ['normal control 3', [[2023, 2, 28], 0, [[2023, 3, 8]], [[2023, 3, 4]]], [2023, 2, 28]]], [['regression trade date counted 1', [[2019, 7, 31], 2, [[2019, 8, 2]], []], [2019, 8, 5]], ['regression trade date counted 2', [[2026, 1, 5], 2, [], [[2026, 1, 11]]], [2026, 1, 7]], ['partial repair probe 1', [[2030, 5, 31], 3, [[2030, 6, 2]], []], [2030, 6, 5]], ['partial repair probe 2', [[2023, 10, 31], 2, [[2023, 11, 7], [2023, 11, 2]], [[2023, 11, 3], [2023, 11, 2]]], [2023, 11, 6]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2020, 4, 30], 0, [[2020, 5, 7]], [[2020, 5, 5], [2020, 5, 1]]], [2020, 4, 30]], ['normal control 2', [[2019, 8, 6], 0, [[2019, 8, 12]], []], [2019, 8, 6]], ['normal control 3', [[2019, 7, 31], 0, [], []], [2019, 7, 31]]], [['regression trade date counted 1', [[2026, 12, 31], 2, [], []], [2027, 1, 4]], ['regression trade date counted 2', [[2026, 11, 9], 2, [[2026, 11, 16]], [[2026, 11, 18], [2026, 11, 12]]], [2026, 11, 11]], ['partial repair probe 1', [[2019, 7, 1], 5, [], []], [2019, 7, 8]], ['partial repair probe 2', [[2029, 5, 28], 2, [], [[2029, 6, 1]]], [2029, 5, 30]], ['boundary control 1', [[2024, 5, 3], 0, [], []], [2024, 5, 3]], ['normal control 1', [[2025, 6, 2], 0, [[2025, 6, 8]], [[2025, 6, 5], [2025, 6, 9]]], [2025, 6, 2]], ['normal control 2', [[2021, 9, 10], 0, [], [[2021, 9, 19]]], [2021, 9, 10]], ['normal control 3', [[2020, 10, 26], 0, [[2020, 10, 28], [2020, 10, 31]], [[2020, 11, 3], [2020, 11, 4]]], [2020, 10, 26]]]]
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 trade date counted 1 | [2028, 4, 13] | [2028, 4, 13] | Passed |
| regression trade date counted 2 | [2027, 8, 9] | [2027, 8, 9] | Passed |
| partial repair probe 1 | [2027, 10, 4] | [2027, 10, 4] | Passed |
| partial repair probe 2 | [2021, 1, 21] | [2021, 1, 21] | Passed |
| boundary control 1 | [2024, 5, 3] | [2024, 5, 3] | Passed |
| normal control 1 | [2029, 3, 5] | [2029, 3, 5] | Passed |
| normal control 2 | [2020, 6, 30] | [2020, 6, 30] | Passed |
| normal control 3 | [2022, 7, 21] | [2022, 7, 21] | Passed |
SHA-256 / af529db1972c854a87db36c6615485af0d5b8eb45404c03a05f9787769aace1c
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.102294+00:00.
Case digest / 143c11e012c49c23906abff3bc7f07fe07b92228001f9cae5204fdcdf66a0244