FA-61906 / Currency rounding and FX conversion / Open access
Customer-facing FX amounts use nearest rounding instead of house-favourable rounding · case 01
Receivable amounts are rounded up to the nearest cent, paying customers fractions the dealer does not hold.
ROOT CAUSE
The counter amount is rounded half-even regardless of which party pays it.
VERIFIED REPAIR
Round amounts the customer pays with ceiling and amounts the customer receives with floor.
Unsuccessful approach: Ceiling the paid amounts while leaving received amounts half-even still rounds some receipts up.
Case contract
solve(side, amount, ccy, pair, bid, ask): pair is six letters BASEQUOTE; side is the customer's action on the base currency ('buy' or 'sell'). The dealer sells base at ask and buys at bid. If amount is in base, the counter amount in quote is amount*rate; if in quote, the counter amount in base is amount/rate. Amounts the customer pays are rounded up (ceiling) and amounts the customer receives are rounded down (floor) at the counter currency exponent (JPY 0, KWD 3, else 2). Return [counter_amount, counter_ccy]; errors: 'ERR:side', 'ERR:crossed-quote' when bid > ask (bid == ask is valid), 'ERR:currency-not-in-pair'.
Why this case matters
Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(side, amount, ccy, pair, bid, ask):
exps = {'JPY': 0, 'KWD': 3}
base, quote = pair[:3], pair[3:]
if side not in ('buy', 'sell'): return 'ERR:side'
b, a = Decimal(bid), Decimal(ask)
if b > a: return 'ERR:crossed-quote'
r = a if side == 'buy' else b
x = Decimal(amount)
if ccy == base:
out, oc = x * r, quote
pays = side == 'buy'
elif ccy == quote:
out, oc = x / r, base
pays = side == 'sell'
else:
return 'ERR:currency-not-in-pair'
mode = ROUND_HALF_EVEN
return [format(out.quantize(Decimal(1).scaleb(-exps.get(oc, 2)), rounding=mode), 'f'), oc]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression house-rounding-direction 1', ('sell', '30057', 'USD', 'EURUSD', '76.9818', '76.9826'),
['390.45', 'EUR']),
('regression house-rounding-direction 2', ('sell', '50691', 'JPY', 'USDJPY', '61.7254', '61.7302'),
['821.24', 'USD']),
('partial repair guard 1', ('sell', '27002', 'KWD', 'KWDUSD', '127.8499', '127.8515'), ['3452202.99', 'USD']),
('partial repair guard 2', ('sell', '39619.07', 'USD', 'USDJPY', '122.3532', '122.3540'), ['4847519', 'JPY']),
('control: buy base in base', ('buy', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.50', 'USD']),
('control: sell base in base', ('sell', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.10', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR'])],
[('regression house-rounding-direction 1', ('sell', '27002', 'KWD', 'KWDUSD', '127.8499', '127.8515'),
['3452202.99', 'USD']),
('regression house-rounding-direction 2', ('sell', '39619.07', 'USD', 'USDJPY', '122.3532', '122.3540'),
['4847519', 'JPY']),
('partial repair guard 1', ('buy', '9849', 'USD', 'KWDUSD', '109.5417', '109.5455'), ['89.907', 'KWD']),
('partial repair guard 2', ('sell', '93017.90', 'EUR', 'EURJPY', '140.8690', '140.8720'), ['13103338', 'JPY']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR']),
('control: yen counter', ('buy', '10.01', 'USD', 'USDJPY', '151.20', '151.24'), ['1514', 'JPY']),
('control: locked quote', ('sell', '250', 'GBP', 'GBPUSD', '1.2650', '1.2650'), ['316.25', 'USD']),
('control: crossed quote', ('buy', '5', 'EUR', 'EURUSD', '1.2', '1.1'), 'ERR:crossed-quote')],
[('regression house-rounding-direction 1', ('sell', '69613.58', 'USD', 'EURUSD', '41.9786', '41.9808'),
['1658.32', 'EUR']),
('regression house-rounding-direction 2', ('sell', '38162.39', 'USD', 'KWDUSD', '111.9590', '111.9634'),
['340.861', 'KWD']),
('partial repair guard 1', ('sell', '90399.83', 'GBP', 'GBPUSD', '112.3034', '112.3100'), ['10152208.26', 'USD']),
('partial repair guard 2', ('buy', '51211.50', 'JPY', 'USDJPY', '106.2807', '106.2865'), ['481.82', 'USD']),
('control: crossed quote', ('buy', '5', 'EUR', 'EURUSD', '1.2', '1.1'), 'ERR:crossed-quote'),
('control: foreign currency', ('buy', '5', 'CHF', 'EURUSD', '1.08', '1.09'), 'ERR:currency-not-in-pair'),
('control: dinar counter', ('sell', '77.77', 'USD', 'KWDUSD', '3.2520', '3.2561'), ['23.915', 'KWD']),
('control: bad side', ('hold', '5', 'EUR', 'EURUSD', '1.08', '1.09'), 'ERR:side')],
[('regression house-rounding-direction 1', ('sell', '350.83', 'KWD', 'USDKWD', '107.9091', '107.9159'),
['3.26', 'USD']),
('regression house-rounding-direction 2', ('sell', '24795.92', 'USD', 'EURUSD', '68.8087', '68.8163'),
['360.37', 'EUR']),
('partial repair guard 1', ('buy', '65703.38', 'USD', 'EURUSD', '135.0637', '135.0675'), ['486.44', 'EUR']),
('partial repair guard 2', ('sell', '60180', 'KWD', 'KWDUSD', '47.5377', '47.5401'), ['2860818.78', 'USD']),
('control: bad side', ('hold', '5', 'EUR', 'EURUSD', '1.08', '1.09'), 'ERR:side'),
('control: buy base in base', ('buy', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.50', 'USD']),
('control: sell base in base', ('sell', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.10', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR'])],
[('regression house-rounding-direction 1', ('buy', '9849', 'USD', 'KWDUSD', '109.5417', '109.5455'),
['89.907', 'KWD']),
('regression house-rounding-direction 2', ('sell', '93017.90', 'EUR', 'EURJPY', '140.8690', '140.8720'),
['13103338', 'JPY']),
('partial repair guard 1', ('buy', '22301.63', 'USD', 'EURUSD', '33.8763', '33.8797'), ['658.25', 'EUR']),
('partial repair guard 2', ('sell', '33002', 'KWD', 'KWDUSD', '77.5684', '77.5746'), ['2559912.33', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR']),
('control: yen counter', ('buy', '10.01', 'USD', 'USDJPY', '151.20', '151.24'), ['1514', 'JPY']),
('control: locked quote', ('sell', '250', 'GBP', 'GBPUSD', '1.2650', '1.2650'), ['316.25', 'USD'])]]
for label, args, expected in cases[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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression house-rounding-direction 1 | ['390.44', 'EUR'] | ['390.45', 'EUR'] | Failed |
| regression house-rounding-direction 2 | ['821.23', 'USD'] | ['821.24', 'USD'] | Failed |
| partial repair guard 1 | ['3452203.00', 'USD'] | ['3452202.99', 'USD'] | Failed |
| partial repair guard 2 | ['4847520', 'JPY'] | ['4847519', 'JPY'] | Failed |
| control: buy base in base | ['1083.50', 'USD'] | ['1083.50', 'USD'] | Passed |
| control: sell base in base | ['1083.10', 'USD'] | ['1083.10', 'USD'] | Passed |
| control: spend quote | ['92.29', 'EUR'] | ['92.29', 'EUR'] | Passed |
| control: receive quote | ['92.33', 'EUR'] | ['92.33', 'EUR'] | Passed |
SHA-256 / 8b5f3569fb24aa5ca08a3387f7606e728cbb19e050af37a3999c7426c580d42f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(side, amount, ccy, pair, bid, ask):
exps = {'JPY': 0, 'KWD': 3}
base, quote = pair[:3], pair[3:]
if side not in ('buy', 'sell'): return 'ERR:side'
b, a = Decimal(bid), Decimal(ask)
if b > a: return 'ERR:crossed-quote'
r = a if side == 'buy' else b
x = Decimal(amount)
if ccy == base:
out, oc = x * r, quote
pays = side == 'buy'
elif ccy == quote:
out, oc = x / r, base
pays = side == 'sell'
else:
return 'ERR:currency-not-in-pair'
mode = ROUND_CEILING if pays else ROUND_HALF_EVEN
return [format(out.quantize(Decimal(1).scaleb(-exps.get(oc, 2)), rounding=mode), 'f'), oc]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression house-rounding-direction 1', ('sell', '30057', 'USD', 'EURUSD', '76.9818', '76.9826'),
['390.45', 'EUR']),
('regression house-rounding-direction 2', ('sell', '50691', 'JPY', 'USDJPY', '61.7254', '61.7302'),
['821.24', 'USD']),
('partial repair guard 1', ('sell', '27002', 'KWD', 'KWDUSD', '127.8499', '127.8515'), ['3452202.99', 'USD']),
('partial repair guard 2', ('sell', '39619.07', 'USD', 'USDJPY', '122.3532', '122.3540'), ['4847519', 'JPY']),
('control: buy base in base', ('buy', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.50', 'USD']),
('control: sell base in base', ('sell', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.10', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR'])],
[('regression house-rounding-direction 1', ('sell', '27002', 'KWD', 'KWDUSD', '127.8499', '127.8515'),
['3452202.99', 'USD']),
('regression house-rounding-direction 2', ('sell', '39619.07', 'USD', 'USDJPY', '122.3532', '122.3540'),
['4847519', 'JPY']),
('partial repair guard 1', ('buy', '9849', 'USD', 'KWDUSD', '109.5417', '109.5455'), ['89.907', 'KWD']),
('partial repair guard 2', ('sell', '93017.90', 'EUR', 'EURJPY', '140.8690', '140.8720'), ['13103338', 'JPY']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR']),
('control: yen counter', ('buy', '10.01', 'USD', 'USDJPY', '151.20', '151.24'), ['1514', 'JPY']),
('control: locked quote', ('sell', '250', 'GBP', 'GBPUSD', '1.2650', '1.2650'), ['316.25', 'USD']),
('control: crossed quote', ('buy', '5', 'EUR', 'EURUSD', '1.2', '1.1'), 'ERR:crossed-quote')],
[('regression house-rounding-direction 1', ('sell', '69613.58', 'USD', 'EURUSD', '41.9786', '41.9808'),
['1658.32', 'EUR']),
('regression house-rounding-direction 2', ('sell', '38162.39', 'USD', 'KWDUSD', '111.9590', '111.9634'),
['340.861', 'KWD']),
('partial repair guard 1', ('sell', '90399.83', 'GBP', 'GBPUSD', '112.3034', '112.3100'), ['10152208.26', 'USD']),
('partial repair guard 2', ('buy', '51211.50', 'JPY', 'USDJPY', '106.2807', '106.2865'), ['481.82', 'USD']),
('control: crossed quote', ('buy', '5', 'EUR', 'EURUSD', '1.2', '1.1'), 'ERR:crossed-quote'),
('control: foreign currency', ('buy', '5', 'CHF', 'EURUSD', '1.08', '1.09'), 'ERR:currency-not-in-pair'),
('control: dinar counter', ('sell', '77.77', 'USD', 'KWDUSD', '3.2520', '3.2561'), ['23.915', 'KWD']),
('control: bad side', ('hold', '5', 'EUR', 'EURUSD', '1.08', '1.09'), 'ERR:side')],
[('regression house-rounding-direction 1', ('sell', '350.83', 'KWD', 'USDKWD', '107.9091', '107.9159'),
['3.26', 'USD']),
('regression house-rounding-direction 2', ('sell', '24795.92', 'USD', 'EURUSD', '68.8087', '68.8163'),
['360.37', 'EUR']),
('partial repair guard 1', ('buy', '65703.38', 'USD', 'EURUSD', '135.0637', '135.0675'), ['486.44', 'EUR']),
('partial repair guard 2', ('sell', '60180', 'KWD', 'KWDUSD', '47.5377', '47.5401'), ['2860818.78', 'USD']),
('control: bad side', ('hold', '5', 'EUR', 'EURUSD', '1.08', '1.09'), 'ERR:side'),
('control: buy base in base', ('buy', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.50', 'USD']),
('control: sell base in base', ('sell', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.10', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR'])],
[('regression house-rounding-direction 1', ('buy', '9849', 'USD', 'KWDUSD', '109.5417', '109.5455'),
['89.907', 'KWD']),
('regression house-rounding-direction 2', ('sell', '93017.90', 'EUR', 'EURJPY', '140.8690', '140.8720'),
['13103338', 'JPY']),
('partial repair guard 1', ('buy', '22301.63', 'USD', 'EURUSD', '33.8763', '33.8797'), ['658.25', 'EUR']),
('partial repair guard 2', ('sell', '33002', 'KWD', 'KWDUSD', '77.5684', '77.5746'), ['2559912.33', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR']),
('control: yen counter', ('buy', '10.01', 'USD', 'USDJPY', '151.20', '151.24'), ['1514', 'JPY']),
('control: locked quote', ('sell', '250', 'GBP', 'GBPUSD', '1.2650', '1.2650'), ['316.25', 'USD'])]]
for label, args, expected in cases[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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression house-rounding-direction 1 | ['390.45', 'EUR'] | ['390.45', 'EUR'] | Passed |
| regression house-rounding-direction 2 | ['821.24', 'USD'] | ['821.24', 'USD'] | Passed |
| partial repair guard 1 | ['3452203.00', 'USD'] | ['3452202.99', 'USD'] | Failed |
| partial repair guard 2 | ['4847520', 'JPY'] | ['4847519', 'JPY'] | Failed |
| control: buy base in base | ['1083.50', 'USD'] | ['1083.50', 'USD'] | Passed |
| control: sell base in base | ['1083.10', 'USD'] | ['1083.10', 'USD'] | Passed |
| control: spend quote | ['92.29', 'EUR'] | ['92.29', 'EUR'] | Passed |
| control: receive quote | ['92.33', 'EUR'] | ['92.33', 'EUR'] | Passed |
SHA-256 / e49cdcd592dddf334ff1a6068d96c1263b3198fcc02c0287d3ea0857048fb7cf
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(side, amount, ccy, pair, bid, ask):
exps = {'JPY': 0, 'KWD': 3}
base, quote = pair[:3], pair[3:]
if side not in ('buy', 'sell'): return 'ERR:side'
b, a = Decimal(bid), Decimal(ask)
if b > a: return 'ERR:crossed-quote'
r = a if side == 'buy' else b
x = Decimal(amount)
if ccy == base:
out, oc = x * r, quote
pays = side == 'buy'
elif ccy == quote:
out, oc = x / r, base
pays = side == 'sell'
else:
return 'ERR:currency-not-in-pair'
mode = ROUND_CEILING if pays else ROUND_FLOOR
return [format(out.quantize(Decimal(1).scaleb(-exps.get(oc, 2)), rounding=mode), 'f'), oc]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression house-rounding-direction 1', ('sell', '30057', 'USD', 'EURUSD', '76.9818', '76.9826'),
['390.45', 'EUR']),
('regression house-rounding-direction 2', ('sell', '50691', 'JPY', 'USDJPY', '61.7254', '61.7302'),
['821.24', 'USD']),
('partial repair guard 1', ('sell', '27002', 'KWD', 'KWDUSD', '127.8499', '127.8515'), ['3452202.99', 'USD']),
('partial repair guard 2', ('sell', '39619.07', 'USD', 'USDJPY', '122.3532', '122.3540'), ['4847519', 'JPY']),
('control: buy base in base', ('buy', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.50', 'USD']),
('control: sell base in base', ('sell', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.10', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR'])],
[('regression house-rounding-direction 1', ('sell', '27002', 'KWD', 'KWDUSD', '127.8499', '127.8515'),
['3452202.99', 'USD']),
('regression house-rounding-direction 2', ('sell', '39619.07', 'USD', 'USDJPY', '122.3532', '122.3540'),
['4847519', 'JPY']),
('partial repair guard 1', ('buy', '9849', 'USD', 'KWDUSD', '109.5417', '109.5455'), ['89.907', 'KWD']),
('partial repair guard 2', ('sell', '93017.90', 'EUR', 'EURJPY', '140.8690', '140.8720'), ['13103338', 'JPY']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR']),
('control: yen counter', ('buy', '10.01', 'USD', 'USDJPY', '151.20', '151.24'), ['1514', 'JPY']),
('control: locked quote', ('sell', '250', 'GBP', 'GBPUSD', '1.2650', '1.2650'), ['316.25', 'USD']),
('control: crossed quote', ('buy', '5', 'EUR', 'EURUSD', '1.2', '1.1'), 'ERR:crossed-quote')],
[('regression house-rounding-direction 1', ('sell', '69613.58', 'USD', 'EURUSD', '41.9786', '41.9808'),
['1658.32', 'EUR']),
('regression house-rounding-direction 2', ('sell', '38162.39', 'USD', 'KWDUSD', '111.9590', '111.9634'),
['340.861', 'KWD']),
('partial repair guard 1', ('sell', '90399.83', 'GBP', 'GBPUSD', '112.3034', '112.3100'), ['10152208.26', 'USD']),
('partial repair guard 2', ('buy', '51211.50', 'JPY', 'USDJPY', '106.2807', '106.2865'), ['481.82', 'USD']),
('control: crossed quote', ('buy', '5', 'EUR', 'EURUSD', '1.2', '1.1'), 'ERR:crossed-quote'),
('control: foreign currency', ('buy', '5', 'CHF', 'EURUSD', '1.08', '1.09'), 'ERR:currency-not-in-pair'),
('control: dinar counter', ('sell', '77.77', 'USD', 'KWDUSD', '3.2520', '3.2561'), ['23.915', 'KWD']),
('control: bad side', ('hold', '5', 'EUR', 'EURUSD', '1.08', '1.09'), 'ERR:side')],
[('regression house-rounding-direction 1', ('sell', '350.83', 'KWD', 'USDKWD', '107.9091', '107.9159'),
['3.26', 'USD']),
('regression house-rounding-direction 2', ('sell', '24795.92', 'USD', 'EURUSD', '68.8087', '68.8163'),
['360.37', 'EUR']),
('partial repair guard 1', ('buy', '65703.38', 'USD', 'EURUSD', '135.0637', '135.0675'), ['486.44', 'EUR']),
('partial repair guard 2', ('sell', '60180', 'KWD', 'KWDUSD', '47.5377', '47.5401'), ['2860818.78', 'USD']),
('control: bad side', ('hold', '5', 'EUR', 'EURUSD', '1.08', '1.09'), 'ERR:side'),
('control: buy base in base', ('buy', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.50', 'USD']),
('control: sell base in base', ('sell', '1000', 'EUR', 'EURUSD', '1.0831', '1.0835'), ['1083.10', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR'])],
[('regression house-rounding-direction 1', ('buy', '9849', 'USD', 'KWDUSD', '109.5417', '109.5455'),
['89.907', 'KWD']),
('regression house-rounding-direction 2', ('sell', '93017.90', 'EUR', 'EURJPY', '140.8690', '140.8720'),
['13103338', 'JPY']),
('partial repair guard 1', ('buy', '22301.63', 'USD', 'EURUSD', '33.8763', '33.8797'), ['658.25', 'EUR']),
('partial repair guard 2', ('sell', '33002', 'KWD', 'KWDUSD', '77.5684', '77.5746'), ['2559912.33', 'USD']),
('control: spend quote', ('buy', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.29', 'EUR']),
('control: receive quote', ('sell', '100', 'USD', 'EURUSD', '1.0831', '1.0835'), ['92.33', 'EUR']),
('control: yen counter', ('buy', '10.01', 'USD', 'USDJPY', '151.20', '151.24'), ['1514', 'JPY']),
('control: locked quote', ('sell', '250', 'GBP', 'GBPUSD', '1.2650', '1.2650'), ['316.25', 'USD'])]]
for label, args, expected in cases[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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression house-rounding-direction 1 | ['390.45', 'EUR'] | ['390.45', 'EUR'] | Passed |
| regression house-rounding-direction 2 | ['821.24', 'USD'] | ['821.24', 'USD'] | Passed |
| partial repair guard 1 | ['3452202.99', 'USD'] | ['3452202.99', 'USD'] | Passed |
| partial repair guard 2 | ['4847519', 'JPY'] | ['4847519', 'JPY'] | Passed |
| control: buy base in base | ['1083.50', 'USD'] | ['1083.50', 'USD'] | Passed |
| control: sell base in base | ['1083.10', 'USD'] | ['1083.10', 'USD'] | Passed |
| control: spend quote | ['92.29', 'EUR'] | ['92.29', 'EUR'] | Passed |
| control: receive quote | ['92.33', 'EUR'] | ['92.33', 'EUR'] | Passed |
SHA-256 / 8b761cbb854aed2dbc4b67cf38c4d728a4d19b3c50854dcae1905757d5646a3a
Verification & scope
A deterministic, bounded teaching model with a stipulated toy contract; it makes no claim of conformance to any real regulation, standard, or institution's rules. 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:59.663467+00:00.
Case digest / 9c51d45c87504a1ea9be7c62d7a045158303acb215ca44f63322ee05425d5770