FAILURE MAP
← Case archive

FA-61501 / Options payoff and settlement / Open access

Option strategy max gain, max loss and breakevens: interpolated breakevens use the wrong sign · case 01

Breakevens are reported outside the segment where value changes sign.

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

ROOT CAUSE

The interpolation adds va*(b-a)/(vb-va) instead of subtracting it.

VERIFIED REPAIR

Solve the linear segment: a - va*(b-a)/(vb-va).

Unsuccessful approach: Using the segment midpoint is only right for symmetric segments.

Case contract

Inputs legs [kind C/P/S, strike (purchase price for stock S), signed qty, premium] and a multiplier. Expiry value V(S) = multiplier * sum(q*(intrinsic - premium)) for options and q*(S - price) for stock, in exact fractions. Breakpoints are 0 and every strike. Tail slope = V(top+1)-V(top). Max gain is None if the slope > 0 else the max over breakpoints; max loss is None if slope < 0 else the min. Breakevens are zeros at breakpoints and linear-interpolated sign changes between them and in the tail. Return [gain, loss, breakevens] rounded to 4.

Why this case matters

Option expiry, exercise and settlement engines move cash and shares; a wrong branch misstates obligations.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(legs, multiplier):
    def value(S):
        t = Fraction(0)
        for kind, k, q, prem in legs:
            p = Fraction(str(prem))
            if kind == 'C':
                t += q * (max(S - k, 0) - p)
            elif kind == 'P':
                t += q * (max(k - S, 0) - p)
            else:
                t += q * (S - k)
        return t * multiplier
    pts = sorted(set([0] + [leg[1] for leg in legs]))
    top = pts[-1]
    slope = value(top + 1) - value(top)
    vals = [value(p) for p in pts]
    gain = None if slope > 0 else max(vals)
    loss = None if slope < 0 else min(vals)
    bes = []
    for a, b in zip(pts, pts[1:]):
        va, vb = value(a), value(b)
        if va == 0:
            bes.append(Fraction(a))
        elif va * vb < 0:
            bes.append(a + va * (b - a) / (vb - va))
    vt = value(top)
    if vt == 0:
        bes.append(Fraction(top))
    elif vt * slope < 0:
        bes.append(top - vt / slope)
    def r4(x):
        return None if x is None else float(round(x, 4))
    return [r4(gain), r4(loss), [r4(x) for x in sorted(set(bes))]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression breakeven interpolation 1', [[['C', 100, -1, 2.0], ['C', 80, 1, 1.25], ['C', 95, 2, 5.1], ['C', 115, 1, 1.25]], 100], [None, -1070.0, [90.7]]], ['regression breakeven interpolation 2', [[['P', 95, -1, 7.75]], 100], [775.0, -8725.0, [87.25]]], ['partial repair probe 1', [[['C', 115, -1, 3.4], ['C', 95, 2, 3.4], ['C', 105, -1, 1.25]], 100], [2785.0, -215.0, [96.075]]], ['partial repair probe 2', [[['P', 85, -1, 2.0]], 100], [200.0, -8300.0, [83.0]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['S', 105, -1, 0.0], ['C', 110, 1, 0.5], ['C', 80, 2, 3.4]], 1], [None, 17.7, []]], ['normal control 2', [[['P', 100, 2, 0.5], ['C', 105, 2, 0.5], ['S', 90, 1, 0.0]], 1], [None, 8.0, []]], ['normal control 3', [[['C', 85, -1, 1.25]], 1], [1.25, None, [86.25]]]], [['regression breakeven interpolation 1', [[['S', 120, -1, 0.0], ['S', 90, 2, 0.0]], 100], [None, -6000.0, [60.0]]], ['regression breakeven interpolation 2', [[['C', 85, -1, 3.4], ['C', 80, -1, 1.25]], 1], [4.65, None, [84.65]]], ['partial repair probe 1', [[['S', 100, 2, 0.0], ['S', 120, 1, 0.0], ['P', 100, -2, 5.1]], 100], [None, -50980.0, [103.2667]]], ['partial repair probe 2', [[['C', 115, -2, 7.75], ['P', 105, -1, 2.0]], 1], [17.5, None, [87.5, 123.75]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 100, -2, 3.4], ['C', 105, 2, 3.4]], 1], [0.0, -10.0, [0.0, 100.0]]], ['normal control 2', [[['S', 95, -1, 0.0], ['C', 105, 2, 2.0], ['S', 110, 1, 0.0]], 1], [None, -19.0, [114.5]]], ['normal control 3', [[['C', 95, 1, 7.75], ['P', 120, 1, 5.1], ['C', 110, 1, 7.75]], 1], [None, 4.4, []]]], [['regression breakeven interpolation 1', [[['P', 110, -1, 5.1], ['P', 95, 1, 1.25]], 100], [385.0, -1115.0, [106.15]]], ['regression breakeven interpolation 2', [[['S', 115, 1, 0.0], ['P', 120, 1, 0.5], ['C', 110, 2, 3.4]], 1], [None, -2.3, [111.15]]], ['partial repair probe 1', [[['C', 110, -2, 5.1], ['P', 80, -1, 3.4]], 1], [13.6, None, [66.4, 116.8]]], ['partial repair probe 2', [[['C', 90, -1, 0.5], ['P', 90, -2, 5.1]], 1], [10.7, None, [84.65, 100.7]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 90, -2, 3.4]], 1], [6.8, None, [93.4]]], ['normal control 2', [[['C', 105, -1, 0.5]], 100], [50.0, None, [105.5]]], ['normal control 3', [[['P', 115, -1, 3.4], ['C', 110, 2, 5.1], ['S', 115, -1, 0.0], ['C', 95, -2, 2.0]], 100], [-280.0, None, []]]], [['regression breakeven interpolation 1', [[['C', 120, -1, 7.75], ['S', 80, -2, 0.0], ['C', 95, -1, 1.25]], 1], [169.0, None, [84.5]]], ['regression breakeven interpolation 2', [[['P', 110, -2, 2.0]], 100], [400.0, -21600.0, [108.0]]], ['partial repair probe 1', [[['P', 110, 1, 1.25]], 100], [10875.0, -125.0, [108.75]]], ['partial repair probe 2', [[['P', 110, -1, 3.4]], 100], [340.0, -10660.0, [106.6]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 105, 1, 7.75]], 100], [None, -775.0, [112.75]]], ['normal control 2', [[['C', 80, 1, 5.1], ['S', 85, 1, 0.0]], 1], [None, -90.1, [85.05]]], ['normal control 3', [[['C', 85, 2, 0.5]], 100], [None, -100.0, [85.5]]]], [['regression breakeven interpolation 1', [[['P', 80, -1, 7.75]], 1], [7.75, -72.25, [72.25]]], ['regression breakeven interpolation 2', [[['C', 90, 1, 7.75], ['P', 105, -2, 1.25]], 1], [None, -215.25, [101.75]]], ['partial repair probe 1', [[['P', 120, -2, 7.75], ['P', 105, 1, 1.25], ['P', 100, 2, 1.25], ['C', 115, 2, 0.5]], 1], [None, -24.25, [75.75, 114.625]]], ['partial repair probe 2', [[['C', 85, 2, 1.25], ['P', 100, -2, 5.1], ['P', 100, 1, 2.0]], 1], [None, -94.3, [88.1]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['S', 100, 1, 0.0], ['C', 105, -2, 2.0], ['P', 105, 1, 2.0], ['C', 95, 2, 1.25]], 1], [None, 4.5, []]], ['normal control 2', [[['S', 90, 1, 0.0], ['P', 115, 1, 7.75]], 1], [None, 17.25, []]], ['normal control 3', [[['C', 105, 1, 3.4]], 100], [None, -340.0, [108.4]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*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
regression breakeven interpolation 1[None, -1070.0, [69.3]][None, -1070.0, [90.7]]Failed
regression breakeven interpolation 2[775.0, -8725.0, [-87.25]][775.0, -8725.0, [87.25]]Failed
partial repair probe 1[2785.0, -215.0, [93.925]][2785.0, -215.0, [96.075]]Failed
partial repair probe 2[200.0, -8300.0, [-83.0]][200.0, -8300.0, [83.0]]Failed
boundary control 1[None, -200.0, [102.0]][None, -200.0, [102.0]]Passed
normal control 1[None, 17.7, []][None, 17.7, []]Passed
normal control 2[None, 8.0, []][None, 8.0, []]Passed
normal control 3[1.25, None, [86.25]][1.25, None, [86.25]]Passed

SHA-256 / a49abd99191f80e84ea6ae72c64f3efc3dbaaeef2307a644bcf6c5784e59d9a3

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(legs, multiplier):
    def value(S):
        t = Fraction(0)
        for kind, k, q, prem in legs:
            p = Fraction(str(prem))
            if kind == 'C':
                t += q * (max(S - k, 0) - p)
            elif kind == 'P':
                t += q * (max(k - S, 0) - p)
            else:
                t += q * (S - k)
        return t * multiplier
    pts = sorted(set([0] + [leg[1] for leg in legs]))
    top = pts[-1]
    slope = value(top + 1) - value(top)
    vals = [value(p) for p in pts]
    gain = None if slope > 0 else max(vals)
    loss = None if slope < 0 else min(vals)
    bes = []
    for a, b in zip(pts, pts[1:]):
        va, vb = value(a), value(b)
        if va == 0:
            bes.append(Fraction(a))
        elif va * vb < 0:
            bes.append(a + Fraction(b - a, 2))
    vt = value(top)
    if vt == 0:
        bes.append(Fraction(top))
    elif vt * slope < 0:
        bes.append(top - vt / slope)
    def r4(x):
        return None if x is None else float(round(x, 4))
    return [r4(gain), r4(loss), [r4(x) for x in sorted(set(bes))]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression breakeven interpolation 1', [[['C', 100, -1, 2.0], ['C', 80, 1, 1.25], ['C', 95, 2, 5.1], ['C', 115, 1, 1.25]], 100], [None, -1070.0, [90.7]]], ['regression breakeven interpolation 2', [[['P', 95, -1, 7.75]], 100], [775.0, -8725.0, [87.25]]], ['partial repair probe 1', [[['C', 115, -1, 3.4], ['C', 95, 2, 3.4], ['C', 105, -1, 1.25]], 100], [2785.0, -215.0, [96.075]]], ['partial repair probe 2', [[['P', 85, -1, 2.0]], 100], [200.0, -8300.0, [83.0]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['S', 105, -1, 0.0], ['C', 110, 1, 0.5], ['C', 80, 2, 3.4]], 1], [None, 17.7, []]], ['normal control 2', [[['P', 100, 2, 0.5], ['C', 105, 2, 0.5], ['S', 90, 1, 0.0]], 1], [None, 8.0, []]], ['normal control 3', [[['C', 85, -1, 1.25]], 1], [1.25, None, [86.25]]]], [['regression breakeven interpolation 1', [[['S', 120, -1, 0.0], ['S', 90, 2, 0.0]], 100], [None, -6000.0, [60.0]]], ['regression breakeven interpolation 2', [[['C', 85, -1, 3.4], ['C', 80, -1, 1.25]], 1], [4.65, None, [84.65]]], ['partial repair probe 1', [[['S', 100, 2, 0.0], ['S', 120, 1, 0.0], ['P', 100, -2, 5.1]], 100], [None, -50980.0, [103.2667]]], ['partial repair probe 2', [[['C', 115, -2, 7.75], ['P', 105, -1, 2.0]], 1], [17.5, None, [87.5, 123.75]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 100, -2, 3.4], ['C', 105, 2, 3.4]], 1], [0.0, -10.0, [0.0, 100.0]]], ['normal control 2', [[['S', 95, -1, 0.0], ['C', 105, 2, 2.0], ['S', 110, 1, 0.0]], 1], [None, -19.0, [114.5]]], ['normal control 3', [[['C', 95, 1, 7.75], ['P', 120, 1, 5.1], ['C', 110, 1, 7.75]], 1], [None, 4.4, []]]], [['regression breakeven interpolation 1', [[['P', 110, -1, 5.1], ['P', 95, 1, 1.25]], 100], [385.0, -1115.0, [106.15]]], ['regression breakeven interpolation 2', [[['S', 115, 1, 0.0], ['P', 120, 1, 0.5], ['C', 110, 2, 3.4]], 1], [None, -2.3, [111.15]]], ['partial repair probe 1', [[['C', 110, -2, 5.1], ['P', 80, -1, 3.4]], 1], [13.6, None, [66.4, 116.8]]], ['partial repair probe 2', [[['C', 90, -1, 0.5], ['P', 90, -2, 5.1]], 1], [10.7, None, [84.65, 100.7]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 90, -2, 3.4]], 1], [6.8, None, [93.4]]], ['normal control 2', [[['C', 105, -1, 0.5]], 100], [50.0, None, [105.5]]], ['normal control 3', [[['P', 115, -1, 3.4], ['C', 110, 2, 5.1], ['S', 115, -1, 0.0], ['C', 95, -2, 2.0]], 100], [-280.0, None, []]]], [['regression breakeven interpolation 1', [[['C', 120, -1, 7.75], ['S', 80, -2, 0.0], ['C', 95, -1, 1.25]], 1], [169.0, None, [84.5]]], ['regression breakeven interpolation 2', [[['P', 110, -2, 2.0]], 100], [400.0, -21600.0, [108.0]]], ['partial repair probe 1', [[['P', 110, 1, 1.25]], 100], [10875.0, -125.0, [108.75]]], ['partial repair probe 2', [[['P', 110, -1, 3.4]], 100], [340.0, -10660.0, [106.6]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 105, 1, 7.75]], 100], [None, -775.0, [112.75]]], ['normal control 2', [[['C', 80, 1, 5.1], ['S', 85, 1, 0.0]], 1], [None, -90.1, [85.05]]], ['normal control 3', [[['C', 85, 2, 0.5]], 100], [None, -100.0, [85.5]]]], [['regression breakeven interpolation 1', [[['P', 80, -1, 7.75]], 1], [7.75, -72.25, [72.25]]], ['regression breakeven interpolation 2', [[['C', 90, 1, 7.75], ['P', 105, -2, 1.25]], 1], [None, -215.25, [101.75]]], ['partial repair probe 1', [[['P', 120, -2, 7.75], ['P', 105, 1, 1.25], ['P', 100, 2, 1.25], ['C', 115, 2, 0.5]], 1], [None, -24.25, [75.75, 114.625]]], ['partial repair probe 2', [[['C', 85, 2, 1.25], ['P', 100, -2, 5.1], ['P', 100, 1, 2.0]], 1], [None, -94.3, [88.1]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['S', 100, 1, 0.0], ['C', 105, -2, 2.0], ['P', 105, 1, 2.0], ['C', 95, 2, 1.25]], 1], [None, 4.5, []]], ['normal control 2', [[['S', 90, 1, 0.0], ['P', 115, 1, 7.75]], 1], [None, 17.25, []]], ['normal control 3', [[['C', 105, 1, 3.4]], 100], [None, -340.0, [108.4]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*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
regression breakeven interpolation 1[None, -1070.0, [87.5]][None, -1070.0, [90.7]]Failed
regression breakeven interpolation 2[775.0, -8725.0, [47.5]][775.0, -8725.0, [87.25]]Failed
partial repair probe 1[2785.0, -215.0, [100.0]][2785.0, -215.0, [96.075]]Failed
partial repair probe 2[200.0, -8300.0, [42.5]][200.0, -8300.0, [83.0]]Failed
boundary control 1[None, -200.0, [102.0]][None, -200.0, [102.0]]Passed
normal control 1[None, 17.7, []][None, 17.7, []]Passed
normal control 2[None, 8.0, []][None, 8.0, []]Passed
normal control 3[1.25, None, [86.25]][1.25, None, [86.25]]Passed

SHA-256 / e0bb3fc817c9d48c1e882ee3f2059e6a1ceea9af8fc76bcc8eb18d70f6627d44

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(legs, multiplier):
    def value(S):
        t = Fraction(0)
        for kind, k, q, prem in legs:
            p = Fraction(str(prem))
            if kind == 'C':
                t += q * (max(S - k, 0) - p)
            elif kind == 'P':
                t += q * (max(k - S, 0) - p)
            else:
                t += q * (S - k)
        return t * multiplier
    pts = sorted(set([0] + [leg[1] for leg in legs]))
    top = pts[-1]
    slope = value(top + 1) - value(top)
    vals = [value(p) for p in pts]
    gain = None if slope > 0 else max(vals)
    loss = None if slope < 0 else min(vals)
    bes = []
    for a, b in zip(pts, pts[1:]):
        va, vb = value(a), value(b)
        if va == 0:
            bes.append(Fraction(a))
        elif va * vb < 0:
            bes.append(a - va * (b - a) / (vb - va))
    vt = value(top)
    if vt == 0:
        bes.append(Fraction(top))
    elif vt * slope < 0:
        bes.append(top - vt / slope)
    def r4(x):
        return None if x is None else float(round(x, 4))
    return [r4(gain), r4(loss), [r4(x) for x in sorted(set(bes))]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression breakeven interpolation 1', [[['C', 100, -1, 2.0], ['C', 80, 1, 1.25], ['C', 95, 2, 5.1], ['C', 115, 1, 1.25]], 100], [None, -1070.0, [90.7]]], ['regression breakeven interpolation 2', [[['P', 95, -1, 7.75]], 100], [775.0, -8725.0, [87.25]]], ['partial repair probe 1', [[['C', 115, -1, 3.4], ['C', 95, 2, 3.4], ['C', 105, -1, 1.25]], 100], [2785.0, -215.0, [96.075]]], ['partial repair probe 2', [[['P', 85, -1, 2.0]], 100], [200.0, -8300.0, [83.0]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['S', 105, -1, 0.0], ['C', 110, 1, 0.5], ['C', 80, 2, 3.4]], 1], [None, 17.7, []]], ['normal control 2', [[['P', 100, 2, 0.5], ['C', 105, 2, 0.5], ['S', 90, 1, 0.0]], 1], [None, 8.0, []]], ['normal control 3', [[['C', 85, -1, 1.25]], 1], [1.25, None, [86.25]]]], [['regression breakeven interpolation 1', [[['S', 120, -1, 0.0], ['S', 90, 2, 0.0]], 100], [None, -6000.0, [60.0]]], ['regression breakeven interpolation 2', [[['C', 85, -1, 3.4], ['C', 80, -1, 1.25]], 1], [4.65, None, [84.65]]], ['partial repair probe 1', [[['S', 100, 2, 0.0], ['S', 120, 1, 0.0], ['P', 100, -2, 5.1]], 100], [None, -50980.0, [103.2667]]], ['partial repair probe 2', [[['C', 115, -2, 7.75], ['P', 105, -1, 2.0]], 1], [17.5, None, [87.5, 123.75]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 100, -2, 3.4], ['C', 105, 2, 3.4]], 1], [0.0, -10.0, [0.0, 100.0]]], ['normal control 2', [[['S', 95, -1, 0.0], ['C', 105, 2, 2.0], ['S', 110, 1, 0.0]], 1], [None, -19.0, [114.5]]], ['normal control 3', [[['C', 95, 1, 7.75], ['P', 120, 1, 5.1], ['C', 110, 1, 7.75]], 1], [None, 4.4, []]]], [['regression breakeven interpolation 1', [[['P', 110, -1, 5.1], ['P', 95, 1, 1.25]], 100], [385.0, -1115.0, [106.15]]], ['regression breakeven interpolation 2', [[['S', 115, 1, 0.0], ['P', 120, 1, 0.5], ['C', 110, 2, 3.4]], 1], [None, -2.3, [111.15]]], ['partial repair probe 1', [[['C', 110, -2, 5.1], ['P', 80, -1, 3.4]], 1], [13.6, None, [66.4, 116.8]]], ['partial repair probe 2', [[['C', 90, -1, 0.5], ['P', 90, -2, 5.1]], 1], [10.7, None, [84.65, 100.7]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 90, -2, 3.4]], 1], [6.8, None, [93.4]]], ['normal control 2', [[['C', 105, -1, 0.5]], 100], [50.0, None, [105.5]]], ['normal control 3', [[['P', 115, -1, 3.4], ['C', 110, 2, 5.1], ['S', 115, -1, 0.0], ['C', 95, -2, 2.0]], 100], [-280.0, None, []]]], [['regression breakeven interpolation 1', [[['C', 120, -1, 7.75], ['S', 80, -2, 0.0], ['C', 95, -1, 1.25]], 1], [169.0, None, [84.5]]], ['regression breakeven interpolation 2', [[['P', 110, -2, 2.0]], 100], [400.0, -21600.0, [108.0]]], ['partial repair probe 1', [[['P', 110, 1, 1.25]], 100], [10875.0, -125.0, [108.75]]], ['partial repair probe 2', [[['P', 110, -1, 3.4]], 100], [340.0, -10660.0, [106.6]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['C', 105, 1, 7.75]], 100], [None, -775.0, [112.75]]], ['normal control 2', [[['C', 80, 1, 5.1], ['S', 85, 1, 0.0]], 1], [None, -90.1, [85.05]]], ['normal control 3', [[['C', 85, 2, 0.5]], 100], [None, -100.0, [85.5]]]], [['regression breakeven interpolation 1', [[['P', 80, -1, 7.75]], 1], [7.75, -72.25, [72.25]]], ['regression breakeven interpolation 2', [[['C', 90, 1, 7.75], ['P', 105, -2, 1.25]], 1], [None, -215.25, [101.75]]], ['partial repair probe 1', [[['P', 120, -2, 7.75], ['P', 105, 1, 1.25], ['P', 100, 2, 1.25], ['C', 115, 2, 0.5]], 1], [None, -24.25, [75.75, 114.625]]], ['partial repair probe 2', [[['C', 85, 2, 1.25], ['P', 100, -2, 5.1], ['P', 100, 1, 2.0]], 1], [None, -94.3, [88.1]]], ['boundary control 1', [[['C', 100, 1, 2.0]], 100], [None, -200.0, [102.0]]], ['normal control 1', [[['S', 100, 1, 0.0], ['C', 105, -2, 2.0], ['P', 105, 1, 2.0], ['C', 95, 2, 1.25]], 1], [None, 4.5, []]], ['normal control 2', [[['S', 90, 1, 0.0], ['P', 115, 1, 7.75]], 1], [None, 17.25, []]], ['normal control 3', [[['C', 105, 1, 3.4]], 100], [None, -340.0, [108.4]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*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
regression breakeven interpolation 1[None, -1070.0, [90.7]][None, -1070.0, [90.7]]Passed
regression breakeven interpolation 2[775.0, -8725.0, [87.25]][775.0, -8725.0, [87.25]]Passed
partial repair probe 1[2785.0, -215.0, [96.075]][2785.0, -215.0, [96.075]]Passed
partial repair probe 2[200.0, -8300.0, [83.0]][200.0, -8300.0, [83.0]]Passed
boundary control 1[None, -200.0, [102.0]][None, -200.0, [102.0]]Passed
normal control 1[None, 17.7, []][None, 17.7, []]Passed
normal control 2[None, 8.0, []][None, 8.0, []]Passed
normal control 3[1.25, None, [86.25]][1.25, None, [86.25]]Passed

SHA-256 / 67c450087eb886cd3af85d761fd18308d13905498a0e6d108bb61d58e6c340ef

Verification & scope

A deterministic toy contract stated explicitly in the contract field; no claim of conformance to any exchange or clearing rulebook. 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:46:55.754914+00:00.

Case digest / 14bdb8d30d78baec2bfca1fb21a222baaf5eea4806b9f9f131f93ee0ddf69833