FAILURE MAP
← Case archive

FA-84571 / Betting odds conversion / Open access

Loss probability taken from the price instead of the estimate · case 01

The Kelly stake ignores the bettor probability for the losing side.

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

ROOT CAUSE

q is computed as 1 / price (the market implied probability).

VERIFIED REPAIR

Use q = 1 - p.

Unsuccessful approach: Using 1 - 1/price is still the market view, not the estimate.

Case contract

Kelly staking. With b = price - 1, p = prob and q = 1 - p, the full Kelly fraction is (b * p - q) / b, floored at 0 when the edge is not positive. The stake is bankroll * min(full Kelly * fraction, max_pct / 100), rounded down to a cent. Return [full Kelly fraction rounded half up to four decimals as a string, stake cents].

Why this case matters

Bankroll tools size stakes with fractional Kelly and a hard cap.

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(prob, price, fraction, bankroll_cents, max_pct):
    p = Fraction(prob)
    b = Fraction(price) - 1
    q = 1 / Fraction(price)
    k = (b * p - q) / b
    if k < 0:
        k = Fraction(0)
    use = min(k * Fraction(fraction), Fraction(max_pct) / 100)
    stake = math.floor(bankroll_cents * use)
    r = math.floor(k * 10000 + Fraction(1, 2))
    return ['%d.%04d' % (r // 10000, r % 10000), stake]
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 even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.60', '2.36', '0.5', 12345, '5'), ['0.3059', 617]),
  ('variant scenario 1', ('0.60', '4.25', '0.25', 12345, '10'), ['0.4769', 1234]),
  ('variant scenario 2', ('0.62', '4.87', '1', 12345, '100'), ['0.5218', 6441])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.55', '4.90', '1', 100000, '2'), ['0.4346', 2000]),
  ('variant scenario 1', ('0.60', '4.89', '1', 50000, '100'), ['0.4972', 24858]),
  ('variant scenario 2', ('0.50', '5.00', '0.25', 12345, '5'), ['0.3750', 617])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.50', '4.71', '1', 12345, '100'), ['0.3652', 4508]),
  ('variant scenario 1', ('0.55', '2.71', '1', 50000, '100'), ['0.2868', 14342]),
  ('variant scenario 2', ('0.50', '5.42', '0.5', 12345, '2'), ['0.3869', 246])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.50', '5.16', '0.5', 100000, '5'), ['0.3798', 5000]),
  ('variant scenario 1', ('0.60', '5.38', '0.25', 100000, '10'), ['0.5087', 10000]),
  ('variant scenario 2', ('0.50', '3.37', '1', 100000, '2'), ['0.2890', 2000])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.55', '5.27', '0.5', 12345, '100'), ['0.4446', 2744]),
  ('variant scenario 1', ('0.60', '1.55', '0.25', 100000, '5'), ['0.0000', 0]),
  ('variant scenario 2', ('0.68', '1.65', '0.5', 100000, '2'), ['0.1877', 2000])]]
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 even-money edge['0.0500', 5000]['0.1000', 10000]Failed
control half kelly['0.0500', 2500]['0.1000', 5000]Failed
boundary capped stake['0.1000', 5000]['0.2000', 5000]Failed
boundary no edge['0.0000', 0]['0.0000', 0]Passed
control underdog edge['0.2167', 21666]['0.0667', 6666]Failed
regression: loss probability['0.2884', 617]['0.3059', 617]Failed
variant scenario 1['0.5276', 1234]['0.4769', 1234]Failed
variant scenario 2['0.5669', 6998]['0.5218', 6441]Failed

SHA-256 / e8016406d5dba6ce5476a71f1fb903d84d7e59473987605ec3b49044182c0fd6

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(prob, price, fraction, bankroll_cents, max_pct):
    p = Fraction(prob)
    b = Fraction(price) - 1
    q = 1 - 1 / Fraction(price)
    k = (b * p - q) / b
    if k < 0:
        k = Fraction(0)
    use = min(k * Fraction(fraction), Fraction(max_pct) / 100)
    stake = math.floor(bankroll_cents * use)
    r = math.floor(k * 10000 + Fraction(1, 2))
    return ['%d.%04d' % (r // 10000, r % 10000), stake]
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 even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.60', '2.36', '0.5', 12345, '5'), ['0.3059', 617]),
  ('variant scenario 1', ('0.60', '4.25', '0.25', 12345, '10'), ['0.4769', 1234]),
  ('variant scenario 2', ('0.62', '4.87', '1', 12345, '100'), ['0.5218', 6441])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.55', '4.90', '1', 100000, '2'), ['0.4346', 2000]),
  ('variant scenario 1', ('0.60', '4.89', '1', 50000, '100'), ['0.4972', 24858]),
  ('variant scenario 2', ('0.50', '5.00', '0.25', 12345, '5'), ['0.3750', 617])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.50', '4.71', '1', 12345, '100'), ['0.3652', 4508]),
  ('variant scenario 1', ('0.55', '2.71', '1', 50000, '100'), ['0.2868', 14342]),
  ('variant scenario 2', ('0.50', '5.42', '0.5', 12345, '2'), ['0.3869', 246])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.50', '5.16', '0.5', 100000, '5'), ['0.3798', 5000]),
  ('variant scenario 1', ('0.60', '5.38', '0.25', 100000, '10'), ['0.5087', 10000]),
  ('variant scenario 2', ('0.50', '3.37', '1', 100000, '2'), ['0.2890', 2000])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.55', '5.27', '0.5', 12345, '100'), ['0.4446', 2744]),
  ('variant scenario 1', ('0.60', '1.55', '0.25', 100000, '5'), ['0.0000', 0]),
  ('variant scenario 2', ('0.68', '1.65', '0.5', 100000, '2'), ['0.1877', 2000])]]
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 even-money edge['0.0500', 5000]['0.1000', 10000]Failed
control half kelly['0.0500', 2500]['0.1000', 5000]Failed
boundary capped stake['0.1000', 5000]['0.2000', 5000]Failed
boundary no edge['0.0000', 0]['0.0000', 0]Passed
control underdog edge['0.0500', 5000]['0.0667', 6666]Failed
regression: loss probability['0.1763', 617]['0.3059', 617]Failed
variant scenario 1['0.3647', 1125]['0.4769', 1234]Failed
variant scenario 2['0.4147', 5118]['0.5218', 6441]Failed

