{"abstract":"Multi-contract trades are undercharged.","category":"Options payoff and settlement","checks":8,"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].","contract_signature":"trades, multiplier, fee","evaluation_group":"w2-options_payoff_and_settlement-fifo-option-pnl","failed_approach":"Multiplying by the contract multiplier charges per share instead of per contract.","family":"w2-options_payoff_and_settlement-fifo-option-pnl-fee-basis","id":"FA-61676","implementations":{"attempt":{"sha256":"5da06aa80c7a2e3b0f54ccb53fe4ef81e3027dbd2bf63f2691dac88f68a6cf4b","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport collections\nN = 1\nobservations = []\ndef solve(trades, multiplier, fee):\n    lots = collections.deque()\n    realized = 0\n    fees = 0\n    fee_c = round(fee * 100)\n    for side, qty, price in trades:\n        p = round(price * 100)\n        sgn = 1 if side == 'B' else -1\n        fees += qty * fee_c * multiplier // 100\n        left = qty\n        while left and lots and (lots[0][0] > 0) != (sgn > 0):\n            lot = lots[0]\n            m = min(left, abs(lot[0]))\n            direction = 1 if lot[0] > 0 else -1\n            realized += (p - lot[1]) * m * direction\n            lot[0] -= m * direction\n            left -= m\n            if lot[0] == 0:\n                lots.popleft()\n        if left:\n            lots.append([sgn * left, p])\n    pos = sum(l[0] for l in lots)\n    return [pos, realized * multiplier / 100, fees / 100]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['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]]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"26bfd292ecaad5af445a818abef0c3ff2d251b26f9b98cc96f1574cac8063d7b","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport collections\nN = 1\nobservations = []\ndef solve(trades, multiplier, fee):\n    lots = collections.deque()\n    realized = 0\n    fees = 0\n    fee_c = round(fee * 100)\n    for side, qty, price in trades:\n        p = round(price * 100)\n        sgn = 1 if side == 'B' else -1\n        fees += fee_c\n        left = qty\n        while left and lots and (lots[0][0] > 0) != (sgn > 0):\n            lot = lots[0]\n            m = min(left, abs(lot[0]))\n            direction = 1 if lot[0] > 0 else -1\n            realized += (p - lot[1]) * m * direction\n            lot[0] -= m * direction\n            left -= m\n            if lot[0] == 0:\n                lots.popleft()\n        if left:\n            lots.append([sgn * left, p])\n    pos = sum(l[0] for l in lots)\n    return [pos, realized * multiplier / 100, fees / 100]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['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]]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-options_payoff_and_settlement-fifo-option-pnl-fee-basis","generated_at":"2026-09-29T14:46:57.450720+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Option expiry, exercise and settlement engines move cash and shares; a wrong branch misstates obligations.","root_cause":"The fee is added per trade instead of per contract.","sha256":"b4b2764f91f3596c0fcf2f8846d58c1505144c700cbe509f38a9a0ee13017880","title":"FIFO realized P&L for option trades: fees are charged once per trade · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":40.767,"exit_code":1,"observations":[{"actual":[-1,-405.0,1.95],"check":"regression fee basis 1","expected":[-1,-405.0,1.95],"passed":true},{"actual":[-6,0.0,0.6],"check":"regression fee basis 2","expected":[-6,0.0,6.0],"passed":false},{"actual":[0,3.5,0.12],"check":"partial repair probe 1","expected":[0,3.5,1.3],"passed":false},{"actual":[-2,0.0,0.12],"check":"partial repair probe 2","expected":[-2,0.0,1.3],"passed":false},{"actual":[0,100.0,2.0],"check":"boundary control 1","expected":[0,100.0,2.0],"passed":true},{"actual":[-1,50.0,0.0],"check":"boundary control 2","expected":[-1,50.0,0.0],"passed":true},{"actual":[7,-425.0,0.0],"check":"normal control 1","expected":[7,-425.0,0.0],"passed":true},{"actual":[2,0.0,0.0],"check":"normal control 2","expected":[2,0.0,0.0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression fee basis 1\", \"actual\": [-1, -405.0, 1.95], \"expected\": [-1, -405.0, 1.95], \"passed\": true}, {\"check\": \"regression fee basis 2\", \"actual\": [-6, 0.0, 0.6], \"expected\": [-6, 0.0, 6.0], \"passed\": false}, {\"check\": \"partial repair probe 1\", \"actual\": [0, 3.5, 0.12], \"expected\": [0, 3.5, 1.3], \"passed\": false}, {\"check\": \"partial repair probe 2\", \"actual\": [-2, 0.0, 0.12], \"expected\": [-2, 0.0, 1.3], \"passed\": false}, {\"check\": \"boundary control 1\", \"actual\": [0, 100.0, 2.0], \"expected\": [0, 100.0, 2.0], \"passed\": true}, {\"check\": \"boundary control 2\", \"actual\": [-1, 50.0, 0.0], \"expected\": [-1, 50.0, 0.0], \"passed\": true}, {\"check\": \"normal control 1\", \"actual\": [7, -425.0, 0.0], \"expected\": [7, -425.0, 0.0], \"passed\": true}, {\"check\": \"normal control 2\", \"actual\": [2, 0.0, 0.0], \"expected\": [2, 0.0, 0.0], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.891,"exit_code":1,"observations":[{"actual":[-1,-405.0,1.3],"check":"regression fee basis 1","expected":[-1,-405.0,1.95],"passed":false},{"actual":[-6,0.0,3.0],"check":"regression fee basis 2","expected":[-6,0.0,6.0],"passed":false},{"actual":[0,3.5,1.3],"check":"partial repair probe 1","expected":[0,3.5,1.3],"passed":true},{"actual":[-2,0.0,1.3],"check":"partial repair probe 2","expected":[-2,0.0,1.3],"passed":true},{"actual":[0,100.0,2.0],"check":"boundary control 1","expected":[0,100.0,2.0],"passed":true},{"actual":[-1,50.0,0.0],"check":"boundary control 2","expected":[-1,50.0,0.0],"passed":true},{"actual":[7,-425.0,0.0],"check":"normal control 1","expected":[7,-425.0,0.0],"passed":true},{"actual":[2,0.0,0.0],"check":"normal control 2","expected":[2,0.0,0.0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression fee basis 1\", \"actual\": [-1, -405.0, 1.3], \"expected\": [-1, -405.0, 1.95], \"passed\": false}, {\"check\": \"regression fee basis 2\", \"actual\": [-6, 0.0, 3.0], \"expected\": [-6, 0.0, 6.0], \"passed\": false}, {\"check\": \"partial repair probe 1\", \"actual\": [0, 3.5, 1.3], \"expected\": [0, 3.5, 1.3], \"passed\": true}, {\"check\": \"partial repair probe 2\", \"actual\": [-2, 0.0, 1.3], \"expected\": [-2, 0.0, 1.3], \"passed\": true}, {\"check\": \"boundary control 1\", \"actual\": [0, 100.0, 2.0], \"expected\": [0, 100.0, 2.0], \"passed\": true}, {\"check\": \"boundary control 2\", \"actual\": [-1, 50.0, 0.0], \"expected\": [-1, 50.0, 0.0], \"passed\": true}, {\"check\": \"normal control 1\", \"actual\": [7, -425.0, 0.0], \"expected\": [7, -425.0, 0.0], \"passed\": true}, {\"check\": \"normal control 2\", \"actual\": [2, 0.0, 0.0], \"expected\": [2, 0.0, 0.0], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}