FAILURE MAP
← Case archive

FA-84666 / Betting odds conversion / Open access

Combined deductions exceed the cap · case 01

Two short-priced withdrawals remove more than 75p in the pound.

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

ROOT CAUSE

The summed deduction is not capped.

VERIFIED REPAIR

Cap the summed deduction at 75.

Unsuccessful approach: Capping each withdrawal separately does not bound the sum.

Case contract

Non-runner deduction for a winning bet. Each withdrawn runner's decimal price maps to pence-in-the-pound from the first band whose limit it does not exceed: [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]; above 15.00 it is 0. Deductions from several withdrawals are summed and capped at 75. The deduction applies to winnings only: return = stake + floor(stake * (price - 1) * (100 - deduction) / 100). Return [deduction, return cents].

Why this case matters

Racing settlement reduces winnings when a runner is withdrawn after prices were struck.

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(stake_cents, price, withdrawn):
    TABLE = [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]
    def ded(p):
        p = Fraction(p)
        for limit, pence in TABLE:
            if p <= Fraction(limit):
                return pence
        return 0
    total = sum(ded(w) for w in withdrawn)
    profit = stake_cents * (Fraction(price) - 1)
    return [total, stake_cents + math.floor(profit * (100 - total) / 100)]
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 no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '3.41', ['1.80', '1.30', '2.50']), [75, 400]),
  ('variant scenario 1', (500, '4.54', []), [0, 2270]),
  ('variant scenario 2', (500, '8.92', ['2.75', '2.50']), [75, 1490])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '10.89', ['2.75', '1.80', '6.50']), [75, 868]),
  ('variant scenario 1', (1000, '4.14', ['2.21', '1.95', '18.92']), [75, 1785]),
  ('variant scenario 2', (1000, '7.69', []), [0, 7690])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (500, '10.54', ['19.32', '1.53', '1.40']), [75, 1692]),
  ('variant scenario 1', (500, '7.00', ['12.05']), [5, 3350]),
  ('variant scenario 2', (500, '2.93', []), [0, 1465])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '6.43', ['12.30', '3.25', '1.80']), [75, 589]),
  ('variant scenario 1', (1000, '8.99', ['5.00', '4.00']), [45, 5394]),
  ('variant scenario 2', (250, '9.92', ['3.44']), [25, 1922])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (500, '11.98', ['1.53', '6.50']), [75, 1872]),
  ('variant scenario 1', (250, '3.13', ['12.77']), [5, 755]),
  ('variant scenario 2', (250, '1.88', []), [0, 470])]]
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 fixtureActualExpectedOutcome
control no withdrawal[0, 5000][0, 5000]Passed
boundary price on band limit[40, 3400][40, 3400]Passed
control long-shot withdrawal[0, 5000][0, 5000]Passed
boundary cap at 75[130, 400][75, 1500]Failed
control two withdrawals[40, 2200][40, 2200]Passed
regression: deduction cap[170, -172][75, 400]Failed
variant scenario 1[0, 2270][0, 2270]Passed
variant scenario 2[75, 1490][75, 1490]Passed

