FAILURE MAP
← Case archive

FA-84621 / Betting odds conversion / Open access

Tick distance has the wrong sign · case 01

Moving from 3.10 down to 2.90 reports +7 ticks.

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

ROOT CAUSE

The subtraction order is reversed.

VERIFIED REPAIR

Return index(b) - index(a).

Unsuccessful approach: Taking the absolute value discards the direction.

Case contract

Signed tick distance from price a to price b on the ladder [(101, 200, 1), (200, 300, 2), (300, 400, 5), (400, 600, 10), (600, 1000, 20), (1000, 2000, 50), (2000, 3000, 100), (3000, 5000, 200), (5000, 10000, 500), (10000, 100001, 1000)] (hundredths). Prices must be within 1.01..1000 ("invalid") and exactly on a tick ("off ladder"). Tick index counts all ticks of lower bands ((hi - lo) / step each) plus (v - lo) / step within the band. Return index(b) - index(a).

Why this case matters

Trading bots express stop-loss and offset orders as tick counts across ladder bands.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(a, b):
    BANDS = [(101, 200, 1), (200, 300, 2), (300, 400, 5), (400, 600, 10), (600, 1000, 20), (1000, 2000, 50), (2000, 3000, 100), (3000, 5000, 200), (5000, 10000, 500), (10000, 100001, 1000)]
    def index(v):
        n = 0
        for lo, hi, step in BANDS:
            if v >= hi:
                n += (hi - lo) // step
            else:
                if (v - lo) % step:
                    return None
                return n + (v - lo) // step
        return None
    out = []
    for p in (a, b):
        c = Fraction(p) * 100
        if c.denominator != 1 or c < 101 or c > 100000:
            return 'invalid'
        i = index(int(c))
        if i is None:
            return 'off ladder'
        out.append(i)
    return out[0] - out[1]
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 within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('2.10', '3.30'), 51),
  ('regression: distance sign', ('20.00', '4.00'), -60),
  ('variant scenario 1', ('5.90', '2.36'), -71),
  ('variant scenario 2', ('70.00', '1.16'), -238)],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('17.50', '2.10'), -120),
  ('variant scenario 1', ('4.70', '8.00'), 23),
  ('variant scenario 2', ('42.00', '8.21'), 'off ladder')],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('4.20', '11.00'), 40),
  ('regression: distance sign', ('5.10', '1.91'), -90),
  ('variant scenario 1', ('19.01', '11.50'), 'off ladder'),
  ('variant scenario 2', ('9.20', '560.00'), 100)],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('1.31', '2.88'), 113),
  ('regression: distance sign', ('8.40', '2.76'), -64),
  ('variant scenario 1', ('44.00', '95.00'), 12),
  ('variant scenario 2', ('5.91', '30.00'), 'off ladder')],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('2.38', '4.00'), 51),
  ('regression: distance sign', ('18.00', '12.50'), -11),
  ('variant scenario 1', ('2.12', '2.34'), 11),
  ('variant scenario 2', ('3.90', '5.50'), 17)]]
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 within band-1010Failed
boundary crossing two-44Failed
control downward move7-7Failed
boundary off ladderoff ladderoff ladderPassed
control full ladder-349349Failed
regression: distance sign-5151Failed
regression: distance sign60-60Failed
variant scenario 171-71Failed
variant scenario 2238-238Failed

