FAILURE MAP
← Case archive

FA-84836 / Betting odds conversion / Open access

Equivalent price rounded with binary floats or truncated · case 01

Laying at 17 shows 1.062 instead of 1.063.

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

ROOT CAUSE

The value is formatted with '%.3f' on a float.

VERIFIED REPAIR

Round the exact value half up.

Unsuccessful approach: Truncating to three decimals misreports values just below a boundary.

Case contract

Laying a selection at price L (> 1, else "invalid") is equivalent to backing "not this selection" at L / (L - 1). After exchange commission c percent on winnings, the effective price is 1 + (equivalent - 1) * (100 - c) / 100. Return both, rounded half up to three decimals.

Why this case matters

Matched-betting and trading calculators compare lay prices with bookmaker back prices.

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(lay_price, commission_pct):
    L = Fraction(lay_price)
    if L <= 1:
        return 'invalid'
    eq = L / (L - 1)
    eff = 1 + (eq - 1) * (100 - Fraction(commission_pct)) / 100
    def fmt(v):
        return '%.3f' % float(v)
    return [fmt(eq), fmt(eff)]
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 lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '5'), ['1.031', '1.030']),
  ('regression: third decimal rounding', ('17', '2'), ['1.063', '1.061']),
  ('variant scenario 1', ('9', '0'), ['1.125', '1.125']),
  ('variant scenario 2', ('33', '6.5'), ['1.031', '1.029'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('9', '6.5'), ['1.125', '1.117']),
  ('regression: third decimal rounding', ('17', '6.5'), ['1.063', '1.058']),
  ('variant scenario 1', ('2.00', '5'), ['2.000', '1.950']),
  ('variant scenario 2', ('1.25', '0'), ['5.000', '5.000'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '2'), ['1.031', '1.031']),
  ('regression: third decimal rounding', ('17', '5'), ['1.063', '1.059']),
  ('variant scenario 1', ('9', '2'), ['1.125', '1.123']),
  ('variant scenario 2', ('9', '0'), ['1.125', '1.125'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('8.31', '5'), ['1.137', '1.130']),
  ('regression: third decimal rounding', ('17', '2'), ['1.063', '1.061']),
  ('variant scenario 1', ('33', '6.5'), ['1.031', '1.029']),
  ('variant scenario 2', ('9', '2'), ['1.125', '1.123'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '5'), ['1.031', '1.030']),
  ('regression: third decimal rounding', ('17', '5'), ['1.063', '1.059']),
  ('variant scenario 1', ('9', '0'), ['1.125', '1.125']),
  ('variant scenario 2', ('9', '6.5'), ['1.125', '1.117'])]]
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 lay evens['2.000', '2.000']['2.000', '2.000']Passed
control lay favourite['3.000', '2.900']['3.000', '2.900']Passed
boundary half-up third decimal['1.062', '1.062']['1.063', '1.063']Failed
boundary no-profit layinvalidinvalidPassed
regression: third decimal rounding['1.031', '1.030']['1.031', '1.030']Passed
regression: third decimal rounding['1.062', '1.061']['1.063', '1.061']Failed
variant scenario 1['1.125', '1.125']['1.125', '1.125']Passed
variant scenario 2['1.031', '1.029']['1.031', '1.029']Passed

SHA-256 / 717c4c2b03ccd1fa48972e3308ea1ee281479a2a619a951bc6fdcbcf0cbd8a16

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(lay_price, commission_pct):
    L = Fraction(lay_price)
    if L <= 1:
        return 'invalid'
    eq = L / (L - 1)
    eff = 1 + (eq - 1) * (100 - Fraction(commission_pct)) / 100
    def fmt(v):
        c = math.floor(v * 1000)
        return '%d.%03d' % (c // 1000, c % 1000)
    return [fmt(eq), fmt(eff)]
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 lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '5'), ['1.031', '1.030']),
  ('regression: third decimal rounding', ('17', '2'), ['1.063', '1.061']),
  ('variant scenario 1', ('9', '0'), ['1.125', '1.125']),
  ('variant scenario 2', ('33', '6.5'), ['1.031', '1.029'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('9', '6.5'), ['1.125', '1.117']),
  ('regression: third decimal rounding', ('17', '6.5'), ['1.063', '1.058']),
  ('variant scenario 1', ('2.00', '5'), ['2.000', '1.950']),
  ('variant scenario 2', ('1.25', '0'), ['5.000', '5.000'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '2'), ['1.031', '1.031']),
  ('regression: third decimal rounding', ('17', '5'), ['1.063', '1.059']),
  ('variant scenario 1', ('9', '2'), ['1.125', '1.123']),
  ('variant scenario 2', ('9', '0'), ['1.125', '1.125'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('8.31', '5'), ['1.137', '1.130']),
  ('regression: third decimal rounding', ('17', '2'), ['1.063', '1.061']),
  ('variant scenario 1', ('33', '6.5'), ['1.031', '1.029']),
  ('variant scenario 2', ('9', '2'), ['1.125', '1.123'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '5'), ['1.031', '1.030']),
  ('regression: third decimal rounding', ('17', '5'), ['1.063', '1.059']),
  ('variant scenario 1', ('9', '0'), ['1.125', '1.125']),
  ('variant scenario 2', ('9', '6.5'), ['1.125', '1.117'])]]
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 lay evens['2.000', '2.000']['2.000', '2.000']Passed
control lay favourite['3.000', '2.900']['3.000', '2.900']Passed
boundary half-up third decimal['1.062', '1.062']['1.063', '1.063']Failed
boundary no-profit layinvalidinvalidPassed
regression: third decimal rounding['1.031', '1.029']['1.031', '1.030']Failed
regression: third decimal rounding['1.062', '1.061']['1.063', '1.061']Failed
variant scenario 1['1.125', '1.125']['1.125', '1.125']Passed
variant scenario 2['1.031', '1.029']['1.031', '1.029']Passed

