FAILURE MAP
← Case archive

FA-61601 / Options payoff and settlement / Open access

Listed option expiration date calendar: a quarter-end month maps to the next quarter · case 01

March, June and September quarterly contracts expire three months late.

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

ROOT CAUSE

The quarter month is computed from m // 3 instead of (m - 1) // 3.

VERIFIED REPAIR

Map months 1-3 to March, 4-6 to June and so on.

Unsuccessful approach: Clamping the result at December fixes only the December overflow.

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 // 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 quarter month mapping 1', [2021, 3, 'quarterly', [[2021, 3, 29]]], [2021, 3, 31]], ['regression quarter month mapping 2', [2026, 6, 'quarterly', [[2026, 6, 19], [2026, 6, 18]]], [2026, 6, 30]], ['partial repair probe 1', [2030, 9, 'quarterly', []], [2030, 9, 30]], ['partial repair probe 2', [2025, 9, 'quarterly', []], [2025, 9, 30]], ['boundary control 1', [2024, 3, 'monthly', []], [2024, 3, 15]], ['boundary control 2', [2024, 6, 'monthly', []], [2024, 6, 21]], ['normal control 1', [2031, 3, 'monthly', []], [2031, 3, 21]], ['normal control 2', [2024, 3, 'monthly', [[2024, 3, 15], [2024, 3, 14]]], [2024, 3, 13]]], [['regression quarter month mapping 1', [2030, 3, 'quarterly', []], [2030, 3, 29]], ['regression quarter month mapping 2', [2027, 6, 'quarterly', [[2027, 6, 27]]], [2027, 6, 30]], ['partial repair probe 1', [2020, 6, 'quarterly', [[2020, 6, 19], [2020, 6, 18]]], [2020, 6, 30]], ['partial repair probe 2', [2029, 3, 'quarterly', [[2029, 3, 28]]], [2029, 3, 30]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2028, 11, 'monthly', [[2028, 11, 17], [2028, 11, 16]]], [2028, 11, 15]], ['normal control 2', [2030, 11, 'quarterly', []], [2030, 12, 31]]], [['regression quarter month mapping 1', [2026, 9, 'quarterly', []], [2026, 9, 30]], ['regression quarter month mapping 2', [2027, 6, 'quarterly', [[2027, 6, 18], [2027, 6, 28]]], [2027, 6, 30]], ['partial repair probe 1', [2030, 9, 'quarterly', []], [2030, 9, 30]], ['partial repair probe 2', [2029, 9, 'quarterly', [[2029, 9, 21], [2029, 9, 28]]], [2029, 9, 27]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2029, 8, 'monthly', []], [2029, 8, 17]], ['normal control 2', [2022, 4, 'monthly', [[2022, 4, 15]]], [2022, 4, 14]]], [['regression quarter month mapping 1', [2031, 9, 'quarterly', [[2031, 9, 27]]], [2031, 9, 30]], ['regression quarter month mapping 2', [2032, 3, 'quarterly', [[2032, 3, 28]]], [2032, 3, 31]], ['partial repair probe 1', [2029, 6, 'quarterly', []], [2029, 6, 29]], ['partial repair probe 2', [2027, 9, 'quarterly', [[2027, 9, 17], [2027, 9, 27]]], [2027, 9, 30]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2023, 3, 'monthly', []], [2023, 3, 17]], ['normal control 2', [2032, 5, 'quarterly', [[2032, 6, 28]]], [2032, 6, 30]]], [['regression quarter month mapping 1', [2029, 3, 'quarterly', [[2029, 3, 16], [2029, 3, 30]]], [2029, 3, 29]], ['regression quarter month mapping 2', [2029, 3, 'quarterly', []], [2029, 3, 30]], ['partial repair probe 1', [2029, 3, 'quarterly', [[2029, 3, 16], [2029, 3, 15], [2029, 3, 30]]], [2029, 3, 29]], ['partial repair probe 2', [2019, 9, 'quarterly', [[2019, 9, 20], [2019, 9, 30]]], [2019, 9, 27]], ['boundary control 1', [2024, 3, 'monthly', []], [2024, 3, 15]], ['boundary control 2', [2024, 6, 'monthly', []], [2024, 6, 21]], ['normal control 1', [2020, 7, 'quarterly', [[2020, 9, 30]]], [2020, 9, 29]], ['normal control 2', [2026, 9, 'monthly', [[2026, 9, 18]]], [2026, 9, 17]]]]
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 quarter month mapping 1[2021, 6, 30][2021, 3, 31]Failed
regression quarter month mapping 2[2026, 9, 30][2026, 6, 30]Failed
partial repair probe 1[2030, 12, 31][2030, 9, 30]Failed
partial repair probe 2[2025, 12, 31][2025, 9, 30]Failed
boundary control 1[2024, 3, 15][2024, 3, 15]Passed
boundary control 2[2024, 6, 21][2024, 6, 21]Passed
normal control 1[2031, 3, 21][2031, 3, 21]Passed
normal control 2[2024, 3, 13][2024, 3, 13]Passed

