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 = (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 fractional deliverable 1', [47.5, 1, 150, 'split', [5, 4]], [47.5, 1, 187]], ['regression fractional deliverable 2', [12.5, 3, 150, 'split', [5, 4]], [12.5, 3, 187]], ['partial repair probe 1', [12.5, 10, 100, 'split', [5, 3]], [12.5, 10, 166]], ['partial repair probe 2', [33.33, 3, 100, 'split', [5, 3]], [33.33, 3, 166]], ['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', [25.25, 1, 150, 'special_div', 1.25], [24.0, 1, 150]], ['normal control 2', [12.5, 3, 100, 'split', [2, 1]], [6.25, 6, 100]]], [['regression fractional deliverable 1', [33.33, 1, 100, 'split', [5, 3]], [33.33, 1, 166]], ['regression fractional deliverable 2', [150.05, 1, 100, 'split', [5, 3]], [150.05, 1, 166]], ['partial repair probe 1', [47.5, 3, 150, 'split', [5, 4]], [47.5, 3, 187]], ['partial repair probe 2', [47.5, 1, 100, 'split', [5, 3]], [47.5, 1, 166]], ['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', [33.33, 10, 150, 'merger', 0.125], [33.33, 10, 150]], ['normal control 2', [47.5, 10, 150, 'special_div', 0.125], [47.38, 10, 150]]], [['regression fractional deliverable 1', [150.05, 10, 150, 'split', [5, 4]], [150.05, 10, 187]], ['regression fractional deliverable 2', [25.25, 3, 100, 'split', [5, 3]], [25.25, 3, 166]], ['partial repair probe 1', [87.75, 3, 100, 'split', [5, 3]], [87.75, 3, 166]], ['partial repair probe 2', [40, 10, 100, 'split', [5, 3]], [40.0, 10, 166]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [150.05, 3, 100, 'special_div', 0.5], [149.55, 3, 100]], ['normal control 2', [47.5, 10, 150, 'split', [6, 3]], [23.75, 20, 150]]], [['regression fractional deliverable 1', [33.33, 10, 100, 'split', [5, 3]], [33.33, 10, 166]], ['regression fractional deliverable 2', [101.01, 10, 100, 'split', [5, 3]], [101.01, 10, 166]], ['partial repair probe 1', [101.01, 10, 150, 'split', [5, 4]], [101.01, 10, 187]], ['partial repair probe 2', [25.25, 10, 100, 'split', [5, 3]], [25.25, 10, 166]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [150.05, 10, 100, 'split', [6, 3]], [75.03, 20, 100]], ['normal control 2', [33.33, 1, 100, 'split', [4, 2]], [16.67, 2, 100]]], [['regression fractional deliverable 1', [33.33, 10, 100, 'split', [5, 3]], [33.33, 10, 166]], ['regression fractional deliverable 2', [33.33, 1, 100, 'split', [5, 3]], [33.33, 1, 166]], ['partial repair probe 1', [40, 1, 100, 'split', [5, 3]], [40.0, 1, 166]], ['partial repair probe 2', [47.5, 3, 100, 'split', [5, 3]], [47.5, 3, 166]], ['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', [101.01, 3, 150, 'split', [1, 2]], [101.01, 3, 75]], ['normal control 2', [150.05, 1, 150, 'special_div', 0.5], [149.55, 1, 150]]]]
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 = (2 * k + r) // (2 * r)
            contracts = contracts * r
        else:
            deliverable = round(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 fractional deliverable 1', [47.5, 1, 150, 'split', [5, 4]], [47.5, 1, 187]], ['regression fractional deliverable 2', [12.5, 3, 150, 'split', [5, 4]], [12.5, 3, 187]], ['partial repair probe 1', [12.5, 10, 100, 'split', [5, 3]], [12.5, 10, 166]], ['partial repair probe 2', [33.33, 3, 100, 'split', [5, 3]], [33.33, 3, 166]], ['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', [25.25, 1, 150, 'special_div', 1.25], [24.0, 1, 150]], ['normal control 2', [12.5, 3, 100, 'split', [2, 1]], [6.25, 6, 100]]], [['regression fractional deliverable 1', [33.33, 1, 100, 'split', [5, 3]], [33.33, 1, 166]], ['regression fractional deliverable 2', [150.05, 1, 100, 'split', [5, 3]], [150.05, 1, 166]], ['partial repair probe 1', [47.5, 3, 150, 'split', [5, 4]], [47.5, 3, 187]], ['partial repair probe 2', [47.5, 1, 100, 'split', [5, 3]], [47.5, 1, 166]], ['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', [33.33, 10, 150, 'merger', 0.125], [33.33, 10, 150]], ['normal control 2', [47.5, 10, 150, 'special_div', 0.125], [47.38, 10, 150]]], [['regression fractional deliverable 1', [150.05, 10, 150, 'split', [5, 4]], [150.05, 10, 187]], ['regression fractional deliverable 2', [25.25, 3, 100, 'split', [5, 3]], [25.25, 3, 166]], ['partial repair probe 1', [87.75, 3, 100, 'split', [5, 3]], [87.75, 3, 166]], ['partial repair probe 2', [40, 10, 100, 'split', [5, 3]], [40.0, 10, 166]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [150.05, 3, 100, 'special_div', 0.5], [149.55, 3, 100]], ['normal control 2', [47.5, 10, 150, 'split', [6, 3]], [23.75, 20, 150]]], [['regression fractional deliverable 1', [33.33, 10, 100, 'split', [5, 3]], [33.33, 10, 166]], ['regression fractional deliverable 2', [101.01, 10, 100, 'split', [5, 3]], [101.01, 10, 166]], ['partial repair probe 1', [101.01, 10, 150, 'split', [5, 4]], [101.01, 10, 187]], ['partial repair probe 2', [25.25, 10, 100, 'split', [5, 3]], [25.25, 10, 166]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [150.05, 10, 100, 'split', [6, 3]], [75.03, 20, 100]], ['normal control 2', [33.33, 1, 100, 'split', [4, 2]], [16.67, 2, 100]]], [['regression fractional deliverable 1', [33.33, 10, 100, 'split', [5, 3]], [33.33, 10, 166]], ['regression fractional deliverable 2', [33.33, 1, 100, 'split', [5, 3]], [33.33, 1, 166]], ['partial repair probe 1', [40, 1, 100, 'split', [5, 3]], [40.0, 1, 166]], ['partial repair probe 2', [47.5, 3, 100, 'split', [5, 3]], [47.5, 3, 166]], ['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', [101.01, 3, 150, 'split', [1, 2]], [101.01, 3, 75]], ['normal control 2', [150.05, 1, 150, 'special_div', 0.5], [149.55, 1, 150]]]]
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:
Deliverables such as 166.67 shares are produced for 5-for-3 splits.

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 = (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 special dividend threshold 1', [101.01, 10, 100, 'special_div', 0.125], [100.89, 10, 100]], ['regression special dividend threshold 2', [12.5, 3, 150, 'special_div', 0.125], [12.38, 3, 150]], ['partial repair probe 1', [150.05, 3, 100, 'special_div', 0.1], [150.05, 3, 100]], ['partial repair probe 2', [150.05, 10, 100, 'special_div', 0.124], [150.05, 10, 100]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [12.5, 3, 150, 'special_div', 0.01], [12.5, 3, 150]], ['normal control 2', [150.05, 1, 150, 'ordinary_div', 2.375], [150.05, 1, 150]]], [['regression special dividend threshold 1', [87.75, 1, 150, 'special_div', 0.125], [87.63, 1, 150]], ['regression special dividend threshold 2', [40, 1, 150, 'special_div', 0.125], [39.88, 1, 150]], ['partial repair probe 1', [87.75, 3, 100, 'special_div', 0.1], [87.75, 3, 100]], ['partial repair probe 2', [150.05, 1, 100, 'special_div', 0.124], [150.05, 1, 100]], ['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', [12.5, 3, 100, 'merger', 0.5], [12.5, 3, 100]], ['normal control 2', [87.75, 3, 150, 'split', [3, 1]], [29.25, 9, 150]]], [['regression special dividend threshold 1', [87.75, 10, 100, 'special_div', 0.125], [87.63, 10, 100]], ['regression special dividend threshold 2', [33.33, 1, 100, 'special_div', 0.125], [33.21, 1, 100]], ['partial repair probe 1', [101.01, 10, 150, 'special_div', 0.1], [101.01, 10, 150]], ['partial repair probe 2', [150.05, 1, 150, 'special_div', 0.124], [150.05, 1, 150]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['normal control 1', [87.75, 3, 100, 'split', [5, 4]], [87.75, 3, 125]], ['normal control 2', [12.5, 1, 100, 'split', [1, 2]], [12.5, 1, 50]]], [['regression special dividend threshold 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['regression special dividend threshold 2', [12.5, 10, 100, 'special_div', 0.125], [12.38, 10, 100]], ['partial repair probe 1', [25.25, 1, 150, 'special_div', 0.1], [25.25, 1, 150]], ['partial repair probe 2', [33.33, 1, 150, 'special_div', 0.124], [33.33, 1, 150]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [25.25, 3, 100, 'ordinary_div', 0.5], [25.25, 3, 100]], ['normal control 2', [47.5, 10, 100, 'merger', 0.5], [47.5, 10, 100]]], [['regression special dividend threshold 1', [12.5, 1, 100, 'special_div', 0.125], [12.38, 1, 100]], ['regression special dividend threshold 2', [40, 3, 150, 'special_div', 0.125], [39.88, 3, 150]], ['partial repair probe 1', [25.25, 10, 150, 'special_div', 0.124], [25.25, 10, 150]], ['partial repair probe 2', [101.01, 1, 100, 'special_div', 0.1], [101.01, 1, 100]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [87.75, 3, 100, 'merger', 0.124], [87.75, 3, 100]], ['normal control 2', [25.25, 10, 150, 'special_div', 1.25], [24.0, 10, 150]]]]
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(strike, contracts, deliverable, action, value):
    k = round(strike * 100)
    if action == 'split':
        new, old = value
        if new % old == 0:
            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 >= 12.5:
            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 special dividend threshold 1', [101.01, 10, 100, 'special_div', 0.125], [100.89, 10, 100]], ['regression special dividend threshold 2', [12.5, 3, 150, 'special_div', 0.125], [12.38, 3, 150]], ['partial repair probe 1', [150.05, 3, 100, 'special_div', 0.1], [150.05, 3, 100]], ['partial repair probe 2', [150.05, 10, 100, 'special_div', 0.124], [150.05, 10, 100]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [12.5, 3, 150, 'special_div', 0.01], [12.5, 3, 150]], ['normal control 2', [150.05, 1, 150, 'ordinary_div', 2.375], [150.05, 1, 150]]], [['regression special dividend threshold 1', [87.75, 1, 150, 'special_div', 0.125], [87.63, 1, 150]], ['regression special dividend threshold 2', [40, 1, 150, 'special_div', 0.125], [39.88, 1, 150]], ['partial repair probe 1', [87.75, 3, 100, 'special_div', 0.1], [87.75, 3, 100]], ['partial repair probe 2', [150.05, 1, 100, 'special_div', 0.124], [150.05, 1, 100]], ['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', [12.5, 3, 100, 'merger', 0.5], [12.5, 3, 100]], ['normal control 2', [87.75, 3, 150, 'split', [3, 1]], [29.25, 9, 150]]], [['regression special dividend threshold 1', [87.75, 10, 100, 'special_div', 0.125], [87.63, 10, 100]], ['regression special dividend threshold 2', [33.33, 1, 100, 'special_div', 0.125], [33.21, 1, 100]], ['partial repair probe 1', [101.01, 10, 150, 'special_div', 0.1], [101.01, 10, 150]], ['partial repair probe 2', [150.05, 1, 150, 'special_div', 0.124], [150.05, 1, 150]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['normal control 1', [87.75, 3, 100, 'split', [5, 4]], [87.75, 3, 125]], ['normal control 2', [12.5, 1, 100, 'split', [1, 2]], [12.5, 1, 50]]], [['regression special dividend threshold 1', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['regression special dividend threshold 2', [12.5, 10, 100, 'special_div', 0.125], [12.38, 10, 100]], ['partial repair probe 1', [25.25, 1, 150, 'special_div', 0.1], [25.25, 1, 150]], ['partial repair probe 2', [33.33, 1, 150, 'special_div', 0.124], [33.33, 1, 150]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [25.25, 3, 100, 'ordinary_div', 0.5], [25.25, 3, 100]], ['normal control 2', [47.5, 10, 100, 'merger', 0.5], [47.5, 10, 100]]], [['regression special dividend threshold 1', [12.5, 1, 100, 'special_div', 0.125], [12.38, 1, 100]], ['regression special dividend threshold 2', [40, 3, 150, 'special_div', 0.125], [39.88, 3, 150]], ['partial repair probe 1', [25.25, 10, 150, 'special_div', 0.124], [25.25, 10, 150]], ['partial repair probe 2', [101.01, 1, 100, 'special_div', 0.1], [101.01, 1, 100]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [87.75, 3, 100, 'merger', 0.124], [87.75, 3, 100]], ['normal control 2', [25.25, 10, 150, 'special_div', 1.25], [24.0, 10, 150]]]]
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 12.5-cent special dividend leaves strikes unchanged.

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 = (2 * k + r) // (2 * r)
            contracts = contracts * r
        else:
            deliverable = deliverable * new // old
    elif action in ('special_div', 'ordinary_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 ordinary dividend exclusion 1', [12.5, 1, 100, 'ordinary_div', 0.126], [12.5, 1, 100]], ['regression ordinary dividend exclusion 2', [25.25, 3, 150, 'ordinary_div', 0.5], [25.25, 3, 150]], ['partial repair probe 1', [150.05, 1, 150, 'merger', 1.25], [150.05, 1, 150]], ['partial repair probe 2', [87.75, 3, 100, 'merger', 0.125], [87.75, 3, 100]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [87.75, 3, 100, 'split', [6, 3]], [43.88, 6, 100]], ['normal control 2', [150.05, 1, 100, 'split', [3, 2]], [150.05, 1, 150]]], [['regression ordinary dividend exclusion 1', [47.5, 10, 100, 'ordinary_div', 2.375], [47.5, 10, 100]], ['regression ordinary dividend exclusion 2', [47.5, 10, 150, 'ordinary_div', 1.25], [47.5, 10, 150]], ['partial repair probe 1', [101.01, 10, 100, 'merger', 2.375], [101.01, 10, 100]], ['partial repair probe 2', [150.05, 10, 100, 'merger', 2.375], [150.05, 10, 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', [12.5, 3, 100, 'special_div', 0.1], [12.5, 3, 100]], ['normal control 2', [25.25, 10, 150, 'special_div', 0.125], [25.13, 10, 150]]], [['regression ordinary dividend exclusion 1', [33.33, 3, 100, 'ordinary_div', 0.5], [33.33, 3, 100]], ['regression ordinary dividend exclusion 2', [150.05, 3, 150, 'ordinary_div', 2.375], [150.05, 3, 150]], ['partial repair probe 1', [87.75, 3, 150, 'merger', 1.25], [87.75, 3, 150]], ['partial repair probe 2', [33.33, 1, 150, 'merger', 0.5], [33.33, 1, 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, 3, 100, 'split', [1, 2]], [40.0, 3, 50]], ['normal control 2', [40, 3, 100, 'special_div', 2.375], [37.63, 3, 100]]], [['regression ordinary dividend exclusion 1', [25.25, 3, 150, 'ordinary_div', 1.25], [25.25, 3, 150]], ['regression ordinary dividend exclusion 2', [40, 1, 100, 'ordinary_div', 0.5], [40.0, 1, 100]], ['partial repair probe 1', [40, 1, 100, 'merger', 2.375], [40.0, 1, 100]], ['partial repair probe 2', [12.5, 1, 150, 'merger', 1.25], [12.5, 1, 150]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [87.75, 1, 100, 'split', [4, 2]], [43.88, 2, 100]], ['normal control 2', [150.05, 10, 150, 'split', [3, 2]], [150.05, 10, 225]]], [['regression ordinary dividend exclusion 1', [12.5, 10, 100, 'ordinary_div', 0.125], [12.5, 10, 100]], ['regression ordinary dividend exclusion 2', [47.5, 3, 150, 'ordinary_div', 0.126], [47.5, 3, 150]], ['partial repair probe 1', [150.05, 10, 100, 'merger', 0.5], [150.05, 10, 100]], ['partial repair probe 2', [87.75, 10, 150, 'merger', 1.25], [87.75, 10, 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', [33.33, 1, 150, 'special_div', 0.124], [33.33, 1, 150]], ['normal control 2', [47.5, 1, 100, 'special_div', 0.125], [47.38, 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 new % old == 0:
            r = new // old
            k = (2 * k + r) // (2 * r)
            contracts = contracts * r
        else:
            deliverable = deliverable * new // old
    elif action != 'split':
        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 ordinary dividend exclusion 1', [12.5, 1, 100, 'ordinary_div', 0.126], [12.5, 1, 100]], ['regression ordinary dividend exclusion 2', [25.25, 3, 150, 'ordinary_div', 0.5], [25.25, 3, 150]], ['partial repair probe 1', [150.05, 1, 150, 'merger', 1.25], [150.05, 1, 150]], ['partial repair probe 2', [87.75, 3, 100, 'merger', 0.125], [87.75, 3, 100]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['normal control 1', [87.75, 3, 100, 'split', [6, 3]], [43.88, 6, 100]], ['normal control 2', [150.05, 1, 100, 'split', [3, 2]], [150.05, 1, 150]]], [['regression ordinary dividend exclusion 1', [47.5, 10, 100, 'ordinary_div', 2.375], [47.5, 10, 100]], ['regression ordinary dividend exclusion 2', [47.5, 10, 150, 'ordinary_div', 1.25], [47.5, 10, 150]], ['partial repair probe 1', [101.01, 10, 100, 'merger', 2.375], [101.01, 10, 100]], ['partial repair probe 2', [150.05, 10, 100, 'merger', 2.375], [150.05, 10, 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', [12.5, 3, 100, 'special_div', 0.1], [12.5, 3, 100]], ['normal control 2', [25.25, 10, 150, 'special_div', 0.125], [25.13, 10, 150]]], [['regression ordinary dividend exclusion 1', [33.33, 3, 100, 'ordinary_div', 0.5], [33.33, 3, 100]], ['regression ordinary dividend exclusion 2', [150.05, 3, 150, 'ordinary_div', 2.375], [150.05, 3, 150]], ['partial repair probe 1', [87.75, 3, 150, 'merger', 1.25], [87.75, 3, 150]], ['partial repair probe 2', [33.33, 1, 150, 'merger', 0.5], [33.33, 1, 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, 3, 100, 'split', [1, 2]], [40.0, 3, 50]], ['normal control 2', [40, 3, 100, 'special_div', 2.375], [37.63, 3, 100]]], [['regression ordinary dividend exclusion 1', [25.25, 3, 150, 'ordinary_div', 1.25], [25.25, 3, 150]], ['regression ordinary dividend exclusion 2', [40, 1, 100, 'ordinary_div', 0.5], [40.0, 1, 100]], ['partial repair probe 1', [40, 1, 100, 'merger', 2.375], [40.0, 1, 100]], ['partial repair probe 2', [12.5, 1, 150, 'merger', 1.25], [12.5, 1, 150]], ['boundary control 1', [25.25, 1, 100, 'split', [2, 1]], [12.63, 2, 100]], ['boundary control 2', [40, 1, 100, 'special_div', 0.125], [39.88, 1, 100]], ['normal control 1', [87.75, 1, 100, 'split', [4, 2]], [43.88, 2, 100]], ['normal control 2', [150.05, 10, 150, 'split', [3, 2]], [150.05, 10, 225]]], [['regression ordinary dividend exclusion 1', [12.5, 10, 100, 'ordinary_div', 0.125], [12.5, 10, 100]], ['regression ordinary dividend exclusion 2', [47.5, 3, 150, 'ordinary_div', 0.126], [47.5, 3, 150]], ['partial repair probe 1', [150.05, 10, 100, 'merger', 0.5], [150.05, 10, 100]], ['partial repair probe 2', [87.75, 10, 150, 'merger', 1.25], [87.75, 10, 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', [33.33, 1, 150, 'special_div', 0.124], [33.33, 1, 150]], ['normal control 2', [47.5, 1, 100, 'special_div', 0.125], [47.38, 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:
Regular dividends trigger contract adjustments.

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 = (2 * k + r) // (2 * r)
            contracts = contracts
        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 split contract scaling 1', [87.75, 1, 100, 'split', [4, 2]], [43.88, 2, 100]], ['regression split contract scaling 2', [101.01, 1, 100, 'split', [2, 1]], [50.51, 2, 100]], ['partial repair probe 1', [25.25, 1, 100, 'split', [4, 2]], [12.63, 2, 100]], ['partial repair probe 2', [12.5, 10, 100, 'split', [4, 2]], [6.25, 20, 100]], ['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', [25.25, 1, 100, 'merger', 1.25], [25.25, 1, 100]], ['normal control 2', [87.75, 3, 100, 'split', [3, 2]], [87.75, 3, 150]]], [['regression split contract scaling 1', [40, 3, 100, 'split', [4, 2]], [20.0, 6, 100]], ['regression split contract scaling 2', [12.5, 10, 150, 'split', [6, 3]], [6.25, 20, 150]], ['partial repair probe 1', [87.75, 3, 150, 'split', [6, 3]], [43.88, 6, 150]], ['partial repair probe 2', [87.75, 10, 150, 'split', [6, 3]], [43.88, 20, 150]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [150.05, 3, 100, 'ordinary_div', 0.5], [150.05, 3, 100]], ['normal control 2', [33.33, 10, 100, 'ordinary_div', 0.124], [33.33, 10, 100]]], [['regression split contract scaling 1', [33.33, 3, 100, 'split', [3, 1]], [11.11, 9, 100]], ['regression split contract scaling 2', [101.01, 1, 100, 'split', [4, 2]], [50.51, 2, 100]], ['partial repair probe 1', [150.05, 1, 100, 'split', [4, 2]], [75.03, 2, 100]], ['partial repair probe 2', [40, 10, 100, 'split', [6, 3]], [20.0, 20, 100]], ['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', [12.5, 1, 150, 'split', [3, 2]], [12.5, 1, 225]], ['normal control 2', [87.75, 10, 100, 'merger', 1.25], [87.75, 10, 100]]], [['regression split contract scaling 1', [47.5, 10, 100, 'split', [6, 3]], [23.75, 20, 100]], ['regression split contract scaling 2', [12.5, 3, 100, 'split', [2, 1]], [6.25, 6, 100]], ['partial repair probe 1', [25.25, 1, 100, 'split', [6, 3]], [12.63, 2, 100]], ['partial repair probe 2', [47.5, 3, 100, 'split', [4, 2]], [23.75, 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, 100, 'split', [3, 2]], [40.0, 1, 150]], ['normal control 2', [47.5, 10, 150, 'split', [3, 2]], [47.5, 10, 225]]], [['regression split contract scaling 1', [47.5, 10, 100, 'split', [2, 1]], [23.75, 20, 100]], ['regression split contract scaling 2', [101.01, 1, 100, 'split', [3, 1]], [33.67, 3, 100]], ['partial repair probe 1', [25.25, 3, 100, 'split', [4, 2]], [12.63, 6, 100]], ['partial repair probe 2', [87.75, 10, 150, 'split', [6, 3]], [43.88, 20, 150]], ['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', [40, 1, 150, 'special_div', 0.1], [40.0, 1, 150]], ['normal control 2', [25.25, 1, 100, 'merger', 1.25], [25.25, 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 new % old == 0:
            r = new // old
            k = (2 * k + r) // (2 * r)
            contracts = contracts * new
        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 split contract scaling 1', [87.75, 1, 100, 'split', [4, 2]], [43.88, 2, 100]], ['regression split contract scaling 2', [101.01, 1, 100, 'split', [2, 1]], [50.51, 2, 100]], ['partial repair probe 1', [25.25, 1, 100, 'split', [4, 2]], [12.63, 2, 100]], ['partial repair probe 2', [12.5, 10, 100, 'split', [4, 2]], [6.25, 20, 100]], ['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', [25.25, 1, 100, 'merger', 1.25], [25.25, 1, 100]], ['normal control 2', [87.75, 3, 100, 'split', [3, 2]], [87.75, 3, 150]]], [['regression split contract scaling 1', [40, 3, 100, 'split', [4, 2]], [20.0, 6, 100]], ['regression split contract scaling 2', [12.5, 10, 150, 'split', [6, 3]], [6.25, 20, 150]], ['partial repair probe 1', [87.75, 3, 150, 'split', [6, 3]], [43.88, 6, 150]], ['partial repair probe 2', [87.75, 10, 150, 'split', [6, 3]], [43.88, 20, 150]], ['boundary control 1', [40, 1, 100, 'split', [3, 2]], [40.0, 1, 150]], ['boundary control 2', [40, 1, 100, 'ordinary_div', 1.0], [40.0, 1, 100]], ['normal control 1', [150.05, 3, 100, 'ordinary_div', 0.5], [150.05, 3, 100]], ['normal control 2', [33.33, 10, 100, 'ordinary_div', 0.124], [33.33, 10, 100]]], [['regression split contract scaling 1', [33.33, 3, 100, 'split', [3, 1]], [11.11, 9, 100]], ['regression split contract scaling 2', [101.01, 1, 100, 'split', [4, 2]], [50.51, 2, 100]], ['partial repair probe 1', [150.05, 1, 100, 'split', [4, 2]], [75.03, 2, 100]], ['partial repair probe 2', [40, 10, 100, 'split', [6, 3]], [20.0, 20, 100]], ['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', [12.5, 1, 150, 'split', [3, 2]], [12.5, 1, 225]], ['normal control 2', [87.75, 10, 100, 'merger', 1.25], [87.75, 10, 100]]], [['regression split contract scaling 1', [47.5, 10, 100, 'split', [6, 3]], [23.75, 20, 100]], ['regression split contract scaling 2', [12.5, 3, 100, 'split', [2, 1]], [6.25, 6, 100]], ['partial repair probe 1', [25.25, 1, 100, 'split', [6, 3]], [12.63, 2, 100]], ['partial repair probe 2', [47.5, 3, 100, 'split', [4, 2]], [23.75, 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, 100, 'split', [3, 2]], [40.0, 1, 150]], ['normal control 2', [47.5, 10, 150, 'split', [3, 2]], [47.5, 10, 225]]], [['regression split contract scaling 1', [47.5, 10, 100, 'split', [2, 1]], [23.75, 20, 100]], ['regression split contract scaling 2', [101.01, 1, 100, 'split', [3, 1]], [33.67, 3, 100]], ['partial repair probe 1', [25.25, 3, 100, 'split', [4, 2]], [12.63, 6, 100]], ['partial repair probe 2', [87.75, 10, 150, 'split', [6, 3]], [43.88, 20, 150]], ['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', [40, 1, 150, 'special_div', 0.1], [40.0, 1, 150]], ['normal control 2', [25.25, 1, 100, 'merger', 1.25], [25.25, 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:
Holders lose exposure after a 2-for-1 split.

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(kind, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[0]
        filled.append(v)
    avg = sum(v for v in fixings if v is not None) / len([v for v in fixings if v is not None])
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression disrupted fixing handling 1', ['strike-call', [None, 87.52, 112.04, 81.76, 108.63, 98.66, 109.85, None], 110, 119.83], 20.35125], ['regression disrupted fixing handling 2', ['price-call', [None, 117.16, 81.52], 90, 95.95], 15.28], ['partial repair probe 1', ['price-put', [None, 92.96], 100, 104.63], 7.04], ['partial repair probe 2', ['price-call', [None, 111.0], 105, 107.34], 6.0], ['normal control 1', ['price-call', [107.13, None, None, 105.03, None, 100.25, None], 110, 104.13], 0.0], ['normal control 2', ['price-call', [104.5, 99.92, 114.23, 95.28], 105, 89.1], 0.0], ['normal control 3', ['price-put', [114.44, 99.53, 94.81], 105, 117.35], 2.073333], ['normal control 4', ['price-call', [90.6, None, 99.94, 92.36, 97.01, 110.32, 105.44, 114.87], 105, 99.53], 0.0]], [['regression disrupted fixing handling 1', ['price-put', [111.81, 89.43, 91.67, None], 100, 119.46], 3.855], ['regression disrupted fixing handling 2', ['price-put', [93.24, 117.39, 94.36, 88.27, None], 105, 96.62], 8.694], ['partial repair probe 1', ['price-put', [114.77, 90.96, 110.13, None, 116.07], 90, 91.76], 0.0], ['partial repair probe 2', ['strike-call', [110.79, 87.87, 85.41, 113.03, None, 93.27], 100, 84.57], 0.0], ['normal control 1', ['price-put', [93.25, 93.38], 110, 115.05], 16.685], ['normal control 2', ['price-call', [101.0, 102.82, 91.23], 90, 82.29], 8.35], ['normal control 3', ['strike-call', [84.17, 113.94, 108.91, 109.85, 112.59, 112.54], 90, 93.23], 0.0], ['normal control 4', ['price-put', [86.22, 80.69, 101.45, 101.34, 86.33, 103.13], 100, 87.56], 6.806667]], [['regression disrupted fixing handling 1', ['price-call', [106.0, 108.3, 96.37, None], 90, 103.03], 11.76], ['regression disrupted fixing handling 2', ['price-call', [99.86, None, 85.17, None, 106.07, 119.67, None, 115.98], 105, 102.54], 0.0], ['partial repair probe 1', ['price-put', [98.13, 107.51, None, 98.65, None], 100, 104.68], 0.0], ['partial repair probe 2', ['strike-call', [None, None, 106.81, 111.64, None, None], 90, 116.42], 7.195], ['normal control 1', ['price-call', [None, None, None, 96.07], 100, 115.84], 0.0], ['normal control 2', ['price-call', [84.48, 87.17, 106.28], 105, 89.71], 0.0], ['normal control 3', ['price-put', [110.16, 105.89, 83.97], 105, 95.8], 4.993333], ['normal control 4', ['price-call', [117.25, 109.64, 94.89, 91.58, 110.73], 105, 84.9], 0.0]], [['regression disrupted fixing handling 1', ['strike-call', [80.95, 115.9, 96.86, None, 91.95, None, None], 105, 102.79], 7.587143], ['regression disrupted fixing handling 2', ['price-call', [None, None, None, 105.25, None, None, 101.32, 112.49], 100, 92.33], 5.66375], ['partial repair probe 1', ['strike-call', [None, 86.49, 95.99, None, 98.83, None, 102.22, None], 105, 119.83], 23.9475], ['partial repair probe 2', ['strike-call', [None, 113.88], 100, 91.48], 0.0], ['normal control 1', ['price-call', [108.16, 89.04, None, 118.06, 104.39, None], 110, 107.4], 0.0], ['normal control 2', ['price-call', [117.04, 101.03, 116.99], 110, 86.66], 1.686667], ['normal control 3', ['strike-call', [109.16, 113.24, 117.9], 105, 84.08], 0.0], ['normal control 4', ['price-call', [113.22, 83.42, 84.09, 87.55, 101.17, 82.4, 102.33, None], 100, 105.59], 0.0]], [['regression disrupted fixing handling 1', ['price-put', [None, 80.26, 110.32, 91.41, 93.3, 83.63, None, None], 100, 96.26], 11.695], ['regression disrupted fixing handling 2', ['strike-call', [80.07, None, 84.32, None, None, 101.78, 117.54, None], 105, 101.59], 7.845], ['partial repair probe 1', ['strike-call', [None, 90.87, 88.7], 90, 81.72], 0.0], ['partial repair probe 2', ['strike-call', [None, 111.73, None, 100.17, 92.24], 105, 87.14], 0.0], ['normal control 1', ['price-call', [100.0, None], 100, 94.42], 0.0], ['normal control 2', ['price-call', [99.74, 116.93], 105, 95.76], 3.335], ['normal control 3', ['price-call', [114.28, 88.93], 105, 88.52], 0.0], ['normal control 4', ['price-call', [118.94, 103.57, None, 86.07, 107.68, None, 98.85], 110, 98.85], 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, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[0]
        filled.append(v)
    avg = sum(v or 0 for v in fixings) / len(fixings)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression disrupted fixing handling 1', ['strike-call', [None, 87.52, 112.04, 81.76, 108.63, 98.66, 109.85, None], 110, 119.83], 20.35125], ['regression disrupted fixing handling 2', ['price-call', [None, 117.16, 81.52], 90, 95.95], 15.28], ['partial repair probe 1', ['price-put', [None, 92.96], 100, 104.63], 7.04], ['partial repair probe 2', ['price-call', [None, 111.0], 105, 107.34], 6.0], ['normal control 1', ['price-call', [107.13, None, None, 105.03, None, 100.25, None], 110, 104.13], 0.0], ['normal control 2', ['price-call', [104.5, 99.92, 114.23, 95.28], 105, 89.1], 0.0], ['normal control 3', ['price-put', [114.44, 99.53, 94.81], 105, 117.35], 2.073333], ['normal control 4', ['price-call', [90.6, None, 99.94, 92.36, 97.01, 110.32, 105.44, 114.87], 105, 99.53], 0.0]], [['regression disrupted fixing handling 1', ['price-put', [111.81, 89.43, 91.67, None], 100, 119.46], 3.855], ['regression disrupted fixing handling 2', ['price-put', [93.24, 117.39, 94.36, 88.27, None], 105, 96.62], 8.694], ['partial repair probe 1', ['price-put', [114.77, 90.96, 110.13, None, 116.07], 90, 91.76], 0.0], ['partial repair probe 2', ['strike-call', [110.79, 87.87, 85.41, 113.03, None, 93.27], 100, 84.57], 0.0], ['normal control 1', ['price-put', [93.25, 93.38], 110, 115.05], 16.685], ['normal control 2', ['price-call', [101.0, 102.82, 91.23], 90, 82.29], 8.35], ['normal control 3', ['strike-call', [84.17, 113.94, 108.91, 109.85, 112.59, 112.54], 90, 93.23], 0.0], ['normal control 4', ['price-put', [86.22, 80.69, 101.45, 101.34, 86.33, 103.13], 100, 87.56], 6.806667]], [['regression disrupted fixing handling 1', ['price-call', [106.0, 108.3, 96.37, None], 90, 103.03], 11.76], ['regression disrupted fixing handling 2', ['price-call', [99.86, None, 85.17, None, 106.07, 119.67, None, 115.98], 105, 102.54], 0.0], ['partial repair probe 1', ['price-put', [98.13, 107.51, None, 98.65, None], 100, 104.68], 0.0], ['partial repair probe 2', ['strike-call', [None, None, 106.81, 111.64, None, None], 90, 116.42], 7.195], ['normal control 1', ['price-call', [None, None, None, 96.07], 100, 115.84], 0.0], ['normal control 2', ['price-call', [84.48, 87.17, 106.28], 105, 89.71], 0.0], ['normal control 3', ['price-put', [110.16, 105.89, 83.97], 105, 95.8], 4.993333], ['normal control 4', ['price-call', [117.25, 109.64, 94.89, 91.58, 110.73], 105, 84.9], 0.0]], [['regression disrupted fixing handling 1', ['strike-call', [80.95, 115.9, 96.86, None, 91.95, None, None], 105, 102.79], 7.587143], ['regression disrupted fixing handling 2', ['price-call', [None, None, None, 105.25, None, None, 101.32, 112.49], 100, 92.33], 5.66375], ['partial repair probe 1', ['strike-call', [None, 86.49, 95.99, None, 98.83, None, 102.22, None], 105, 119.83], 23.9475], ['partial repair probe 2', ['strike-call', [None, 113.88], 100, 91.48], 0.0], ['normal control 1', ['price-call', [108.16, 89.04, None, 118.06, 104.39, None], 110, 107.4], 0.0], ['normal control 2', ['price-call', [117.04, 101.03, 116.99], 110, 86.66], 1.686667], ['normal control 3', ['strike-call', [109.16, 113.24, 117.9], 105, 84.08], 0.0], ['normal control 4', ['price-call', [113.22, 83.42, 84.09, 87.55, 101.17, 82.4, 102.33, None], 100, 105.59], 0.0]], [['regression disrupted fixing handling 1', ['price-put', [None, 80.26, 110.32, 91.41, 93.3, 83.63, None, None], 100, 96.26], 11.695], ['regression disrupted fixing handling 2', ['strike-call', [80.07, None, 84.32, None, None, 101.78, 117.54, None], 105, 101.59], 7.845], ['partial repair probe 1', ['strike-call', [None, 90.87, 88.7], 90, 81.72], 0.0], ['partial repair probe 2', ['strike-call', [None, 111.73, None, 100.17, 92.24], 105, 87.14], 0.0], ['normal control 1', ['price-call', [100.0, None], 100, 94.42], 0.0], ['normal control 2', ['price-call', [99.74, 116.93], 105, 95.76], 3.335], ['normal control 3', ['price-call', [114.28, 88.93], 105, 88.52], 0.0], ['normal control 4', ['price-call', [118.94, 103.57, None, 86.07, 107.68, None, 98.85], 110, 98.85], 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:
Averages over fewer observations overweight the remaining fixings.

Inputs kind (price-call, price-put, strike-call), fixings (None = disrupted), strike and final price. A disrupted fixing takes the last preceding filled value; if none precedes, the next valid fixing. avg = mean of the filled fixings. price-call pays max(avg-K,0), price-put max(K-avg,0), strike-call max(final-avg,0). Round to 6.

split: open-access


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

N = 1
observations = []
def solve(kind, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = later[0] if later else prev[-1]
        filled.append(v)
    avg = sum(filled) / len(filled)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression fallback priority 1', ['price-put', [107.56, 91.47, None, 93.63, 107.09, 85.05], 100, 107.47], 3.955], ['regression fallback priority 2', ['strike-call', [90.82, 116.42, 97.17, None, 102.9], 100, 102.74], 1.844], ['partial repair probe 1', ['strike-call', [119.87, 109.69, None], 110, 116.2], 3.116667], ['partial repair probe 2', ['price-call', [117.31, 109.18, 80.52, 110.93, None], 90, 89.18], 15.774], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [115.48, 83.47, 98.82], 100, 99.98], 0.743333], ['normal control 2', ['strike-call', [111.57, None, None, None, 98.59, 116.83], 110, 84.9], 0.0], ['normal control 3', ['strike-call', [91.38, None, None], 105, 95.03], 3.65]], [['regression fallback priority 1', ['price-call', [98.02, None, 91.49, 95.03, 98.48, 97.35], 90, 119.72], 6.398333], ['regression fallback priority 2', ['price-put', [119.49, 98.97, 101.06, None, 95.58, 113.4, 91.41, 95.29], 105, 88.56], 2.9675], ['partial repair probe 1', ['strike-call', [88.95, 80.84, None], 110, 112.81], 29.266667], ['partial repair probe 2', ['price-put', [119.4, 88.69, 99.38, 103.22, 102.55, None], 110, 112.44], 7.368333], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [85.84, None], 90, 114.04], 4.16], ['normal control 2', ['price-put', [None, 105.9], 105, 82.58], 0.0], ['normal control 3', ['price-put', [111.7, 101.25, 103.45, 114.56, 86.59, None, 114.39], 100, 96.18], 0.0]], [['regression fallback priority 1', ['price-call', [119.01, None, 115.28], 105, 82.02], 12.766667], ['regression fallback priority 2', ['price-call', [84.27, 118.57, None, None, None, 103.89], 100, 80.29], 10.406667], ['partial repair probe 1', ['price-put', [None, 87.07, 89.34, None], 90, 115.78], 1.795], ['partial repair probe 2', ['price-put', [110.48, 85.44, None, None, None], 110, 102.6], 19.552], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [80.8, 102.44, None, 103.49, 106.76, 93.24, None], 110, 93.16], 0.0], ['normal control 2', ['price-call', [96.59, None, 81.5, 86.37, 117.86, 81.57], 100, 80.38], 0.0], ['normal control 3', ['price-put', [93.19, None, None, None, None], 110, 115.13], 16.81]], [['regression fallback priority 1', ['price-put', [85.19, None, 83.45, 104.23, 100.65, None, 102.76], 110, 109.78], 15.411429], ['regression fallback priority 2', ['strike-call', [86.53, 95.55, None, 100.69, 106.44], 90, 104.86], 7.908], ['partial repair probe 1', ['strike-call', [81.55, 101.38, 89.48, None], 100, 100.13], 9.6575], ['partial repair probe 2', ['price-put', [88.01, 87.96, None], 105, 112.32], 17.023333], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [None, 112.37, None, None], 90, 98.65], 22.37], ['normal control 2', ['price-call', [None, 110.4, 80.07], 90, 95.81], 10.29], ['normal control 3', ['price-put', [110.91, None], 100, 116.16], 0.0]], [['regression fallback priority 1', ['strike-call', [100.62, None, 111.91, 86.61, None], 100, 115.98], 18.706], ['regression fallback priority 2', ['price-put', [116.55, 87.44, 91.05, None, 97.68], 110, 114.79], 13.246], ['partial repair probe 1', ['strike-call', [87.08, 93.2, None, None, None, None], 110, 94.72], 2.54], ['partial repair probe 2', ['price-call', [104.79, 89.0, None, None], 100, 101.84], 0.0], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [None, 98.32, 105.85, 84.08], 100, 117.74], 0.0], ['normal control 2', ['price-call', [80.35, 102.5], 105, 119.19], 0.0], ['normal control 3', ['price-call', [97.46, 119.62, 96.51, 117.63, 87.35, 92.18, 101.58, 80.54], 90, 100.37], 9.10875]]]
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, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = (prev[-1] + later[0]) / 2 if prev and later else (prev or later)[0]
        filled.append(v)
    avg = sum(filled) / len(filled)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression fallback priority 1', ['price-put', [107.56, 91.47, None, 93.63, 107.09, 85.05], 100, 107.47], 3.955], ['regression fallback priority 2', ['strike-call', [90.82, 116.42, 97.17, None, 102.9], 100, 102.74], 1.844], ['partial repair probe 1', ['strike-call', [119.87, 109.69, None], 110, 116.2], 3.116667], ['partial repair probe 2', ['price-call', [117.31, 109.18, 80.52, 110.93, None], 90, 89.18], 15.774], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [115.48, 83.47, 98.82], 100, 99.98], 0.743333], ['normal control 2', ['strike-call', [111.57, None, None, None, 98.59, 116.83], 110, 84.9], 0.0], ['normal control 3', ['strike-call', [91.38, None, None], 105, 95.03], 3.65]], [['regression fallback priority 1', ['price-call', [98.02, None, 91.49, 95.03, 98.48, 97.35], 90, 119.72], 6.398333], ['regression fallback priority 2', ['price-put', [119.49, 98.97, 101.06, None, 95.58, 113.4, 91.41, 95.29], 105, 88.56], 2.9675], ['partial repair probe 1', ['strike-call', [88.95, 80.84, None], 110, 112.81], 29.266667], ['partial repair probe 2', ['price-put', [119.4, 88.69, 99.38, 103.22, 102.55, None], 110, 112.44], 7.368333], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [85.84, None], 90, 114.04], 4.16], ['normal control 2', ['price-put', [None, 105.9], 105, 82.58], 0.0], ['normal control 3', ['price-put', [111.7, 101.25, 103.45, 114.56, 86.59, None, 114.39], 100, 96.18], 0.0]], [['regression fallback priority 1', ['price-call', [119.01, None, 115.28], 105, 82.02], 12.766667], ['regression fallback priority 2', ['price-call', [84.27, 118.57, None, None, None, 103.89], 100, 80.29], 10.406667], ['partial repair probe 1', ['price-put', [None, 87.07, 89.34, None], 90, 115.78], 1.795], ['partial repair probe 2', ['price-put', [110.48, 85.44, None, None, None], 110, 102.6], 19.552], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [80.8, 102.44, None, 103.49, 106.76, 93.24, None], 110, 93.16], 0.0], ['normal control 2', ['price-call', [96.59, None, 81.5, 86.37, 117.86, 81.57], 100, 80.38], 0.0], ['normal control 3', ['price-put', [93.19, None, None, None, None], 110, 115.13], 16.81]], [['regression fallback priority 1', ['price-put', [85.19, None, 83.45, 104.23, 100.65, None, 102.76], 110, 109.78], 15.411429], ['regression fallback priority 2', ['strike-call', [86.53, 95.55, None, 100.69, 106.44], 90, 104.86], 7.908], ['partial repair probe 1', ['strike-call', [81.55, 101.38, 89.48, None], 100, 100.13], 9.6575], ['partial repair probe 2', ['price-put', [88.01, 87.96, None], 105, 112.32], 17.023333], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [None, 112.37, None, None], 90, 98.65], 22.37], ['normal control 2', ['price-call', [None, 110.4, 80.07], 90, 95.81], 10.29], ['normal control 3', ['price-put', [110.91, None], 100, 116.16], 0.0]], [['regression fallback priority 1', ['strike-call', [100.62, None, 111.91, 86.61, None], 100, 115.98], 18.706], ['regression fallback priority 2', ['price-put', [116.55, 87.44, 91.05, None, 97.68], 110, 114.79], 13.246], ['partial repair probe 1', ['strike-call', [87.08, 93.2, None, None, None, None], 110, 94.72], 2.54], ['partial repair probe 2', ['price-call', [104.79, 89.0, None, None], 100, 101.84], 0.0], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [None, 98.32, 105.85, 84.08], 100, 117.74], 0.0], ['normal control 2', ['price-call', [80.35, 102.5], 105, 119.19], 0.0], ['normal control 3', ['price-call', [97.46, 119.62, 96.51, 117.63, 87.35, 92.18, 101.58, 80.54], 90, 100.37], 9.10875]]]
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:
Mid-schedule disruptions borrow a future price.

Inputs kind (price-call, price-put, strike-call), fixings (None = disrupted), strike and final price. A disrupted fixing takes the last preceding filled value; if none precedes, the next valid fixing. avg = mean of the filled fixings. price-call pays max(avg-K,0), price-put max(K-avg,0), strike-call max(final-avg,0). Round to 6.

split: open-access


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

N = 1
observations = []
def solve(kind, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else strike
        filled.append(v)
    avg = sum(filled) / len(filled)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression leading disruption 1', ['price-call', [None, 114.94, 81.32], 90, 117.66], 13.733333], ['regression leading disruption 2', ['strike-call', [None, 100.0], 110, 106.13], 6.13], ['partial repair probe 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 2', ['price-put', [None, None, None, 116.32, None, 103.45], 110, 84.85], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['strike-call', [108.09, 82.6, 92.83, None, 118.91, 91.14, None], 100, 85.45], 0.0], ['normal control 2', ['price-call', [85.01, 94.18, 82.1], 105, 116.61], 0.0], ['normal control 3', ['price-call', [100.84, 82.19, 118.59, 115.87, 90.57], 110, 107.03], 0.0]], [['regression leading disruption 1', ['price-call', [None, 91.48, 111.91, 116.49, 84.19, None, 82.85, 115.29], 90, 118.37], 7.235], ['regression leading disruption 2', ['price-put', [None, 108.91, 94.86], 105, 114.49], 0.773333], ['partial repair probe 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 2', ['price-put', [None, None, 108.41, None, None, 89.67], 100, 105.65], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['strike-call', [119.84, 86.93, 84.4, 83.0, 99.72], 100, 106.94], 12.162], ['normal control 2', ['price-put', [85.42, 115.2, None, 88.06], 110, 85.92], 9.03], ['normal control 3', ['price-call', [None, None, 98.45, 106.81], 105, 119.97], 0.0]], [['regression leading disruption 1', ['price-put', [None, None, 85.09], 100, 101.35], 14.91], ['regression leading disruption 2', ['price-call', [None, 95.74, 111.04, None, 108.46, 115.32, 119.28, 106.15], 105, 114.03], 2.84625], ['partial repair probe 1', ['strike-call', [None, 119.28, 84.0], 110, 100.97], 0.0], ['partial repair probe 2', ['strike-call', [None, 114.32, 85.85, 84.03, 87.82, 93.76, 99.3, 80.58], 110, 93.61], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['price-call', [83.94, None, 90.41, None], 110, 81.54], 0.0], ['normal control 2', ['price-put', [99.0, None, 90.73, None, None, 112.43], 90, 80.77], 0.0], ['normal control 3', ['price-put', [115.63, None, None], 110, 88.42], 0.0]], [['regression leading disruption 1', ['strike-call', [None, None, 103.2, 95.9, 102.92], 90, 119.13], 17.446], ['regression leading disruption 2', ['strike-call', [None, 91.0, 85.59, None, 86.07, None, None], 110, 104.25], 16.908571], ['partial repair probe 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 2', ['strike-call', [None, 110.67, 87.17, None, None, 85.45], 90, 91.16], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['price-call', [108.9, None, 106.45], 100, 117.18], 8.083333], ['normal control 2', ['strike-call', [93.3, 112.85], 90, 109.53], 6.455], ['normal control 3', ['price-put', [80.04, 94.93, None, 116.64, 87.99, None], 100, 114.94], 6.246667]], [['regression leading disruption 1', ['price-call', [None, 81.2, None, 82.68, 83.48, 83.72, 115.81, 110.77], 90, 93.39], 0.0075], ['regression leading disruption 2', ['strike-call', [None, 81.52, None, None, 94.05], 110, 84.49], 0.464], ['partial repair probe 1', ['price-put', [None, None, 94.96, 105.69, 84.52, None], 90, 83.58], 0.0], ['partial repair probe 2', ['price-call', [None, None, 96.59, None, 80.55, 118.41], 100, 119.18], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['strike-call', [None, None, 109.7, 99.56, 90.86, 92.96, 99.08, None], 110, 90.22], 0.0], ['normal control 2', ['strike-call', [92.29, 83.29, None, 108.83, None, None, 117.63, 114.49], 110, 88.43], 0.0], ['normal control 3', ['strike-call', [108.57, 82.78, 81.2, 97.9], 100, 107.11], 14.4975]]]
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, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[-1]
        filled.append(v)
    avg = sum(filled) / len(filled)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression leading disruption 1', ['price-call', [None, 114.94, 81.32], 90, 117.66], 13.733333], ['regression leading disruption 2', ['strike-call', [None, 100.0], 110, 106.13], 6.13], ['partial repair probe 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 2', ['price-put', [None, None, None, 116.32, None, 103.45], 110, 84.85], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['strike-call', [108.09, 82.6, 92.83, None, 118.91, 91.14, None], 100, 85.45], 0.0], ['normal control 2', ['price-call', [85.01, 94.18, 82.1], 105, 116.61], 0.0], ['normal control 3', ['price-call', [100.84, 82.19, 118.59, 115.87, 90.57], 110, 107.03], 0.0]], [['regression leading disruption 1', ['price-call', [None, 91.48, 111.91, 116.49, 84.19, None, 82.85, 115.29], 90, 118.37], 7.235], ['regression leading disruption 2', ['price-put', [None, 108.91, 94.86], 105, 114.49], 0.773333], ['partial repair probe 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 2', ['price-put', [None, None, 108.41, None, None, 89.67], 100, 105.65], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['strike-call', [119.84, 86.93, 84.4, 83.0, 99.72], 100, 106.94], 12.162], ['normal control 2', ['price-put', [85.42, 115.2, None, 88.06], 110, 85.92], 9.03], ['normal control 3', ['price-call', [None, None, 98.45, 106.81], 105, 119.97], 0.0]], [['regression leading disruption 1', ['price-put', [None, None, 85.09], 100, 101.35], 14.91], ['regression leading disruption 2', ['price-call', [None, 95.74, 111.04, None, 108.46, 115.32, 119.28, 106.15], 105, 114.03], 2.84625], ['partial repair probe 1', ['strike-call', [None, 119.28, 84.0], 110, 100.97], 0.0], ['partial repair probe 2', ['strike-call', [None, 114.32, 85.85, 84.03, 87.82, 93.76, 99.3, 80.58], 110, 93.61], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['price-call', [83.94, None, 90.41, None], 110, 81.54], 0.0], ['normal control 2', ['price-put', [99.0, None, 90.73, None, None, 112.43], 90, 80.77], 0.0], ['normal control 3', ['price-put', [115.63, None, None], 110, 88.42], 0.0]], [['regression leading disruption 1', ['strike-call', [None, None, 103.2, 95.9, 102.92], 90, 119.13], 17.446], ['regression leading disruption 2', ['strike-call', [None, 91.0, 85.59, None, 86.07, None, None], 110, 104.25], 16.908571], ['partial repair probe 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 2', ['strike-call', [None, 110.67, 87.17, None, None, 85.45], 90, 91.16], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['price-call', [108.9, None, 106.45], 100, 117.18], 8.083333], ['normal control 2', ['strike-call', [93.3, 112.85], 90, 109.53], 6.455], ['normal control 3', ['price-put', [80.04, 94.93, None, 116.64, 87.99, None], 100, 114.94], 6.246667]], [['regression leading disruption 1', ['price-call', [None, 81.2, None, 82.68, 83.48, 83.72, 115.81, 110.77], 90, 93.39], 0.0075], ['regression leading disruption 2', ['strike-call', [None, 81.52, None, None, 94.05], 110, 84.49], 0.464], ['partial repair probe 1', ['price-put', [None, None, 94.96, 105.69, 84.52, None], 90, 83.58], 0.0], ['partial repair probe 2', ['price-call', [None, None, 96.59, None, 80.55, 118.41], 100, 119.18], 0.0], ['boundary control 1', ['strike-call', [100.0, None, 90.0], 100, 120.0], 23.333333], ['normal control 1', ['strike-call', [None, None, 109.7, 99.56, 90.86, 92.96, 99.08, None], 110, 90.22], 0.0], ['normal control 2', ['strike-call', [92.29, 83.29, None, 108.83, None, None, 117.63, 114.49], 110, 88.43], 0.0], ['normal control 3', ['strike-call', [108.57, 82.78, 81.2, 97.9], 100, 107.11], 14.4975]]]
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:
Schedules that start with a disrupted fixing average in the strike.

Inputs kind (price-call, price-put, strike-call), fixings (None = disrupted), strike and final price. A disrupted fixing takes the last preceding filled value; if none precedes, the next valid fixing. avg = mean of the filled fixings. price-call pays max(avg-K,0), price-put max(K-avg,0), strike-call max(final-avg,0). Round to 6.

split: open-access


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

N = 1
observations = []
def solve(kind, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[0]
        filled.append(v)
    avg = sum(filled) / len(filled)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(avg - final, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression floating strike leg 1', ['strike-call', [103.05, None, None], 110, 93.79], 0.0], ['regression floating strike leg 2', ['strike-call', [None, 90.77, 100.31, 111.32, 86.96, 81.33], 110, 110.43], 16.853333], ['partial repair probe 1', ['strike-call', [None, 96.42, 91.29, 85.33, 103.29, None, 100.83, 98.19], 110, 100.35], 3.4675], ['partial repair probe 2', ['strike-call', [101.79, None, 97.24, 102.75, None], 90, 119.68], 18.416], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [None, None, 90.1, None], 105, 111.03], 14.9], ['normal control 2', ['price-put', [89.66, None, 87.62, 86.54], 100, 115.18], 11.63], ['normal control 3', ['price-put', [111.73, 95.4, 91.7, 102.94, 89.69, 102.29, 99.37, 110.62], 110, 110.4], 9.5325]], [['regression floating strike leg 1', ['strike-call', [97.05, None, 91.77, None, None, 82.64, 96.57, 112.36], 100, 82.53], 0.0], ['regression floating strike leg 2', ['strike-call', [None, 87.57, 95.18, 82.58, None], 110, 80.04], 0.0], ['partial repair probe 1', ['strike-call', [87.17, 102.54, 83.6], 110, 103.05], 11.946667], ['partial repair probe 2', ['strike-call', [117.37, 113.79], 100, 105.4], 0.0], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [115.75, 98.8, None, None], 90, 102.14], 13.0375], ['normal control 2', ['price-put', [None, 102.49], 110, 90.49], 7.51], ['normal control 3', ['price-put', [81.06, None, 82.46, 117.08, 94.93, 115.96], 110, 106.53], 14.575]], [['regression floating strike leg 1', ['strike-call', [106.31, 106.2, 110.92, 88.16], 100, 88.23], 0.0], ['regression floating strike leg 2', ['strike-call', [87.28, 99.15, 107.74, 95.33, 101.03], 105, 105.7], 7.594], ['partial repair probe 1', ['strike-call', [104.99, None, None, 92.17, None, 102.65, 88.75], 110, 118.6], 19.927143], ['partial repair probe 2', ['strike-call', [88.17, None], 90, 107.11], 18.94], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [86.78, 117.58, 90.09, 111.99, 83.86, 115.07, 82.55], 90, 95.52], 0.0], ['normal control 2', ['price-call', [80.15, 119.98, 88.0, 102.79, 87.59, None, None], 100, 117.78], 0.0], ['normal control 3', ['price-call', [100.9, 119.43, 91.91, 84.18, 100.52], 110, 104.53], 0.0]], [['regression floating strike leg 1', ['strike-call', [112.97, 91.85, 111.17], 105, 96.84], 0.0], ['regression floating strike leg 2', ['strike-call', [87.61, None, 97.7, 109.43, None, None, 80.17], 100, 84.68], 0.0], ['partial repair probe 1', ['strike-call', [None, None, None, 108.09, 105.86, 80.01, None, None], 90, 100.06], 2.77875], ['partial repair probe 2', ['strike-call', [82.63, 86.84, 116.07, 94.98, None, 111.46], 90, 91.41], 0.0], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [81.64, 110.92, 119.01, 112.86, 113.88, 113.24], 105, 86.69], 3.591667], ['normal control 2', ['price-call', [94.17, 108.43, 107.73, 88.19, None], 100, 80.09], 0.0], ['normal control 3', ['price-put', [81.81, 90.42, None, 86.29, 104.03, 100.86], 90, 119.4], 0.0]], [['regression floating strike leg 1', ['strike-call', [84.05, 111.33, 119.36, 95.5, 109.08, 81.91], 105, 89.98], 0.0], ['regression floating strike leg 2', ['strike-call', [88.89, None, 92.84], 100, 107.62], 17.413333], ['partial repair probe 1', ['strike-call', [85.48, 100.59, 86.54, None, 96.53, None], 110, 98.91], 6.875], ['partial repair probe 2', ['strike-call', [None, 119.94, 87.68, 92.42, None, None], 105, 114.08], 13.276667], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [93.01, 112.21, 93.6, 118.27, 97.52, 89.11, None, None], 110, 85.35], 0.0], ['normal control 2', ['price-call', [None, 92.28, 115.75, None, 91.4, 106.72, 114.83, 84.89], 100, 82.1], 1.7375], ['normal control 3', ['price-put', [85.64, 111.27, 89.68, 100.6, 119.83, None, 99.77], 105, 96.0], 1.197143]]]
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, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[0]
        filled.append(v)
    avg = sum(filled) / len(filled)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - strike, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression floating strike leg 1', ['strike-call', [103.05, None, None], 110, 93.79], 0.0], ['regression floating strike leg 2', ['strike-call', [None, 90.77, 100.31, 111.32, 86.96, 81.33], 110, 110.43], 16.853333], ['partial repair probe 1', ['strike-call', [None, 96.42, 91.29, 85.33, 103.29, None, 100.83, 98.19], 110, 100.35], 3.4675], ['partial repair probe 2', ['strike-call', [101.79, None, 97.24, 102.75, None], 90, 119.68], 18.416], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [None, None, 90.1, None], 105, 111.03], 14.9], ['normal control 2', ['price-put', [89.66, None, 87.62, 86.54], 100, 115.18], 11.63], ['normal control 3', ['price-put', [111.73, 95.4, 91.7, 102.94, 89.69, 102.29, 99.37, 110.62], 110, 110.4], 9.5325]], [['regression floating strike leg 1', ['strike-call', [97.05, None, 91.77, None, None, 82.64, 96.57, 112.36], 100, 82.53], 0.0], ['regression floating strike leg 2', ['strike-call', [None, 87.57, 95.18, 82.58, None], 110, 80.04], 0.0], ['partial repair probe 1', ['strike-call', [87.17, 102.54, 83.6], 110, 103.05], 11.946667], ['partial repair probe 2', ['strike-call', [117.37, 113.79], 100, 105.4], 0.0], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [115.75, 98.8, None, None], 90, 102.14], 13.0375], ['normal control 2', ['price-put', [None, 102.49], 110, 90.49], 7.51], ['normal control 3', ['price-put', [81.06, None, 82.46, 117.08, 94.93, 115.96], 110, 106.53], 14.575]], [['regression floating strike leg 1', ['strike-call', [106.31, 106.2, 110.92, 88.16], 100, 88.23], 0.0], ['regression floating strike leg 2', ['strike-call', [87.28, 99.15, 107.74, 95.33, 101.03], 105, 105.7], 7.594], ['partial repair probe 1', ['strike-call', [104.99, None, None, 92.17, None, 102.65, 88.75], 110, 118.6], 19.927143], ['partial repair probe 2', ['strike-call', [88.17, None], 90, 107.11], 18.94], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-put', [86.78, 117.58, 90.09, 111.99, 83.86, 115.07, 82.55], 90, 95.52], 0.0], ['normal control 2', ['price-call', [80.15, 119.98, 88.0, 102.79, 87.59, None, None], 100, 117.78], 0.0], ['normal control 3', ['price-call', [100.9, 119.43, 91.91, 84.18, 100.52], 110, 104.53], 0.0]], [['regression floating strike leg 1', ['strike-call', [112.97, 91.85, 111.17], 105, 96.84], 0.0], ['regression floating strike leg 2', ['strike-call', [87.61, None, 97.7, 109.43, None, None, 80.17], 100, 84.68], 0.0], ['partial repair probe 1', ['strike-call', [None, None, None, 108.09, 105.86, 80.01, None, None], 90, 100.06], 2.77875], ['partial repair probe 2', ['strike-call', [82.63, 86.84, 116.07, 94.98, None, 111.46], 90, 91.41], 0.0], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [81.64, 110.92, 119.01, 112.86, 113.88, 113.24], 105, 86.69], 3.591667], ['normal control 2', ['price-call', [94.17, 108.43, 107.73, 88.19, None], 100, 80.09], 0.0], ['normal control 3', ['price-put', [81.81, 90.42, None, 86.29, 104.03, 100.86], 90, 119.4], 0.0]], [['regression floating strike leg 1', ['strike-call', [84.05, 111.33, 119.36, 95.5, 109.08, 81.91], 105, 89.98], 0.0], ['regression floating strike leg 2', ['strike-call', [88.89, None, 92.84], 100, 107.62], 17.413333], ['partial repair probe 1', ['strike-call', [85.48, 100.59, 86.54, None, 96.53, None], 110, 98.91], 6.875], ['partial repair probe 2', ['strike-call', [None, 119.94, 87.68, 92.42, None, None], 105, 114.08], 13.276667], ['boundary control 1', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['normal control 1', ['price-call', [93.01, 112.21, 93.6, 118.27, 97.52, 89.11, None, None], 110, 85.35], 0.0], ['normal control 2', ['price-call', [None, 92.28, 115.75, None, 91.4, 106.72, 114.83, 84.89], 100, 82.1], 1.7375], ['normal control 3', ['price-put', [85.64, 111.27, 89.68, 100.6, 119.83, None, 99.77], 105, 96.0], 1.197143]]]
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:
Floating-strike calls pay when the final price is below the average.

Inputs kind (price-call, price-put, strike-call), fixings (None = disrupted), strike and final price. A disrupted fixing takes the last preceding filled value; if none precedes, the next valid fixing. avg = mean of the filled fixings. price-call pays max(avg-K,0), price-put max(K-avg,0), strike-call max(final-avg,0). Round to 6.

split: open-access


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

N = 1
observations = []
def solve(kind, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[0]
        filled.append(v)
    avg = (sum(filled) + final) / (len(filled) + 1)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression averaging set 1', ['strike-call', [80.18, 83.29, 83.37, 113.46, 117.92, 113.69, 91.1], 90, 101.49], 3.917143], ['regression averaging set 2', ['price-call', [None, 93.86, 86.82, 114.78, 116.01, 106.72, 113.09, 99.31], 100, 97.7], 3.05625], ['partial repair probe 1', ['price-put', [85.47, None, 89.36, 119.71], 90, 108.07], 0.0], ['partial repair probe 2', ['price-put', [94.35, 82.66, 99.58], 90, 119.87], 0.0], ['normal control 1', ['price-put', [119.18, 101.58, None, 97.92, None, 103.75, 115.65, 99.76], 90, 86.86], 0.0], ['normal control 2', ['strike-call', [101.08, 83.38, None, 111.97, 96.17, 119.36, None, 112.17], 110, 97.0], 0.0], ['normal control 3', ['price-put', [109.69, 95.98, 111.39, None, 88.5, 86.77, 109.74], 100, 105.11], 0.0], ['normal control 4', ['price-put', [106.22, 117.4], 100, 88.61], 0.0]], [['regression averaging set 1', ['price-put', [None, None, 112.93, 108.05, 83.92, None], 105, 112.17], 2.553333], ['regression averaging set 2', ['price-put', [105.66, 81.85, 81.44], 105, 87.44], 15.35], ['partial repair probe 1', ['strike-call', [None, 103.34, 92.64, 96.71, 88.34, 81.7, 89.42, 115.57], 105, 96.03], 0.0], ['partial repair probe 2', ['price-put', [119.7, 95.16, None, 116.26], 105, 104.79], 0.0], ['normal control 1', ['strike-call', [None, 103.36, 82.5, 116.07], 90, 85.2], 0.0], ['normal control 2', ['price-put', [85.46, 80.82, 107.2, 114.95, None, 110.68, 98.77, 101.95], 100, 103.02], 0.0], ['normal control 3', ['price-put', [100.59, 114.99, None, 90.36, 118.38], 100, 91.41], 0.0], ['normal control 4', ['strike-call', [86.04, 112.95, None, 116.44, 114.1, 97.61], 100, 81.41], 0.0]], [['regression averaging set 1', ['price-call', [None, None, None, 110.46], 90, 114.65], 20.46], ['regression averaging set 2', ['price-put', [116.89, 107.33, 103.44], 110, 109.18], 0.78], ['partial repair probe 1', ['price-call', [116.24, 96.14, 118.53, 80.19], 110, 110.74], 0.0], ['partial repair probe 2', ['strike-call', [None, 92.85, 108.32], 90, 93.35], 0.0], ['normal control 1', ['strike-call', [104.59, None, None, 82.73], 100, 94.24], 0.0], ['normal control 2', ['price-call', [None, 86.46, 94.24, 98.57, 80.49, 97.12], 100, 113.48], 0.0], ['normal control 3', ['strike-call', [97.17, 95.11, 96.49, 111.33, 93.94, 102.96, None, 84.02], 100, 89.71], 0.0], ['normal control 4', ['strike-call', [None, 96.59, None, 113.0, 114.72, 97.55], 110, 99.24], 0.0]], [['regression averaging set 1', ['price-put', [109.13, None], 110, 105.91], 0.87], ['regression averaging set 2', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 1', ['strike-call', [102.88, 113.6, None], 105, 109.21], 0.0], ['partial repair probe 2', ['price-put', [83.4, 115.69, 97.25, None, 92.32, 111.92, None], 100, 103.18], 0.0], ['normal control 1', ['strike-call', [None, 100.74], 100, 80.87], 0.0], ['normal control 2', ['price-put', [None, 117.64, 104.34, 103.25, 96.88, None], 90, 117.22], 0.0], ['normal control 3', ['strike-call', [117.52, None, 102.65, 89.79, None, 113.85, 95.03], 100, 86.43], 0.0], ['normal control 4', ['price-put', [116.99, None, 112.3, 80.06, 83.34, 105.61, 104.54], 90, 119.98], 0.0]], [['regression averaging set 1', ['price-put', [None, 89.31, 115.64, None, 109.9, None], 110, 110.17], 5.05], ['regression averaging set 2', ['price-call', [92.38, 89.49, 108.11], 90, 88.72], 6.66], ['partial repair probe 1', ['price-call', [111.39, 81.66], 100, 81.74], 0.0], ['partial repair probe 2', ['strike-call', [None, 94.49, 102.83], 100, 95.06], 0.0], ['normal control 1', ['price-call', [None, 104.44, 84.71, 91.43, 87.51], 110, 116.96], 0.0], ['normal control 2', ['price-call', [82.28, 99.04, 80.7, 106.55, None, None], 110, 81.57], 0.0], ['normal control 3', ['price-call', [99.04, None, 87.34, None, 102.98, 83.37, 84.75], 110, 97.22], 0.0], ['normal control 4', ['strike-call', [108.54, 108.11, 96.0, 97.59, 80.67], 110, 95.07], 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, fixings, strike, final):
    vals = list(fixings)
    filled = []
    for i, v in enumerate(vals):
        if v is None:
            prev = [x for x in filled if x is not None]
            later = [x for x in vals[i + 1:] if x is not None]
            v = prev[-1] if prev else later[0]
        filled.append(v)
    avg = sum(filled[:-1]) / (len(filled) - 1)
    if kind == 'price-call':
        pay = max(avg - strike, 0.0)
    elif kind == 'price-put':
        pay = max(strike - avg, 0.0)
    else:
        pay = max(final - avg, 0.0)
    return round(pay, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression averaging set 1', ['strike-call', [80.18, 83.29, 83.37, 113.46, 117.92, 113.69, 91.1], 90, 101.49], 3.917143], ['regression averaging set 2', ['price-call', [None, 93.86, 86.82, 114.78, 116.01, 106.72, 113.09, 99.31], 100, 97.7], 3.05625], ['partial repair probe 1', ['price-put', [85.47, None, 89.36, 119.71], 90, 108.07], 0.0], ['partial repair probe 2', ['price-put', [94.35, 82.66, 99.58], 90, 119.87], 0.0], ['normal control 1', ['price-put', [119.18, 101.58, None, 97.92, None, 103.75, 115.65, 99.76], 90, 86.86], 0.0], ['normal control 2', ['strike-call', [101.08, 83.38, None, 111.97, 96.17, 119.36, None, 112.17], 110, 97.0], 0.0], ['normal control 3', ['price-put', [109.69, 95.98, 111.39, None, 88.5, 86.77, 109.74], 100, 105.11], 0.0], ['normal control 4', ['price-put', [106.22, 117.4], 100, 88.61], 0.0]], [['regression averaging set 1', ['price-put', [None, None, 112.93, 108.05, 83.92, None], 105, 112.17], 2.553333], ['regression averaging set 2', ['price-put', [105.66, 81.85, 81.44], 105, 87.44], 15.35], ['partial repair probe 1', ['strike-call', [None, 103.34, 92.64, 96.71, 88.34, 81.7, 89.42, 115.57], 105, 96.03], 0.0], ['partial repair probe 2', ['price-put', [119.7, 95.16, None, 116.26], 105, 104.79], 0.0], ['normal control 1', ['strike-call', [None, 103.36, 82.5, 116.07], 90, 85.2], 0.0], ['normal control 2', ['price-put', [85.46, 80.82, 107.2, 114.95, None, 110.68, 98.77, 101.95], 100, 103.02], 0.0], ['normal control 3', ['price-put', [100.59, 114.99, None, 90.36, 118.38], 100, 91.41], 0.0], ['normal control 4', ['strike-call', [86.04, 112.95, None, 116.44, 114.1, 97.61], 100, 81.41], 0.0]], [['regression averaging set 1', ['price-call', [None, None, None, 110.46], 90, 114.65], 20.46], ['regression averaging set 2', ['price-put', [116.89, 107.33, 103.44], 110, 109.18], 0.78], ['partial repair probe 1', ['price-call', [116.24, 96.14, 118.53, 80.19], 110, 110.74], 0.0], ['partial repair probe 2', ['strike-call', [None, 92.85, 108.32], 90, 93.35], 0.0], ['normal control 1', ['strike-call', [104.59, None, None, 82.73], 100, 94.24], 0.0], ['normal control 2', ['price-call', [None, 86.46, 94.24, 98.57, 80.49, 97.12], 100, 113.48], 0.0], ['normal control 3', ['strike-call', [97.17, 95.11, 96.49, 111.33, 93.94, 102.96, None, 84.02], 100, 89.71], 0.0], ['normal control 4', ['strike-call', [None, 96.59, None, 113.0, 114.72, 97.55], 110, 99.24], 0.0]], [['regression averaging set 1', ['price-put', [109.13, None], 110, 105.91], 0.87], ['regression averaging set 2', ['price-call', [None, 100.0, 110.0], 100, 100.0], 3.333333], ['partial repair probe 1', ['strike-call', [102.88, 113.6, None], 105, 109.21], 0.0], ['partial repair probe 2', ['price-put', [83.4, 115.69, 97.25, None, 92.32, 111.92, None], 100, 103.18], 0.0], ['normal control 1', ['strike-call', [None, 100.74], 100, 80.87], 0.0], ['normal control 2', ['price-put', [None, 117.64, 104.34, 103.25, 96.88, None], 90, 117.22], 0.0], ['normal control 3', ['strike-call', [117.52, None, 102.65, 89.79, None, 113.85, 95.03], 100, 86.43], 0.0], ['normal control 4', ['price-put', [116.99, None, 112.3, 80.06, 83.34, 105.61, 104.54], 90, 119.98], 0.0]], [['regression averaging set 1', ['price-put', [None, 89.31, 115.64, None, 109.9, None], 110, 110.17], 5.05], ['regression averaging set 2', ['price-call', [92.38, 89.49, 108.11], 90, 88.72], 6.66], ['partial repair probe 1', ['price-call', [111.39, 81.66], 100, 81.74], 0.0], ['partial repair probe 2', ['strike-call', [None, 94.49, 102.83], 100, 95.06], 0.0], ['normal control 1', ['price-call', [None, 104.44, 84.71, 91.43, 87.51], 110, 116.96], 0.0], ['normal control 2', ['price-call', [82.28, 99.04, 80.7, 106.55, None, None], 110, 81.57], 0.0], ['normal control 3', ['price-call', [99.04, None, 87.34, None, 102.98, 83.37, 84.75], 110, 97.22], 0.0], ['normal control 4', ['strike-call', [108.54, 108.11, 96.0, 97.59, 80.67], 110, 95.07], 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:
The final observation is double counted in the average.

Inputs kind (price-call, price-put, strike-call), fixings (None = disrupted), strike and final price. A disrupted fixing takes the last preceding filled value; if none precedes, the next valid fixing. avg = mean of the filled fixings. price-call pays max(avg-K,0), price-put max(K-avg,0), strike-call max(final-avg,0). Round to 6.

split: open-access


prompt:
Paths that touch the barrier level exactly are treated as never touching it.

Inputs kind (up/down, in/out, call/put), observed path including initial and final price, strike, barrier and rebate. The barrier is hit if any observation is >= barrier (up) or <= barrier (down). Knock-out: rebate if hit else vanilla on the final price. Knock-in: vanilla if hit else rebate. Round to 6.

split: open-access


prompt:
A barrier crossed only at expiry is ignored.

Inputs kind (up/down, in/out, call/put), observed path including initial and final price, strike, barrier and rebate. The barrier is hit if any observation is >= barrier (up) or <= barrier (down). Knock-out: rebate if hit else vanilla on the final price. Knock-in: vanilla if hit else rebate. Round to 6.

split: open-access


prompt:
Holders of knock-in options with a rebate receive zero when the barrier is not hit.

Inputs kind (up/down, in/out, call/put), observed path including initial and final price, strike, barrier and rebate. The barrier is hit if any observation is >= barrier (up) or <= barrier (down). Knock-out: rebate if hit else vanilla on the final price. Knock-in: vanilla if hit else rebate. Round to 6.

split: open-access


prompt:
Up-and-out puts and down-and-in calls monitor the wrong side of the barrier.

Inputs kind (up/down, in/out, call/put), observed path including initial and final price, strike, barrier and rebate. The barrier is hit if any observation is >= barrier (up) or <= barrier (down). Knock-out: rebate if hit else vanilla on the final price. Knock-in: vanilla if hit else rebate. Round to 6.

split: open-access


prompt:
Knock-out rebates are never paid.

Inputs kind (up/down, in/out, call/put), observed path including initial and final price, strike, barrier and rebate. The barrier is hit if any observation is >= barrier (up) or <= barrier (down). Knock-out: rebate if hit else vanilla on the final price. Knock-in: vanilla if hit else rebate. Round to 6.

split: open-access


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

N = 1
observations = []
def solve(kind, strike, final, cash_amount):
    if kind.split('-')[1] == 'call':
        state = 1 if final >= strike else 0
    else:
        state = 1 if final < strike else (0.5 if final == strike else 0)
    unit = cash_amount if kind.startswith('cash') else final
    return round(unit * state, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression call at-strike rule 1', ['asset-call', 95, 95, 100], 47.5], ['regression call at-strike rule 2', ['asset-call', 105, 105, 100], 52.5], ['partial repair probe 1', ['cash-call', 95, 95, 1000], 500.0], ['partial repair probe 2', ['cash-call', 95, 95, 10], 5.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['cash-put', 100, 107, 10], 0], ['normal control 2', ['cash-put', 100, 88, 1000], 1000], ['normal control 3', ['cash-call', 105, 104.5, 10], 0]], [['regression call at-strike rule 1', ['cash-call', 95, 95, 100], 50.0], ['regression call at-strike rule 2', ['asset-call', 105, 105, 10], 52.5], ['partial repair probe 1', ['asset-call', 105, 105, 100], 52.5], ['partial repair probe 2', ['cash-call', 105, 105, 1000], 500.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['asset-call', 100, 88, 1000], 0], ['normal control 2', ['cash-put', 95, 95, 10], 5.0], ['normal control 3', ['cash-put', 105, 93, 10], 10]], [['regression call at-strike rule 1', ['asset-call', 95, 95, 1000], 47.5], ['regression call at-strike rule 2', ['cash-call', 100, 100, 1000], 500.0], ['partial repair probe 1', ['cash-call', 95, 95, 10], 5.0], ['partial repair probe 2', ['cash-call', 95, 95, 1000], 500.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['cash-call', 100, 100.5, 100], 100], ['normal control 2', ['asset-call', 95, 94.5, 1000], 0.0], ['normal control 3', ['cash-put', 105, 112, 10], 0]], [['regression call at-strike rule 1', ['asset-call', 95, 95, 10], 47.5], ['regression call at-strike rule 2', ['cash-call', 95, 95, 1000], 500.0], ['partial repair probe 1', ['cash-call', 105, 105, 10], 5.0], ['partial repair probe 2', ['cash-call', 100, 100, 10], 5.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['asset-call', 95, 94.5, 100], 0.0], ['normal control 2', ['cash-put', 105, 112, 100], 0], ['normal control 3', ['cash-put', 100, 100, 1000], 500.0]], [['regression call at-strike rule 1', ['cash-call', 95, 95, 10], 5.0], ['regression call at-strike rule 2', ['asset-call', 105, 105, 10], 52.5], ['partial repair probe 1', ['asset-call', 100, 100, 10], 50.0], ['partial repair probe 2', ['cash-call', 105, 105, 1000], 500.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['cash-call', 105, 104.5, 10], 0], ['normal control 2', ['cash-put', 95, 95.5, 100], 0], ['normal control 3', ['asset-call', 100, 107, 10], 107]]]
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, final, cash_amount):
    if kind.split('-')[1] == 'call':
        state = 1 if final > strike else 0
    else:
        state = 1 if final < strike else (0.5 if final == strike else 0)
    unit = cash_amount if kind.startswith('cash') else final
    return round(unit * state, 6)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression call at-strike rule 1', ['asset-call', 95, 95, 100], 47.5], ['regression call at-strike rule 2', ['asset-call', 105, 105, 100], 52.5], ['partial repair probe 1', ['cash-call', 95, 95, 1000], 500.0], ['partial repair probe 2', ['cash-call', 95, 95, 10], 5.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['cash-put', 100, 107, 10], 0], ['normal control 2', ['cash-put', 100, 88, 1000], 1000], ['normal control 3', ['cash-call', 105, 104.5, 10], 0]], [['regression call at-strike rule 1', ['cash-call', 95, 95, 100], 50.0], ['regression call at-strike rule 2', ['asset-call', 105, 105, 10], 52.5], ['partial repair probe 1', ['asset-call', 105, 105, 100], 52.5], ['partial repair probe 2', ['cash-call', 105, 105, 1000], 500.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['asset-call', 100, 88, 1000], 0], ['normal control 2', ['cash-put', 95, 95, 10], 5.0], ['normal control 3', ['cash-put', 105, 93, 10], 10]], [['regression call at-strike rule 1', ['asset-call', 95, 95, 1000], 47.5], ['regression call at-strike rule 2', ['cash-call', 100, 100, 1000], 500.0], ['partial repair probe 1', ['cash-call', 95, 95, 10], 5.0], ['partial repair probe 2', ['cash-call', 95, 95, 1000], 500.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['cash-call', 100, 100.5, 100], 100], ['normal control 2', ['asset-call', 95, 94.5, 1000], 0.0], ['normal control 3', ['cash-put', 105, 112, 10], 0]], [['regression call at-strike rule 1', ['asset-call', 95, 95, 10], 47.5], ['regression call at-strike rule 2', ['cash-call', 95, 95, 1000], 500.0], ['partial repair probe 1', ['cash-call', 105, 105, 10], 5.0], ['partial repair probe 2', ['cash-call', 100, 100, 10], 5.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['asset-call', 95, 94.5, 100], 0.0], ['normal control 2', ['cash-put', 105, 112, 100], 0], ['normal control 3', ['cash-put', 100, 100, 1000], 500.0]], [['regression call at-strike rule 1', ['cash-call', 95, 95, 10], 5.0], ['regression call at-strike rule 2', ['asset-call', 105, 105, 10], 52.5], ['partial repair probe 1', ['asset-call', 100, 100, 10], 50.0], ['partial repair probe 2', ['cash-call', 105, 105, 1000], 500.0], ['boundary control 1', ['asset-put', 100, 90, 10], 90], ['normal control 1', ['cash-call', 105, 104.5, 10], 0], ['normal control 2', ['cash-put', 95, 95.5, 100], 0], ['normal control 3', ['asset-call', 100, 107, 10], 107]]]
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:
At-the-money calls pay the full amount instead of half.

Inputs kind (cash-call, cash-put, asset-call, asset-put), strike, final price and cash amount. Calls are in the money when final > strike, puts when final < strike; at final == strike both pay half. Cash-or-nothing pays the cash amount, asset-or-nothing pays the final price, times the state (1, 0.5 or 0). Round to 6.

split: open-access