5D Library › 跨境支付智能路由、拒付抗辩博弈与资金池破产边界 · English
第五章 克拉美-伦德伯格模型与滚动保证金
「零破产」买不到
把企业的现金池看作保险公司的盈余:现金从 开始,每周以净毛利 增加;退款批次、拒付、保证金追缴等流出冲击按泊松过程到达,每周 2 次,大小服从均值 RM 8,000 的指数分布。净毛利带一个安全附加 :。这是经典的克拉美-伦德伯格模型 (Lundberg 1903; Cramér 1930),它的破产概率(现金在任何时刻跌破零)有精确解 (Asmussen and Albrecher 2010):
对任何有限的 , 都大于零。所以「零破产概率」是买不到的,能买的只是一个足够小的破产概率。
推导
# Chapter 5. p09: The Cramer-Lundberg model of a cash reserve. Cash
# starts at u and earns net margin c per week; outflow shocks (a batch of
# refunds, chargebacks, a reserve call) arrive as a Poisson process, 2 a
# week, with exponential sizes of mean RM 8,000. Net margin carries a
# safety loading theta = 0.25: c = (1 + theta) * 2 * 8,000. Then the
# probability of EVER running out of cash is exactly
# psi(u) = exp(-theta u / ((1 + theta) mu)) / (1 + theta),
# which is positive for every finite u: zero ruin cannot be bought, only
# a small one. Check by simulation: 4,000 paths of 10 years, seed 85.
import random
from math import exp, log
LAM, MU, THETA = 2.0, 8000.0, 0.25
C = (1 + THETA) * LAM * MU
def psi(u, theta=THETA):
return exp(-theta * u / ((1 + theta) * MU)) / (1 + theta)
def needed(eps, theta=THETA):
return (1 + theta) * MU / theta * log(1 / ((1 + theta) * eps))
def simulate(rng, u, weeks=520):
cash, t = u, 0.0
while True:
dt = rng.expovariate(LAM)
t += dt
if t > weeks:
return False
cash += C * dt - rng.expovariate(1 / MU)
if cash < 0:
return True
if __name__ == "__main__":
rng = random.Random(85)
print(" reserve RM psi(u) formula ruined within 10 years (sim)")
for u in (0.0, 50000.0, 100000.0, 175000.0):
sim = sum(simulate(rng, u) for _ in range(4000)) / 4000
print(" {:10,.0f} {:14.4f} {:.4f}".format(u, psi(u), sim))
for eps in (0.01, 0.001):
print(" reserve for ruin {:.1%}: RM {:,.0f}".format(eps,
needed(eps)))
for th in (0.10, 0.50):
print(" with loading {:.2f}: reserve for 1% RM {:,.0f}".format(
th, needed(0.01, th)))
# reserve RM psi(u) formula ruined within 10 years (sim)
# 0 0.8000 0.8060
# 50,000 0.2292 0.2280
# 100,000 0.0657 0.0722
# 175,000 0.0101 0.0097
# reserve for ruin 1.0%: RM 175,281
# reserve for ruin 0.1%: RM 267,384
# with loading 0.10: reserve for 1% RM 396,868
# with loading 0.50: reserve for 1% RM 100,793安全附加 0.25 时,没有储备的现金池破产概率是 0.8000(模拟十年为 0.8060);储备 RM 50,000 时是 0.2292;RM 100,000 时是 0.0657;要把破产概率压到 1.0%,需要 RM 175,281;压到 0.1%,需要 RM 267,384。储备与目标的关系是对数的:破产概率每降低十倍,只需再加一个固定的金额。安全附加对储备的影响更大:附加只有 0.10 时,1% 的目标要 RM 396,868;附加 0.50 时只要 RM 100,793。
滚动保证金:钱没丢,只是晚到
支付网关常要求「滚动保证金」:每天扣下一定比例的结算款,放满若干天后再释放。钱没有丢,但在开始扣留的那段时间里,现金流会被压低。下面模拟一家每天卡交易 RM 40,000 的商户:网关两天后付出 97%,成本占 75%,正常退款 3%;第 300 天起有 14 天退款是平常的三倍;再加上上面的随机冲击。
推导
# Chapter 5. p10: A rolling reserve meets a refund season. Card sales are
# RM 40,000 a day; the gateway pays out 97% of each day's sales (after
# fees) two days later, but holds back a share r of every day for H days
# before releasing it. Costs (goods, ads, staff) are 75% of sales and
# normal refunds 3%, paid daily; from day 300 for 14 days refunds run at
# three times normal (a post-sale return season); on top come the random
# shocks of p09 (2 a week, mean RM 8,000). The reserve is imposed from
# day 0. Cash needed so that the balance never goes below zero over two
# years in 99% of 1,000 paths = the 99th percentile of the deepest
# shortfall. Seed 85.
import random
from math import exp
def shocks(rng, lam):
"""Number of shocks in a day: Poisson(lam) by inversion."""
k, term, u = 0, exp(-lam), rng.random()
cum = term
while u > cum:
k += 1
term *= lam / k
cum += term
return k
V, PAY, COST, REF = 40000.0, 0.97, 0.75, 0.03
def path(rng, r, H, days=730):
cash, low = 0.0, 0.0
for d in range(days):
inflow = 0.0
if d >= 2:
inflow += (1 - r) * PAY * V
if d >= H:
inflow += r * PAY * V
refunds = REF * V * (3 if 300 <= d < 314 else 1)
cash += inflow - COST * V - refunds
for _ in range(shocks(rng, 2 / 7)):
cash -= rng.expovariate(1 / 8000.0)
low = min(low, cash)
return -low
def need(r, H, n=1000, seed=85):
rng = random.Random(seed)
s = sorted(path(rng, r, H) for _ in range(n))
return s[int(0.99 * n) - 1]
if __name__ == "__main__":
print(" hold r for H days held at peak RM cash needed (99%) RM")
for r, H in ((0.0, 0), (0.10, 90), (0.10, 180), (0.20, 90),
(0.20, 180)):
held = r * PAY * V * H
print(" {:6.0%} {:10d} {:15,.0f} {:20,.0f}".format(
r, H, held, need(r, H)))
# hold r for H days held at peak RM cash needed (99%) RM
# 0% 0 0 109,668
# 10% 90 349,200 154,991
# 10% 180 698,400 157,884
# 20% 90 698,400 428,954
# 20% 180 1,396,800 706,439不扣保证金时,要让两年内 99% 的情形现金都不跌破零,需要 RM 109,668。扣 10%、放 90 天时,网关手上最多压着 RM 349,200,但商户需要的现金只多一点,RM 154,991:因为扣下 10% 之后每天的现金流仍是正的。扣 20% 时情况完全不同:每天扣下的钱多于净毛利,在开始扣留的那段时间里现金每天都在流失;放 90 天要 RM 428,954,放 180 天要 RM 706,439。
注
看保证金比例与净毛利率的大小关系。 保证金比例低于净毛利率时,它主要是一笔被压着的钱;高于净毛利率时,它在扣留期内每天都在消耗现金,所需储备随扣留天数线性增长。
小结
在克拉美-伦德伯格模型中,「零破产」不可能,储备只能把破产概率压小,而且每降低十倍只需加一个固定金额;在示意参数下,1% 需要 RM 175,281。滚动保证金是否危险,取决于它是否超过净毛利率:超过时,扣留期越长,所需储备越多。
参考文献
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).