SHA-256 / 2beea99b81c32357209a80781ca568e450ab20426b9a8879cb1abd9d30075888

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(lay_price, commission_pct):
    L = Fraction(lay_price)
    if L <= 1:
        return 'invalid'
    eq = L / (L - 1)
    eff = 1 + (eq - 1) * (100 - Fraction(commission_pct)) / 100
    def fmt(v):
        c = math.floor(v * 1000 + Fraction(1, 2))
        return '%d.%03d' % (c // 1000, c % 1000)
    return [fmt(eq), fmt(eff)]
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 lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '5'), ['1.031', '1.030']),
  ('regression: third decimal rounding', ('17', '2'), ['1.063', '1.061']),
  ('variant scenario 1', ('9', '0'), ['1.125', '1.125']),
  ('variant scenario 2', ('33', '6.5'), ['1.031', '1.029'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('9', '6.5'), ['1.125', '1.117']),
  ('regression: third decimal rounding', ('17', '6.5'), ['1.063', '1.058']),
  ('variant scenario 1', ('2.00', '5'), ['2.000', '1.950']),
  ('variant scenario 2', ('1.25', '0'), ['5.000', '5.000'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '2'), ['1.031', '1.031']),
  ('regression: third decimal rounding', ('17', '5'), ['1.063', '1.059']),
  ('variant scenario 1', ('9', '2'), ['1.125', '1.123']),
  ('variant scenario 2', ('9', '0'), ['1.125', '1.125'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('8.31', '5'), ['1.137', '1.130']),
  ('regression: third decimal rounding', ('17', '2'), ['1.063', '1.061']),
  ('variant scenario 1', ('33', '6.5'), ['1.031', '1.029']),
  ('variant scenario 2', ('9', '2'), ['1.125', '1.123'])],
 [('control lay evens', ('2.00', '0'), ['2.000', '2.000']),
  ('control lay favourite', ('1.50', '5'), ['3.000', '2.900']),
  ('boundary half-up third decimal', ('17', '0'), ['1.063', '1.063']),
  ('boundary no-profit lay', ('1.00', '5'), 'invalid'),
  ('regression: third decimal rounding', ('33', '5'), ['1.031', '1.030']),
  ('regression: third decimal rounding', ('17', '5'), ['1.063', '1.059']),
  ('variant scenario 1', ('9', '0'), ['1.125', '1.125']),
  ('variant scenario 2', ('9', '6.5'), ['1.125', '1.117'])]]
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 lay evens['2.000', '2.000']['2.000', '2.000']Passed
control lay favourite['3.000', '2.900']['3.000', '2.900']Passed
boundary half-up third decimal['1.063', '1.063']['1.063', '1.063']Passed
boundary no-profit layinvalidinvalidPassed
regression: third decimal rounding['1.031', '1.030']['1.031', '1.030']Passed
regression: third decimal rounding['1.063', '1.061']['1.063', '1.061']Passed
variant scenario 1['1.125', '1.125']['1.125', '1.125']Passed
variant scenario 2['1.031', '1.029']['1.031', '1.029']Passed

SHA-256 / 6826e8ef12e8647f2e5a0fe9d0863c86d4bdafa6df9e4ee26d138481181169fa

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

Case digest / bee430ef6d5ffa6c339b11ae33fc911bf746afb2d008d41b48cb5cd2681fe64c