SHA-256 / 9b58c2bc3dcc93fc07adc5983b7942494ed8970132e74088f1d6927dff23b6f9

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 = min(12, (m // 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 quarter month mapping 1', [2021, 3, 'quarterly', [[2021, 3, 29]]], [2021, 3, 31]], ['regression quarter month mapping 2', [2026, 6, 'quarterly', [[2026, 6, 19], [2026, 6, 18]]], [2026, 6, 30]], ['partial repair probe 1', [2030, 9, 'quarterly', []], [2030, 9, 30]], ['partial repair probe 2', [2025, 9, 'quarterly', []], [2025, 9, 30]], ['boundary control 1', [2024, 3, 'monthly', []], [2024, 3, 15]], ['boundary control 2', [2024, 6, 'monthly', []], [2024, 6, 21]], ['normal control 1', [2031, 3, 'monthly', []], [2031, 3, 21]], ['normal control 2', [2024, 3, 'monthly', [[2024, 3, 15], [2024, 3, 14]]], [2024, 3, 13]]], [['regression quarter month mapping 1', [2030, 3, 'quarterly', []], [2030, 3, 29]], ['regression quarter month mapping 2', [2027, 6, 'quarterly', [[2027, 6, 27]]], [2027, 6, 30]], ['partial repair probe 1', [2020, 6, 'quarterly', [[2020, 6, 19], [2020, 6, 18]]], [2020, 6, 30]], ['partial repair probe 2', [2029, 3, 'quarterly', [[2029, 3, 28]]], [2029, 3, 30]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2028, 11, 'monthly', [[2028, 11, 17], [2028, 11, 16]]], [2028, 11, 15]], ['normal control 2', [2030, 11, 'quarterly', []], [2030, 12, 31]]], [['regression quarter month mapping 1', [2026, 9, 'quarterly', []], [2026, 9, 30]], ['regression quarter month mapping 2', [2027, 6, 'quarterly', [[2027, 6, 18], [2027, 6, 28]]], [2027, 6, 30]], ['partial repair probe 1', [2030, 9, 'quarterly', []], [2030, 9, 30]], ['partial repair probe 2', [2029, 9, 'quarterly', [[2029, 9, 21], [2029, 9, 28]]], [2029, 9, 27]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2029, 8, 'monthly', []], [2029, 8, 17]], ['normal control 2', [2022, 4, 'monthly', [[2022, 4, 15]]], [2022, 4, 14]]], [['regression quarter month mapping 1', [2031, 9, 'quarterly', [[2031, 9, 27]]], [2031, 9, 30]], ['regression quarter month mapping 2', [2032, 3, 'quarterly', [[2032, 3, 28]]], [2032, 3, 31]], ['partial repair probe 1', [2029, 6, 'quarterly', []], [2029, 6, 29]], ['partial repair probe 2', [2027, 9, 'quarterly', [[2027, 9, 17], [2027, 9, 27]]], [2027, 9, 30]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2023, 3, 'monthly', []], [2023, 3, 17]], ['normal control 2', [2032, 5, 'quarterly', [[2032, 6, 28]]], [2032, 6, 30]]], [['regression quarter month mapping 1', [2029, 3, 'quarterly', [[2029, 3, 16], [2029, 3, 30]]], [2029, 3, 29]], ['regression quarter month mapping 2', [2029, 3, 'quarterly', []], [2029, 3, 30]], ['partial repair probe 1', [2029, 3, 'quarterly', [[2029, 3, 16], [2029, 3, 15], [2029, 3, 30]]], [2029, 3, 29]], ['partial repair probe 2', [2019, 9, 'quarterly', [[2019, 9, 20], [2019, 9, 30]]], [2019, 9, 27]], ['boundary control 1', [2024, 3, 'monthly', []], [2024, 3, 15]], ['boundary control 2', [2024, 6, 'monthly', []], [2024, 6, 21]], ['normal control 1', [2020, 7, 'quarterly', [[2020, 9, 30]]], [2020, 9, 29]], ['normal control 2', [2026, 9, 'monthly', [[2026, 9, 18]]], [2026, 9, 17]]]]
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 quarter month mapping 1[2021, 6, 30][2021, 3, 31]Failed
regression quarter month mapping 2[2026, 9, 30][2026, 6, 30]Failed
partial repair probe 1[2030, 12, 31][2030, 9, 30]Failed
partial repair probe 2[2025, 12, 31][2025, 9, 30]Failed
boundary control 1[2024, 3, 15][2024, 3, 15]Passed
boundary control 2[2024, 6, 21][2024, 6, 21]Passed
normal control 1[2031, 3, 21][2031, 3, 21]Passed
normal control 2[2024, 3, 13][2024, 3, 13]Passed

SHA-256 / dd5666a1aa0336178aa7c01f413a572ee154ba168f706888be3913e05c6f9c9f

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 quarter month mapping 1', [2021, 3, 'quarterly', [[2021, 3, 29]]], [2021, 3, 31]], ['regression quarter month mapping 2', [2026, 6, 'quarterly', [[2026, 6, 19], [2026, 6, 18]]], [2026, 6, 30]], ['partial repair probe 1', [2030, 9, 'quarterly', []], [2030, 9, 30]], ['partial repair probe 2', [2025, 9, 'quarterly', []], [2025, 9, 30]], ['boundary control 1', [2024, 3, 'monthly', []], [2024, 3, 15]], ['boundary control 2', [2024, 6, 'monthly', []], [2024, 6, 21]], ['normal control 1', [2031, 3, 'monthly', []], [2031, 3, 21]], ['normal control 2', [2024, 3, 'monthly', [[2024, 3, 15], [2024, 3, 14]]], [2024, 3, 13]]], [['regression quarter month mapping 1', [2030, 3, 'quarterly', []], [2030, 3, 29]], ['regression quarter month mapping 2', [2027, 6, 'quarterly', [[2027, 6, 27]]], [2027, 6, 30]], ['partial repair probe 1', [2020, 6, 'quarterly', [[2020, 6, 19], [2020, 6, 18]]], [2020, 6, 30]], ['partial repair probe 2', [2029, 3, 'quarterly', [[2029, 3, 28]]], [2029, 3, 30]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2028, 11, 'monthly', [[2028, 11, 17], [2028, 11, 16]]], [2028, 11, 15]], ['normal control 2', [2030, 11, 'quarterly', []], [2030, 12, 31]]], [['regression quarter month mapping 1', [2026, 9, 'quarterly', []], [2026, 9, 30]], ['regression quarter month mapping 2', [2027, 6, 'quarterly', [[2027, 6, 18], [2027, 6, 28]]], [2027, 6, 30]], ['partial repair probe 1', [2030, 9, 'quarterly', []], [2030, 9, 30]], ['partial repair probe 2', [2029, 9, 'quarterly', [[2029, 9, 21], [2029, 9, 28]]], [2029, 9, 27]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2029, 8, 'monthly', []], [2029, 8, 17]], ['normal control 2', [2022, 4, 'monthly', [[2022, 4, 15]]], [2022, 4, 14]]], [['regression quarter month mapping 1', [2031, 9, 'quarterly', [[2031, 9, 27]]], [2031, 9, 30]], ['regression quarter month mapping 2', [2032, 3, 'quarterly', [[2032, 3, 28]]], [2032, 3, 31]], ['partial repair probe 1', [2029, 6, 'quarterly', []], [2029, 6, 29]], ['partial repair probe 2', [2027, 9, 'quarterly', [[2027, 9, 17], [2027, 9, 27]]], [2027, 9, 30]], ['boundary control 1', [2024, 6, 'monthly', []], [2024, 6, 21]], ['boundary control 2', [2024, 3, 'monthly', []], [2024, 3, 15]], ['normal control 1', [2023, 3, 'monthly', []], [2023, 3, 17]], ['normal control 2', [2032, 5, 'quarterly', [[2032, 6, 28]]], [2032, 6, 30]]], [['regression quarter month mapping 1', [2029, 3, 'quarterly', [[2029, 3, 16], [2029, 3, 30]]], [2029, 3, 29]], ['regression quarter month mapping 2', [2029, 3, 'quarterly', []], [2029, 3, 30]], ['partial repair probe 1', [2029, 3, 'quarterly', [[2029, 3, 16], [2029, 3, 15], [2029, 3, 30]]], [2029, 3, 29]], ['partial repair probe 2', [2019, 9, 'quarterly', [[2019, 9, 20], [2019, 9, 30]]], [2019, 9, 27]], ['boundary control 1', [2024, 3, 'monthly', []], [2024, 3, 15]], ['boundary control 2', [2024, 6, 'monthly', []], [2024, 6, 21]], ['normal control 1', [2020, 7, 'quarterly', [[2020, 9, 30]]], [2020, 9, 29]], ['normal control 2', [2026, 9, 'monthly', [[2026, 9, 18]]], [2026, 9, 17]]]]
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 quarter month mapping 1[2021, 3, 31][2021, 3, 31]Passed
regression quarter month mapping 2[2026, 6, 30][2026, 6, 30]Passed
partial repair probe 1[2030, 9, 30][2030, 9, 30]Passed
partial repair probe 2[2025, 9, 30][2025, 9, 30]Passed
boundary control 1[2024, 3, 15][2024, 3, 15]Passed
boundary control 2[2024, 6, 21][2024, 6, 21]Passed
normal control 1[2031, 3, 21][2031, 3, 21]Passed
normal control 2[2024, 3, 13][2024, 3, 13]Passed

SHA-256 / 5cf8a421a3dd94b9045cc63732a2277c7be09695e4bf4d782b74b742decac770

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

Case digest / 4a547f2a87554cded586364c7c10584a1ed2767e634f1a20116f37ad3c300798