FA-61611 / Options payoff and settlement / Open access
Listed option expiration date calendar: the Friday offset uses the Saturday index · case 01
Monthly expiries land on the third Saturday.
ROOT CAUSE
The offset uses 5 with weekday(), mixing it up with isoweekday() numbering.
VERIFIED REPAIR
With weekday(), Friday is 4.
Unsuccessful approach: Switching to isoweekday() but keeping 4 targets Thursday.
Case contract
Inputs year, month, kind and holidays. Monthly expiry is the third Friday of the month; quarterly expiry is the last calendar day of the quarter-end month (Mar/Jun/Sep/Dec) containing the month. Either date rolls back to the preceding business day (weekday not in holidays) when it is not a business day. Return [y,m,d].
Why this case matters
Option expiry, exercise and settlement engines move cash and shares; a wrong branch misstates obligations.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(y, m, kind, holidays):
H = {datetime.date(*h) for h in holidays}
def biz(x):
return x.weekday() < 5 and x not in H
def mlen(yy, mm):
if mm == 2:
return 29 if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0 else 28
return 30 if mm in (4, 6, 9, 11) else 31
if kind == 'quarterly':
qm = ((m - 1) // 3 + 1) * 3
x = datetime.date(y, qm, mlen(y, qm))
else:
first = datetime.date(y, m, 1)
offset = (5 - first.weekday()) % 7
x = first + datetime.timedelta(days=offset + 14)
while not biz(x):
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 weekday numbering 1', [2022, 10, 'monthly', []], [2022, 10, 21]], ['regression weekday numbering 2', [2028, 4, 'monthly', [[2028, 4, 21]]], [2028, 4, 20]], ['partial repair probe 1', [2023, 6, 'monthly', []], [2023, 6, 16]], ['partial repair probe 2', [2022, 4, 'monthly', []], [2022, 4, 15]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2024, 2, 'quarterly', [[2024, 2, 16], [2024, 2, 15], [2024, 3, 31]]], [2024, 3, 29]], ['normal control 2', [2030, 6, 'quarterly', [[2030, 6, 28]]], [2030, 6, 27]]], [['regression weekday numbering 1', [2031, 11, 'monthly', [[2031, 11, 21], [2031, 11, 20]]], [2031, 11, 19]], ['regression weekday numbering 2', [2032, 5, 'monthly', []], [2032, 5, 21]], ['partial repair probe 1', [2019, 7, 'monthly', []], [2019, 7, 19]], ['partial repair probe 2', [2029, 6, 'monthly', [[2029, 6, 15], [2029, 6, 14]]], [2029, 6, 13]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2022, 2, 'quarterly', []], [2022, 3, 31]], ['normal control 2', [2032, 12, 'monthly', [[2032, 12, 17], [2032, 12, 16]]], [2032, 12, 15]]], [['regression weekday numbering 1', [2028, 4, 'monthly', []], [2028, 4, 21]], ['regression weekday numbering 2', [2025, 11, 'monthly', [[2025, 11, 21], [2025, 11, 20]]], [2025, 11, 19]], ['partial repair probe 1', [2028, 2, 'monthly', []], [2028, 2, 18]], ['partial repair probe 2', [2022, 11, 'monthly', []], [2022, 11, 18]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2026, 7, 'quarterly', []], [2026, 9, 30]], ['normal control 2', [2031, 5, 'monthly', [[2031, 5, 16], [2031, 5, 15]]], [2031, 5, 14]]], [['regression weekday numbering 1', [2020, 8, 'monthly', []], [2020, 8, 21]], ['regression weekday numbering 2', [2031, 11, 'monthly', []], [2031, 11, 21]], ['partial repair probe 1', [2024, 8, 'monthly', []], [2024, 8, 16]], ['partial repair probe 2', [2029, 5, 'monthly', []], [2029, 5, 18]], ['boundary control 1', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['boundary control 2', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['normal control 1', [2030, 12, 'monthly', [[2030, 12, 20]]], [2030, 12, 19]], ['normal control 2', [2031, 3, 'quarterly', [[2031, 3, 28]]], [2031, 3, 31]]], [['regression weekday numbering 1', [2028, 1, 'monthly', []], [2028, 1, 21]], ['regression weekday numbering 2', [2025, 3, 'monthly', []], [2025, 3, 21]], ['partial repair probe 1', [2025, 8, 'monthly', []], [2025, 8, 15]], ['partial repair probe 2', [2030, 2, 'monthly', [[2030, 2, 15]]], [2030, 2, 14]], ['boundary control 1', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['boundary control 2', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['normal control 1', [2019, 5, 'quarterly', []], [2019, 6, 28]], ['normal control 2', [2024, 5, 'quarterly', [[2024, 5, 17], [2024, 6, 27]]], [2024, 6, 28]]]]
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 weekday numbering 1 | [2022, 10, 14] | [2022, 10, 21] | Failed |
| regression weekday numbering 2 | [2028, 4, 14] | [2028, 4, 20] | Failed |
| partial repair probe 1 | [2023, 6, 16] | [2023, 6, 16] | Passed |
| partial repair probe 2 | [2022, 4, 15] | [2022, 4, 15] | Passed |
| boundary control 1 | [2024, 3, 29] | [2024, 3, 29] | Passed |
| boundary control 2 | [2024, 12, 31] | [2024, 12, 31] | Passed |
| normal control 1 | [2024, 3, 29] | [2024, 3, 29] | Passed |
| normal control 2 | [2030, 6, 27] | [2030, 6, 27] | Passed |
SHA-256 / bd37d9d68467db7d92be8b48754e49a7dfcbe4ea64954aa9d4e786bd189238dc
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(y, m, kind, holidays):
H = {datetime.date(*h) for h in holidays}
def biz(x):
return x.weekday() < 5 and x not in H
def mlen(yy, mm):
if mm == 2:
return 29 if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0 else 28
return 30 if mm in (4, 6, 9, 11) else 31
if kind == 'quarterly':
qm = ((m - 1) // 3 + 1) * 3
x = datetime.date(y, qm, mlen(y, qm))
else:
first = datetime.date(y, m, 1)
offset = (4 - first.isoweekday()) % 7
x = first + datetime.timedelta(days=offset + 14)
while not biz(x):
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 weekday numbering 1', [2022, 10, 'monthly', []], [2022, 10, 21]], ['regression weekday numbering 2', [2028, 4, 'monthly', [[2028, 4, 21]]], [2028, 4, 20]], ['partial repair probe 1', [2023, 6, 'monthly', []], [2023, 6, 16]], ['partial repair probe 2', [2022, 4, 'monthly', []], [2022, 4, 15]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2024, 2, 'quarterly', [[2024, 2, 16], [2024, 2, 15], [2024, 3, 31]]], [2024, 3, 29]], ['normal control 2', [2030, 6, 'quarterly', [[2030, 6, 28]]], [2030, 6, 27]]], [['regression weekday numbering 1', [2031, 11, 'monthly', [[2031, 11, 21], [2031, 11, 20]]], [2031, 11, 19]], ['regression weekday numbering 2', [2032, 5, 'monthly', []], [2032, 5, 21]], ['partial repair probe 1', [2019, 7, 'monthly', []], [2019, 7, 19]], ['partial repair probe 2', [2029, 6, 'monthly', [[2029, 6, 15], [2029, 6, 14]]], [2029, 6, 13]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2022, 2, 'quarterly', []], [2022, 3, 31]], ['normal control 2', [2032, 12, 'monthly', [[2032, 12, 17], [2032, 12, 16]]], [2032, 12, 15]]], [['regression weekday numbering 1', [2028, 4, 'monthly', []], [2028, 4, 21]], ['regression weekday numbering 2', [2025, 11, 'monthly', [[2025, 11, 21], [2025, 11, 20]]], [2025, 11, 19]], ['partial repair probe 1', [2028, 2, 'monthly', []], [2028, 2, 18]], ['partial repair probe 2', [2022, 11, 'monthly', []], [2022, 11, 18]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2026, 7, 'quarterly', []], [2026, 9, 30]], ['normal control 2', [2031, 5, 'monthly', [[2031, 5, 16], [2031, 5, 15]]], [2031, 5, 14]]], [['regression weekday numbering 1', [2020, 8, 'monthly', []], [2020, 8, 21]], ['regression weekday numbering 2', [2031, 11, 'monthly', []], [2031, 11, 21]], ['partial repair probe 1', [2024, 8, 'monthly', []], [2024, 8, 16]], ['partial repair probe 2', [2029, 5, 'monthly', []], [2029, 5, 18]], ['boundary control 1', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['boundary control 2', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['normal control 1', [2030, 12, 'monthly', [[2030, 12, 20]]], [2030, 12, 19]], ['normal control 2', [2031, 3, 'quarterly', [[2031, 3, 28]]], [2031, 3, 31]]], [['regression weekday numbering 1', [2028, 1, 'monthly', []], [2028, 1, 21]], ['regression weekday numbering 2', [2025, 3, 'monthly', []], [2025, 3, 21]], ['partial repair probe 1', [2025, 8, 'monthly', []], [2025, 8, 15]], ['partial repair probe 2', [2030, 2, 'monthly', [[2030, 2, 15]]], [2030, 2, 14]], ['boundary control 1', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['boundary control 2', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['normal control 1', [2019, 5, 'quarterly', []], [2019, 6, 28]], ['normal control 2', [2024, 5, 'quarterly', [[2024, 5, 17], [2024, 6, 27]]], [2024, 6, 28]]]]
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 weekday numbering 1 | [2022, 10, 20] | [2022, 10, 21] | Failed |
| regression weekday numbering 2 | [2028, 4, 20] | [2028, 4, 20] | Passed |
| partial repair probe 1 | [2023, 6, 15] | [2023, 6, 16] | Failed |
| partial repair probe 2 | [2022, 4, 21] | [2022, 4, 15] | Failed |
| boundary control 1 | [2024, 3, 29] | [2024, 3, 29] | Passed |
| boundary control 2 | [2024, 12, 31] | [2024, 12, 31] | Passed |
| normal control 1 | [2024, 3, 29] | [2024, 3, 29] | Passed |
| normal control 2 | [2030, 6, 27] | [2030, 6, 27] | Passed |
SHA-256 / d280885c09e41fa9f0727e98857a87372c0e6077505d4f7a7a8b0645c268d7e8
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(y, m, kind, holidays):
H = {datetime.date(*h) for h in holidays}
def biz(x):
return x.weekday() < 5 and x not in H
def mlen(yy, mm):
if mm == 2:
return 29 if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0 else 28
return 30 if mm in (4, 6, 9, 11) else 31
if kind == 'quarterly':
qm = ((m - 1) // 3 + 1) * 3
x = datetime.date(y, qm, mlen(y, qm))
else:
first = datetime.date(y, m, 1)
offset = (4 - first.weekday()) % 7
x = first + datetime.timedelta(days=offset + 14)
while not biz(x):
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 weekday numbering 1', [2022, 10, 'monthly', []], [2022, 10, 21]], ['regression weekday numbering 2', [2028, 4, 'monthly', [[2028, 4, 21]]], [2028, 4, 20]], ['partial repair probe 1', [2023, 6, 'monthly', []], [2023, 6, 16]], ['partial repair probe 2', [2022, 4, 'monthly', []], [2022, 4, 15]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2024, 2, 'quarterly', [[2024, 2, 16], [2024, 2, 15], [2024, 3, 31]]], [2024, 3, 29]], ['normal control 2', [2030, 6, 'quarterly', [[2030, 6, 28]]], [2030, 6, 27]]], [['regression weekday numbering 1', [2031, 11, 'monthly', [[2031, 11, 21], [2031, 11, 20]]], [2031, 11, 19]], ['regression weekday numbering 2', [2032, 5, 'monthly', []], [2032, 5, 21]], ['partial repair probe 1', [2019, 7, 'monthly', []], [2019, 7, 19]], ['partial repair probe 2', [2029, 6, 'monthly', [[2029, 6, 15], [2029, 6, 14]]], [2029, 6, 13]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2022, 2, 'quarterly', []], [2022, 3, 31]], ['normal control 2', [2032, 12, 'monthly', [[2032, 12, 17], [2032, 12, 16]]], [2032, 12, 15]]], [['regression weekday numbering 1', [2028, 4, 'monthly', []], [2028, 4, 21]], ['regression weekday numbering 2', [2025, 11, 'monthly', [[2025, 11, 21], [2025, 11, 20]]], [2025, 11, 19]], ['partial repair probe 1', [2028, 2, 'monthly', []], [2028, 2, 18]], ['partial repair probe 2', [2022, 11, 'monthly', []], [2022, 11, 18]], ['boundary control 1', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['boundary control 2', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['normal control 1', [2026, 7, 'quarterly', []], [2026, 9, 30]], ['normal control 2', [2031, 5, 'monthly', [[2031, 5, 16], [2031, 5, 15]]], [2031, 5, 14]]], [['regression weekday numbering 1', [2020, 8, 'monthly', []], [2020, 8, 21]], ['regression weekday numbering 2', [2031, 11, 'monthly', []], [2031, 11, 21]], ['partial repair probe 1', [2024, 8, 'monthly', []], [2024, 8, 16]], ['partial repair probe 2', [2029, 5, 'monthly', []], [2029, 5, 18]], ['boundary control 1', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['boundary control 2', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['normal control 1', [2030, 12, 'monthly', [[2030, 12, 20]]], [2030, 12, 19]], ['normal control 2', [2031, 3, 'quarterly', [[2031, 3, 28]]], [2031, 3, 31]]], [['regression weekday numbering 1', [2028, 1, 'monthly', []], [2028, 1, 21]], ['regression weekday numbering 2', [2025, 3, 'monthly', []], [2025, 3, 21]], ['partial repair probe 1', [2025, 8, 'monthly', []], [2025, 8, 15]], ['partial repair probe 2', [2030, 2, 'monthly', [[2030, 2, 15]]], [2030, 2, 14]], ['boundary control 1', [2024, 12, 'quarterly', []], [2024, 12, 31]], ['boundary control 2', [2024, 3, 'quarterly', []], [2024, 3, 29]], ['normal control 1', [2019, 5, 'quarterly', []], [2019, 6, 28]], ['normal control 2', [2024, 5, 'quarterly', [[2024, 5, 17], [2024, 6, 27]]], [2024, 6, 28]]]]
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 weekday numbering 1 | [2022, 10, 21] | [2022, 10, 21] | Passed |
| regression weekday numbering 2 | [2028, 4, 20] | [2028, 4, 20] | Passed |
| partial repair probe 1 | [2023, 6, 16] | [2023, 6, 16] | Passed |
| partial repair probe 2 | [2022, 4, 15] | [2022, 4, 15] | Passed |
| boundary control 1 | [2024, 3, 29] | [2024, 3, 29] | Passed |
| boundary control 2 | [2024, 12, 31] | [2024, 12, 31] | Passed |
| normal control 1 | [2024, 3, 29] | [2024, 3, 29] | Passed |
| normal control 2 | [2030, 6, 27] | [2030, 6, 27] | Passed |
SHA-256 / e605a00b7357024c71978254419819384703107ecd0cd8e8b41f78785f6c94b8
Verification & scope
A deterministic toy contract stated explicitly in the contract field; no claim of conformance to any exchange or clearing rulebook. 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:56.783989+00:00.
Case digest / b13cb227abc70b2489c766af82b96b9dc647b72a14a461bc895c7fa71df39825