FAILURE MAP
← Case archive

FA-84521 / Betting odds conversion / Open access

Handicap applied to the wrong side · case 01

A home -1.5 bet wins when the home side loses.

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

ROOT CAUSE

The handicap is subtracted from the home margin.

VERIFIED REPAIR

Add the home line to home_goals - away_goals.

Unsuccessful approach: Computing the away margin plus the line settles the away bet, not the home bet.

Case contract

Asian handicap bet on the home side. line is a multiple of 0.25 (else "invalid line"). Whole and half lines are a single bet; quarter lines split the stake equally between line - 0.25 and line + 0.25. Each part: margin = home_goals - away_goals + part_line; positive wins stake_part * price, zero refunds stake_part, negative loses. Return [total return in cents rounded down, label] where the label is win, half-win, push, half-lose or lose from the summed part outcomes.

Why this case matters

Asian handicap settlement with split quarter lines is a common source of payout disputes.

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(line, home_goals, away_goals, stake_cents, price):
    L = Fraction(line)
    if (L * 4).denominator != 1:
        return 'invalid line'
    if (L * 2).denominator == 1:
        parts = [L]
    else:
        parts = [L - Fraction(1, 4), L + Fraction(1, 4)]
    d = Fraction(price)
    share = Fraction(stake_cents, len(parts))
    ret = Fraction(0)
    res = []
    for p in parts:
        m = home_goals - away_goals - p
        if m > 0:
            ret += share * d
            res.append(1)
        elif m == 0:
            ret += share
            res.append(0)
        else:
            res.append(-1)
    score = sum(res) * 2 // len(parts)
    label = {2: 'win', 1: 'half-win', 0: 'push', -1: 'half-lose', -2: 'lose'}[score]
    return [math.floor(ret), label]
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 half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.75', 0, 4, 999, '1.90'), [0, 'lose']),
  ('regression: line orientation', ('-1.5', 2, 3, 500, '2.00'), [0, 'lose']),
  ('variant scenario 1', ('-0.3', 0, 0, 999, '1.90'), 'invalid line'),
  ('variant scenario 2', ('-0.3', 2, 0, 250, '2.00'), 'invalid line')],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('-0.25', 4, 0, 999, '1.90'), [1898, 'win']),
  ('regression: line orientation', ('-0.25', 3, 3, 500, '2.00'), [250, 'half-lose']),
  ('variant scenario 1', ('+1.25', 1, 3, 999, '2.05'), [0, 'lose']),
  ('variant scenario 2', ('-0.5', 3, 4, 1000, '2.05'), [0, 'lose'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.25', 0, 0, 999, '1.85'), [1423, 'half-win']),
  ('regression: line orientation', ('+0.75', 2, 4, 1000, '2.00'), [0, 'lose']),
  ('variant scenario 1', ('-0.5', 1, 0, 250, '2.00'), [500, 'win']),
  ('variant scenario 2', ('-1.5', 4, 0, 250, '2.00'), [500, 'win'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('-0.25', 4, 0, 250, '2.05'), [512, 'win']),
  ('regression: line orientation', ('-1.75', 2, 3, 999, '1.85'), [0, 'lose']),
  ('variant scenario 1', ('-0.3', 1, 2, 250, '1.90'), 'invalid line'),
  ('variant scenario 2', ('+0.25', 4, 3, 250, '2.05'), [512, 'win'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.5', 4, 2, 500, '2.00'), [1000, 'win']),
  ('regression: line orientation', ('+0.75', 4, 3, 250, '1.85'), [462, 'win']),
  ('variant scenario 1', ('+0.75', 2, 0, 1000, '1.90'), [1900, 'win']),
  ('variant scenario 2', ('-1', 0, 3, 250, '2.05'), [0, 'lose'])]]
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 half line win[1900, 'win'][1900, 'win']Passed
boundary whole line push[1900, 'win'][1000, 'push']Failed
boundary quarter half-lose[1450, 'half-win'][500, 'half-lose']Failed
boundary quarter half-win[2000, 'win'][1500, 'half-win']Failed
control lose[0, 'lose'][0, 'lose']Passed
boundary off-grid lineinvalid lineinvalid linePassed
regression: line orientation[0, 'lose'][0, 'lose']Passed
regression: line orientation[1000, 'win'][0, 'lose']Failed
variant scenario 1invalid lineinvalid linePassed
variant scenario 2invalid lineinvalid linePassed

SHA-256 / bc968c338e097b1ded8b25f5af8c414ed846872359e1e5b424548b91912ae279

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(line, home_goals, away_goals, stake_cents, price):
    L = Fraction(line)
    if (L * 4).denominator != 1:
        return 'invalid line'
    if (L * 2).denominator == 1:
        parts = [L]
    else:
        parts = [L - Fraction(1, 4), L + Fraction(1, 4)]
    d = Fraction(price)
    share = Fraction(stake_cents, len(parts))
    ret = Fraction(0)
    res = []
    for p in parts:
        m = away_goals - home_goals + p
        if m > 0:
            ret += share * d
            res.append(1)
        elif m == 0:
            ret += share
            res.append(0)
        else:
            res.append(-1)
    score = sum(res) * 2 // len(parts)
    label = {2: 'win', 1: 'half-win', 0: 'push', -1: 'half-lose', -2: 'lose'}[score]
    return [math.floor(ret), label]
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 half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.75', 0, 4, 999, '1.90'), [0, 'lose']),
  ('regression: line orientation', ('-1.5', 2, 3, 500, '2.00'), [0, 'lose']),
  ('variant scenario 1', ('-0.3', 0, 0, 999, '1.90'), 'invalid line'),
  ('variant scenario 2', ('-0.3', 2, 0, 250, '2.00'), 'invalid line')],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('-0.25', 4, 0, 999, '1.90'), [1898, 'win']),
  ('regression: line orientation', ('-0.25', 3, 3, 500, '2.00'), [250, 'half-lose']),
  ('variant scenario 1', ('+1.25', 1, 3, 999, '2.05'), [0, 'lose']),
  ('variant scenario 2', ('-0.5', 3, 4, 1000, '2.05'), [0, 'lose'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.25', 0, 0, 999, '1.85'), [1423, 'half-win']),
  ('regression: line orientation', ('+0.75', 2, 4, 1000, '2.00'), [0, 'lose']),
  ('variant scenario 1', ('-0.5', 1, 0, 250, '2.00'), [500, 'win']),
  ('variant scenario 2', ('-1.5', 4, 0, 250, '2.00'), [500, 'win'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('-0.25', 4, 0, 250, '2.05'), [512, 'win']),
  ('regression: line orientation', ('-1.75', 2, 3, 999, '1.85'), [0, 'lose']),
  ('variant scenario 1', ('-0.3', 1, 2, 250, '1.90'), 'invalid line'),
  ('variant scenario 2', ('+0.25', 4, 3, 250, '2.05'), [512, 'win'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.5', 4, 2, 500, '2.00'), [1000, 'win']),
  ('regression: line orientation', ('+0.75', 4, 3, 250, '1.85'), [462, 'win']),
  ('variant scenario 1', ('+0.75', 2, 0, 1000, '1.90'), [1900, 'win']),
  ('variant scenario 2', ('-1', 0, 3, 250, '2.05'), [0, 'lose'])]]
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 half line win[0, 'lose'][1900, 'win']Failed
boundary whole line push[0, 'lose'][1000, 'push']Failed
boundary quarter half-lose[500, 'half-lose'][500, 'half-lose']Passed
boundary quarter half-win[0, 'lose'][1500, 'half-win']Failed
control lose[1900, 'win'][0, 'lose']Failed
boundary off-grid lineinvalid lineinvalid linePassed
regression: line orientation[1898, 'win'][0, 'lose']Failed
regression: line orientation[0, 'lose'][0, 'lose']Passed
variant scenario 1invalid lineinvalid linePassed
variant scenario 2invalid lineinvalid linePassed

SHA-256 / 38422eef802e81e2686dbe578169a1d46ae93ae9ba42a6b32bf4207503ef52f8

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(line, home_goals, away_goals, stake_cents, price):
    L = Fraction(line)
    if (L * 4).denominator != 1:
        return 'invalid line'
    if (L * 2).denominator == 1:
        parts = [L]
    else:
        parts = [L - Fraction(1, 4), L + Fraction(1, 4)]
    d = Fraction(price)
    share = Fraction(stake_cents, len(parts))
    ret = Fraction(0)
    res = []
    for p in parts:
        m = home_goals - away_goals + p
        if m > 0:
            ret += share * d
            res.append(1)
        elif m == 0:
            ret += share
            res.append(0)
        else:
            res.append(-1)
    score = sum(res) * 2 // len(parts)
    label = {2: 'win', 1: 'half-win', 0: 'push', -1: 'half-lose', -2: 'lose'}[score]
    return [math.floor(ret), label]
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 half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.75', 0, 4, 999, '1.90'), [0, 'lose']),
  ('regression: line orientation', ('-1.5', 2, 3, 500, '2.00'), [0, 'lose']),
  ('variant scenario 1', ('-0.3', 0, 0, 999, '1.90'), 'invalid line'),
  ('variant scenario 2', ('-0.3', 2, 0, 250, '2.00'), 'invalid line')],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('-0.25', 4, 0, 999, '1.90'), [1898, 'win']),
  ('regression: line orientation', ('-0.25', 3, 3, 500, '2.00'), [250, 'half-lose']),
  ('variant scenario 1', ('+1.25', 1, 3, 999, '2.05'), [0, 'lose']),
  ('variant scenario 2', ('-0.5', 3, 4, 1000, '2.05'), [0, 'lose'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.25', 0, 0, 999, '1.85'), [1423, 'half-win']),
  ('regression: line orientation', ('+0.75', 2, 4, 1000, '2.00'), [0, 'lose']),
  ('variant scenario 1', ('-0.5', 1, 0, 250, '2.00'), [500, 'win']),
  ('variant scenario 2', ('-1.5', 4, 0, 250, '2.00'), [500, 'win'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('-0.25', 4, 0, 250, '2.05'), [512, 'win']),
  ('regression: line orientation', ('-1.75', 2, 3, 999, '1.85'), [0, 'lose']),
  ('variant scenario 1', ('-0.3', 1, 2, 250, '1.90'), 'invalid line'),
  ('variant scenario 2', ('+0.25', 4, 3, 250, '2.05'), [512, 'win'])],
 [('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
  ('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
  ('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
  ('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
  ('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
  ('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
  ('regression: line orientation', ('+0.5', 4, 2, 500, '2.00'), [1000, 'win']),
  ('regression: line orientation', ('+0.75', 4, 3, 250, '1.85'), [462, 'win']),
  ('variant scenario 1', ('+0.75', 2, 0, 1000, '1.90'), [1900, 'win']),
  ('variant scenario 2', ('-1', 0, 3, 250, '2.05'), [0, 'lose'])]]
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 half line win[1900, 'win'][1900, 'win']Passed
boundary whole line push[1000, 'push'][1000, 'push']Passed
boundary quarter half-lose[500, 'half-lose'][500, 'half-lose']Passed
boundary quarter half-win[1500, 'half-win'][1500, 'half-win']Passed
control lose[0, 'lose'][0, 'lose']Passed
boundary off-grid lineinvalid lineinvalid linePassed
regression: line orientation[0, 'lose'][0, 'lose']Passed
regression: line orientation[0, 'lose'][0, 'lose']Passed
variant scenario 1invalid lineinvalid linePassed
variant scenario 2invalid lineinvalid linePassed

SHA-256 / c03da6b2e7a92ac7d11393d79d798a16fd828d5c4131ffa75291b89b2fd62ce2

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

Case digest / 86a481d02b1afc48bc2ab8fb0eebac38c90a9fc7c9df195d499525f9fa8a2137