FA-61676 / Options payoff and settlement / Open access
FIFO realized P&L for option trades: fees are charged once per trade · case 01
Multi-contract trades are undercharged.
ROOT CAUSE
The fee is added per trade instead of per contract.
VERIFIED REPAIR
Charge the fee for every contract traded.
Unsuccessful approach: Multiplying by the contract multiplier charges per share instead of per contract.
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 += 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 fee basis 1', [[['S', 2, 0.05], ['B', 1, 4.1]], 100, 0.65], [-1, -405.0, 1.95]], ['regression fee basis 2', [[['S', 2, 0.85], ['S', 1, 1.2], ['S', 3, 2.05]], 10, 1.0], [-6, 0.0, 6.0]], ['partial repair probe 1', [[['S', 1, 1.2], ['B', 1, 0.85]], 10, 0.65], [0, 3.5, 1.3]], ['partial repair probe 2', [[['S', 1, 1.2], ['S', 1, 4.1]], 10, 0.65], [-2, 0.0, 1.3]], ['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', 1, 0.85], ['B', 3, 3.5], ['B', 5, 0.05], ['S', 2, 0.05]], 100, 0.0], [7, -425.0, 0.0]], ['normal control 2', [[['B', 2, 1.2]], 10, 0.0], [2, 0.0, 0.0]]], [['regression fee basis 1', [[['B', 1, 1.2], ['B', 5, 3.5]], 100, 0.65], [6, 0.0, 3.9]], ['regression fee basis 2', [[['S', 3, 0.85], ['B', 3, 4.1], ['S', 1, 1.2], ['S', 1, 3.5]], 10, 0.65], [-2, -97.5, 5.2]], ['partial repair probe 1', [[['S', 1, 1.2], ['S', 1, 2.05]], 10, 0.65], [-2, 0.0, 1.3]], ['partial repair probe 2', [[['S', 1, 4.1]], 10, 1.0], [-1, 0.0, 1.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, 0.05], ['S', 1, 1.2], ['B', 2, 4.1], ['S', 5, 2.05], ['S', 5, 0.05], ['S', 3, 0.05]], 10, 0.0], [-11, -29.5, 0.0]], ['normal control 2', [[['B', 1, 1.2]], 10, 0.0], [1, 0.0, 0.0]]], [['regression fee basis 1', [[['S', 2, 0.85], ['B', 2, 0.05]], 100, 1.0], [0, 160.0, 4.0]], ['regression fee basis 2', [[['S', 5, 2.05], ['S', 1, 2.05], ['B', 2, 4.1], ['B', 3, 0.85], ['B', 2, 3.5], ['S', 5, 2.05]], 100, 0.65], [-4, -340.0, 11.7]], ['partial repair probe 1', [[['S', 1, 4.1]], 10, 1.0], [-1, 0.0, 1.0]], ['partial repair probe 2', [[['B', 1, 2.05]], 10, 1.0], [1, 0.0, 1.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', 3, 2.05], ['B', 5, 4.1], ['B', 1, 1.2], ['B', 3, 0.05], ['B', 1, 1.2]], 100, 0.0], [13, 0.0, 0.0]], ['normal control 2', [[['B', 2, 1.2], ['B', 1, 3.5], ['B', 3, 2.05], ['B', 2, 0.85], ['S', 3, 1.2], ['S', 2, 4.1]], 100, 0.0], [3, 180.0, 0.0]]], [['regression fee basis 1', [[['S', 3, 0.85], ['S', 5, 0.05], ['S', 3, 1.2], ['S', 2, 0.85], ['B', 1, 0.85]], 100, 1.0], [-12, 0.0, 14.0]], ['regression fee basis 2', [[['S', 2, 1.2]], 10, 0.65], [-2, 0.0, 1.3]], ['partial repair probe 1', [[['S', 1, 1.2]], 10, 0.65], [-1, 0.0, 0.65]], ['partial repair probe 2', [[['B', 1, 3.5], ['S', 1, 2.05]], 10, 0.65], [0, -14.5, 1.3]], ['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', 5, 3.5], ['S', 5, 0.85], ['B', 2, 0.85]], 100, 0.0], [2, -1325.0, 0.0]], ['normal control 2', [[['S', 1, 1.2], ['B', 5, 3.5], ['B', 3, 0.85], ['S', 5, 4.1]], 10, 0.0], [2, 33.5, 0.0]]], [['regression fee basis 1', [[['S', 1, 3.5], ['S', 2, 1.2], ['B', 3, 0.85]], 10, 1.0], [0, 33.5, 6.0]], ['regression fee basis 2', [[['B', 5, 0.05], ['S', 5, 1.2], ['S', 2, 1.2], ['S', 1, 4.1], ['S', 1, 0.85], ['S', 3, 0.85]], 100, 1.0], [-7, 575.0, 17.0]], ['partial repair probe 1', [[['B', 1, 0.85]], 10, 0.65], [1, 0.0, 0.65]], ['partial repair probe 2', [[['S', 1, 4.1]], 10, 0.65], [-1, 0.0, 0.65]], ['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', [[['S', 3, 0.85], ['S', 3, 3.5]], 10, 0.0], [-6, 0.0, 0.0]], ['normal control 2', [[['B', 3, 4.1], ['S', 3, 2.05], ['B', 5, 2.05], ['S', 1, 4.1]], 100, 0.0], [4, -410.0, 0.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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression fee basis 1 | [-1, -405.0, 1.3] | [-1, -405.0, 1.95] | Failed |
| regression fee basis 2 | [-6, 0.0, 3.0] | [-6, 0.0, 6.0] | Failed |
| partial repair probe 1 | [0, 3.5, 1.3] | [0, 3.5, 1.3] | Passed |
| partial repair probe 2 | [-2, 0.0, 1.3] | [-2, 0.0, 1.3] | 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 | [7, -425.0, 0.0] | [7, -425.0, 0.0] | Passed |
| normal control 2 | [2, 0.0, 0.0] | [2, 0.0, 0.0] | Passed |
SHA-256 / 26bfd292ecaad5af445a818abef0c3ff2d251b26f9b98cc96f1574cac8063d7b
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 * multiplier // 100
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 fee basis 1', [[['S', 2, 0.05], ['B', 1, 4.1]], 100, 0.65], [-1, -405.0, 1.95]], ['regression fee basis 2', [[['S', 2, 0.85], ['S', 1, 1.2], ['S', 3, 2.05]], 10, 1.0], [-6, 0.0, 6.0]], ['partial repair probe 1', [[['S', 1, 1.2], ['B', 1, 0.85]], 10, 0.65], [0, 3.5, 1.3]], ['partial repair probe 2', [[['S', 1, 1.2], ['S', 1, 4.1]], 10, 0.65], [-2, 0.0, 1.3]], ['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', 1, 0.85], ['B', 3, 3.5], ['B', 5, 0.05], ['S', 2, 0.05]], 100, 0.0], [7, -425.0, 0.0]], ['normal control 2', [[['B', 2, 1.2]], 10, 0.0], [2, 0.0, 0.0]]], [['regression fee basis 1', [[['B', 1, 1.2], ['B', 5, 3.5]], 100, 0.65], [6, 0.0, 3.9]], ['regression fee basis 2', [[['S', 3, 0.85], ['B', 3, 4.1], ['S', 1, 1.2], ['S', 1, 3.5]], 10, 0.65], [-2, -97.5, 5.2]], ['partial repair probe 1', [[['S', 1, 1.2], ['S', 1, 2.05]], 10, 0.65], [-2, 0.0, 1.3]], ['partial repair probe 2', [[['S', 1, 4.1]], 10, 1.0], [-1, 0.0, 1.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, 0.05], ['S', 1, 1.2], ['B', 2, 4.1], ['S', 5, 2.05], ['S', 5, 0.05], ['S', 3, 0.05]], 10, 0.0], [-11, -29.5, 0.0]], ['normal control 2', [[['B', 1, 1.2]], 10, 0.0], [1, 0.0, 0.0]]], [['regression fee basis 1', [[['S', 2, 0.85], ['B', 2, 0.05]], 100, 1.0], [0, 160.0, 4.0]], ['regression fee basis 2', [[['S', 5, 2.05], ['S', 1, 2.05], ['B', 2, 4.1], ['B', 3, 0.85], ['B', 2, 3.5], ['S', 5, 2.05]], 100, 0.65], [-4, -340.0, 11.7]], ['partial repair probe 1', [[['S', 1, 4.1]], 10, 1.0], [-1, 0.0, 1.0]], ['partial repair probe 2', [[['B', 1, 2.05]], 10, 1.0], [1, 0.0, 1.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', 3, 2.05], ['B', 5, 4.1], ['B', 1, 1.2], ['B', 3, 0.05], ['B', 1, 1.2]], 100, 0.0], [13, 0.0, 0.0]], ['normal control 2', [[['B', 2, 1.2], ['B', 1, 3.5], ['B', 3, 2.05], ['B', 2, 0.85], ['S', 3, 1.2], ['S', 2, 4.1]], 100, 0.0], [3, 180.0, 0.0]]], [['regression fee basis 1', [[['S', 3, 0.85], ['S', 5, 0.05], ['S', 3, 1.2], ['S', 2, 0.85], ['B', 1, 0.85]], 100, 1.0], [-12, 0.0, 14.0]], ['regression fee basis 2', [[['S', 2, 1.2]], 10, 0.65], [-2, 0.0, 1.3]], ['partial repair probe 1', [[['S', 1, 1.2]], 10, 0.65], [-1, 0.0, 0.65]], ['partial repair probe 2', [[['B', 1, 3.5], ['S', 1, 2.05]], 10, 0.65], [0, -14.5, 1.3]], ['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', 5, 3.5], ['S', 5, 0.85], ['B', 2, 0.85]], 100, 0.0], [2, -1325.0, 0.0]], ['normal control 2', [[['S', 1, 1.2], ['B', 5, 3.5], ['B', 3, 0.85], ['S', 5, 4.1]], 10, 0.0], [2, 33.5, 0.0]]], [['regression fee basis 1', [[['S', 1, 3.5], ['S', 2, 1.2], ['B', 3, 0.85]], 10, 1.0], [0, 33.5, 6.0]], ['regression fee basis 2', [[['B', 5, 0.05], ['S', 5, 1.2], ['S', 2, 1.2], ['S', 1, 4.1], ['S', 1, 0.85], ['S', 3, 0.85]], 100, 1.0], [-7, 575.0, 17.0]], ['partial repair probe 1', [[['B', 1, 0.85]], 10, 0.65], [1, 0.0, 0.65]], ['partial repair probe 2', [[['S', 1, 4.1]], 10, 0.65], [-1, 0.0, 0.65]], ['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', [[['S', 3, 0.85], ['S', 3, 3.5]], 10, 0.0], [-6, 0.0, 0.0]], ['normal control 2', [[['B', 3, 4.1], ['S', 3, 2.05], ['B', 5, 2.05], ['S', 1, 4.1]], 100, 0.0], [4, -410.0, 0.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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression fee basis 1 | [-1, -405.0, 1.95] | [-1, -405.0, 1.95] | Passed |
| regression fee basis 2 | [-6, 0.0, 0.6] | [-6, 0.0, 6.0] | Failed |
| partial repair probe 1 | [0, 3.5, 0.12] | [0, 3.5, 1.3] | Failed |
| partial repair probe 2 | [-2, 0.0, 0.12] | [-2, 0.0, 1.3] | 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 | [7, -425.0, 0.0] | [7, -425.0, 0.0] | Passed |
| normal control 2 | [2, 0.0, 0.0] | [2, 0.0, 0.0] | Passed |
SHA-256 / 5da06aa80c7a2e3b0f54ccb53fe4ef81e3027dbd2bf63f2691dac88f68a6cf4b
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 fee basis 1', [[['S', 2, 0.05], ['B', 1, 4.1]], 100, 0.65], [-1, -405.0, 1.95]], ['regression fee basis 2', [[['S', 2, 0.85], ['S', 1, 1.2], ['S', 3, 2.05]], 10, 1.0], [-6, 0.0, 6.0]], ['partial repair probe 1', [[['S', 1, 1.2], ['B', 1, 0.85]], 10, 0.65], [0, 3.5, 1.3]], ['partial repair probe 2', [[['S', 1, 1.2], ['S', 1, 4.1]], 10, 0.65], [-2, 0.0, 1.3]], ['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', 1, 0.85], ['B', 3, 3.5], ['B', 5, 0.05], ['S', 2, 0.05]], 100, 0.0], [7, -425.0, 0.0]], ['normal control 2', [[['B', 2, 1.2]], 10, 0.0], [2, 0.0, 0.0]]], [['regression fee basis 1', [[['B', 1, 1.2], ['B', 5, 3.5]], 100, 0.65], [6, 0.0, 3.9]], ['regression fee basis 2', [[['S', 3, 0.85], ['B', 3, 4.1], ['S', 1, 1.2], ['S', 1, 3.5]], 10, 0.65], [-2, -97.5, 5.2]], ['partial repair probe 1', [[['S', 1, 1.2], ['S', 1, 2.05]], 10, 0.65], [-2, 0.0, 1.3]], ['partial repair probe 2', [[['S', 1, 4.1]], 10, 1.0], [-1, 0.0, 1.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, 0.05], ['S', 1, 1.2], ['B', 2, 4.1], ['S', 5, 2.05], ['S', 5, 0.05], ['S', 3, 0.05]], 10, 0.0], [-11, -29.5, 0.0]], ['normal control 2', [[['B', 1, 1.2]], 10, 0.0], [1, 0.0, 0.0]]], [['regression fee basis 1', [[['S', 2, 0.85], ['B', 2, 0.05]], 100, 1.0], [0, 160.0, 4.0]], ['regression fee basis 2', [[['S', 5, 2.05], ['S', 1, 2.05], ['B', 2, 4.1], ['B', 3, 0.85], ['B', 2, 3.5], ['S', 5, 2.05]], 100, 0.65], [-4, -340.0, 11.7]], ['partial repair probe 1', [[['S', 1, 4.1]], 10, 1.0], [-1, 0.0, 1.0]], ['partial repair probe 2', [[['B', 1, 2.05]], 10, 1.0], [1, 0.0, 1.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', 3, 2.05], ['B', 5, 4.1], ['B', 1, 1.2], ['B', 3, 0.05], ['B', 1, 1.2]], 100, 0.0], [13, 0.0, 0.0]], ['normal control 2', [[['B', 2, 1.2], ['B', 1, 3.5], ['B', 3, 2.05], ['B', 2, 0.85], ['S', 3, 1.2], ['S', 2, 4.1]], 100, 0.0], [3, 180.0, 0.0]]], [['regression fee basis 1', [[['S', 3, 0.85], ['S', 5, 0.05], ['S', 3, 1.2], ['S', 2, 0.85], ['B', 1, 0.85]], 100, 1.0], [-12, 0.0, 14.0]], ['regression fee basis 2', [[['S', 2, 1.2]], 10, 0.65], [-2, 0.0, 1.3]], ['partial repair probe 1', [[['S', 1, 1.2]], 10, 0.65], [-1, 0.0, 0.65]], ['partial repair probe 2', [[['B', 1, 3.5], ['S', 1, 2.05]], 10, 0.65], [0, -14.5, 1.3]], ['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', 5, 3.5], ['S', 5, 0.85], ['B', 2, 0.85]], 100, 0.0], [2, -1325.0, 0.0]], ['normal control 2', [[['S', 1, 1.2], ['B', 5, 3.5], ['B', 3, 0.85], ['S', 5, 4.1]], 10, 0.0], [2, 33.5, 0.0]]], [['regression fee basis 1', [[['S', 1, 3.5], ['S', 2, 1.2], ['B', 3, 0.85]], 10, 1.0], [0, 33.5, 6.0]], ['regression fee basis 2', [[['B', 5, 0.05], ['S', 5, 1.2], ['S', 2, 1.2], ['S', 1, 4.1], ['S', 1, 0.85], ['S', 3, 0.85]], 100, 1.0], [-7, 575.0, 17.0]], ['partial repair probe 1', [[['B', 1, 0.85]], 10, 0.65], [1, 0.0, 0.65]], ['partial repair probe 2', [[['S', 1, 4.1]], 10, 0.65], [-1, 0.0, 0.65]], ['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', [[['S', 3, 0.85], ['S', 3, 3.5]], 10, 0.0], [-6, 0.0, 0.0]], ['normal control 2', [[['B', 3, 4.1], ['S', 3, 2.05], ['B', 5, 2.05], ['S', 1, 4.1]], 100, 0.0], [4, -410.0, 0.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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression fee basis 1 | [-1, -405.0, 1.95] | [-1, -405.0, 1.95] | Passed |
| regression fee basis 2 | [-6, 0.0, 6.0] | [-6, 0.0, 6.0] | Passed |
| partial repair probe 1 | [0, 3.5, 1.3] | [0, 3.5, 1.3] | Passed |
| partial repair probe 2 | [-2, 0.0, 1.3] | [-2, 0.0, 1.3] | 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 | [7, -425.0, 0.0] | [7, -425.0, 0.0] | Passed |
| normal control 2 | [2, 0.0, 0.0] | [2, 0.0, 0.0] | Passed |
SHA-256 / 819b9a88bba248395ffc25944d653487eb5a9c9211e09b14c557e322d0d8c54e
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.450720+00:00.
Case digest / e0f9b1e7e36a79f4e64eb70e122d6116aafa487b855b473361bf7fab12842038