SHA-256 / a3f2ecef930746d6b471b22377ba3bf9a455a5ab6b4dfea444ea77d50d872cf8

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(stake_cents, price, withdrawn):
    TABLE = [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]
    def ded(p):
        p = Fraction(p)
        for limit, pence in TABLE:
            if p <= Fraction(limit):
                return pence
        return 0
    total = sum(min(75, ded(w)) for w in withdrawn)
    profit = stake_cents * (Fraction(price) - 1)
    return [total, stake_cents + math.floor(profit * (100 - total) / 100)]
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 no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '3.41', ['1.80', '1.30', '2.50']), [75, 400]),
  ('variant scenario 1', (500, '4.54', []), [0, 2270]),
  ('variant scenario 2', (500, '8.92', ['2.75', '2.50']), [75, 1490])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '10.89', ['2.75', '1.80', '6.50']), [75, 868]),
  ('variant scenario 1', (1000, '4.14', ['2.21', '1.95', '18.92']), [75, 1785]),
  ('variant scenario 2', (1000, '7.69', []), [0, 7690])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (500, '10.54', ['19.32', '1.53', '1.40']), [75, 1692]),
  ('variant scenario 1', (500, '7.00', ['12.05']), [5, 3350]),
  ('variant scenario 2', (500, '2.93', []), [0, 1465])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '6.43', ['12.30', '3.25', '1.80']), [75, 589]),
  ('variant scenario 1', (1000, '8.99', ['5.00', '4.00']), [45, 5394]),
  ('variant scenario 2', (250, '9.92', ['3.44']), [25, 1922])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (500, '11.98', ['1.53', '6.50']), [75, 1872]),
  ('variant scenario 1', (250, '3.13', ['12.77']), [5, 755]),
  ('variant scenario 2', (250, '1.88', []), [0, 470])]]
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 fixtureActualExpectedOutcome
control no withdrawal[0, 5000][0, 5000]Passed
boundary price on band limit[40, 3400][40, 3400]Passed
control long-shot withdrawal[0, 5000][0, 5000]Passed
boundary cap at 75[130, 400][75, 1500]Failed
control two withdrawals[40, 2200][40, 2200]Passed
regression: deduction cap[170, -172][75, 400]Failed
variant scenario 1[0, 2270][0, 2270]Passed
variant scenario 2[75, 1490][75, 1490]Passed

SHA-256 / 4c7754bb4bd77317df737e33d0affaeb97af90cd396e540ba4303ffa8cd8f05f

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(stake_cents, price, withdrawn):
    TABLE = [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]
    def ded(p):
        p = Fraction(p)
        for limit, pence in TABLE:
            if p <= Fraction(limit):
                return pence
        return 0
    total = min(75, sum(ded(w) for w in withdrawn))
    profit = stake_cents * (Fraction(price) - 1)
    return [total, stake_cents + math.floor(profit * (100 - total) / 100)]
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 no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '3.41', ['1.80', '1.30', '2.50']), [75, 400]),
  ('variant scenario 1', (500, '4.54', []), [0, 2270]),
  ('variant scenario 2', (500, '8.92', ['2.75', '2.50']), [75, 1490])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '10.89', ['2.75', '1.80', '6.50']), [75, 868]),
  ('variant scenario 1', (1000, '4.14', ['2.21', '1.95', '18.92']), [75, 1785]),
  ('variant scenario 2', (1000, '7.69', []), [0, 7690])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (500, '10.54', ['19.32', '1.53', '1.40']), [75, 1692]),
  ('variant scenario 1', (500, '7.00', ['12.05']), [5, 3350]),
  ('variant scenario 2', (500, '2.93', []), [0, 1465])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (250, '6.43', ['12.30', '3.25', '1.80']), [75, 589]),
  ('variant scenario 1', (1000, '8.99', ['5.00', '4.00']), [45, 5394]),
  ('variant scenario 2', (250, '9.92', ['3.44']), [25, 1922])],
 [('control no withdrawal', (1000, '5.00', []), [0, 5000]),
  ('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
  ('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
  ('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
  ('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
  ('regression: deduction cap', (500, '11.98', ['1.53', '6.50']), [75, 1872]),
  ('variant scenario 1', (250, '3.13', ['12.77']), [5, 755]),
  ('variant scenario 2', (250, '1.88', []), [0, 470])]]
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 fixtureActualExpectedOutcome
control no withdrawal[0, 5000][0, 5000]Passed
boundary price on band limit[40, 3400][40, 3400]Passed
control long-shot withdrawal[0, 5000][0, 5000]Passed
boundary cap at 75[75, 1500][75, 1500]Passed
control two withdrawals[40, 2200][40, 2200]Passed
regression: deduction cap[75, 400][75, 400]Passed
variant scenario 1[0, 2270][0, 2270]Passed
variant scenario 2[75, 1490][75, 1490]Passed

SHA-256 / f6ca09e2669dcb55784e1f582c1ae469277cdedc79abc32999b61dc43369a3da

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

Case digest / 38b12dd982cf90accf983132835d98f5130de6f1694eb2c0304e3de427647fb7