FAILURE MAP
← Case archive

FA-84611 / Betting odds conversion / Open access

Band boundary tick counted twice or dropped · case 01

Tick distances crossing a band boundary are off by one per boundary crossed.

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

ROOT CAUSE

Each completed band contributes (hi - lo) / step + 1 ticks, double-counting the shared boundary price.

VERIFIED REPAIR

Count (hi - lo) / step ticks per completed band.

Unsuccessful approach: Subtracting one per band drops a real tick at each boundary.

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 + 1
            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: band fencepost', ('2.38', '850.00'), 216),
  ('variant scenario 1', ('6.00', '2.16'), -82),
  ('variant scenario 2', ('3.01', '5.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: band fencepost', ('4.50', '1.60'), -115),
  ('variant scenario 1', ('3.76', '2.22'), 'off ladder'),
  ('variant scenario 2', ('6.00', '9.60'), 18)],
 [('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: band fencepost', ('530.00', '5.10'), -122),
  ('variant scenario 1', ('5.40', '3.30'), -28),
  ('variant scenario 2', ('3.70', '7.40'), 33)],
 [('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: band fencepost', ('5.40', '13.50'), 33),
  ('variant scenario 1', ('7.41', '2.64'), 'off ladder'),
  ('variant scenario 2', ('5.00', '2.76'), -42)],
 [('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: band fencepost', ('1.46', '7.20'), 150),
  ('variant scenario 1', ('2.66', '5.80'), 55),
  ('variant scenario 2', ('5.21', '2.00'), 'off ladder')]]
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 two54Failed
control downward move-8-7Failed
boundary off ladderoff ladderoff ladderPassed
control full ladder358349Failed
regression: band fencepost224216Failed
variant scenario 1-85-82Failed
variant scenario 2off ladderoff ladderPassed

SHA-256 / add53df892d850e952bc9cd4a9e6e9533df9d9336ccbccdfb6825edc676cd85a

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 - 1
            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: band fencepost', ('2.38', '850.00'), 216),
  ('variant scenario 1', ('6.00', '2.16'), -82),
  ('variant scenario 2', ('3.01', '5.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: band fencepost', ('4.50', '1.60'), -115),
  ('variant scenario 1', ('3.76', '2.22'), 'off ladder'),
  ('variant scenario 2', ('6.00', '9.60'), 18)],
 [('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: band fencepost', ('530.00', '5.10'), -122),
  ('variant scenario 1', ('5.40', '3.30'), -28),
  ('variant scenario 2', ('3.70', '7.40'), 33)],
 [('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: band fencepost', ('5.40', '13.50'), 33),
  ('variant scenario 1', ('7.41', '2.64'), 'off ladder'),
  ('variant scenario 2', ('5.00', '2.76'), -42)],
 [('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: band fencepost', ('1.46', '7.20'), 150),
  ('variant scenario 1', ('2.66', '5.80'), 55),
  ('variant scenario 2', ('5.21', '2.00'), 'off ladder')]]
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 two34Failed
control downward move-6-7Failed
boundary off ladderoff ladderoff ladderPassed
control full ladder340349Failed
regression: band fencepost208216Failed
variant scenario 1-79-82Failed
variant scenario 2off ladderoff ladderPassed

SHA-256 / a2a92a5e5850bec19f17ce7013054f6940b4035a5e1ae5478716589b420a22ad

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: band fencepost', ('2.38', '850.00'), 216),
  ('variant scenario 1', ('6.00', '2.16'), -82),
  ('variant scenario 2', ('3.01', '5.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: band fencepost', ('4.50', '1.60'), -115),
  ('variant scenario 1', ('3.76', '2.22'), 'off ladder'),
  ('variant scenario 2', ('6.00', '9.60'), 18)],
 [('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: band fencepost', ('530.00', '5.10'), -122),
  ('variant scenario 1', ('5.40', '3.30'), -28),
  ('variant scenario 2', ('3.70', '7.40'), 33)],
 [('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: band fencepost', ('5.40', '13.50'), 33),
  ('variant scenario 1', ('7.41', '2.64'), 'off ladder'),
  ('variant scenario 2', ('5.00', '2.76'), -42)],
 [('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: band fencepost', ('1.46', '7.20'), 150),
  ('variant scenario 1', ('2.66', '5.80'), 55),
  ('variant scenario 2', ('5.21', '2.00'), 'off ladder')]]
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: band fencepost216216Passed
variant scenario 1-82-82Passed
variant scenario 2off ladderoff ladderPassed

SHA-256 / 80ab2129001cde7b41b38fcb787020afa994eed853e12d0685d79fd06abfc81b

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

Case digest / 0b0c2445d1911ac792bd49bcb6464d4f62ae779fe843184932a4e61a66a1818b