SHA-256 / 01c1ac7092044e06be061814b60992e8056ad60706c9071be15d71454490c8bc

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(a, b):
    BANDS = [(101, 200, 1), (200, 300, 2), (300, 400, 5), (400, 600, 10), (600, 1000, 20), (1000, 2000, 50), (2000, 3000, 100), (3000, 5000, 200), (5000, 10000, 500), (10000, 100001, 1000)]
    def index(v):
        n = 0
        for lo, hi, step in BANDS:
            if v >= hi:
                n += (hi - lo) // step
            else:
                if (v - lo) % step:
                    return None
                return n + (v - lo) // step
        return None
    out = []
    for p in (a, b):
        c = Fraction(p) * 100
        if c.denominator != 1 or c < 101 or c > 100000:
            return 'invalid'
        i = index(int(c))
        if i is None:
            return 'off ladder'
        out.append(i)
    return abs(out[1] - out[0])
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 within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('2.10', '3.30'), 51),
  ('regression: distance sign', ('20.00', '4.00'), -60),
  ('variant scenario 1', ('5.90', '2.36'), -71),
  ('variant scenario 2', ('70.00', '1.16'), -238)],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('17.50', '2.10'), -120),
  ('variant scenario 1', ('4.70', '8.00'), 23),
  ('variant scenario 2', ('42.00', '8.21'), 'off ladder')],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('4.20', '11.00'), 40),
  ('regression: distance sign', ('5.10', '1.91'), -90),
  ('variant scenario 1', ('19.01', '11.50'), 'off ladder'),
  ('variant scenario 2', ('9.20', '560.00'), 100)],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('1.31', '2.88'), 113),
  ('regression: distance sign', ('8.40', '2.76'), -64),
  ('variant scenario 1', ('44.00', '95.00'), 12),
  ('variant scenario 2', ('5.91', '30.00'), 'off ladder')],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('2.38', '4.00'), 51),
  ('regression: distance sign', ('18.00', '12.50'), -11),
  ('variant scenario 1', ('2.12', '2.34'), 11),
  ('variant scenario 2', ('3.90', '5.50'), 17)]]
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 within band1010Passed
boundary crossing two44Passed
control downward move7-7Failed
boundary off ladderoff ladderoff ladderPassed
control full ladder349349Passed
regression: distance sign5151Passed
regression: distance sign60-60Failed
variant scenario 171-71Failed
variant scenario 2238-238Failed

SHA-256 / 34a0d1efc1aed197f3b95a4c96ea0b2f75ce70f286621b457e36516224d16aa3

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(a, b):
    BANDS = [(101, 200, 1), (200, 300, 2), (300, 400, 5), (400, 600, 10), (600, 1000, 20), (1000, 2000, 50), (2000, 3000, 100), (3000, 5000, 200), (5000, 10000, 500), (10000, 100001, 1000)]
    def index(v):
        n = 0
        for lo, hi, step in BANDS:
            if v >= hi:
                n += (hi - lo) // step
            else:
                if (v - lo) % step:
                    return None
                return n + (v - lo) // step
        return None
    out = []
    for p in (a, b):
        c = Fraction(p) * 100
        if c.denominator != 1 or c < 101 or c > 100000:
            return 'invalid'
        i = index(int(c))
        if i is None:
            return 'off ladder'
        out.append(i)
    return out[1] - out[0]
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 within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('2.10', '3.30'), 51),
  ('regression: distance sign', ('20.00', '4.00'), -60),
  ('variant scenario 1', ('5.90', '2.36'), -71),
  ('variant scenario 2', ('70.00', '1.16'), -238)],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('17.50', '2.10'), -120),
  ('variant scenario 1', ('4.70', '8.00'), 23),
  ('variant scenario 2', ('42.00', '8.21'), 'off ladder')],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('4.20', '11.00'), 40),
  ('regression: distance sign', ('5.10', '1.91'), -90),
  ('variant scenario 1', ('19.01', '11.50'), 'off ladder'),
  ('variant scenario 2', ('9.20', '560.00'), 100)],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('1.31', '2.88'), 113),
  ('regression: distance sign', ('8.40', '2.76'), -64),
  ('variant scenario 1', ('44.00', '95.00'), 12),
  ('variant scenario 2', ('5.91', '30.00'), 'off ladder')],
 [('control within band', ('1.50', '1.60'), 10),
  ('boundary crossing two', ('1.98', '2.04'), 4),
  ('control downward move', ('3.10', '2.90'), -7),
  ('boundary off ladder', ('2.01', '2.50'), 'off ladder'),
  ('control full ladder', ('1.01', '1000'), 349),
  ('regression: distance sign', ('2.38', '4.00'), 51),
  ('regression: distance sign', ('18.00', '12.50'), -11),
  ('variant scenario 1', ('2.12', '2.34'), 11),
  ('variant scenario 2', ('3.90', '5.50'), 17)]]
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 within band1010Passed
boundary crossing two44Passed
control downward move-7-7Passed
boundary off ladderoff ladderoff ladderPassed
control full ladder349349Passed
regression: distance sign5151Passed
regression: distance sign-60-60Passed
variant scenario 1-71-71Passed
variant scenario 2-238-238Passed

SHA-256 / 4c3457c512491a7eab6e0f1ba818dea112dd977b50957c672680d25e31330ec5

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

Case digest / 5b468dfcdab9570e35776517ac76ad042da9fdd72fa146f2b62293a53a0a8bb7