FAILURE MAP
← Case archive

FA-61761 / Options payoff and settlement / Open access

Delta hedge order sized in lots: lots are truncated toward zero · case 01

Hedges are systematically under-sized.

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

ROOT CAUSE

The lot count is truncated instead of rounded half away from zero.

THE FAILURE

The lot count is truncated instead of rounded half away from zero.

Unsuccessful approach: Python round() sends exact halves to even lots.

Case contract

Inputs positions [kind, signed contracts, absolute delta], multiplier, lot size and existing shares. Put delta is negative. Exposure = sum(sign*delta*contracts*multiplier); target shares = -exposure; the order is target - existing, rounded to whole lots with halves away from zero. Return the signed share quantity.

Why this case matters

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

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(positions, multiplier, lot, existing):
    exposure = Fraction(0)
    for kind, c, d in positions:
        sgn = -1 if kind == 'P' else 1
        exposure += sgn * Fraction(str(d)) * c * multiplier
    target = -exposure
    trade = target - existing
    lots = trade / lot
    n = math.floor(abs(lots))
    return int((n if lots >= 0 else -n) * lot)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression lot rounding 1', [[['P', 1, 0.6]], 10, 100, 100], -100], ['regression lot rounding 2', [[['C', -1, 0.75]], 100, 50, 100], -50], ['partial repair probe 1', [[['C', 5, 0.75], ['C', 10, 0.75]], 100, 50, 0], -1150], ['partial repair probe 2', [[['C', -1, 0.25]], 100, 50, 0], 50], ['normal control 1', [[['P', -3, 0.05], ['C', 10, 0.05]], 10, 100, 0], 0], ['normal control 2', [[['C', 1, 0.35]], 100, 100, 100], -100], ['normal control 3', [[['P', 10, 0.75], ['C', -1, 0.6]], 10, 25, 75], 0], ['normal control 4', [[['P', 10, 0.25], ['C', -3, 0.35], ['C', 2, 0.25]], 100, 50, -250], 550]], [['regression lot rounding 1', [[['P', -3, 0.05], ['P', -3, 0.6]], 100, 25, 50], -250], ['regression lot rounding 2', [[['C', 10, 0.75], ['C', 1, 0.05], ['C', -1, 0.6], ['P', 5, 0.5]], 10, 50, 0], -50], ['partial repair probe 1', [[['C', 5, 0.25]], 100, 50, 0], -150], ['partial repair probe 2', [[['C', 5, 0.35]], 100, 100, 75], -300], ['normal control 1', [[['P', -1, 0.35]], 10, 100, -250], 200], ['normal control 2', [[['P', 1, 0.5], ['C', -1, 0.6], ['C', 5, 0.25]], 100, 25, -250], 225], ['normal control 3', [[['C', -1, 0.75], ['P', 10, 0.75], ['P', 5, 0.5]], 100, 100, 50], 1000], ['normal control 4', [[['P', 2, 0.25]], 100, 50, 100], -50]], [['regression lot rounding 1', [[['P', 1, 0.25], ['C', 2, 0.25], ['C', 2, 0.6]], 10, 25, 0], -25], ['regression lot rounding 2', [[['C', 10, 0.35], ['C', 2, 0.05], ['C', 1, 0.6], ['C', 5, 0.25]], 10, 100, -250], 200], ['partial repair probe 1', [[['P', 2, 0.75], ['P', 10, 0.25]], 100, 50, 75], 350], ['partial repair probe 2', [[['P', 10, 0.6], ['P', -3, 0.05], ['C', 2, 0.75], ['C', 1, 0.6]], 100, 50, -250], 650], ['normal control 1', [[['P', 10, 0.05], ['P', -1, 0.5], ['C', 2, 0.05], ['C', 2, 0.5]], 100, 100, 0], -100], ['normal control 2', [[['C', 1, 0.75], ['P', -3, 0.6], ['C', 1, 0.35]], 10, 50, -250], 200], ['normal control 3', [[['P', 10, 0.6], ['C', -3, 0.25], ['P', 5, 0.05], ['P', 10, 0.5]], 100, 100, 100], 1100], ['normal control 4', [[['P', -1, 0.05], ['C', -1, 0.6]], 100, 100, -250], 300]], [['regression lot rounding 1', [[['C', 5, 0.35], ['C', 10, 0.35], ['P', 10, 0.05]], 100, 50, 0], -500], ['regression lot rounding 2', [[['C', 2, 0.75], ['P', 10, 0.05], ['P', 5, 0.75]], 100, 100, 100], 200], ['partial repair probe 1', [[['P', 5, 0.6]], 100, 100, 50], 300], ['partial repair probe 2', [[['C', 10, 0.05], ['P', 1, 0.5], ['P', 5, 0.25], ['P', 5, 0.6]], 100, 50, 0], 450], ['normal control 1', [[['P', -3, 0.35]], 10, 25, 0], 0], ['normal control 2', [[['P', -1, 0.25], ['C', 1, 0.6]], 10, 25, 0], 0], ['normal control 3', [[['P', 10, 0.35], ['C', 5, 0.35], ['C', 2, 0.5]], 100, 100, 75], 0], ['normal control 4', [[['P', 5, 0.75], ['C', -1, 0.05]], 100, 25, 75], 300]], [['regression lot rounding 1', [[['P', 5, 0.05], ['P', -1, 0.35], ['C', 2, 0.75]], 100, 100, -250], 100], ['regression lot rounding 2', [[['P', 1, 0.5], ['C', 5, 0.25]], 10, 100, 50], -100], ['partial repair probe 1', [[['C', 5, 0.25]], 100, 50, 100], -250], ['partial repair probe 2', [[['C', 5, 0.05], ['P', 5, 0.05], ['P', -3, 0.25], ['C', -3, 0.75]], 100, 100, 100], 100], ['normal control 1', [[['P', 5, 0.5], ['P', 1, 0.5], ['P', 1, 0.75], ['C', -3, 0.05]], 10, 100, 75], 0], ['normal control 2', [[['C', 10, 0.25]], 100, 50, 0], -250], ['normal control 3', [[['P', 5, 0.6]], 10, 100, 50], 0], ['normal control 4', [[['P', 1, 0.6]], 100, 100, 50], 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)
