FA-84531 / Betting odds conversion / Open access
Commission charged per winning bet instead of per market · case 01
A hedged market pays commission on the winning leg despite a small net profit.
ROOT CAUSE
The net ledger is keyed per bet, so every winning bet is commissioned separately.
VERIFIED REPAIR
Aggregate profit and loss per market before charging commission.
Unsuccessful approach: Aggregating only the winning bets per market still charges commission on gross winnings.
Case contract
Betting exchange settlement. bets rows are [market, side, stake_cents, price, won] where won says whether the bet won. Back: win profit floor(stake * (price - 1)), loss -stake. Lay: win +stake, loss -ceil(stake * (price - 1)) (the liability). Commission is charged per market on the market net profit only when that net is positive, at rate_pct percent rounded half up to a cent. Return [total net after commission, total commission] in cents.
Why this case matters
Exchanges charge commission on net market winnings, not per winning bet.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(bets, rate_pct):
nets = {}
for market, side, stake, price, won in bets:
p = Fraction(price)
if side == 'back':
pl = math.floor(stake * (p - 1)) if won else -stake
else:
pl = stake if won else -math.ceil(stake * (p - 1))
nets[(market, len(nets))] = pl
comm = 0
for m, net in nets.items():
if net > 0:
comm += math.floor(net * Fraction(rate_pct) / 100 + Fraction(1, 2))
return [sum(nets.values()) - comm, comm]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
try:
return solve(*args)
except Exception as exc:
return 'raised ' + type(exc).__name__
cases = [[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m1', 'back', 100, '5.20', False],
['m2', 'lay', 2000, '6.81', True],
['m3', 'back', 100, '6.84', False],
['m1', 'back', 777, '1.71', True],
['m2', 'lay', 2000, '4.81', False]],
'6.5'),
[-5298, 29]),
('variant scenario 1',
([['m3', 'back', 1000, '2.37', False],
['m3', 'lay', 1000, '5.47', True],
['m3', 'lay', 1000, '2.53', True],
['m3', 'back', 2000, '5.43', False]],
'2'),
[-1000, 0]),
('variant scenario 2',
([['m1', 'lay', 100, '6.53', True],
['m1', 'lay', 250, '1.42', False],
['m3', 'back', 100, '5.84', True],
['m1', 'back', 250, '4.21', False]],
'6.5'),
[198, 31])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission', ([['m3', 'back', 100, '3.97', False]], '5'), [-100, 0]),
('regression: per bet commission',
([['m3', 'lay', 100, '2.39', True],
['m1', 'lay', 2000, '5.94', False],
['m3', 'back', 777, '3.75', True]],
'6.5'),
[-7789, 145]),
('variant scenario 1',
([['m1', 'back', 777, '1.23', False],
['m2', 'lay', 250, '7.80', True],
['m2', 'back', 100, '4.41', True]],
'5'),
[-216, 30]),
('variant scenario 2',
([['m3', 'back', 2000, '4.01', False],
['m1', 'lay', 100, '3.22', False],
['m3', 'lay', 777, '7.56', False],
['m1', 'back', 2000, '1.35', False]],
'6.5'),
[-9320, 0])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m1', 'lay', 1000, '2.47', True],
['m3', 'back', 777, '7.09', False],
['m3', 'lay', 2000, '2.84', True]],
'5'),
[2112, 111]),
('variant scenario 1', ([['m3', 'lay', 250, '4.16', False]], '5'), [-790, 0]),
('variant scenario 2',
([['m3', 'back', 2000, '1.81', False],
['m2', 'lay', 2000, '7.12', False],
['m1', 'lay', 250, '4.83', False]],
'6.5'),
[-15198, 0])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m3', 'lay', 100, '6.30', True],
['m1', 'back', 250, '7.35', False],
['m3', 'lay', 2000, '7.86', True]],
'6.5'),
[1713, 137]),
('regression: per bet commission',
([['m3', 'back', 250, '6.32', True],
['m3', 'back', 1000, '4.82', False],
['m3', 'lay', 250, '5.41', False],
['m1', 'lay', 100, '6.23', True],
['m2', 'lay', 777, '7.89', False]],
'5'),
[-6032, 5]),
('variant scenario 1',
([['m2', 'back', 1000, '5.07', True], ['m1', 'back', 250, '6.46', True]], '6.5'),
[5081, 354]),
('variant scenario 2',
([['m3', 'back', 2000, '2.17', True],
['m2', 'back', 2000, '5.63', True],
['m1', 'back', 250, '2.32', False],
['m2', 'lay', 2000, '6.97', True]],
'5'),
[12670, 680])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m3', 'back', 2000, '4.23', False],
['m3', 'lay', 100, '4.06', False],
['m3', 'lay', 2000, '2.15', False],
['m2', 'lay', 250, '4.89', True],
['m3', 'back', 250, '5.27', False]],
'5'),
[-4619, 13]),
('regression: per bet commission',
([['m2', 'back', 100, '4.06', False],
['m2', 'lay', 1000, '3.28', True],
['m2', 'back', 1000, '3.20', False],
['m1', 'back', 2000, '2.10', False],
['m1', 'lay', 250, '4.14', False]],
'2'),
[-2885, 0]),
('variant scenario 1',
([['m1', 'lay', 2000, '2.07', False], ['m1', 'lay', 1000, '6.85', False]], '5'),
[-7990, 0]),
('variant scenario 2',
([['m2', 'lay', 777, '1.87', True], ['m3', 'back', 100, '2.04', False]], '5'),
[638, 39])]]
for label, args, expected in cases[N - 1]:
check(label, run(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 |
|---|---|---|---|
| control single back winner | [1900, 100] | [1900, 100] | Passed |
| boundary hedged market nets out | [400, 100] | [475, 25] | Failed |
| control lay winner | [950, 50] | [950, 50] | Passed |
| boundary losing market no commission | [-525, 25] | [-500, 0] | Failed |
| regression: per bet commission | [-5435, 166] | [-5298, 29] | Failed |
| variant scenario 1 | [-1040, 40] | [-1000, 0] | Failed |
| variant scenario 2 | [191, 38] | [198, 31] | Failed |
SHA-256 / ff92e4ab1d9d008a20a4389d080f22085c22cc6d62965f42b1258e5205dbc9ab
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(bets, rate_pct):
nets = {}
for market, side, stake, price, won in bets:
p = Fraction(price)
if side == 'back':
pl = math.floor(stake * (p - 1)) if won else -stake
else:
pl = stake if won else -math.ceil(stake * (p - 1))
nets[market] = nets.get(market, 0) + max(pl, 0)
comm = 0
for m, net in nets.items():
if net > 0:
comm += math.floor(net * Fraction(rate_pct) / 100 + Fraction(1, 2))
return [sum(nets.values()) - comm, comm]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
try:
return solve(*args)
except Exception as exc:
return 'raised ' + type(exc).__name__
cases = [[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m1', 'back', 100, '5.20', False],
['m2', 'lay', 2000, '6.81', True],
['m3', 'back', 100, '6.84', False],
['m1', 'back', 777, '1.71', True],
['m2', 'lay', 2000, '4.81', False]],
'6.5'),
[-5298, 29]),
('variant scenario 1',
([['m3', 'back', 1000, '2.37', False],
['m3', 'lay', 1000, '5.47', True],
['m3', 'lay', 1000, '2.53', True],
['m3', 'back', 2000, '5.43', False]],
'2'),
[-1000, 0]),
('variant scenario 2',
([['m1', 'lay', 100, '6.53', True],
['m1', 'lay', 250, '1.42', False],
['m3', 'back', 100, '5.84', True],
['m1', 'back', 250, '4.21', False]],
'6.5'),
[198, 31])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission', ([['m3', 'back', 100, '3.97', False]], '5'), [-100, 0]),
('regression: per bet commission',
([['m3', 'lay', 100, '2.39', True],
['m1', 'lay', 2000, '5.94', False],
['m3', 'back', 777, '3.75', True]],
'6.5'),
[-7789, 145]),
('variant scenario 1',
([['m1', 'back', 777, '1.23', False],
['m2', 'lay', 250, '7.80', True],
['m2', 'back', 100, '4.41', True]],
'5'),
[-216, 30]),
('variant scenario 2',
([['m3', 'back', 2000, '4.01', False],
['m1', 'lay', 100, '3.22', False],
['m3', 'lay', 777, '7.56', False],
['m1', 'back', 2000, '1.35', False]],
'6.5'),
[-9320, 0])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m1', 'lay', 1000, '2.47', True],
['m3', 'back', 777, '7.09', False],
['m3', 'lay', 2000, '2.84', True]],
'5'),
[2112, 111]),
('variant scenario 1', ([['m3', 'lay', 250, '4.16', False]], '5'), [-790, 0]),
('variant scenario 2',
([['m3', 'back', 2000, '1.81', False],
['m2', 'lay', 2000, '7.12', False],
['m1', 'lay', 250, '4.83', False]],
'6.5'),
[-15198, 0])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m3', 'lay', 100, '6.30', True],
['m1', 'back', 250, '7.35', False],
['m3', 'lay', 2000, '7.86', True]],
'6.5'),
[1713, 137]),
('regression: per bet commission',
([['m3', 'back', 250, '6.32', True],
['m3', 'back', 1000, '4.82', False],
['m3', 'lay', 250, '5.41', False],
['m1', 'lay', 100, '6.23', True],
['m2', 'lay', 777, '7.89', False]],
'5'),
[-6032, 5]),
('variant scenario 1',
([['m2', 'back', 1000, '5.07', True], ['m1', 'back', 250, '6.46', True]], '6.5'),
[5081, 354]),
('variant scenario 2',
([['m3', 'back', 2000, '2.17', True],
['m2', 'back', 2000, '5.63', True],
['m1', 'back', 250, '2.32', False],
['m2', 'lay', 2000, '6.97', True]],
'5'),
[12670, 680])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m3', 'back', 2000, '4.23', False],
['m3', 'lay', 100, '4.06', False],
['m3', 'lay', 2000, '2.15', False],
['m2', 'lay', 250, '4.89', True],
['m3', 'back', 250, '5.27', False]],
'5'),
[-4619, 13]),
('regression: per bet commission',
([['m2', 'back', 100, '4.06', False],
['m2', 'lay', 1000, '3.28', True],
['m2', 'back', 1000, '3.20', False],
['m1', 'back', 2000, '2.10', False],
['m1', 'lay', 250, '4.14', False]],
'2'),
[-2885, 0]),
('variant scenario 1',
([['m1', 'lay', 2000, '2.07', False], ['m1', 'lay', 1000, '6.85', False]], '5'),
[-7990, 0]),
('variant scenario 2',
([['m2', 'lay', 777, '1.87', True], ['m3', 'back', 100, '2.04', False]], '5'),
[638, 39])]]
for label, args, expected in cases[N - 1]:
check(label, run(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 |
|---|---|---|---|
| control single back winner | [1900, 100] | [1900, 100] | Passed |
| boundary hedged market nets out | [1900, 100] | [475, 25] | Failed |
| control lay winner | [950, 50] | [950, 50] | Passed |
| boundary losing market no commission | [475, 25] | [-500, 0] | Failed |
| regression: per bet commission | [2385, 166] | [-5298, 29] | Failed |
| variant scenario 1 | [1960, 40] | [-1000, 0] | Failed |
| variant scenario 2 | [546, 38] | [198, 31] | Failed |
SHA-256 / 39973ae394463d7074e91a388b1644bc8ba6b2c531963256f6a85f084828c976
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(bets, rate_pct):
nets = {}
for market, side, stake, price, won in bets:
p = Fraction(price)
if side == 'back':
pl = math.floor(stake * (p - 1)) if won else -stake
else:
pl = stake if won else -math.ceil(stake * (p - 1))
nets[market] = nets.get(market, 0) + pl
comm = 0
for m, net in nets.items():
if net > 0:
comm += math.floor(net * Fraction(rate_pct) / 100 + Fraction(1, 2))
return [sum(nets.values()) - comm, comm]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
try:
return solve(*args)
except Exception as exc:
return 'raised ' + type(exc).__name__
cases = [[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m1', 'back', 100, '5.20', False],
['m2', 'lay', 2000, '6.81', True],
['m3', 'back', 100, '6.84', False],
['m1', 'back', 777, '1.71', True],
['m2', 'lay', 2000, '4.81', False]],
'6.5'),
[-5298, 29]),
('variant scenario 1',
([['m3', 'back', 1000, '2.37', False],
['m3', 'lay', 1000, '5.47', True],
['m3', 'lay', 1000, '2.53', True],
['m3', 'back', 2000, '5.43', False]],
'2'),
[-1000, 0]),
('variant scenario 2',
([['m1', 'lay', 100, '6.53', True],
['m1', 'lay', 250, '1.42', False],
['m3', 'back', 100, '5.84', True],
['m1', 'back', 250, '4.21', False]],
'6.5'),
[198, 31])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission', ([['m3', 'back', 100, '3.97', False]], '5'), [-100, 0]),
('regression: per bet commission',
([['m3', 'lay', 100, '2.39', True],
['m1', 'lay', 2000, '5.94', False],
['m3', 'back', 777, '3.75', True]],
'6.5'),
[-7789, 145]),
('variant scenario 1',
([['m1', 'back', 777, '1.23', False],
['m2', 'lay', 250, '7.80', True],
['m2', 'back', 100, '4.41', True]],
'5'),
[-216, 30]),
('variant scenario 2',
([['m3', 'back', 2000, '4.01', False],
['m1', 'lay', 100, '3.22', False],
['m3', 'lay', 777, '7.56', False],
['m1', 'back', 2000, '1.35', False]],
'6.5'),
[-9320, 0])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m1', 'lay', 1000, '2.47', True],
['m3', 'back', 777, '7.09', False],
['m3', 'lay', 2000, '2.84', True]],
'5'),
[2112, 111]),
('variant scenario 1', ([['m3', 'lay', 250, '4.16', False]], '5'), [-790, 0]),
('variant scenario 2',
([['m3', 'back', 2000, '1.81', False],
['m2', 'lay', 2000, '7.12', False],
['m1', 'lay', 250, '4.83', False]],
'6.5'),
[-15198, 0])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m3', 'lay', 100, '6.30', True],
['m1', 'back', 250, '7.35', False],
['m3', 'lay', 2000, '7.86', True]],
'6.5'),
[1713, 137]),
('regression: per bet commission',
([['m3', 'back', 250, '6.32', True],
['m3', 'back', 1000, '4.82', False],
['m3', 'lay', 250, '5.41', False],
['m1', 'lay', 100, '6.23', True],
['m2', 'lay', 777, '7.89', False]],
'5'),
[-6032, 5]),
('variant scenario 1',
([['m2', 'back', 1000, '5.07', True], ['m1', 'back', 250, '6.46', True]], '6.5'),
[5081, 354]),
('variant scenario 2',
([['m3', 'back', 2000, '2.17', True],
['m2', 'back', 2000, '5.63', True],
['m1', 'back', 250, '2.32', False],
['m2', 'lay', 2000, '6.97', True]],
'5'),
[12670, 680])],
[('control single back winner', ([['m1', 'back', 1000, '3.00', True]], '5'), [1900, 100]),
('boundary hedged market nets out',
([['m1', 'back', 1000, '3.00', True], ['m1', 'lay', 1000, '2.50', False]], '5'),
[475, 25]),
('control lay winner', ([['m2', 'lay', 1000, '4.00', True]], '5'), [950, 50]),
('boundary losing market no commission',
([['m1', 'back', 1000, '3.00', False], ['m1', 'lay', 500, '2.00', True]], '5'),
[-500, 0]),
('regression: per bet commission',
([['m3', 'back', 2000, '4.23', False],
['m3', 'lay', 100, '4.06', False],
['m3', 'lay', 2000, '2.15', False],
['m2', 'lay', 250, '4.89', True],
['m3', 'back', 250, '5.27', False]],
'5'),
[-4619, 13]),
('regression: per bet commission',
([['m2', 'back', 100, '4.06', False],
['m2', 'lay', 1000, '3.28', True],
['m2', 'back', 1000, '3.20', False],
['m1', 'back', 2000, '2.10', False],
['m1', 'lay', 250, '4.14', False]],
'2'),
[-2885, 0]),
('variant scenario 1',
([['m1', 'lay', 2000, '2.07', False], ['m1', 'lay', 1000, '6.85', False]], '5'),
[-7990, 0]),
('variant scenario 2',
([['m2', 'lay', 777, '1.87', True], ['m3', 'back', 100, '2.04', False]], '5'),
[638, 39])]]
for label, args, expected in cases[N - 1]:
check(label, run(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 |
|---|---|---|---|
| control single back winner | [1900, 100] | [1900, 100] | Passed |
| boundary hedged market nets out | [475, 25] | [475, 25] | Passed |
| control lay winner | [950, 50] | [950, 50] | Passed |
| boundary losing market no commission | [-500, 0] | [-500, 0] | Passed |
| regression: per bet commission | [-5298, 29] | [-5298, 29] | Passed |
| variant scenario 1 | [-1000, 0] | [-1000, 0] | Passed |
| variant scenario 2 | [198, 31] | [198, 31] | Passed |
SHA-256 / fd6541c6e99bf2539e74b2d2410eea6b9781a491f4f89de865eedaaab4990897
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:31.782757+00:00.
Case digest / a32c7b860d532f12ea6f971a970886ec7af59d0980d678979d3687bdb0ccd45b