FAILURE MAP
← Case archive

FA-61666 / Options payoff and settlement / Open access

FIFO realized P&L for option trades: closing trades match the newest lot · case 01

Realized P&L follows LIFO instead of FIFO.

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

ROOT CAUSE

The matcher reads and removes lots from the right end.

VERIFIED REPAIR

Match and remove from the oldest lot first.

Unsuccessful approach: Matching the oldest lot but popping from the newest end discards an unmatched lot.

Case contract

Inputs trades [side B/S, contracts, premium], multiplier and fee per contract. Positions may be long or short. Each trade first closes opposite-direction lots oldest first; realized P&L per matched contract is (close - open) for long lots and (open - close) for short lots, times the multiplier. Any remainder opens a new lot in the trade direction. Fees = contracts traded * fee. Work in cents; return [net position, realized, fees].

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 collections
N = 1
observations = []
def solve(trades, multiplier, fee):
    lots = collections.deque()
    realized = 0
    fees = 0
    fee_c = round(fee * 100)
    for side, qty, price in trades:
        p = round(price * 100)
        sgn = 1 if side == 'B' else -1
        fees += qty * fee_c
        left = qty
        while left and lots and (lots[0][0] > 0) != (sgn > 0):
            lot = lots[-1]
            m = min(left, abs(lot[0]))
            direction = 1 if lot[0] > 0 else -1
            realized += (p - lot[1]) * m * direction
            lot[0] -= m * direction
            left -= m
            if lot[0] == 0:
                lots.pop()
        if left:
            lots.append([sgn * left, p])
    pos = sum(l[0] for l in lots)
    return [pos, realized * multiplier / 100, fees / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression lot matching order 1', [[['B', 5, 3.5], ['B', 2, 1.2], ['S', 2, 0.85], ['S', 2, 2.05], ['B', 3, 2.05]], 100, 1.0], [6, -820.0, 14.0]], ['regression lot matching order 2', [[['B', 2, 0.05], ['B', 3, 0.05], ['B', 2, 4.1], ['B', 3, 2.05], ['S', 5, 2.05], ['S', 2, 1.2]], 10, 0.0], [3, 42.0, 0.0]], ['partial repair probe 1', [[['S', 3, 0.85], ['B', 5, 0.05], ['S', 1, 0.85], ['B', 1, 0.05], ['S', 5, 0.05], ['B', 1, 4.1]], 100, 0.65], [-2, -85.0, 10.4]], ['partial repair probe 2', [[['S', 5, 1.2], ['B', 3, 0.85], ['S', 3, 0.85], ['B', 1, 2.05], ['B', 2, 1.2], ['B', 5, 1.2]], 10, 1.0], [3, -8.5, 19.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['S', 5, 1.2], ['S', 2, 1.2], ['S', 2, 3.5]], 100, 0.0], [-9, 0.0, 0.0]], ['normal control 2', [[['B', 5, 0.85], ['S', 1, 0.05]], 100, 1.0], [4, -80.0, 6.0]]], [['regression lot matching order 1', [[['S', 3, 4.1], ['B', 2, 0.85], ['S', 2, 1.2], ['B', 1, 2.05], ['S', 3, 3.5]], 10, 1.0], [-5, 85.5, 11.0]], ['regression lot matching order 2', [[['B', 2, 0.85], ['S', 5, 0.05], ['S', 5, 0.85], ['B', 1, 1.2]], 10, 0.0], [-7, -27.5, 0.0]], ['partial repair probe 1', [[['S', 3, 4.1], ['B', 1, 3.5], ['S', 2, 4.1], ['B', 5, 4.1], ['B', 3, 1.2], ['S', 5, 0.85]], 10, 1.0], [-1, -37.0, 19.0]], ['partial repair probe 2', [[['S', 1, 3.5], ['S', 1, 0.05], ['S', 2, 3.5], ['B', 5, 4.1], ['S', 1, 1.2]], 100, 1.0], [0, -875.0, 10.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['B', 3, 2.05], ['B', 3, 2.05], ['B', 3, 2.05], ['B', 2, 3.5]], 10, 0.65], [11, 0.0, 7.15]], ['normal control 2', [[['S', 2, 3.5], ['B', 3, 0.05], ['S', 1, 1.2]], 100, 0.65], [0, 805.0, 3.9]]], [['regression lot matching order 1', [[['S', 5, 4.1], ['S', 2, 3.5], ['B', 2, 2.05]], 10, 0.65], [-5, 41.0, 5.85]], ['regression lot matching order 2', [[['B', 1, 0.05], ['B', 3, 3.5], ['S', 5, 1.2], ['S', 2, 0.05], ['B', 2, 0.05]], 10, 0.0], [-1, -46.0, 0.0]], ['partial repair probe 1', [[['S', 1, 3.5], ['S', 5, 2.05], ['B', 1, 4.1], ['S', 1, 3.5], ['B', 1, 0.05]], 100, 0.65], [-5, 140.0, 5.85]], ['partial repair probe 2', [[['B', 2, 3.5], ['B', 3, 2.05], ['S', 1, 1.2], ['S', 5, 1.2], ['S', 3, 0.05]], 100, 1.0], [-4, -715.0, 14.0]], ['boundary control 1', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['boundary control 2', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['normal control 1', [[['B', 1, 2.05], ['S', 5, 3.5]], 100, 1.0], [-4, 145.0, 6.0]], ['normal control 2', [[['S', 1, 1.2], ['B', 2, 3.5]], 10, 0.0], [1, -23.0, 0.0]]], [['regression lot matching order 1', [[['S', 2, 4.1], ['S', 5, 1.2], ['B', 1, 0.05], ['B', 3, 1.2], ['S', 5, 0.05], ['B', 5, 4.1]], 100, 0.65], [-3, -985.0, 13.65]], ['regression lot matching order 2', [[['B', 2, 0.05], ['B', 2, 2.05], ['B', 2, 0.85], ['S', 5, 2.05]], 100, 0.65], [1, 520.0, 7.15]], ['partial repair probe 1', [[['S', 2, 0.85], ['S', 1, 1.2], ['B', 3, 3.5]], 10, 0.0], [0, -76.0, 0.0]], ['partial repair probe 2', [[['S', 2, 1.2], ['B', 3, 1.2], ['B', 1, 4.1], ['B', 2, 1.2], ['S', 1, 4.1], ['B', 5, 4.1]], 100, 1.0], [8, 290.0, 14.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['B', 3, 4.1], ['S', 3, 3.5], ['S', 5, 0.05]], 10, 1.0], [-5, -18.0, 11.0]], ['normal control 2', [[['B', 5, 0.05], ['B', 2, 2.05], ['B', 2, 1.2], ['B', 2, 3.5], ['B', 1, 4.1]], 10, 1.0], [12, 0.0, 12.0]]], [['regression lot matching order 1', [[['B', 3, 1.2], ['B', 5, 4.1], ['S', 5, 1.2], ['B', 5, 4.1], ['B', 1, 3.5], ['S', 3, 1.2]], 100, 0.0], [6, -1450.0, 0.0]], ['regression lot matching order 2', [[['S', 5, 2.05], ['B', 1, 4.1], ['B', 2, 4.1], ['B', 3, 1.2], ['B', 1, 4.1], ['S', 1, 0.85]], 100, 0.65], [1, -480.0, 8.45]], ['partial repair probe 1', [[['B', 1, 0.85], ['B', 1, 3.5], ['S', 3, 4.1], ['B', 3, 3.5]], 100, 0.0], [2, 445.0, 0.0]], ['partial repair probe 2', [[['S', 3, 0.05], ['B', 5, 0.85], ['S', 3, 2.05], ['S', 2, 1.2], ['B', 5, 0.85], ['B', 2, 4.1]], 100, 1.0], [4, 190.0, 20.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['S', 5, 4.1]], 10, 0.0], [-5, 0.0, 0.0]], ['normal control 2', [[['S', 1, 3.5], ['B', 5, 2.05]], 100, 1.0], [4, 145.0, 6.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 lot matching order 1[6, -360.0, 14.0][6, -820.0, 14.0]Failed
regression lot matching order 2[3, -18.0, 0.0][3, 42.0, 0.0]Failed
partial repair probe 1[-2, -85.0, 10.4][-2, -85.0, 10.4]Passed
partial repair probe 2[3, -8.5, 19.0][3, -8.5, 19.0]Passed
boundary control 1[0, 100.0, 2.0][0, 100.0, 2.0]Passed
boundary control 2[-1, 50.0, 0.0][-1, 50.0, 0.0]Passed
normal control 1[-9, 0.0, 0.0][-9, 0.0, 0.0]Passed
normal control 2[4, -80.0, 6.0][4, -80.0, 6.0]Passed

SHA-256 / 6fd11bc45a58f79ad14cb2f94feaaa36e220dc6aa870214321e5c799a8394732

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(trades, multiplier, fee):
    lots = collections.deque()
    realized = 0
    fees = 0
    fee_c = round(fee * 100)
    for side, qty, price in trades:
        p = round(price * 100)
        sgn = 1 if side == 'B' else -1
        fees += qty * fee_c
        left = qty
        while left and lots and (lots[0][0] > 0) != (sgn > 0):
            lot = lots[0]
            m = min(left, abs(lot[0]))
            direction = 1 if lot[0] > 0 else -1
            realized += (p - lot[1]) * m * direction
            lot[0] -= m * direction
            left -= m
            if lot[0] == 0:
                lots.pop()
        if left:
            lots.append([sgn * left, p])
    pos = sum(l[0] for l in lots)
    return [pos, realized * multiplier / 100, fees / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression lot matching order 1', [[['B', 5, 3.5], ['B', 2, 1.2], ['S', 2, 0.85], ['S', 2, 2.05], ['B', 3, 2.05]], 100, 1.0], [6, -820.0, 14.0]], ['regression lot matching order 2', [[['B', 2, 0.05], ['B', 3, 0.05], ['B', 2, 4.1], ['B', 3, 2.05], ['S', 5, 2.05], ['S', 2, 1.2]], 10, 0.0], [3, 42.0, 0.0]], ['partial repair probe 1', [[['S', 3, 0.85], ['B', 5, 0.05], ['S', 1, 0.85], ['B', 1, 0.05], ['S', 5, 0.05], ['B', 1, 4.1]], 100, 0.65], [-2, -85.0, 10.4]], ['partial repair probe 2', [[['S', 5, 1.2], ['B', 3, 0.85], ['S', 3, 0.85], ['B', 1, 2.05], ['B', 2, 1.2], ['B', 5, 1.2]], 10, 1.0], [3, -8.5, 19.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['S', 5, 1.2], ['S', 2, 1.2], ['S', 2, 3.5]], 100, 0.0], [-9, 0.0, 0.0]], ['normal control 2', [[['B', 5, 0.85], ['S', 1, 0.05]], 100, 1.0], [4, -80.0, 6.0]]], [['regression lot matching order 1', [[['S', 3, 4.1], ['B', 2, 0.85], ['S', 2, 1.2], ['B', 1, 2.05], ['S', 3, 3.5]], 10, 1.0], [-5, 85.5, 11.0]], ['regression lot matching order 2', [[['B', 2, 0.85], ['S', 5, 0.05], ['S', 5, 0.85], ['B', 1, 1.2]], 10, 0.0], [-7, -27.5, 0.0]], ['partial repair probe 1', [[['S', 3, 4.1], ['B', 1, 3.5], ['S', 2, 4.1], ['B', 5, 4.1], ['B', 3, 1.2], ['S', 5, 0.85]], 10, 1.0], [-1, -37.0, 19.0]], ['partial repair probe 2', [[['S', 1, 3.5], ['S', 1, 0.05], ['S', 2, 3.5], ['B', 5, 4.1], ['S', 1, 1.2]], 100, 1.0], [0, -875.0, 10.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['B', 3, 2.05], ['B', 3, 2.05], ['B', 3, 2.05], ['B', 2, 3.5]], 10, 0.65], [11, 0.0, 7.15]], ['normal control 2', [[['S', 2, 3.5], ['B', 3, 0.05], ['S', 1, 1.2]], 100, 0.65], [0, 805.0, 3.9]]], [['regression lot matching order 1', [[['S', 5, 4.1], ['S', 2, 3.5], ['B', 2, 2.05]], 10, 0.65], [-5, 41.0, 5.85]], ['regression lot matching order 2', [[['B', 1, 0.05], ['B', 3, 3.5], ['S', 5, 1.2], ['S', 2, 0.05], ['B', 2, 0.05]], 10, 0.0], [-1, -46.0, 0.0]], ['partial repair probe 1', [[['S', 1, 3.5], ['S', 5, 2.05], ['B', 1, 4.1], ['S', 1, 3.5], ['B', 1, 0.05]], 100, 0.65], [-5, 140.0, 5.85]], ['partial repair probe 2', [[['B', 2, 3.5], ['B', 3, 2.05], ['S', 1, 1.2], ['S', 5, 1.2], ['S', 3, 0.05]], 100, 1.0], [-4, -715.0, 14.0]], ['boundary control 1', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['boundary control 2', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['normal control 1', [[['B', 1, 2.05], ['S', 5, 3.5]], 100, 1.0], [-4, 145.0, 6.0]], ['normal control 2', [[['S', 1, 1.2], ['B', 2, 3.5]], 10, 0.0], [1, -23.0, 0.0]]], [['regression lot matching order 1', [[['S', 2, 4.1], ['S', 5, 1.2], ['B', 1, 0.05], ['B', 3, 1.2], ['S', 5, 0.05], ['B', 5, 4.1]], 100, 0.65], [-3, -985.0, 13.65]], ['regression lot matching order 2', [[['B', 2, 0.05], ['B', 2, 2.05], ['B', 2, 0.85], ['S', 5, 2.05]], 100, 0.65], [1, 520.0, 7.15]], ['partial repair probe 1', [[['S', 2, 0.85], ['S', 1, 1.2], ['B', 3, 3.5]], 10, 0.0], [0, -76.0, 0.0]], ['partial repair probe 2', [[['S', 2, 1.2], ['B', 3, 1.2], ['B', 1, 4.1], ['B', 2, 1.2], ['S', 1, 4.1], ['B', 5, 4.1]], 100, 1.0], [8, 290.0, 14.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['B', 3, 4.1], ['S', 3, 3.5], ['S', 5, 0.05]], 10, 1.0], [-5, -18.0, 11.0]], ['normal control 2', [[['B', 5, 0.05], ['B', 2, 2.05], ['B', 2, 1.2], ['B', 2, 3.5], ['B', 1, 4.1]], 10, 1.0], [12, 0.0, 12.0]]], [['regression lot matching order 1', [[['B', 3, 1.2], ['B', 5, 4.1], ['S', 5, 1.2], ['B', 5, 4.1], ['B', 1, 3.5], ['S', 3, 1.2]], 100, 0.0], [6, -1450.0, 0.0]], ['regression lot matching order 2', [[['S', 5, 2.05], ['B', 1, 4.1], ['B', 2, 4.1], ['B', 3, 1.2], ['B', 1, 4.1], ['S', 1, 0.85]], 100, 0.65], [1, -480.0, 8.45]], ['partial repair probe 1', [[['B', 1, 0.85], ['B', 1, 3.5], ['S', 3, 4.1], ['B', 3, 3.5]], 100, 0.0], [2, 445.0, 0.0]], ['partial repair probe 2', [[['S', 3, 0.05], ['B', 5, 0.85], ['S', 3, 2.05], ['S', 2, 1.2], ['B', 5, 0.85], ['B', 2, 4.1]], 100, 1.0], [4, 190.0, 20.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['S', 5, 4.1]], 10, 0.0], [-5, 0.0, 0.0]], ['normal control 2', [[['S', 1, 3.5], ['B', 5, 2.05]], 100, 1.0], [4, 145.0, 6.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 lot matching order 1[6, -820.0, 14.0][6, -820.0, 14.0]Passed
regression lot matching order 2[0, 40.0, 0.0][3, 42.0, 0.0]Failed
partial repair probe 1[1, 320.0, 10.4][-2, -85.0, 10.4]Failed
partial repair probe 2[6, 2.0, 19.0][3, -8.5, 19.0]Failed
boundary control 1[0, 100.0, 2.0][0, 100.0, 2.0]Passed
boundary control 2[-1, 50.0, 0.0][-1, 50.0, 0.0]Passed
normal control 1[-9, 0.0, 0.0][-9, 0.0, 0.0]Passed
normal control 2[4, -80.0, 6.0][4, -80.0, 6.0]Passed

SHA-256 / 37c2e276fa43a9117fd886e8becd722f9083dbe09a4d6a615e4e96d6ea9ae1ba

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(trades, multiplier, fee):
    lots = collections.deque()
    realized = 0
    fees = 0
    fee_c = round(fee * 100)
    for side, qty, price in trades:
        p = round(price * 100)
        sgn = 1 if side == 'B' else -1
        fees += qty * fee_c
        left = qty
        while left and lots and (lots[0][0] > 0) != (sgn > 0):
            lot = lots[0]
            m = min(left, abs(lot[0]))
            direction = 1 if lot[0] > 0 else -1
            realized += (p - lot[1]) * m * direction
            lot[0] -= m * direction
            left -= m
            if lot[0] == 0:
                lots.popleft()
        if left:
            lots.append([sgn * left, p])
    pos = sum(l[0] for l in lots)
    return [pos, realized * multiplier / 100, fees / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression lot matching order 1', [[['B', 5, 3.5], ['B', 2, 1.2], ['S', 2, 0.85], ['S', 2, 2.05], ['B', 3, 2.05]], 100, 1.0], [6, -820.0, 14.0]], ['regression lot matching order 2', [[['B', 2, 0.05], ['B', 3, 0.05], ['B', 2, 4.1], ['B', 3, 2.05], ['S', 5, 2.05], ['S', 2, 1.2]], 10, 0.0], [3, 42.0, 0.0]], ['partial repair probe 1', [[['S', 3, 0.85], ['B', 5, 0.05], ['S', 1, 0.85], ['B', 1, 0.05], ['S', 5, 0.05], ['B', 1, 4.1]], 100, 0.65], [-2, -85.0, 10.4]], ['partial repair probe 2', [[['S', 5, 1.2], ['B', 3, 0.85], ['S', 3, 0.85], ['B', 1, 2.05], ['B', 2, 1.2], ['B', 5, 1.2]], 10, 1.0], [3, -8.5, 19.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['S', 5, 1.2], ['S', 2, 1.2], ['S', 2, 3.5]], 100, 0.0], [-9, 0.0, 0.0]], ['normal control 2', [[['B', 5, 0.85], ['S', 1, 0.05]], 100, 1.0], [4, -80.0, 6.0]]], [['regression lot matching order 1', [[['S', 3, 4.1], ['B', 2, 0.85], ['S', 2, 1.2], ['B', 1, 2.05], ['S', 3, 3.5]], 10, 1.0], [-5, 85.5, 11.0]], ['regression lot matching order 2', [[['B', 2, 0.85], ['S', 5, 0.05], ['S', 5, 0.85], ['B', 1, 1.2]], 10, 0.0], [-7, -27.5, 0.0]], ['partial repair probe 1', [[['S', 3, 4.1], ['B', 1, 3.5], ['S', 2, 4.1], ['B', 5, 4.1], ['B', 3, 1.2], ['S', 5, 0.85]], 10, 1.0], [-1, -37.0, 19.0]], ['partial repair probe 2', [[['S', 1, 3.5], ['S', 1, 0.05], ['S', 2, 3.5], ['B', 5, 4.1], ['S', 1, 1.2]], 100, 1.0], [0, -875.0, 10.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['B', 3, 2.05], ['B', 3, 2.05], ['B', 3, 2.05], ['B', 2, 3.5]], 10, 0.65], [11, 0.0, 7.15]], ['normal control 2', [[['S', 2, 3.5], ['B', 3, 0.05], ['S', 1, 1.2]], 100, 0.65], [0, 805.0, 3.9]]], [['regression lot matching order 1', [[['S', 5, 4.1], ['S', 2, 3.5], ['B', 2, 2.05]], 10, 0.65], [-5, 41.0, 5.85]], ['regression lot matching order 2', [[['B', 1, 0.05], ['B', 3, 3.5], ['S', 5, 1.2], ['S', 2, 0.05], ['B', 2, 0.05]], 10, 0.0], [-1, -46.0, 0.0]], ['partial repair probe 1', [[['S', 1, 3.5], ['S', 5, 2.05], ['B', 1, 4.1], ['S', 1, 3.5], ['B', 1, 0.05]], 100, 0.65], [-5, 140.0, 5.85]], ['partial repair probe 2', [[['B', 2, 3.5], ['B', 3, 2.05], ['S', 1, 1.2], ['S', 5, 1.2], ['S', 3, 0.05]], 100, 1.0], [-4, -715.0, 14.0]], ['boundary control 1', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['boundary control 2', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['normal control 1', [[['B', 1, 2.05], ['S', 5, 3.5]], 100, 1.0], [-4, 145.0, 6.0]], ['normal control 2', [[['S', 1, 1.2], ['B', 2, 3.5]], 10, 0.0], [1, -23.0, 0.0]]], [['regression lot matching order 1', [[['S', 2, 4.1], ['S', 5, 1.2], ['B', 1, 0.05], ['B', 3, 1.2], ['S', 5, 0.05], ['B', 5, 4.1]], 100, 0.65], [-3, -985.0, 13.65]], ['regression lot matching order 2', [[['B', 2, 0.05], ['B', 2, 2.05], ['B', 2, 0.85], ['S', 5, 2.05]], 100, 0.65], [1, 520.0, 7.15]], ['partial repair probe 1', [[['S', 2, 0.85], ['S', 1, 1.2], ['B', 3, 3.5]], 10, 0.0], [0, -76.0, 0.0]], ['partial repair probe 2', [[['S', 2, 1.2], ['B', 3, 1.2], ['B', 1, 4.1], ['B', 2, 1.2], ['S', 1, 4.1], ['B', 5, 4.1]], 100, 1.0], [8, 290.0, 14.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['B', 3, 4.1], ['S', 3, 3.5], ['S', 5, 0.05]], 10, 1.0], [-5, -18.0, 11.0]], ['normal control 2', [[['B', 5, 0.05], ['B', 2, 2.05], ['B', 2, 1.2], ['B', 2, 3.5], ['B', 1, 4.1]], 10, 1.0], [12, 0.0, 12.0]]], [['regression lot matching order 1', [[['B', 3, 1.2], ['B', 5, 4.1], ['S', 5, 1.2], ['B', 5, 4.1], ['B', 1, 3.5], ['S', 3, 1.2]], 100, 0.0], [6, -1450.0, 0.0]], ['regression lot matching order 2', [[['S', 5, 2.05], ['B', 1, 4.1], ['B', 2, 4.1], ['B', 3, 1.2], ['B', 1, 4.1], ['S', 1, 0.85]], 100, 0.65], [1, -480.0, 8.45]], ['partial repair probe 1', [[['B', 1, 0.85], ['B', 1, 3.5], ['S', 3, 4.1], ['B', 3, 3.5]], 100, 0.0], [2, 445.0, 0.0]], ['partial repair probe 2', [[['S', 3, 0.05], ['B', 5, 0.85], ['S', 3, 2.05], ['S', 2, 1.2], ['B', 5, 0.85], ['B', 2, 4.1]], 100, 1.0], [4, 190.0, 20.0]], ['boundary control 1', [[['S', 1, 2.0], ['B', 1, 1.0]], 100, 1.0], [0, 100.0, 2.0]], ['boundary control 2', [[['B', 1, 1.0], ['S', 2, 1.5]], 100, 0.0], [-1, 50.0, 0.0]], ['normal control 1', [[['S', 5, 4.1]], 10, 0.0], [-5, 0.0, 0.0]], ['normal control 2', [[['S', 1, 3.5], ['B', 5, 2.05]], 100, 1.0], [4, 145.0, 6.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 lot matching order 1[6, -820.0, 14.0][6, -820.0, 14.0]Passed
regression lot matching order 2[3, 42.0, 0.0][3, 42.0, 0.0]Passed
partial repair probe 1[-2, -85.0, 10.4][-2, -85.0, 10.4]Passed
partial repair probe 2[3, -8.5, 19.0][3, -8.5, 19.0]Passed
boundary control 1[0, 100.0, 2.0][0, 100.0, 2.0]Passed
boundary control 2[-1, 50.0, 0.0][-1, 50.0, 0.0]Passed
normal control 1[-9, 0.0, 0.0][-9, 0.0, 0.0]Passed
normal control 2[4, -80.0, 6.0][4, -80.0, 6.0]Passed

SHA-256 / 4683c240ca20da3ac4ec1f57e4b7e7677bc5ea48ed85d159e925fa4d80adaa03

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

Case digest / a585b2ab6da58343b83e7d6a7a38ae201e4b38b63039c55eff7ecbd267781cc3