broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic > thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression automatic exercise threshold 1', ['C', 101.5, 101.52, -10, 10, 0.02, 'exercise'], [True, -2.0]], ['regression automatic exercise threshold 2', ['C', 101.5, 101.51, -10, 100, 0.01, 'dnx'], [True, -10.0]], ['partial repair probe 1', ['P', 50, 51.37, 1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['P', 25, 25.05, -4, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 150, 149.95, -10, 100, 0.02, 'exercise'], [False, 0.0]], ['normal control 2', ['C', 25, 24.95, 1, 100, 0.05, 'auto'], [False, 0.0]]], [['regression automatic exercise threshold 1', ['P', 50, 49.99, -4, 100, 0.01, 'auto'], [True, -4.0]], ['regression automatic exercise threshold 2', ['C', 100, 100.05, 3, 100, 0.05, 'auto'], [True, 15.0]], ['partial repair probe 1', ['C', 101.5, 101.49, -10, 10, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['C', 4500, 4500, -4, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['P', 100, 99.95, 1, 50, 0.05, 'exercise'], [True, 2.5]], ['normal control 2', ['C', 150, 149.99, -4, 10, 0.02, 'auto'], [False, 0.0]]], [['regression automatic exercise threshold 1', ['P', 100, 99.99, -1, 50, 0.01, 'dnx'], [True, -0.5]], ['regression automatic exercise threshold 2', ['C', 4500, 4500.01, -4, 100, 0.01, 'exercise'], [True, -4.0]], ['partial repair probe 1', ['P', 101.5, 113.75, -10, 10, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 50, 50.02, -1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['C', 25, 24.98, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 2', ['C', 101.5, 101.6, -10, 100, 0.05, 'dnx'], [True, -100.0]]], [['regression automatic exercise threshold 1', ['C', 100, 100.02, -1, 50, 0.02, 'auto'], [True, -1.0]], ['regression automatic exercise threshold 2', ['C', 150, 150.05, -10, 100, 0.05, 'exercise'], [True, -50.0]], ['partial repair probe 1', ['P', 50, 62.25, -1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['C', 50, 49.99, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 212.5, 212.55, 10, 50, 0.02, 'dnx'], [False, 0.0]], ['normal control 2', ['P', 4500, 4500.04, -10, 10, 0.05, 'auto'], [False, 0.0]]], [['regression automatic exercise threshold 1', ['P', 101.5, 101.48, -10, 100, 0.02, 'auto'], [True, -20.0]], ['regression automatic exercise threshold 2', ['C', 101.5, 101.51, -1, 100, 0.01, 'dnx'], [True, -1.0]], ['partial repair probe 1', ['P', 101.5, 102.87, -1, 100, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['P', 25, 25, 1, 10, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 212.5, 212.48, -4, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['P', 101.5, 101.5, -1, 100, 0.02, 'exercise'], [False, 0.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr - 1
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression automatic exercise threshold 1', ['C', 101.5, 101.52, -10, 10, 0.02, 'exercise'], [True, -2.0]], ['regression automatic exercise threshold 2', ['C', 101.5, 101.51, -10, 100, 0.01, 'dnx'], [True, -10.0]], ['partial repair probe 1', ['P', 50, 51.37, 1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['P', 25, 25.05, -4, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 150, 149.95, -10, 100, 0.02, 'exercise'], [False, 0.0]], ['normal control 2', ['C', 25, 24.95, 1, 100, 0.05, 'auto'], [False, 0.0]]], [['regression automatic exercise threshold 1', ['P', 50, 49.99, -4, 100, 0.01, 'auto'], [True, -4.0]], ['regression automatic exercise threshold 2', ['C', 100, 100.05, 3, 100, 0.05, 'auto'], [True, 15.0]], ['partial repair probe 1', ['C', 101.5, 101.49, -10, 10, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['C', 4500, 4500, -4, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['P', 100, 99.95, 1, 50, 0.05, 'exercise'], [True, 2.5]], ['normal control 2', ['C', 150, 149.99, -4, 10, 0.02, 'auto'], [False, 0.0]]], [['regression automatic exercise threshold 1', ['P', 100, 99.99, -1, 50, 0.01, 'dnx'], [True, -0.5]], ['regression automatic exercise threshold 2', ['C', 4500, 4500.01, -4, 100, 0.01, 'exercise'], [True, -4.0]], ['partial repair probe 1', ['P', 101.5, 113.75, -10, 10, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 50, 50.02, -1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['C', 25, 24.98, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 2', ['C', 101.5, 101.6, -10, 100, 0.05, 'dnx'], [True, -100.0]]], [['regression automatic exercise threshold 1', ['C', 100, 100.02, -1, 50, 0.02, 'auto'], [True, -1.0]], ['regression automatic exercise threshold 2', ['C', 150, 150.05, -10, 100, 0.05, 'exercise'], [True, -50.0]], ['partial repair probe 1', ['P', 50, 62.25, -1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['C', 50, 49.99, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 212.5, 212.55, 10, 50, 0.02, 'dnx'], [False, 0.0]], ['normal control 2', ['P', 4500, 4500.04, -10, 10, 0.05, 'auto'], [False, 0.0]]], [['regression automatic exercise threshold 1', ['P', 101.5, 101.48, -10, 100, 0.02, 'auto'], [True, -20.0]], ['regression automatic exercise threshold 2', ['C', 101.5, 101.51, -1, 100, 0.01, 'dnx'], [True, -1.0]], ['partial repair probe 1', ['P', 101.5, 102.87, -1, 100, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['P', 25, 25, 1, 10, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 212.5, 212.48, -4, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['P', 101.5, 101.5, -1, 100, 0.02, 'exercise'], [False, 0.0]]]]
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)

prompt:
Positions in the money by exactly the threshold expire worthless.

Inputs kind C/P, strike, settlement price, signed contracts (+long, -short), multiplier, a minimum in-the-money amount and a long-holder instruction (auto, exercise, dnx). Work in integer cents. Intrinsic is max(0, S-K) for calls, max(0, K-S) for puts. The automatic rule exercises when intrinsic >= threshold. Longs follow their instruction (exercise always exercises, dnx never, auto uses the rule); shorts are assigned by the automatic rule. Cash = intrinsic*multiplier*|contracts| if exercised, negative for shorts. Return [exercised, cash in currency units].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = abs(s - k)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression put intrinsic value 1', ['C', 101.5, 101.45, -4, 100, 0.02, 'auto'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 50, 51.37, 10, 100, 0.02, 'exercise'], [True, 0.0]], ['partial repair probe 1', ['P', 150, 150.02, -4, 50, 0.01, 'exercise'], [False, 0.0]], ['partial repair probe 2', ['P', 150, 150.05, 3, 100, 0.02, 'auto'], [False, 0.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 50, 50.02, 10, 100, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 150, 150, -4, 10, 0.01, 'auto'], [False, 0.0]]], [['regression put intrinsic value 1', ['P', 101.5, 102.87, -10, 50, 0.01, 'dnx'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 50, 50.01, -1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 1', ['P', 4500, 4512.25, -10, 100, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4500.1, -1, 50, 0.01, 'exercise'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 212.5, 212.5, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 2', ['C', 50, 50.01, 3, 10, 0.01, 'dnx'], [False, 0.0]]], [['regression put intrinsic value 1', ['P', 150, 150.05, -10, 100, 0.05, 'dnx'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 25, 25.1, -10, 50, 0.02, 'exercise'], [False, 0.0]], ['partial repair probe 1', ['P', 50, 50.1, -1, 50, 0.05, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4500.1, -4, 100, 0.01, 'exercise'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 212.5, 212.6, 10, 100, 0.05, 'dnx'], [False, 0.0]], ['normal control 2', ['C', 101.5, 101.5, 10, 50, 0.02, 'dnx'], [False, 0.0]]], [['regression put intrinsic value 1', ['C', 4500, 4499.99, -4, 100, 0.01, 'auto'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 50, 50.05, -10, 10, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 1', ['P', 100, 100.1, -10, 10, 0.05, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 50, 50.05, -10, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 50, 50.02, -4, 100, 0.01, 'dnx'], [True, -8.0]], ['normal control 2', ['P', 25, 25, 3, 100, 0.02, 'exercise'], [True, 0.0]]], [['regression put intrinsic value 1', ['C', 4500, 4499.98, 1, 10, 0.01, 'exercise'], [True, 0.0]], ['regression put intrinsic value 2', ['P', 212.5, 213.87, -1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 1', ['P', 50, 50.05, 3, 100, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['P', 50, 50.05, -10, 50, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['normal control 1', ['P', 101.5, 101.5, 1, 50, 0.01, 'exercise'], [True, 0.0]], ['normal control 2', ['P', 101.5, 101.49, 10, 100, 0.02, 'auto'], [False, 0.0]]]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else abs(k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression put intrinsic value 1', ['C', 101.5, 101.45, -4, 100, 0.02, 'auto'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 50, 51.37, 10, 100, 0.02, 'exercise'], [True, 0.0]], ['partial repair probe 1', ['P', 150, 150.02, -4, 50, 0.01, 'exercise'], [False, 0.0]], ['partial repair probe 2', ['P', 150, 150.05, 3, 100, 0.02, 'auto'], [False, 0.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 50, 50.02, 10, 100, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 150, 150, -4, 10, 0.01, 'auto'], [False, 0.0]]], [['regression put intrinsic value 1', ['P', 101.5, 102.87, -10, 50, 0.01, 'dnx'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 50, 50.01, -1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 1', ['P', 4500, 4512.25, -10, 100, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4500.1, -1, 50, 0.01, 'exercise'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 212.5, 212.5, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 2', ['C', 50, 50.01, 3, 10, 0.01, 'dnx'], [False, 0.0]]], [['regression put intrinsic value 1', ['P', 150, 150.05, -10, 100, 0.05, 'dnx'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 25, 25.1, -10, 50, 0.02, 'exercise'], [False, 0.0]], ['partial repair probe 1', ['P', 50, 50.1, -1, 50, 0.05, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4500.1, -4, 100, 0.01, 'exercise'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 212.5, 212.6, 10, 100, 0.05, 'dnx'], [False, 0.0]], ['normal control 2', ['C', 101.5, 101.5, 10, 50, 0.02, 'dnx'], [False, 0.0]]], [['regression put intrinsic value 1', ['C', 4500, 4499.99, -4, 100, 0.01, 'auto'], [False, 0.0]], ['regression put intrinsic value 2', ['P', 50, 50.05, -10, 10, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 1', ['P', 100, 100.1, -10, 10, 0.05, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 50, 50.05, -10, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 50, 50.02, -4, 100, 0.01, 'dnx'], [True, -8.0]], ['normal control 2', ['P', 25, 25, 3, 100, 0.02, 'exercise'], [True, 0.0]]], [['regression put intrinsic value 1', ['C', 4500, 4499.98, 1, 10, 0.01, 'exercise'], [True, 0.0]], ['regression put intrinsic value 2', ['P', 212.5, 213.87, -1, 50, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 1', ['P', 50, 50.05, 3, 100, 0.01, 'auto'], [False, 0.0]], ['partial repair probe 2', ['P', 50, 50.05, -10, 50, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['normal control 1', ['P', 101.5, 101.5, 1, 50, 0.01, 'exercise'], [True, 0.0]], ['normal control 2', ['P', 101.5, 101.49, 10, 100, 0.02, 'auto'], [False, 0.0]]]]
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)

prompt:
Out-of-the-money options are exercised and paid as if in the money.

Inputs kind C/P, strike, settlement price, signed contracts (+long, -short), multiplier, a minimum in-the-money amount and a long-holder instruction (auto, exercise, dnx). Work in integer cents. Intrinsic is max(0, S-K) for calls, max(0, K-S) for puts. The automatic rule exercises when intrinsic >= threshold. Longs follow their instruction (exercise always exercises, dnx never, auto uses the rule); shorts are assigned by the automatic rule. Cash = intrinsic*multiplier*|contracts| if exercised, negative for shorts. Return [exercised, cash in currency units].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'DNX':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression contrary instruction match 1', ['C', 50, 51.37, 1, 50, 0.05, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['P', 100, 97.5, 10, 100, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 101.5, 113.75, 1, 50, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4497.5, 10, 100, 0.05, 'dnx'], [False, 0.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['normal control 1', ['P', 50, 50.05, 3, 100, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 50, 51.37, 3, 100, 0.01, 'auto'], [False, 0.0]]], [['regression contrary instruction match 1', ['C', 4500, 4500.02, 3, 10, 0.01, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 212.5, 212.54, 10, 10, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 25, 24.99, 3, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 4500, 4500, -10, 10, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 100, 101.37, -10, 100, 0.01, 'auto'], [False, 0.0]]], [['regression contrary instruction match 1', ['C', 25, 37.25, 10, 10, 0.05, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 50, 50.02, 1, 10, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 150, 150.1, 1, 50, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['C', 100, 101.37, 1, 100, 0.02, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 50, 49.99, -1, 10, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['C', 25, 24.95, 10, 50, 0.01, 'dnx'], [False, 0.0]]], [['regression contrary instruction match 1', ['C', 100, 100.04, 10, 100, 0.01, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 100, 100.1, 3, 100, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 212.5, 212.54, 1, 10, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4497.5, 3, 10, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 101.5, 101.49, 1, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['P', 150, 150.1, -10, 10, 0.05, 'auto'], [False, 0.0]]], [['regression contrary instruction match 1', ['P', 4500, 4499.98, 3, 100, 0.02, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 50, 50.1, 10, 100, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['P', 50, 47.5, 1, 50, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['C', 150, 150.04, 10, 10, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['C', 101.5, 99.0, -4, 10, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['C', 150, 150.02, 3, 10, 0.05, 'auto'], [False, 0.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction.upper() == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression contrary instruction match 1', ['C', 50, 51.37, 1, 50, 0.05, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['P', 100, 97.5, 10, 100, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 101.5, 113.75, 1, 50, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4497.5, 10, 100, 0.05, 'dnx'], [False, 0.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['normal control 1', ['P', 50, 50.05, 3, 100, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 50, 51.37, 3, 100, 0.01, 'auto'], [False, 0.0]]], [['regression contrary instruction match 1', ['C', 4500, 4500.02, 3, 10, 0.01, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 212.5, 212.54, 10, 10, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 25, 24.99, 3, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 4500, 4500, -10, 10, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 100, 101.37, -10, 100, 0.01, 'auto'], [False, 0.0]]], [['regression contrary instruction match 1', ['C', 25, 37.25, 10, 10, 0.05, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 50, 50.02, 1, 10, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 150, 150.1, 1, 50, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['C', 100, 101.37, 1, 100, 0.02, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 50, 49.99, -1, 10, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['C', 25, 24.95, 10, 50, 0.01, 'dnx'], [False, 0.0]]], [['regression contrary instruction match 1', ['C', 100, 100.04, 10, 100, 0.01, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 100, 100.1, 3, 100, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['C', 212.5, 212.54, 1, 10, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['P', 4500, 4497.5, 3, 10, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 101.5, 101.49, 1, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['P', 150, 150.1, -10, 10, 0.05, 'auto'], [False, 0.0]]], [['regression contrary instruction match 1', ['P', 4500, 4499.98, 3, 100, 0.02, 'dnx'], [False, 0.0]], ['regression contrary instruction match 2', ['C', 50, 50.1, 10, 100, 0.02, 'dnx'], [False, 0.0]], ['partial repair probe 1', ['P', 50, 47.5, 1, 50, 0.01, 'dnx'], [False, 0.0]], ['partial repair probe 2', ['C', 150, 150.04, 10, 10, 0.01, 'dnx'], [False, 0.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['C', 101.5, 99.0, -4, 10, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['C', 150, 150.02, 3, 10, 0.05, 'auto'], [False, 0.0]]]]
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)

prompt:
Holders who instructed not to exercise are exercised automatically.

Inputs kind C/P, strike, settlement price, signed contracts (+long, -short), multiplier, a minimum in-the-money amount and a long-holder instruction (auto, exercise, dnx). Work in integer cents. Intrinsic is max(0, S-K) for calls, max(0, K-S) for puts. The automatic rule exercises when intrinsic >= threshold. Longs follow their instruction (exercise always exercises, dnx never, auto uses the rule); shorts are assigned by the automatic rule. Cash = intrinsic*multiplier*|contracts| if exercised, negative for shorts. Return [exercised, cash in currency units].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * abs(contracts) if ex else 0
    if contracts < 0:
        cash = abs(cash)
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression short settlement sign 1', ['C', 150, 150.04, -10, 50, 0.01, 'dnx'], [True, -20.0]], ['regression short settlement sign 2', ['P', 25, 22.5, -10, 10, 0.05, 'dnx'], [True, -250.0]], ['partial repair probe 1', ['P', 100, 99.99, -4, 100, 0.01, 'dnx'], [True, -4.0]], ['partial repair probe 2', ['C', 101.5, 101.54, -4, 100, 0.01, 'auto'], [True, -16.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 100, 100.1, 1, 10, 0.01, 'auto'], [True, 1.0]], ['normal control 2', ['C', 101.5, 101.49, -4, 10, 0.02, 'dnx'], [False, 0.0]]], [['regression short settlement sign 1', ['C', 101.5, 101.54, -10, 100, 0.01, 'exercise'], [True, -40.0]], ['regression short settlement sign 2', ['C', 4500, 4500.02, -10, 10, 0.01, 'auto'], [True, -2.0]], ['partial repair probe 1', ['P', 100, 97.5, -10, 100, 0.01, 'auto'], [True, -2500.0]], ['partial repair probe 2', ['P', 150, 149.99, -4, 50, 0.01, 'dnx'], [True, -2.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 50, 50.01, 3, 50, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 50, 50.1, -1, 10, 0.02, 'exercise'], [False, 0.0]]], [['regression short settlement sign 1', ['C', 101.5, 102.87, -10, 100, 0.02, 'dnx'], [True, -1370.0]], ['regression short settlement sign 2', ['C', 100, 100.02, -1, 100, 0.01, 'auto'], [True, -2.0]], ['partial repair probe 1', ['C', 25, 25.05, -4, 100, 0.02, 'auto'], [True, -20.0]], ['partial repair probe 2', ['C', 101.5, 101.52, -1, 50, 0.01, 'dnx'], [True, -1.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['P', 25, 25.1, -10, 100, 0.02, 'dnx'], [False, 0.0]], ['normal control 2', ['P', 100, 100.01, 3, 50, 0.01, 'dnx'], [False, 0.0]]], [['regression short settlement sign 1', ['P', 50, 49.95, -4, 100, 0.01, 'dnx'], [True, -20.0]], ['regression short settlement sign 2', ['C', 150, 150.1, -1, 100, 0.01, 'auto'], [True, -10.0]], ['partial repair probe 1', ['C', 25, 25.04, -1, 50, 0.02, 'dnx'], [True, -2.0]], ['partial repair probe 2', ['C', 50, 50.02, -1, 100, 0.01, 'exercise'], [True, -2.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 100, 99.98, 1, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['C', 4500, 4500, 3, 100, 0.05, 'dnx'], [False, 0.0]]], [['regression short settlement sign 1', ['C', 25, 37.25, -1, 100, 0.01, 'dnx'], [True, -1225.0]], ['regression short settlement sign 2', ['C', 25, 25.1, -1, 100, 0.02, 'dnx'], [True, -10.0]], ['partial repair probe 1', ['C', 25, 25.05, -10, 100, 0.01, 'auto'], [True, -50.0]], ['partial repair probe 2', ['P', 50, 47.5, -10, 100, 0.01, 'auto'], [True, -2500.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 25, 24.95, 1, 10, 0.01, 'auto'], [False, 0.0]], ['normal control 2', ['P', 212.5, 224.75, -10, 50, 0.01, 'auto'], [False, 0.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * multiplier * contracts if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression short settlement sign 1', ['C', 150, 150.04, -10, 50, 0.01, 'dnx'], [True, -20.0]], ['regression short settlement sign 2', ['P', 25, 22.5, -10, 10, 0.05, 'dnx'], [True, -250.0]], ['partial repair probe 1', ['P', 100, 99.99, -4, 100, 0.01, 'dnx'], [True, -4.0]], ['partial repair probe 2', ['C', 101.5, 101.54, -4, 100, 0.01, 'auto'], [True, -16.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 100, 100.1, 1, 10, 0.01, 'auto'], [True, 1.0]], ['normal control 2', ['C', 101.5, 101.49, -4, 10, 0.02, 'dnx'], [False, 0.0]]], [['regression short settlement sign 1', ['C', 101.5, 101.54, -10, 100, 0.01, 'exercise'], [True, -40.0]], ['regression short settlement sign 2', ['C', 4500, 4500.02, -10, 10, 0.01, 'auto'], [True, -2.0]], ['partial repair probe 1', ['P', 100, 97.5, -10, 100, 0.01, 'auto'], [True, -2500.0]], ['partial repair probe 2', ['P', 150, 149.99, -4, 50, 0.01, 'dnx'], [True, -2.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 50, 50.01, 3, 50, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['P', 50, 50.1, -1, 10, 0.02, 'exercise'], [False, 0.0]]], [['regression short settlement sign 1', ['C', 101.5, 102.87, -10, 100, 0.02, 'dnx'], [True, -1370.0]], ['regression short settlement sign 2', ['C', 100, 100.02, -1, 100, 0.01, 'auto'], [True, -2.0]], ['partial repair probe 1', ['C', 25, 25.05, -4, 100, 0.02, 'auto'], [True, -20.0]], ['partial repair probe 2', ['C', 101.5, 101.52, -1, 50, 0.01, 'dnx'], [True, -1.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['P', 25, 25.1, -10, 100, 0.02, 'dnx'], [False, 0.0]], ['normal control 2', ['P', 100, 100.01, 3, 50, 0.01, 'dnx'], [False, 0.0]]], [['regression short settlement sign 1', ['P', 50, 49.95, -4, 100, 0.01, 'dnx'], [True, -20.0]], ['regression short settlement sign 2', ['C', 150, 150.1, -1, 100, 0.01, 'auto'], [True, -10.0]], ['partial repair probe 1', ['C', 25, 25.04, -1, 50, 0.02, 'dnx'], [True, -2.0]], ['partial repair probe 2', ['C', 50, 50.02, -1, 100, 0.01, 'exercise'], [True, -2.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['normal control 1', ['C', 100, 99.98, 1, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['C', 4500, 4500, 3, 100, 0.05, 'dnx'], [False, 0.0]]], [['regression short settlement sign 1', ['C', 25, 37.25, -1, 100, 0.01, 'dnx'], [True, -1225.0]], ['regression short settlement sign 2', ['C', 25, 25.1, -1, 100, 0.02, 'dnx'], [True, -10.0]], ['partial repair probe 1', ['C', 25, 25.05, -10, 100, 0.01, 'auto'], [True, -50.0]], ['partial repair probe 2', ['P', 50, 47.5, -10, 100, 0.01, 'auto'], [True, -2500.0]], ['boundary control 1', ['C', 100, 100.01, 1, 100, 0.01, 'auto'], [True, 1.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 25, 24.95, 1, 10, 0.01, 'auto'], [False, 0.0]], ['normal control 2', ['P', 212.5, 224.75, -10, 50, 0.01, 'auto'], [False, 0.0]]]]
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)

prompt:
Short holders are credited instead of debited on assignment.

Inputs kind C/P, strike, settlement price, signed contracts (+long, -short), multiplier, a minimum in-the-money amount and a long-holder instruction (auto, exercise, dnx). Work in integer cents. Intrinsic is max(0, S-K) for calls, max(0, K-S) for puts. The automatic rule exercises when intrinsic >= threshold. Longs follow their instruction (exercise always exercises, dnx never, auto uses the rule); shorts are assigned by the automatic rule. Cash = intrinsic*multiplier*|contracts| if exercised, negative for shorts. Return [exercised, cash in currency units].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression contract multiplier 1', ['C', 212.5, 212.54, -1, 100, 0.01, 'dnx'], [True, -4.0]], ['regression contract multiplier 2', ['P', 50, 47.5, -10, 100, 0.05, 'dnx'], [True, -2500.0]], ['partial repair probe 1', ['P', 212.5, 212.49, -1, 50, 0.01, 'dnx'], [True, -0.5]], ['partial repair probe 2', ['C', 212.5, 224.75, -4, 10, 0.01, 'auto'], [True, -490.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 101.5, 101.5, -10, 10, 0.05, 'dnx'], [False, 0.0]], ['normal control 2', ['C', 25, 24.98, 1, 100, 0.01, 'auto'], [False, 0.0]]], [['regression contract multiplier 1', ['C', 100, 101.37, -1, 50, 0.05, 'auto'], [True, -68.5]], ['regression contract multiplier 2', ['P', 150, 149.95, -10, 10, 0.05, 'exercise'], [True, -5.0]], ['partial repair probe 1', ['P', 50, 49.98, 1, 10, 0.01, 'exercise'], [True, 0.2]], ['partial repair probe 2', ['P', 25, 22.5, -10, 50, 0.01, 'auto'], [True, -1250.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 4500, 4500.05, 1, 50, 0.02, 'exercise'], [True, 0.0]], ['normal control 2', ['P', 212.5, 224.75, -1, 50, 0.02, 'auto'], [False, 0.0]]], [['regression contract multiplier 1', ['C', 100, 112.25, -10, 10, 0.01, 'auto'], [True, -1225.0]], ['regression contract multiplier 2', ['P', 101.5, 101.45, -1, 50, 0.02, 'auto'], [True, -2.5]], ['partial repair probe 1', ['C', 212.5, 213.87, -10, 10, 0.01, 'dnx'], [True, -137.0]], ['partial repair probe 2', ['P', 150, 147.5, -10, 10, 0.01, 'auto'], [True, -250.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 101.5, 101.6, -10, 100, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['C', 25, 25, -1, 100, 0.05, 'exercise'], [False, 0.0]]], [['regression contract multiplier 1', ['P', 212.5, 212.45, -10, 10, 0.02, 'auto'], [True, -5.0]], ['regression contract multiplier 2', ['C', 100, 100.05, 1, 10, 0.01, 'auto'], [True, 0.5]], ['partial repair probe 1', ['C', 50, 62.25, -4, 50, 0.01, 'dnx'], [True, -2450.0]], ['partial repair probe 2', ['C', 25, 37.25, -4, 50, 0.02, 'exercise'], [True, -2450.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['P', 100, 100.02, 10, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['P', 212.5, 212.55, -1, 50, 0.05, 'dnx'], [False, 0.0]]], [['regression contract multiplier 1', ['C', 4500, 4501.37, -10, 50, 0.02, 'dnx'], [True, -685.0]], ['regression contract multiplier 2', ['C', 100, 112.25, -10, 50, 0.01, 'dnx'], [True, -6125.0]], ['partial repair probe 1', ['C', 4500, 4500.02, 1, 10, 0.02, 'auto'], [True, 0.2]], ['partial repair probe 2', ['C', 212.5, 212.51, -1, 50, 0.01, 'auto'], [True, -0.5]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 4500, 4497.5, -10, 50, 0.01, 'exercise'], [False, 0.0]], ['normal control 2', ['P', 50, 49.98, -1, 100, 0.05, 'dnx'], [False, 0.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, settle, contracts, multiplier, min_itm, instruction):
    k = round(strike * 100)
    s = round(settle * 100)
    thr = round(min_itm * 100)
    intrinsic = max(0, s - k) if kind == 'C' else max(0, k - s)
    auto = intrinsic >= thr
    if contracts > 0:
        if instruction == 'exercise':
            ex = True
        elif instruction == 'dnx':
            ex = False
        else:
            ex = auto
    else:
        ex = auto
    cash = intrinsic * 100 * abs(contracts) if ex else 0
    if contracts < 0:
        cash = -cash
    return [ex, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression contract multiplier 1', ['C', 212.5, 212.54, -1, 100, 0.01, 'dnx'], [True, -4.0]], ['regression contract multiplier 2', ['P', 50, 47.5, -10, 100, 0.05, 'dnx'], [True, -2500.0]], ['partial repair probe 1', ['P', 212.5, 212.49, -1, 50, 0.01, 'dnx'], [True, -0.5]], ['partial repair probe 2', ['C', 212.5, 224.75, -4, 10, 0.01, 'auto'], [True, -490.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 101.5, 101.5, -10, 10, 0.05, 'dnx'], [False, 0.0]], ['normal control 2', ['C', 25, 24.98, 1, 100, 0.01, 'auto'], [False, 0.0]]], [['regression contract multiplier 1', ['C', 100, 101.37, -1, 50, 0.05, 'auto'], [True, -68.5]], ['regression contract multiplier 2', ['P', 150, 149.95, -10, 10, 0.05, 'exercise'], [True, -5.0]], ['partial repair probe 1', ['P', 50, 49.98, 1, 10, 0.01, 'exercise'], [True, 0.2]], ['partial repair probe 2', ['P', 25, 22.5, -10, 50, 0.01, 'auto'], [True, -1250.0]], ['boundary control 1', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 4500, 4500.05, 1, 50, 0.02, 'exercise'], [True, 0.0]], ['normal control 2', ['P', 212.5, 224.75, -1, 50, 0.02, 'auto'], [False, 0.0]]], [['regression contract multiplier 1', ['C', 100, 112.25, -10, 10, 0.01, 'auto'], [True, -1225.0]], ['regression contract multiplier 2', ['P', 101.5, 101.45, -1, 50, 0.02, 'auto'], [True, -2.5]], ['partial repair probe 1', ['C', 212.5, 213.87, -10, 10, 0.01, 'dnx'], [True, -137.0]], ['partial repair probe 2', ['P', 150, 147.5, -10, 10, 0.01, 'auto'], [True, -250.0]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['normal control 1', ['P', 101.5, 101.6, -10, 100, 0.05, 'auto'], [False, 0.0]], ['normal control 2', ['C', 25, 25, -1, 100, 0.05, 'exercise'], [False, 0.0]]], [['regression contract multiplier 1', ['P', 212.5, 212.45, -10, 10, 0.02, 'auto'], [True, -5.0]], ['regression contract multiplier 2', ['C', 100, 100.05, 1, 10, 0.01, 'auto'], [True, 0.5]], ['partial repair probe 1', ['C', 50, 62.25, -4, 50, 0.01, 'dnx'], [True, -2450.0]], ['partial repair probe 2', ['C', 25, 37.25, -4, 50, 0.02, 'exercise'], [True, -2450.0]], ['boundary control 1', ['C', 100, 99.0, 2, 100, 0.01, 'exercise'], [True, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['P', 100, 100.02, 10, 100, 0.02, 'auto'], [False, 0.0]], ['normal control 2', ['P', 212.5, 212.55, -1, 50, 0.05, 'dnx'], [False, 0.0]]], [['regression contract multiplier 1', ['C', 4500, 4501.37, -10, 50, 0.02, 'dnx'], [True, -685.0]], ['regression contract multiplier 2', ['C', 100, 112.25, -10, 50, 0.01, 'dnx'], [True, -6125.0]], ['partial repair probe 1', ['C', 4500, 4500.02, 1, 10, 0.02, 'auto'], [True, 0.2]], ['partial repair probe 2', ['C', 212.5, 212.51, -1, 50, 0.01, 'auto'], [True, -0.5]], ['boundary control 1', ['P', 100, 100, 1, 100, 0.01, 'auto'], [False, 0.0]], ['boundary control 2', ['C', 100, 105, 1, 100, 0.01, 'dnx'], [False, 0.0]], ['normal control 1', ['C', 4500, 4497.5, -10, 50, 0.01, 'exercise'], [False, 0.0]], ['normal control 2', ['P', 50, 49.98, -1, 100, 0.05, 'dnx'], [False, 0.0]]]]
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)

prompt:
Cash settlement is a fraction of the correct amount.

Inputs kind C/P, strike, settlement price, signed contracts (+long, -short), multiplier, a minimum in-the-money amount and a long-holder instruction (auto, exercise, dnx). Work in integer cents. Intrinsic is max(0, S-K) for calls, max(0, K-S) for puts. The automatic rule exercises when intrinsic >= threshold. Longs follow their instruction (exercise always exercises, dnx never, auto uses the rule); shorts are assigned by the automatic rule. Cash = intrinsic*multiplier*|contracts| if exercised, negative for shorts. Return [exercised, cash in currency units].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = 1
    if contracts < 0:
        direction = -direction
    shares = direction * n
    cash = -direction * n * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression put delivery direction 1', ['P', 10, 5, 100, True], [-500, 5000.0]], ['regression put delivery direction 2', ['P', 42.5, -3, 100, True], [300, -12750.0]], ['partial repair probe 1', ['P', 250, -1, 50, True], [50, -12500.0]], ['partial repair probe 2', ['P', 101.25, -3, 133, True], [399, -40398.75]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 2, 133, True], [266, -66500.0]], ['normal control 2', ['C', 42.5, -1, 50, True], [-50, 2125.0]]], [['regression put delivery direction 1', ['P', 10, 5, 50, True], [-250, 2500.0]], ['regression put delivery direction 2', ['P', 10, 2, 150, True], [-300, 3000.0]], ['partial repair probe 1', ['P', 250, -3, 133, True], [399, -99750.0]], ['partial repair probe 2', ['P', 101.25, -1, 150, True], [150, -15187.5]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 42.5, -3, 150, False], [0, 0.0]], ['normal control 2', ['P', 10, 1, 100, False], [0, 0.0]]], [['regression put delivery direction 1', ['P', 42.5, 2, 150, True], [-300, 12750.0]], ['regression put delivery direction 2', ['P', 250, 2, 100, True], [-200, 50000.0]], ['partial repair probe 1', ['P', 42.5, -1, 50, True], [50, -2125.0]], ['partial repair probe 2', ['P', 250, -3, 50, True], [150, -37500.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 1, 133, True], [133, -33250.0]], ['normal control 2', ['C', 250, 2, 100, True], [200, -50000.0]]], [['regression put delivery direction 1', ['P', 10, -3, 150, True], [450, -4500.0]], ['regression put delivery direction 2', ['P', 42.5, -1, 133, True], [133, -5652.5]], ['partial repair probe 1', ['P', 250, -3, 100, True], [300, -75000.0]], ['partial repair probe 2', ['P', 101.25, -3, 50, True], [150, -15187.5]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 42.5, -1, 100, True], [-100, 4250.0]], ['normal control 2', ['C', 101.25, 5, 100, True], [500, -50625.0]]], [['regression put delivery direction 1', ['P', 42.5, 1, 50, True], [-50, 2125.0]], ['regression put delivery direction 2', ['P', 42.5, -3, 100, True], [300, -12750.0]], ['partial repair probe 1', ['P', 42.5, -1, 100, True], [100, -4250.0]], ['partial repair probe 2', ['P', 101.25, -1, 133, True], [133, -13466.25]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 250, -3, 100, True], [-300, 75000.0]], ['normal control 2', ['C', 10, -3, 150, True], [-450, 4500.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = -1 if kind == 'P' and contracts > 0 else 1
    if contracts < 0:
        direction = -direction
    shares = direction * n
    cash = -direction * n * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression put delivery direction 1', ['P', 10, 5, 100, True], [-500, 5000.0]], ['regression put delivery direction 2', ['P', 42.5, -3, 100, True], [300, -12750.0]], ['partial repair probe 1', ['P', 250, -1, 50, True], [50, -12500.0]], ['partial repair probe 2', ['P', 101.25, -3, 133, True], [399, -40398.75]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 2, 133, True], [266, -66500.0]], ['normal control 2', ['C', 42.5, -1, 50, True], [-50, 2125.0]]], [['regression put delivery direction 1', ['P', 10, 5, 50, True], [-250, 2500.0]], ['regression put delivery direction 2', ['P', 10, 2, 150, True], [-300, 3000.0]], ['partial repair probe 1', ['P', 250, -3, 133, True], [399, -99750.0]], ['partial repair probe 2', ['P', 101.25, -1, 150, True], [150, -15187.5]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 42.5, -3, 150, False], [0, 0.0]], ['normal control 2', ['P', 10, 1, 100, False], [0, 0.0]]], [['regression put delivery direction 1', ['P', 42.5, 2, 150, True], [-300, 12750.0]], ['regression put delivery direction 2', ['P', 250, 2, 100, True], [-200, 50000.0]], ['partial repair probe 1', ['P', 42.5, -1, 50, True], [50, -2125.0]], ['partial repair probe 2', ['P', 250, -3, 50, True], [150, -37500.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 1, 133, True], [133, -33250.0]], ['normal control 2', ['C', 250, 2, 100, True], [200, -50000.0]]], [['regression put delivery direction 1', ['P', 10, -3, 150, True], [450, -4500.0]], ['regression put delivery direction 2', ['P', 42.5, -1, 133, True], [133, -5652.5]], ['partial repair probe 1', ['P', 250, -3, 100, True], [300, -75000.0]], ['partial repair probe 2', ['P', 101.25, -3, 50, True], [150, -15187.5]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 42.5, -1, 100, True], [-100, 4250.0]], ['normal control 2', ['C', 101.25, 5, 100, True], [500, -50625.0]]], [['regression put delivery direction 1', ['P', 42.5, 1, 50, True], [-50, 2125.0]], ['regression put delivery direction 2', ['P', 42.5, -3, 100, True], [300, -12750.0]], ['partial repair probe 1', ['P', 42.5, -1, 100, True], [100, -4250.0]], ['partial repair probe 2', ['P', 101.25, -1, 133, True], [133, -13466.25]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 250, -3, 100, True], [-300, 75000.0]], ['normal control 2', ['C', 10, -3, 150, True], [-450, 4500.0]]]]
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)

prompt:
Exercised puts add shares and debit cash instead of delivering shares for cash.

Inputs kind C/P, strike, signed contracts (+long exercised, -short assigned), deliverable shares per contract and whether exercise happened. Long calls and short puts receive shares and pay strike*shares; long puts and short calls deliver shares and receive strike*shares. Return [share delta, cash delta] (cash in currency, computed in cents); unexercised returns [0, 0.0].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = 1 if kind == 'C' else -1
    if contracts < 0 and kind == 'C':
        direction = -direction
    shares = direction * n
    cash = -direction * n * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression assignment inversion 1', ['P', 101.25, -3, 100, True], [300, -30375.0]], ['regression assignment inversion 2', ['P', 42.5, -3, 100, True], [300, -12750.0]], ['partial repair probe 1', ['C', 42.5, -3, 150, True], [-450, 19125.0]], ['partial repair probe 2', ['C', 250, -3, 133, True], [-399, 99750.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 250, 1, 100, True], [100, -25000.0]], ['normal control 2', ['P', 42.5, 1, 50, True], [-50, 2125.0]]], [['regression assignment inversion 1', ['P', 250, -1, 133, True], [133, -33250.0]], ['regression assignment inversion 2', ['P', 101.25, -1, 100, True], [100, -10125.0]], ['partial repair probe 1', ['C', 101.25, -3, 150, True], [-450, 45562.5]], ['partial repair probe 2', ['C', 250, -1, 100, True], [-100, 25000.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 10, 5, 100, True], [500, -5000.0]], ['normal control 2', ['C', 101.25, -3, 100, False], [0, 0.0]]], [['regression assignment inversion 1', ['P', 10, -1, 50, True], [50, -500.0]], ['regression assignment inversion 2', ['P', 42.5, -1, 150, True], [150, -6375.0]], ['partial repair probe 1', ['C', 101.25, -1, 150, True], [-150, 15187.5]], ['partial repair probe 2', ['C', 101.25, -1, 50, True], [-50, 5062.5]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['P', 10, 2, 150, True], [-300, 3000.0]], ['normal control 2', ['C', 101.25, 2, 50, False], [0, 0.0]]], [['regression assignment inversion 1', ['P', 42.5, -3, 50, True], [150, -6375.0]], ['regression assignment inversion 2', ['P', 10, -1, 50, True], [50, -500.0]], ['partial repair probe 1', ['C', 42.5, -3, 100, True], [-300, 12750.0]], ['partial repair probe 2', ['C', 250, -1, 150, True], [-150, 37500.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 5, 100, True], [500, -125000.0]], ['normal control 2', ['P', 10, 5, 100, True], [-500, 5000.0]]], [['regression assignment inversion 1', ['P', 42.5, -1, 50, True], [50, -2125.0]], ['regression assignment inversion 2', ['P', 10, -1, 150, True], [150, -1500.0]], ['partial repair probe 1', ['C', 101.25, -1, 50, True], [-50, 5062.5]], ['partial repair probe 2', ['C', 42.5, -1, 100, True], [-100, 4250.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 2, 133, True], [266, -66500.0]], ['normal control 2', ['C', 10, 5, 100, True], [500, -5000.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = 1 if kind == 'C' else -1
    if contracts < 0 and kind == 'P':
        direction = -direction
    shares = direction * n
    cash = -direction * n * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression assignment inversion 1', ['P', 101.25, -3, 100, True], [300, -30375.0]], ['regression assignment inversion 2', ['P', 42.5, -3, 100, True], [300, -12750.0]], ['partial repair probe 1', ['C', 42.5, -3, 150, True], [-450, 19125.0]], ['partial repair probe 2', ['C', 250, -3, 133, True], [-399, 99750.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 250, 1, 100, True], [100, -25000.0]], ['normal control 2', ['P', 42.5, 1, 50, True], [-50, 2125.0]]], [['regression assignment inversion 1', ['P', 250, -1, 133, True], [133, -33250.0]], ['regression assignment inversion 2', ['P', 101.25, -1, 100, True], [100, -10125.0]], ['partial repair probe 1', ['C', 101.25, -3, 150, True], [-450, 45562.5]], ['partial repair probe 2', ['C', 250, -1, 100, True], [-100, 25000.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 10, 5, 100, True], [500, -5000.0]], ['normal control 2', ['C', 101.25, -3, 100, False], [0, 0.0]]], [['regression assignment inversion 1', ['P', 10, -1, 50, True], [50, -500.0]], ['regression assignment inversion 2', ['P', 42.5, -1, 150, True], [150, -6375.0]], ['partial repair probe 1', ['C', 101.25, -1, 150, True], [-150, 15187.5]], ['partial repair probe 2', ['C', 101.25, -1, 50, True], [-50, 5062.5]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['P', 10, 2, 150, True], [-300, 3000.0]], ['normal control 2', ['C', 101.25, 2, 50, False], [0, 0.0]]], [['regression assignment inversion 1', ['P', 42.5, -3, 50, True], [150, -6375.0]], ['regression assignment inversion 2', ['P', 10, -1, 50, True], [50, -500.0]], ['partial repair probe 1', ['C', 42.5, -3, 100, True], [-300, 12750.0]], ['partial repair probe 2', ['C', 250, -1, 150, True], [-150, 37500.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 5, 100, True], [500, -125000.0]], ['normal control 2', ['P', 10, 5, 100, True], [-500, 5000.0]]], [['regression assignment inversion 1', ['P', 42.5, -1, 50, True], [50, -2125.0]], ['regression assignment inversion 2', ['P', 10, -1, 150, True], [150, -1500.0]], ['partial repair probe 1', ['C', 101.25, -1, 50, True], [-50, 5062.5]], ['partial repair probe 2', ['C', 42.5, -1, 100, True], [-100, 4250.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 250, 2, 133, True], [266, -66500.0]], ['normal control 2', ['C', 10, 5, 100, True], [500, -5000.0]]]]
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)

prompt:
Assigned short puts deliver shares they should receive.

Inputs kind C/P, strike, signed contracts (+long exercised, -short assigned), deliverable shares per contract and whether exercise happened. Long calls and short puts receive shares and pay strike*shares; long puts and short calls deliver shares and receive strike*shares. Return [share delta, cash delta] (cash in currency, computed in cents); unexercised returns [0, 0.0].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = 1 if kind == 'C' else -1
    if contracts < 0:
        direction = -direction
    shares = direction * n
    cash = direction * n * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression cash leg sign 1', ['P', 101.25, 5, 150, True], [-750, 75937.5]], ['regression cash leg sign 2', ['C', 10, 5, 150, True], [750, -7500.0]], ['partial repair probe 1', ['P', 10, 1, 50, True], [-50, 500.0]], ['partial repair probe 2', ['P', 42.5, 1, 133, True], [-133, 5652.5]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['P', 42.5, -3, 150, False], [0, 0.0]], ['normal control 2', ['C', 250, -1, 100, False], [0, 0.0]], ['normal control 3', ['C', 42.5, 2, 150, False], [0, 0.0]]], [['regression cash leg sign 1', ['P', 101.25, 5, 50, True], [-250, 25312.5]], ['regression cash leg sign 2', ['C', 250, -1, 100, True], [-100, 25000.0]], ['partial repair probe 1', ['P', 101.25, 5, 150, True], [-750, 75937.5]], ['partial repair probe 2', ['P', 42.5, 2, 100, True], [-200, 8500.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 101.25, 1, 133, False], [0, 0.0]], ['normal control 2', ['P', 101.25, -1, 100, False], [0, 0.0]], ['normal control 3', ['P', 10, 5, 100, False], [0, 0.0]]], [['regression cash leg sign 1', ['C', 250, -3, 50, True], [-150, 37500.0]], ['regression cash leg sign 2', ['C', 42.5, 2, 50, True], [100, -4250.0]], ['partial repair probe 1', ['P', 101.25, 5, 150, True], [-750, 75937.5]], ['partial repair probe 2', ['C', 10, -1, 100, True], [-100, 1000.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 101.25, 2, 100, False], [0, 0.0]], ['normal control 2', ['C', 101.25, -1, 50, False], [0, 0.0]], ['normal control 3', ['C', 42.5, 1, 100, False], [0, 0.0]]], [['regression cash leg sign 1', ['P', 42.5, 2, 150, True], [-300, 12750.0]], ['regression cash leg sign 2', ['P', 10, -1, 150, True], [150, -1500.0]], ['partial repair probe 1', ['C', 10, -1, 133, True], [-133, 1330.0]], ['partial repair probe 2', ['C', 250, -3, 50, True], [-150, 37500.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['P', 101.25, -3, 50, False], [0, 0.0]], ['normal control 2', ['P', 101.25, 2, 133, False], [0, 0.0]], ['normal control 3', ['C', 101.25, 5, 100, False], [0, 0.0]]], [['regression cash leg sign 1', ['C', 250, 1, 100, True], [100, -25000.0]], ['regression cash leg sign 2', ['P', 250, 1, 50, True], [-50, 12500.0]], ['partial repair probe 1', ['C', 101.25, -3, 100, True], [-300, 30375.0]], ['partial repair probe 2', ['C', 250, -3, 100, True], [-300, 75000.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 101.25, -3, 133, False], [0, 0.0]], ['normal control 2', ['C', 10, 5, 50, False], [0, 0.0]], ['normal control 3', ['C', 101.25, -1, 50, False], [0, 0.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = 1 if kind == 'C' else -1
    if contracts < 0:
        direction = -direction
    shares = direction * n
    cash = -abs(direction * n * k)
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression cash leg sign 1', ['P', 101.25, 5, 150, True], [-750, 75937.5]], ['regression cash leg sign 2', ['C', 10, 5, 150, True], [750, -7500.0]], ['partial repair probe 1', ['P', 10, 1, 50, True], [-50, 500.0]], ['partial repair probe 2', ['P', 42.5, 1, 133, True], [-133, 5652.5]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['P', 42.5, -3, 150, False], [0, 0.0]], ['normal control 2', ['C', 250, -1, 100, False], [0, 0.0]], ['normal control 3', ['C', 42.5, 2, 150, False], [0, 0.0]]], [['regression cash leg sign 1', ['P', 101.25, 5, 50, True], [-250, 25312.5]], ['regression cash leg sign 2', ['C', 250, -1, 100, True], [-100, 25000.0]], ['partial repair probe 1', ['P', 101.25, 5, 150, True], [-750, 75937.5]], ['partial repair probe 2', ['P', 42.5, 2, 100, True], [-200, 8500.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 101.25, 1, 133, False], [0, 0.0]], ['normal control 2', ['P', 101.25, -1, 100, False], [0, 0.0]], ['normal control 3', ['P', 10, 5, 100, False], [0, 0.0]]], [['regression cash leg sign 1', ['C', 250, -3, 50, True], [-150, 37500.0]], ['regression cash leg sign 2', ['C', 42.5, 2, 50, True], [100, -4250.0]], ['partial repair probe 1', ['P', 101.25, 5, 150, True], [-750, 75937.5]], ['partial repair probe 2', ['C', 10, -1, 100, True], [-100, 1000.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 101.25, 2, 100, False], [0, 0.0]], ['normal control 2', ['C', 101.25, -1, 50, False], [0, 0.0]], ['normal control 3', ['C', 42.5, 1, 100, False], [0, 0.0]]], [['regression cash leg sign 1', ['P', 42.5, 2, 150, True], [-300, 12750.0]], ['regression cash leg sign 2', ['P', 10, -1, 150, True], [150, -1500.0]], ['partial repair probe 1', ['C', 10, -1, 133, True], [-133, 1330.0]], ['partial repair probe 2', ['C', 250, -3, 50, True], [-150, 37500.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['P', 101.25, -3, 50, False], [0, 0.0]], ['normal control 2', ['P', 101.25, 2, 133, False], [0, 0.0]], ['normal control 3', ['C', 101.25, 5, 100, False], [0, 0.0]]], [['regression cash leg sign 1', ['C', 250, 1, 100, True], [100, -25000.0]], ['regression cash leg sign 2', ['P', 250, 1, 50, True], [-50, 12500.0]], ['partial repair probe 1', ['C', 101.25, -3, 100, True], [-300, 30375.0]], ['partial repair probe 2', ['C', 250, -3, 100, True], [-300, 75000.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 101.25, -3, 133, False], [0, 0.0]], ['normal control 2', ['C', 10, 5, 50, False], [0, 0.0]], ['normal control 3', ['C', 101.25, -1, 50, False], [0, 0.0]]]]
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)

prompt:
Buyers of shares are credited the strike price.

Inputs kind C/P, strike, signed contracts (+long exercised, -short assigned), deliverable shares per contract and whether exercise happened. Long calls and short puts receive shares and pay strike*shares; long puts and short calls deliver shares and receive strike*shares. Return [share delta, cash delta] (cash in currency, computed in cents); unexercised returns [0, 0.0].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * 100
    k = round(strike * 100)
    direction = 1 if kind == 'C' else -1
    if contracts < 0:
        direction = -direction
    shares = direction * n
    cash = -direction * n * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression adjusted deliverable 1', ['P', 250, -3, 50, True], [150, -37500.0]], ['regression adjusted deliverable 2', ['C', 101.25, 5, 150, True], [750, -75937.5]], ['partial repair probe 1', ['P', 10, -3, 150, True], [450, -4500.0]], ['partial repair probe 2', ['C', 101.25, 5, 50, True], [250, -25312.5]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['P', 50, -1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 10, -3, 50, False], [0, 0.0]], ['normal control 2', ['C', 10, 1, 100, True], [100, -1000.0]]], [['regression adjusted deliverable 1', ['C', 42.5, 5, 50, True], [250, -10625.0]], ['regression adjusted deliverable 2', ['P', 101.25, -3, 50, True], [150, -15187.5]], ['partial repair probe 1', ['C', 101.25, 2, 150, True], [300, -30375.0]], ['partial repair probe 2', ['C', 42.5, -3, 150, True], [-450, 19125.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['P', 50, -1, 100, True], [100, -5000.0]], ['normal control 1', ['P', 42.5, -1, 100, True], [100, -4250.0]], ['normal control 2', ['P', 101.25, -1, 100, True], [100, -10125.0]]], [['regression adjusted deliverable 1', ['C', 250, 2, 150, True], [300, -75000.0]], ['regression adjusted deliverable 2', ['P', 101.25, 1, 50, True], [-50, 5062.5]], ['partial repair probe 1', ['C', 101.25, -1, 150, True], [-150, 15187.5]], ['partial repair probe 2', ['P', 42.5, 5, 50, True], [-250, 10625.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 250, -1, 50, False], [0, 0.0]], ['normal control 2', ['P', 42.5, 2, 100, True], [-200, 8500.0]]], [['regression adjusted deliverable 1', ['P', 250, 5, 50, True], [-250, 62500.0]], ['regression adjusted deliverable 2', ['C', 250, 1, 50, True], [50, -12500.0]], ['partial repair probe 1', ['P', 10, 5, 133, True], [-665, 6650.0]], ['partial repair probe 2', ['P', 250, 1, 50, True], [-50, 12500.0]], ['boundary control 1', ['P', 50, -1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 10, -1, 133, False], [0, 0.0]], ['normal control 2', ['C', 10, -3, 100, False], [0, 0.0]]], [['regression adjusted deliverable 1', ['C', 250, -1, 150, True], [-150, 37500.0]], ['regression adjusted deliverable 2', ['P', 250, 1, 50, True], [-50, 12500.0]], ['partial repair probe 1', ['C', 250, -1, 133, True], [-133, 33250.0]], ['partial repair probe 2', ['C', 42.5, -3, 50, True], [-150, 6375.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 42.5, 2, 100, False], [0, 0.0]], ['normal control 2', ['C', 10, -1, 100, True], [-100, 1000.0]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(kind, strike, contracts, deliverable, exercised):
    if not exercised:
        return [0, 0.0]
    n = abs(contracts) * deliverable
    k = round(strike * 100)
    direction = 1 if kind == 'C' else -1
    if contracts < 0:
        direction = -direction
    shares = direction * n
    cash = -direction * abs(contracts) * 100 * k
    return [shares, cash / 100]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression adjusted deliverable 1', ['P', 250, -3, 50, True], [150, -37500.0]], ['regression adjusted deliverable 2', ['C', 101.25, 5, 150, True], [750, -75937.5]], ['partial repair probe 1', ['P', 10, -3, 150, True], [450, -4500.0]], ['partial repair probe 2', ['C', 101.25, 5, 50, True], [250, -25312.5]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['P', 50, -1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 10, -3, 50, False], [0, 0.0]], ['normal control 2', ['C', 10, 1, 100, True], [100, -1000.0]]], [['regression adjusted deliverable 1', ['C', 42.5, 5, 50, True], [250, -10625.0]], ['regression adjusted deliverable 2', ['P', 101.25, -3, 50, True], [150, -15187.5]], ['partial repair probe 1', ['C', 101.25, 2, 150, True], [300, -30375.0]], ['partial repair probe 2', ['C', 42.5, -3, 150, True], [-450, 19125.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['P', 50, -1, 100, True], [100, -5000.0]], ['normal control 1', ['P', 42.5, -1, 100, True], [100, -4250.0]], ['normal control 2', ['P', 101.25, -1, 100, True], [100, -10125.0]]], [['regression adjusted deliverable 1', ['C', 250, 2, 150, True], [300, -75000.0]], ['regression adjusted deliverable 2', ['P', 101.25, 1, 50, True], [-50, 5062.5]], ['partial repair probe 1', ['C', 101.25, -1, 150, True], [-150, 15187.5]], ['partial repair probe 2', ['P', 42.5, 5, 50, True], [-250, 10625.0]], ['boundary control 1', ['C', 50, 1, 100, False], [0, 0.0]], ['boundary control 2', ['C', 50, 1, 100, True], [100, -5000.0]], ['normal control 1', ['C', 250, -1, 50, False], [0, 0.0]], ['normal control 2', ['P', 42.5, 2, 100, True], [-200, 8500.0]]], [['regression adjusted deliverable 1', ['P', 250, 5, 50, True], [-250, 62500.0]], ['regression adjusted deliverable 2', ['C', 250, 1, 50, True], [50, -12500.0]], ['partial repair probe 1', ['P', 10, 5, 133, True], [-665, 6650.0]], ['partial repair probe 2', ['P', 250, 1, 50, True], [-50, 12500.0]], ['boundary control 1', ['P', 50, -1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 10, -1, 133, False], [0, 0.0]], ['normal control 2', ['C', 10, -3, 100, False], [0, 0.0]]], [['regression adjusted deliverable 1', ['C', 250, -1, 150, True], [-150, 37500.0]], ['regression adjusted deliverable 2', ['P', 250, 1, 50, True], [-50, 12500.0]], ['partial repair probe 1', ['C', 250, -1, 133, True], [-133, 33250.0]], ['partial repair probe 2', ['C', 42.5, -3, 50, True], [-150, 6375.0]], ['boundary control 1', ['C', 50, 1, 100, True], [100, -5000.0]], ['boundary control 2', ['C', 50, 1, 100, False], [0, 0.0]], ['normal control 1', ['C', 42.5, 2, 100, False], [0, 0.0]], ['normal control 2', ['C', 10, -1, 100, True], [-100, 1000.0]]]]
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)

prompt:
Adjusted contracts after corporate actions deliver the wrong share count.

Inputs kind C/P, strike, signed contracts (+long exercised, -short assigned), deliverable shares per contract and whether exercise happened. Long calls and short puts receive shares and pay strike*shares; long puts and short calls deliver shares and receive strike*shares. Return [share delta, cash delta] (cash in currency, computed in cents); unexercised returns [0, 0.0].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(strike, contracts, deliverable, action, value):
    k = round(strike * 100)
    if action == 'split':
        new, old = value
        if new > old:
            r = new // old
            k = (2 * k + r) // (2 * r)
            contracts = contracts * r
        else:
            deliverable = deliverable * new // old
    elif action == 'special_div':
        amt = round(value * 1000)
        if amt >= 125:
            k = (k * 10 - amt + 5) // 10
    return [k / 100, contracts, deliverable]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression integral ratio detection 1', [47.5, 1, 100, 'split', [5, 3]], [47.5, 1, 166]], ['regression integral ratio detection 2', [101.01, 1, 150, 'split', [5, 3]], [101.01, 1, 250]], ['partial repair probe 1', [87.75, 1, 100, 'split', [6, 3]], [43.88, 2, 100]], ['partial repair probe 2', [25.25, 1, 150, 'split', [6, 3]], [12.63, 2, 150]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [87.75, 10, 150, 'special_div', 0.124], [87.75, 10, 150]], ['normal control 2', [47.5, 10, 100, 'special_div', 2.375], [45.13, 10, 100]]], [['regression integral ratio detection 1', [150.05, 3, 150, 'split', [5, 4]], [150.05, 3, 187]], ['regression integral ratio detection 2', [47.5, 10, 100, 'split', [3, 2]], [47.5, 10, 150]], ['partial repair probe 1', [12.5, 3, 150, 'split', [4, 2]], [6.25, 6, 150]], ['partial repair probe 2', [40, 10, 100, 'split', [4, 2]], [20.0, 20, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [33.33, 10, 100, 'split', [3, 1]], [11.11, 30, 100]], ['normal control 2', [101.01, 1, 150, 'ordinary_div', 2.375], [101.01, 1, 150]]], [['regression integral ratio detection 1', [25.25, 10, 150, 'split', [5, 3]], [25.25, 10, 250]], ['regression integral ratio detection 2', [101.01, 1, 100, 'split', [3, 2]], [101.01, 1, 150]], ['partial repair probe 1', [87.75, 3, 100, 'split', [4, 2]], [43.88, 6, 100]], ['partial repair probe 2', [150.05, 3, 100, 'split', [4, 2]], [75.03, 6, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [40, 3, 100, 'special_div', 0.1], [40.0, 3, 100]], ['normal control 2', [12.5, 3, 100, 'split', [1, 2]], [12.5, 3, 50]]], [['regression integral ratio detection 1', [101.01, 1, 100, 'split', [5, 4]], [101.01, 1, 125]], ['regression integral ratio detection 2', [87.75, 3, 150, 'split', [3, 2]], [87.75, 3, 225]], ['partial repair probe 1', [101.01, 3, 100, 'split', [4, 2]], [50.51, 6, 100]], ['partial repair probe 2', [12.5, 3, 100, 'split', [6, 3]], [6.25, 6, 100]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [40, 3, 100, 'merger', 0.126], [40.0, 3, 100]], ['normal control 2', [33.33, 10, 100, 'split', [2, 1]], [16.67, 20, 100]]], [['regression integral ratio detection 1', [40, 3, 150, 'split', [5, 3]], [40.0, 3, 250]], ['regression integral ratio detection 2', [12.5, 10, 150, 'split', [5, 4]], [12.5, 10, 187]], ['partial repair probe 1', [33.33, 3, 100, 'split', [4, 2]], [16.67, 6, 100]], ['partial repair probe 2', [101.01, 1, 100, 'split', [4, 2]], [50.51, 2, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [150.05, 1, 100, 'special_div', 2.375], [147.68, 1, 100]], ['normal control 2', [12.5, 1, 100, 'merger', 0.124], [12.5, 1, 100]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(strike, contracts, deliverable, action, value):
    k = round(strike * 100)
    if action == 'split':
        new, old = value
        if old == 1:
            r = new // old
            k = (2 * k + r) // (2 * r)
            contracts = contracts * r
        else:
            deliverable = deliverable * new // old
    elif action == 'special_div':
        amt = round(value * 1000)
        if amt >= 125:
            k = (k * 10 - amt + 5) // 10
    return [k / 100, contracts, deliverable]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression integral ratio detection 1', [47.5, 1, 100, 'split', [5, 3]], [47.5, 1, 166]], ['regression integral ratio detection 2', [101.01, 1, 150, 'split', [5, 3]], [101.01, 1, 250]], ['partial repair probe 1', [87.75, 1, 100, 'split', [6, 3]], [43.88, 2, 100]], ['partial repair probe 2', [25.25, 1, 150, 'split', [6, 3]], [12.63, 2, 150]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [87.75, 10, 150, 'special_div', 0.124], [87.75, 10, 150]], ['normal control 2', [47.5, 10, 100, 'special_div', 2.375], [45.13, 10, 100]]], [['regression integral ratio detection 1', [150.05, 3, 150, 'split', [5, 4]], [150.05, 3, 187]], ['regression integral ratio detection 2', [47.5, 10, 100, 'split', [3, 2]], [47.5, 10, 150]], ['partial repair probe 1', [12.5, 3, 150, 'split', [4, 2]], [6.25, 6, 150]], ['partial repair probe 2', [40, 10, 100, 'split', [4, 2]], [20.0, 20, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [33.33, 10, 100, 'split', [3, 1]], [11.11, 30, 100]], ['normal control 2', [101.01, 1, 150, 'ordinary_div', 2.375], [101.01, 1, 150]]], [['regression integral ratio detection 1', [25.25, 10, 150, 'split', [5, 3]], [25.25, 10, 250]], ['regression integral ratio detection 2', [101.01, 1, 100, 'split', [3, 2]], [101.01, 1, 150]], ['partial repair probe 1', [87.75, 3, 100, 'split', [4, 2]], [43.88, 6, 100]], ['partial repair probe 2', [150.05, 3, 100, 'split', [4, 2]], [75.03, 6, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [40, 3, 100, 'special_div', 0.1], [40.0, 3, 100]], ['normal control 2', [12.5, 3, 100, 'split', [1, 2]], [12.5, 3, 50]]], [['regression integral ratio detection 1', [101.01, 1, 100, 'split', [5, 4]], [101.01, 1, 125]], ['regression integral ratio detection 2', [87.75, 3, 150, 'split', [3, 2]], [87.75, 3, 225]], ['partial repair probe 1', [101.01, 3, 100, 'split', [4, 2]], [50.51, 6, 100]], ['partial repair probe 2', [12.5, 3, 100, 'split', [6, 3]], [6.25, 6, 100]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [40, 3, 100, 'merger', 0.126], [40.0, 3, 100]], ['normal control 2', [33.33, 10, 100, 'split', [2, 1]], [16.67, 20, 100]]], [['regression integral ratio detection 1', [40, 3, 150, 'split', [5, 3]], [40.0, 3, 250]], ['regression integral ratio detection 2', [12.5, 10, 150, 'split', [5, 4]], [12.5, 10, 187]], ['partial repair probe 1', [33.33, 3, 100, 'split', [4, 2]], [16.67, 6, 100]], ['partial repair probe 2', [101.01, 1, 100, 'split', [4, 2]], [50.51, 2, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [150.05, 1, 100, 'special_div', 2.375], [147.68, 1, 100]], ['normal control 2', [12.5, 1, 100, 'merger', 0.124], [12.5, 1, 100]]]]
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)

prompt:
A 3-for-2 split leaves strike and contracts unchanged and the deliverable unadjusted.

Inputs strike, contracts, deliverable, action and value. split [new, old]: if new is a multiple of old (ratio r), strike becomes strike/r rounded half-up to cents and contracts become contracts*r; otherwise the deliverable becomes floor(deliverable*new/old) with strike and contracts unchanged. special_div of at least 0.125 per share reduces the strike by the amount (rounded half-up to cents). Other actions, including ordinary_div, change nothing. Return [strike, contracts, deliverable].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(strike, contracts, deliverable, action, value):
    k = round(strike * 100)
    if action == 'split':
        new, old = value
        if new % old == 0:
            r = new // old
            k = k // r
            contracts = contracts * r
        else:
            deliverable = deliverable * new // old
    elif action == 'special_div':
        amt = round(value * 1000)
        if amt >= 125:
            k = (k * 10 - amt + 5) // 10
    return [k / 100, contracts, deliverable]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression adjusted strike rounding 1', [33.33, 1, 100, 'split', [2, 1]], [16.67, 2, 100]], ['regression adjusted strike rounding 2', [25.25, 10, 100, 'split', [4, 2]], [12.63, 20, 100]], ['partial repair probe 1', [33.33, 3, 100, 'split', [4, 2]], [16.67, 6, 100]], ['partial repair probe 2', [25.25, 1, 150, 'split', [2, 1]], [12.63, 2, 150]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [33.33, 1, 100, 'merger', 0.125], [33.33, 1, 100]], ['normal control 2', [47.5, 3, 100, 'special_div', 1.25], [46.25, 3, 100]]], [['regression adjusted strike rounding 1', [25.25, 1, 100, 'split', [3, 1]], [8.42, 3, 100]], ['regression adjusted strike rounding 2', [33.33, 10, 100, 'split', [4, 2]], [16.67, 20, 100]], ['partial repair probe 1', [150.05, 1, 150, 'split', [4, 2]], [75.03, 2, 150]], ['partial repair probe 2', [150.05, 3, 150, 'split', [2, 1]], [75.03, 6, 150]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['normal control 1', [40, 10, 150, 'split', [3, 1]], [13.33, 30, 150]], ['normal control 2', [47.5, 3, 100, 'split', [2, 1]], [23.75, 6, 100]]], [['regression adjusted strike rounding 1', [33.33, 1, 100, 'split', [4, 2]], [16.67, 2, 100]], ['regression adjusted strike rounding 2', [25.25, 10, 150, 'split', [2, 1]], [12.63, 20, 150]], ['partial repair probe 1', [150.05, 10, 150, 'split', [2, 1]], [75.03, 20, 150]], ['partial repair probe 2', [33.33, 10, 100, 'split', [6, 3]], [16.67, 20, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [33.33, 3, 100, 'special_div', 0.125], [33.21, 3, 100]], ['normal control 2', [40, 10, 100, 'special_div', 0.5], [39.5, 10, 100]]], [['regression adjusted strike rounding 1', [150.05, 1, 150, 'split', [2, 1]], [75.03, 2, 150]], ['regression adjusted strike rounding 2', [25.25, 1, 100, 'split', [6, 3]], [12.63, 2, 100]], ['partial repair probe 1', [33.33, 3, 100, 'split', [4, 2]], [16.67, 6, 100]], ['partial repair probe 2', [150.05, 3, 100, 'split', [4, 2]], [75.03, 6, 100]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [40, 1, 150, 'split', [2, 1]], [20.0, 2, 150]], ['normal control 2', [87.75, 3, 100, 'ordinary_div', 0.126], [87.75, 3, 100]]], [['regression adjusted strike rounding 1', [25.25, 10, 150, 'split', [2, 1]], [12.63, 20, 150]], ['regression adjusted strike rounding 2', [150.05, 1, 100, 'split', [4, 2]], [75.03, 2, 100]], ['partial repair probe 1', [25.25, 3, 100, 'split', [4, 2]], [12.63, 6, 100]], ['partial repair probe 2', [25.25, 3, 150, 'split', [2, 1]], [12.63, 6, 150]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [25.25, 1, 100, 'merger', 1.25], [25.25, 1, 100]], ['normal control 2', [12.5, 10, 100, 'split', [5, 4]], [12.5, 10, 125]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(strike, contracts, deliverable, action, value):
    k = round(strike * 100)
    if action == 'split':
        new, old = value
        if new % old == 0:
            r = new // old
            k = round(k / r)
            contracts = contracts * r
        else:
            deliverable = deliverable * new // old
    elif action == 'special_div':
        amt = round(value * 1000)
        if amt >= 125:
            k = (k * 10 - amt + 5) // 10
    return [k / 100, contracts, deliverable]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression adjusted strike rounding 1', [33.33, 1, 100, 'split', [2, 1]], [16.67, 2, 100]], ['regression adjusted strike rounding 2', [25.25, 10, 100, 'split', [4, 2]], [12.63, 20, 100]], ['partial repair probe 1', [33.33, 3, 100, 'split', [4, 2]], [16.67, 6, 100]], ['partial repair probe 2', [25.25, 1, 150, 'split', [2, 1]], [12.63, 2, 150]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [33.33, 1, 100, 'merger', 0.125], [33.33, 1, 100]], ['normal control 2', [47.5, 3, 100, 'special_div', 1.25], [46.25, 3, 100]]], [['regression adjusted strike rounding 1', [25.25, 1, 100, 'split', [3, 1]], [8.42, 3, 100]], ['regression adjusted strike rounding 2', [33.33, 10, 100, 'split', [4, 2]], [16.67, 20, 100]], ['partial repair probe 1', [150.05, 1, 150, 'split', [4, 2]], [75.03, 2, 150]], ['partial repair probe 2', [150.05, 3, 150, 'split', [2, 1]], [75.03, 6, 150]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['normal control 1', [40, 10, 150, 'split', [3, 1]], [13.33, 30, 150]], ['normal control 2', [47.5, 3, 100, 'split', [2, 1]], [23.75, 6, 100]]], [['regression adjusted strike rounding 1', [33.33, 1, 100, 'split', [4, 2]], [16.67, 2, 100]], ['regression adjusted strike rounding 2', [25.25, 10, 150, 'split', [2, 1]], [12.63, 20, 150]], ['partial repair probe 1', [150.05, 10, 150, 'split', [2, 1]], [75.03, 20, 150]], ['partial repair probe 2', [33.33, 10, 100, 'split', [6, 3]], [16.67, 20, 100]], ['boundary control 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [33.33, 3, 100, 'special_div', 0.125], [33.21, 3, 100]], ['normal control 2', [40, 10, 100, 'special_div', 0.5], [39.5, 10, 100]]], [['regression adjusted strike rounding 1', [150.05, 1, 150, 'split', [2, 1]], [75.03, 2, 150]], ['regression adjusted strike rounding 2', [25.25, 1, 100, 'split', [6, 3]], [12.63, 2, 100]], ['partial repair probe 1', [33.33, 3, 100, 'split', [4, 2]], [16.67, 6, 100]], ['partial repair probe 2', [150.05, 3, 100, 'split', [4, 2]], [75.03, 6, 100]], ['boundary control 1', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [40, 1, 150, 'split', [2, 1]], [20.0, 2, 150]], ['normal control 2', [87.75, 3, 100, 'ordinary_div', 0.126], [87.75, 3, 100]]], [['regression adjusted strike rounding 1', [25.25, 10, 150, 'split', [2, 1]], [12.63, 20, 150]], ['regression adjusted strike rounding 2', [150.05, 1, 100, 'split', [4, 2]], [75.03, 2, 100]], ['partial repair probe 1', [25.25, 3, 100, 'split', [4, 2]], [12.63, 6, 100]], ['partial repair probe 2', [25.25, 3, 150, 'split', [2, 1]], [12.63, 6, 150]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [25.25, 1, 100, 'merger', 1.25], [25.25, 1, 100]], ['normal control 2', [12.5, 10, 100, 'split', [5, 4]], [12.5, 10, 125]]]]
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)

prompt:
Strikes whose division leaves half a cent or more are a cent too low.

Inputs strike, contracts, deliverable, action and value. split [new, old]: if new is a multiple of old (ratio r), strike becomes strike/r rounded half-up to cents and contracts become contracts*r; otherwise the deliverable becomes floor(deliverable*new/old) with strike and contracts unchanged. special_div of at least 0.125 per share reduces the strike by the amount (rounded half-up to cents). Other actions, including ordinary_div, change nothing. Return [strike, contracts, deliverable].

split: open-access