5D Library › Cross-Border Payment Routing, Chargeback Defense Games and Treasury Ruin Bounds · 中文
Chapter 8. A Year’s Ledger, Stress Tests and a Pre-Registered Experiment
A ledger for 144,000 orders a year
Putting the parts of the first seven chapters together, three setups: A, everything on cards, evidence prepared by hand (win 0.35, RM 60 a case), refunds within 7 days, no alert service, one gateway; B, routing at 0.9%, an automatic evidence package (win 0.711, RM 15 a case), refunds within 1 day; C, B plus an alert service stopping 30% of disputes, and three gateways.
Calculation
# Chapter 8. p14: A year's ledger for 144,000 orders (12,000 a month),
# putting the pieces together. Setups:
# A all on cards, evidence prepared by hand (win 0.35, RM 60 a case),
# refunds paid in 7 days, no alert service, one gateway;
# B the 0.90% routing of p01, automatic evidence package (win 0.711,
# RM 15 a case), refunds within 1 day;
# C as B, plus alerts that catch 30% of disputes, and three gateways.
# Margin from p01, friendly fraud from p05, the refund season from p04
# (one peak month a year), alerts from p08, the cash buffer from p12.
import importlib.util
def load(name):
spec = importlib.util.spec_from_file_location(name, name + ".py")
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
p01, p04 = load("p01_routing"), load("p04_refund_speed")
p05, p12 = load("p05_deterrence"), load("p12_gateways")
YEAR = 144000 / 10000 # units of 10,000 orders
def setup(x, w, prep, days, caught, k, rng):
ratio, paid, m = p01.evaluate(x)
margin = 1e4 * m * YEAR
ff = p05.loss(w, prep)[2] * YEAR
peak = p04.month(days)[2] - p04.month(1)[2]
counted = ratio * (1 - caught)
alert = caught * ratio * 0.9 * 144000 * 25
need = sorted(p12.path(rng, k)[0] for _ in range(300))[296]
return margin, ff, peak, alert, margin - ff - peak - alert, counted, need
if __name__ == "__main__":
import random
rng = random.Random(85)
rows = {"A": ((1.0,) * 5, 0.35, 60.0, 7, 0.0, 1),
"B": (p01.best(0.009), 0.711, 15.0, 1, 0.0, 1),
"C": (p01.best(0.009), 0.711, 15.0, 1, 0.3, 3)}
print(" setup margin RM friendly season alerts net RM"
" ratio cash RM")
for name, args in rows.items():
mg, ff, pk, al, net, r, need = setup(*args, rng)
print(" {:<5} {:10,.0f} {:8,.0f} {:6,.0f} {:6,.0f} {:10,.0f}"
" {:5.2%} {:9,.0f}".format(name, mg, ff, pk, al, net, r,
need))
# setup margin RM friendly season alerts net RM ratio cash RM
# A 18,567,559 432,000 10,298 0 18,125,260 0.94% 3,115,772
# B 18,468,285 16,385 0 0 18,451,900 0.86% 3,175,855
# C 18,468,285 16,385 0 8,331 18,443,569 0.60% 1,467,058A has the highest margin (RM 18,567,559), but friendly fraud costs RM 432,000 and slow refunds in the peak season a further RM 10,298, for a net of RM 18,125,260, a card ratio of 0.94% and a cash reserve need of RM 3,115,772. B’s margin is slightly lower (RM 18,468,285), friendly fraud costs only RM 16,385, the net is RM 18,451,900 and the ratio 0.86%. C pays a further RM 8,331 for alerts and nets RM 18,443,569, with the ratio down to 0.60% and the reserve need down from over three million to RM 1,467,058. Going from B to C costs almost nothing and buys a lower ratio and less than half the reserve.
Stress tests
For an established merchant running setup C, the buffer needed under four scenarios.
Calculation
# Chapter 8. p15: Stress tests for the cash buffer of an established
# business on setup C (three gateways, a 10% reserve already rolling, so
# releases match new holds). During a scenario of T days the daily drift
# of cash is
# (share of payouts arriving * 0.97 * (1 - extra hold) - 0.75
# - 0.03 * refund multiple) * V - mean shocks,
# and the buffer needed is the cash drained if the drift is negative,
# plus a 2.326-sd swing of the random shocks over T days, plus any lump.
# S1 one of the three gateways freezes payouts for 180 days;
# S2 a return season at five times normal refunds for 30 days;
# S3 every gateway raises its hold from 10% to 30% for 180 days;
# S4 S1, with S2's extra refunds (a lump) inside it.
from math import sqrt
V, PAY, COST, REF, MU, LAM = 40000.0, 0.97, 0.75, 0.03, 8000.0, 2 / 7
def need(share, hold, refund_x, T, lump=0.0):
drift = (share * PAY * (1 - hold) - COST - REF * refund_x) * V \
- LAM * MU
swing = 2.326 * sqrt(T * LAM * 2 * MU ** 2)
return drift, max(0.0, -drift) * T + swing + lump
if __name__ == "__main__":
lump = 4 * REF * V * 30
cases = (("S1 one gateway frozen 180 d", 2 / 3, 0.0, 1, 180, 0.0),
("S2 refunds x5 for 30 d", 1.0, 0.0, 5, 30, 0.0),
("S3 hold 30% for 180 d", 1.0, 0.2, 1, 180, 0.0),
("S4 = S1 with S2 inside", 2 / 3, 0.0, 1, 180, lump))
print(" scenario daily drift RM buffer RM")
for name, share, hold, rx, T, lp in cases:
d, u = need(share, hold, rx, T, lp)
print(" {:<28} {:14,.0f} {:9,.0f}".format(name, d, u))
# scenario daily drift RM buffer RM
# S1 one gateway frozen 180 d -7,619 1,560,148
# S2 refunds x5 for 30 d 514 77,044
# S3 hold 30% for 180 d -2,446 628,948
# S4 = S1 with S2 inside -7,619 1,704,148If one of the three gateways freezes for 180 days, the daily cash drift becomes RM -7,619 and RM 1,560,148 is needed; a return season of five times normal refunds for 30 days leaves the drift positive (RM 514), needing only RM 77,044 against the swings; all gateways raising their reserve from 10% to 30% for 180 days gives a drift of RM -2,446 and needs RM 628,948; a return season during a gateway freeze needs RM 1,704,148. The worst scenario is not refunds but a freeze.
Note
A four-step check. First, use 0.9% as the internal alert line and 0.65% as the buffer (p01), and route by score at checkout rather than waiting for last month’s ratio (Visa 2025). Second, handle refunds within 1 day and join a pre-dispute alert service. Third, build a hash-chained evidence package for every order automatically, keep identity fields only as keyed hashes, and use matches that meet Compelling Evidence 3.0 first (p06) (Visa 2023). Fourth, spread card sales over at least three channels, size the cash reserve by the formula of Chapter 6 and set its amount by stress tests, and accept that “zero ruin” cannot be had.
A pre-registered experiment
Calculation
# Chapter 8. p16: Sample sizes for pre-registered tests (two-sided alpha
# 0.05, power 0.80). (1) Win rate of disputes fought with the basic
# package (order log + terms, 0.426) against the full package (0.711,
# p06): disputes per arm. (2) Share of refund requesters who dispute when
# refunds are paid within 1 day (0.091) against 7 days (0.377, p04):
# requesters per arm. (3) Card event ratio all on cards (0.94%) against
# the 0.90% routing (0.86%, p01): card sales per arm.
from math import ceil, sqrt
ZA, ZB = 1.96, 0.84
def n_per_arm(p1, p2):
pb = (p1 + p2) / 2
num = (ZA * sqrt(2 * pb * (1 - pb)) +
ZB * sqrt(p1 * (1 - p1) + p2 * (1 - p2))) ** 2
return ceil(num / (p1 - p2) ** 2)
if __name__ == "__main__":
for label, a, b in (("(1) win rate 0.426 vs 0.711", 0.426, 0.711),
("(2) dispute 0.091 vs 0.377", 0.091, 0.377),
("(3) ratio 0.94% vs 0.86%", 0.0094, 0.0086)):
print(" {:<28} {:>9,} per arm".format(label, n_per_arm(a, b)))
# (1) win rate 0.426 vs 0.711 47 per arm
# (2) dispute 0.091 vs 0.377 34 per arm
# (3) ratio 0.94% vs 0.86% 218,515 per armTesting whether the full evidence package raises the win rate from 0.426 to 0.711 needs only 47 disputes per arm; testing whether 1-day refunds cut the share of refund requesters who dispute from 0.377 to 0.091 needs only 34 requesters per arm. Testing whether routing cuts the card event ratio from 0.94% to 0.86% needs 218,515 card sales per arm: a difference that small can hardly be shown by experiment in a single shop, and one must rely on the model and long records.
Hypothesis · not established
Pre-registered prediction (not yet tested): the full evidence package raises the win rate on fraud disputes by at least 15 percentage points; refunding within 1 day at least halves the share of refund requesters who dispute. What would show it wrong: the win rate rises significantly less than 15 points, or the dispute share falls significantly less than half.
Summary of the book
0.9% is the threshold of the retired VDMP; the current VAMP draws its Asia Pacific line at 1.5% and 1,500 events (p03), and counts fraud reports and disputes together. Routing by order score at checkout lowers the card ratio for about 2% of margin; chargebacks arrive late, so reacting to last month’s ratio is always a step behind. The cheapest controls are fast refunds and pre-dispute alerts; evidence packages reduce false disputes by deterrence, but disputes that are won still count in the ratio. A cash reserve cannot buy “zero ruin”, only a small ruin probability; a reserve rate above the net margin rate drains cash continuously, and the greatest risk is a gateway freeze, against which spreading channels does more than a larger reserve.
References
Fan, Y. (2026). Cross-Border Payment Routing, Chargeback Defense Games and Treasury Ruin Bounds: Multi-Acquirer Success Optimization, Dispute Evidence Scoring and Cramér-Lundberg Cash Reserves [跨境支付智能路由、拒付抗辩博弈与资金池破产边界] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090225 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).