SHA-256 / 60b9bffa23cbce04e07d24b81a49e4e5d6619c2a32f1572da4aee05a1971774f

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(prob, price, fraction, bankroll_cents, max_pct):
    p = Fraction(prob)
    b = Fraction(price) - 1
    q = 1 - p
    k = (b * p - q) / b
    if k < 0:
        k = Fraction(0)
    use = min(k * Fraction(fraction), Fraction(max_pct) / 100)
    stake = math.floor(bankroll_cents * use)
    r = math.floor(k * 10000 + Fraction(1, 2))
    return ['%d.%04d' % (r // 10000, r % 10000), stake]
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 even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.60', '2.36', '0.5', 12345, '5'), ['0.3059', 617]),
  ('variant scenario 1', ('0.60', '4.25', '0.25', 12345, '10'), ['0.4769', 1234]),
  ('variant scenario 2', ('0.62', '4.87', '1', 12345, '100'), ['0.5218', 6441])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.55', '4.90', '1', 100000, '2'), ['0.4346', 2000]),
  ('variant scenario 1', ('0.60', '4.89', '1', 50000, '100'), ['0.4972', 24858]),
  ('variant scenario 2', ('0.50', '5.00', '0.25', 12345, '5'), ['0.3750', 617])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.50', '4.71', '1', 12345, '100'), ['0.3652', 4508]),
  ('variant scenario 1', ('0.55', '2.71', '1', 50000, '100'), ['0.2868', 14342]),
  ('variant scenario 2', ('0.50', '5.42', '0.5', 12345, '2'), ['0.3869', 246])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.50', '5.16', '0.5', 100000, '5'), ['0.3798', 5000]),
  ('variant scenario 1', ('0.60', '5.38', '0.25', 100000, '10'), ['0.5087', 10000]),
  ('variant scenario 2', ('0.50', '3.37', '1', 100000, '2'), ['0.2890', 2000])],
 [('control even-money edge', ('0.55', '2.00', '1', 100000, '100'), ['0.1000', 10000]),
  ('control half kelly', ('0.55', '2.00', '0.5', 100000, '100'), ['0.1000', 5000]),
  ('boundary capped stake', ('0.60', '2.00', '1', 100000, '5'), ['0.2000', 5000]),
  ('boundary no edge', ('0.40', '2.00', '1', 100000, '5'), ['0.0000', 0]),
  ('control underdog edge', ('0.30', '4.00', '1', 100000, '100'), ['0.0667', 6666]),
  ('regression: loss probability', ('0.55', '5.27', '0.5', 12345, '100'), ['0.4446', 2744]),
  ('variant scenario 1', ('0.60', '1.55', '0.25', 100000, '5'), ['0.0000', 0]),
  ('variant scenario 2', ('0.68', '1.65', '0.5', 100000, '2'), ['0.1877', 2000])]]
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 even-money edge['0.1000', 10000]['0.1000', 10000]Passed
control half kelly['0.1000', 5000]['0.1000', 5000]Passed
boundary capped stake['0.2000', 5000]['0.2000', 5000]Passed
boundary no edge['0.0000', 0]['0.0000', 0]Passed
control underdog edge['0.0667', 6666]['0.0667', 6666]Passed
regression: loss probability['0.3059', 617]['0.3059', 617]Passed
variant scenario 1['0.4769', 1234]['0.4769', 1234]Passed
variant scenario 2['0.5218', 6441]['0.5218', 6441]Passed

SHA-256 / a9d7caa354593de225f2ffb7a7a899f965b45a1cf20e05a0d869554121b7a294

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

Case digest / 18054bddef3fa49d2f9f0f09a5fb22d65de5ab32d8287ee3a7891f9919c4d9d2