{"abstract":"After cashing out half the value, the remaining stake is the cashed portion or the stake minus cents.","category":"Betting odds conversion","checks":9,"contract":"Cash-out offer for a single or multiple back bet. legs rows are [price taken, current] where current is a decimal price for an open leg, \"won\" or \"lost\". Any lost leg makes the offer [0, 0]. Otherwise value = stake * product of prices taken / product of current prices of open legs, reduced by margin_pct percent, rounded down to a cent. partial_cents 0 means full cash-out: return [value, 0]. A partial amount above the value returns \"invalid\"; otherwise return [partial, remaining stake] with remaining = floor(stake * (1 - partial / value)).","contract_signature":"legs, stake_cents, margin_pct, partial_cents","evaluation_group":"w2-odds-conversion-cash-out-valuation","failed_approach":"Using the cashed proportion instead of the remaining proportion swaps the two parts.","family":"w2-odds-conversion-cash-out-valuation-partial-remaining-stake","id":"FA-84706","implementations":{"attempt":{"sha256":"3afc395fa1325b9e09aba30aacb3ba3863ce11bf274f518c0e43313ecdeeb5f8","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nimport math\nN = 1\nobservations = []\ndef solve(legs, stake_cents, margin_pct, partial_cents):\n    value = Fraction(stake_cents)\n    for price, cur in legs:\n        if cur == 'lost':\n            return [0, 0]\n        value *= Fraction(price)\n        if cur != 'won':\n            value /= Fraction(cur)\n    value = value * (100 - Fraction(margin_pct)) / 100\n    full = math.floor(value)\n    if partial_cents == 0:\n        return [full, 0]\n    if partial_cents > full:\n        return 'invalid'\n    remaining = math.floor(stake_cents * Fraction(partial_cents, full))\n    return [partial_cents, remaining]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ndef run(args):\n    try:\n        return solve(*args)\n    except Exception as exc:\n        return 'raised ' + type(exc).__name__\ncases = [[('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake', ([['2.79', 'won']], 500, '5', 800), [800, 198]),\n  ('variant scenario 1',\n   ([['1.51', 'won'], ['3.49', 'won'], ['3.39', 'lost'], ['1.99', 'won']], 500, '7.5', 0),\n   [0, 0]),\n  ('variant scenario 2',\n   ([['3.71', 'lost'], ['1.47', '4.60'], ['1.32', 'won'], ['1.57', '2.91']], 1000, '5', 200),\n   [0, 0])],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake',\n   ([['3.43', '4.22'], ['4.58', 'won'], ['2.70', 'won']], 1000, '5', 500),\n   [500, 947]),\n  ('variant scenario 1', ([['5.00', '5.10']], 500, '0', 0), [490, 0]),\n  ('variant scenario 2',\n   ([['4.09', '4.06'], ['1.44', 'lost'], ['4.51', '1.56'], ['4.68', 'won']], 1000, '0', 0),\n   [0, 0])],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake', ([['3.79', '2.66']], 1000, '7.5', 500), [500, 620]),\n  ('variant scenario 1', ([['4.71', 'won']], 1000, '0', 0), [4710, 0]),\n  ('variant scenario 2', ([['1.46', '1.60']], 500, '5', 500), 'invalid')],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake',\n   ([['3.65', 'won'], ['2.14', '1.31'], ['2.44', '2.91']], 1000, '5', 500),\n   [500, 894]),\n  ('variant scenario 1',\n   ([['3.39', 'won'], ['2.49', '5.36'], ['1.49', '4.00'], ['3.15', '5.06']], 2500, '5', 0),\n   [867, 0]),\n  ('variant scenario 2', ([['2.52', 'lost'], ['4.68', '4.00']], 1000, '5', 0), [0, 0])],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake', ([['4.93', 'won']], 2500, '5', 500), [500, 2393]),\n  ('variant scenario 1',\n   ([['3.53', '1.91'], ['3.32', 'lost'], ['1.63', 'won'], ['2.97', '4.57']], 500, '0', 500),\n   [0, 0]),\n  ('variant scenario 2', ([['2.73', 'won'], ['2.11', '4.03']], 1000, '0', 0), [1429, 0])]]\nfor label, args, expected in cases[N - 1]:\n    check(label, run(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":"3f0213d417d3bb65b230cdf24b360a97ff42082fd2ce223d80ab528dd47b6c8e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nimport math\nN = 1\nobservations = []\ndef solve(legs, stake_cents, margin_pct, partial_cents):\n    value = Fraction(stake_cents)\n    for price, cur in legs:\n        if cur == 'lost':\n            return [0, 0]\n        value *= Fraction(price)\n        if cur != 'won':\n            value /= Fraction(cur)\n    value = value * (100 - Fraction(margin_pct)) / 100\n    full = math.floor(value)\n    if partial_cents == 0:\n        return [full, 0]\n    if partial_cents > full:\n        return 'invalid'\n    remaining = stake_cents - partial_cents\n    return [partial_cents, remaining]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ndef run(args):\n    try:\n        return solve(*args)\n    except Exception as exc:\n        return 'raised ' + type(exc).__name__\ncases = [[('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake', ([['2.79', 'won']], 500, '5', 800), [800, 198]),\n  ('variant scenario 1',\n   ([['1.51', 'won'], ['3.49', 'won'], ['3.39', 'lost'], ['1.99', 'won']], 500, '7.5', 0),\n   [0, 0]),\n  ('variant scenario 2',\n   ([['3.71', 'lost'], ['1.47', '4.60'], ['1.32', 'won'], ['1.57', '2.91']], 1000, '5', 200),\n   [0, 0])],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake',\n   ([['3.43', '4.22'], ['4.58', 'won'], ['2.70', 'won']], 1000, '5', 500),\n   [500, 947]),\n  ('variant scenario 1', ([['5.00', '5.10']], 500, '0', 0), [490, 0]),\n  ('variant scenario 2',\n   ([['4.09', '4.06'], ['1.44', 'lost'], ['4.51', '1.56'], ['4.68', 'won']], 1000, '0', 0),\n   [0, 0])],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake', ([['3.79', '2.66']], 1000, '7.5', 500), [500, 620]),\n  ('variant scenario 1', ([['4.71', 'won']], 1000, '0', 0), [4710, 0]),\n  ('variant scenario 2', ([['1.46', '1.60']], 500, '5', 500), 'invalid')],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake',\n   ([['3.65', 'won'], ['2.14', '1.31'], ['2.44', '2.91']], 1000, '5', 500),\n   [500, 894]),\n  ('variant scenario 1',\n   ([['3.39', 'won'], ['2.49', '5.36'], ['1.49', '4.00'], ['3.15', '5.06']], 2500, '5', 0),\n   [867, 0]),\n  ('variant scenario 2', ([['2.52', 'lost'], ['4.68', '4.00']], 1000, '5', 0), [0, 0])],\n [('control single shortened', ([['3.00', '2.00']], 1000, '0', 0), [1500, 0]),\n  ('control margin applied', ([['3.00', '2.00']], 1000, '5', 0), [1425, 0]),\n  ('boundary won leg keeps price', ([['2.00', 'won'], ['2.00', '1.50']], 1000, '0', 0), [2666, 0]),\n  ('boundary partial cash out', ([['3.00', '2.00']], 1000, '0', 500), [500, 666]),\n  ('control lost leg', ([['2.00', 'lost'], ['2.00', '1.50']], 1000, '0', 0), [0, 0]),\n  ('boundary partial above value', ([['2.00', '4.00']], 1000, '0', 600), 'invalid'),\n  ('regression: partial remaining stake', ([['4.93', 'won']], 2500, '5', 500), [500, 2393]),\n  ('variant scenario 1',\n   ([['3.53', '1.91'], ['3.32', 'lost'], ['1.63', 'won'], ['2.97', '4.57']], 500, '0', 500),\n   [0, 0]),\n  ('variant scenario 2', ([['2.73', 'won'], ['2.11', '4.03']], 1000, '0', 0), [1429, 0])]]\nfor label, args, expected in cases[N - 1]:\n    check(label, run(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":"Stipulated, bounded toy contract stated in the contract field; not a claim of conformance with any operator, exchange or regulator rule set. 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-odds-conversion-cash-out-valuation-partial-remaining-stake","generated_at":"2026-09-29T14:50:33.495728+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Cash-out and partial cash-out offers are recomputed from live prices on every tick.","root_cause":"The remaining stake is computed as stake minus the cashed amount.","sha256":"22f0562a374383422fc3f57729281edeefb4ef3c8187b417242c5416bca42898","title":"Partial cash-out leaves the wrong remaining stake · 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":44.159,"exit_code":1,"observations":[{"actual":[1500,0],"check":"control single shortened","expected":[1500,0],"passed":true},{"actual":[1425,0],"check":"control margin applied","expected":[1425,0],"passed":true},{"actual":[2666,0],"check":"boundary won leg keeps price","expected":[2666,0],"passed":true},{"actual":[500,333],"check":"boundary partial cash out","expected":[500,666],"passed":false},{"actual":[0,0],"check":"control lost leg","expected":[0,0],"passed":true},{"actual":"invalid","check":"boundary partial above value","expected":"invalid","passed":true},{"actual":[800,301],"check":"regression: partial remaining stake","expected":[800,198],"passed":false},{"actual":[0,0],"check":"variant scenario 1","expected":[0,0],"passed":true},{"actual":[0,0],"check":"variant scenario 2","expected":[0,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"control single shortened\", \"actual\": [1500, 0], \"expected\": [1500, 0], \"passed\": true}, {\"check\": \"control margin applied\", \"actual\": [1425, 0], \"expected\": [1425, 0], \"passed\": true}, {\"check\": \"boundary won leg keeps price\", \"actual\": [2666, 0], \"expected\": [2666, 0], \"passed\": true}, {\"check\": \"boundary partial cash out\", \"actual\": [500, 333], \"expected\": [500, 666], \"passed\": false}, {\"check\": \"control lost leg\", \"actual\": [0, 0], \"expected\": [0, 0], \"passed\": true}, {\"check\": \"boundary partial above value\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"regression: partial remaining stake\", \"actual\": [800, 301], \"expected\": [800, 198], \"passed\": false}, {\"check\": \"variant scenario 1\", \"actual\": [0, 0], \"expected\": [0, 0], \"passed\": true}, {\"check\": \"variant scenario 2\", \"actual\": [0, 0], \"expected\": [0, 0], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":44.545,"exit_code":1,"observations":[{"actual":[1500,0],"check":"control single shortened","expected":[1500,0],"passed":true},{"actual":[1425,0],"check":"control margin applied","expected":[1425,0],"passed":true},{"actual":[2666,0],"check":"boundary won leg keeps price","expected":[2666,0],"passed":true},{"actual":[500,500],"check":"boundary partial cash out","expected":[500,666],"passed":false},{"actual":[0,0],"check":"control lost leg","expected":[0,0],"passed":true},{"actual":"invalid","check":"boundary partial above value","expected":"invalid","passed":true},{"actual":[800,-300],"check":"regression: partial remaining stake","expected":[800,198],"passed":false},{"actual":[0,0],"check":"variant scenario 1","expected":[0,0],"passed":true},{"actual":[0,0],"check":"variant scenario 2","expected":[0,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"control single shortened\", \"actual\": [1500, 0], \"expected\": [1500, 0], \"passed\": true}, {\"check\": \"control margin applied\", \"actual\": [1425, 0], \"expected\": [1425, 0], \"passed\": true}, {\"check\": \"boundary won leg keeps price\", \"actual\": [2666, 0], \"expected\": [2666, 0], \"passed\": true}, {\"check\": \"boundary partial cash out\", \"actual\": [500, 500], \"expected\": [500, 666], \"passed\": false}, {\"check\": \"control lost leg\", \"actual\": [0, 0], \"expected\": [0, 0], \"passed\": true}, {\"check\": \"boundary partial above value\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"regression: partial remaining stake\", \"actual\": [800, -300], \"expected\": [800, 198], \"passed\": false}, {\"check\": \"variant scenario 1\", \"actual\": [0, 0], \"expected\": [0, 0], \"passed\": true}, {\"check\": \"variant scenario 2\", \"actual\": [0, 0], \"expected\": [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."}}