Boundary fixtureActualExpectedOutcome
regression lot rounding 10-100Failed
regression lot rounding 20-50Failed
partial repair probe 1-1100-1150Failed
partial repair probe 2050Failed
normal control 100Passed
normal control 2-100-100Passed
normal control 300Passed
normal control 4550550Passed

SHA-256 / 5631e4673575e2054a7c825bbf5655d3609c716451cd6f7f68a4b7d51bdc8b9d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(positions, multiplier, lot, existing):
    exposure = Fraction(0)
    for kind, c, d in positions:
        sgn = -1 if kind == 'P' else 1
        exposure += sgn * Fraction(str(d)) * c * multiplier
    target = -exposure
    trade = target - existing
    lots = trade / lot
    n = round(abs(lots))
    return int((n if lots >= 0 else -n) * lot)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression lot rounding 1', [[['P', 1, 0.6]], 10, 100, 100], -100], ['regression lot rounding 2', [[['C', -1, 0.75]], 100, 50, 100], -50], ['partial repair probe 1', [[['C', 5, 0.75], ['C', 10, 0.75]], 100, 50, 0], -1150], ['partial repair probe 2', [[['C', -1, 0.25]], 100, 50, 0], 50], ['normal control 1', [[['P', -3, 0.05], ['C', 10, 0.05]], 10, 100, 0], 0], ['normal control 2', [[['C', 1, 0.35]], 100, 100, 100], -100], ['normal control 3', [[['P', 10, 0.75], ['C', -1, 0.6]], 10, 25, 75], 0], ['normal control 4', [[['P', 10, 0.25], ['C', -3, 0.35], ['C', 2, 0.25]], 100, 50, -250], 550]], [['regression lot rounding 1', [[['P', -3, 0.05], ['P', -3, 0.6]], 100, 25, 50], -250], ['regression lot rounding 2', [[['C', 10, 0.75], ['C', 1, 0.05], ['C', -1, 0.6], ['P', 5, 0.5]], 10, 50, 0], -50], ['partial repair probe 1', [[['C', 5, 0.25]], 100, 50, 0], -150], ['partial repair probe 2', [[['C', 5, 0.35]], 100, 100, 75], -300], ['normal control 1', [[['P', -1, 0.35]], 10, 100, -250], 200], ['normal control 2', [[['P', 1, 0.5], ['C', -1, 0.6], ['C', 5, 0.25]], 100, 25, -250], 225], ['normal control 3', [[['C', -1, 0.75], ['P', 10, 0.75], ['P', 5, 0.5]], 100, 100, 50], 1000], ['normal control 4', [[['P', 2, 0.25]], 100, 50, 100], -50]], [['regression lot rounding 1', [[['P', 1, 0.25], ['C', 2, 0.25], ['C', 2, 0.6]], 10, 25, 0], -25], ['regression lot rounding 2', [[['C', 10, 0.35], ['C', 2, 0.05], ['C', 1, 0.6], ['C', 5, 0.25]], 10, 100, -250], 200], ['partial repair probe 1', [[['P', 2, 0.75], ['P', 10, 0.25]], 100, 50, 75], 350], ['partial repair probe 2', [[['P', 10, 0.6], ['P', -3, 0.05], ['C', 2, 0.75], ['C', 1, 0.6]], 100, 50, -250], 650], ['normal control 1', [[['P', 10, 0.05], ['P', -1, 0.5], ['C', 2, 0.05], ['C', 2, 0.5]], 100, 100, 0], -100], ['normal control 2', [[['C', 1, 0.75], ['P', -3, 0.6], ['C', 1, 0.35]], 10, 50, -250], 200], ['normal control 3', [[['P', 10, 0.6], ['C', -3, 0.25], ['P', 5, 0.05], ['P', 10, 0.5]], 100, 100, 100], 1100], ['normal control 4', [[['P', -1, 0.05], ['C', -1, 0.6]], 100, 100, -250], 300]], [['regression lot rounding 1', [[['C', 5, 0.35], ['C', 10, 0.35], ['P', 10, 0.05]], 100, 50, 0], -500], ['regression lot rounding 2', [[['C', 2, 0.75], ['P', 10, 0.05], ['P', 5, 0.75]], 100, 100, 100], 200], ['partial repair probe 1', [[['P', 5, 0.6]], 100, 100, 50], 300], ['partial repair probe 2', [[['C', 10, 0.05], ['P', 1, 0.5], ['P', 5, 0.25], ['P', 5, 0.6]], 100, 50, 0], 450], ['normal control 1', [[['P', -3, 0.35]], 10, 25, 0], 0], ['normal control 2', [[['P', -1, 0.25], ['C', 1, 0.6]], 10, 25, 0], 0], ['normal control 3', [[['P', 10, 0.35], ['C', 5, 0.35], ['C', 2, 0.5]], 100, 100, 75], 0], ['normal control 4', [[['P', 5, 0.75], ['C', -1, 0.05]], 100, 25, 75], 300]], [['regression lot rounding 1', [[['P', 5, 0.05], ['P', -1, 0.35], ['C', 2, 0.75]], 100, 100, -250], 100], ['regression lot rounding 2', [[['P', 1, 0.5], ['C', 5, 0.25]], 10, 100, 50], -100], ['partial repair probe 1', [[['C', 5, 0.25]], 100, 50, 100], -250], ['partial repair probe 2', [[['C', 5, 0.05], ['P', 5, 0.05], ['P', -3, 0.25], ['C', -3, 0.75]], 100, 100, 100], 100], ['normal control 1', [[['P', 5, 0.5], ['P', 1, 0.5], ['P', 1, 0.75], ['C', -3, 0.05]], 10, 100, 75], 0], ['normal control 2', [[['C', 10, 0.25]], 100, 50, 0], -250], ['normal control 3', [[['P', 5, 0.6]], 10, 100, 50], 0], ['normal control 4', [[['P', 1, 0.6]], 100, 100, 50], 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)
Boundary fixtureActualExpectedOutcome
regression lot rounding 1-100-100Passed
regression lot rounding 20-50Failed
partial repair probe 1-1100-1150Failed
partial repair probe 2050Failed
normal control 100Passed
normal control 2-100-100Passed
normal control 300Passed
normal control 4550550Passed

SHA-256 / 1830a956e09fa73f902d4d01947dccbaf28e5717e6a71bd0006398212974dee1

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic toy contract stated explicitly in the contract field; no claim of conformance to any exchange or clearing rulebook. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:46:58.204458+00:00.

Case digest / a6041ebe4371efeb0581724412608663dea97e35f770b6684e5bf2f7aabf108c