5D Library › Cross-Border Payment Routing, Chargeback Defense Games and Treasury Ruin Bounds · 中文

Chapter 5. The Cramér-Lundberg Model and the Rolling Reserve

“Zero ruin” cannot be bought

Treat the firm’s cash pool like an insurer’s surplus: cash starts at uu and grows at a net margin cc per week; outflow shocks (a batch of refunds, chargebacks, a reserve call) arrive as a Poisson process, 2 a week, with sizes exponential with mean RM 8,000. Net margin carries a safety loading θ\theta: c=(1+θ)λμc = (1+\theta)\lambda\mu. This is the classical Cramér-Lundberg model (Lundberg 1903; Cramér 1930), whose ruin probability (cash ever falling below zero) has an exact solution (Asmussen and Albrecher 2010):

ψ(u)=11+θexp⁡(−θu(1+θ)μ).\psi(u) = \frac{1}{1+\theta}\exp\!\left(-\frac{\theta\,u}{(1+\theta)\mu}\right).

For every finite uu, ψ(u)\psi(u) is above zero. So a “zero probability of ruin” cannot be bought; what can be bought is a small enough one.

Calculation

# 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

With a safety loading of 0.25, a cash pool with no reserve is ruined with probability 0.8000 (0.8060 in ten simulated years); with a reserve of RM 50,000, 0.2292; with RM 100,000, 0.0657; pushing the ruin probability down to 1.0% needs RM 175,281, and to 0.1% needs RM 267,384. The relation between reserve and target is logarithmic: each tenfold cut in the ruin probability takes only a further fixed amount. The safety loading matters more: with a loading of only 0.10, the 1% target needs RM 396,868; with 0.50, only RM 100,793.

Ruin probability against starting reserve for three safety loadings (p09, log scale). The dotted line marks 1%.

The rolling reserve: money not lost, only late

Payment gateways often impose a “rolling reserve”: a share of each day’s settlement is held back and released after a set number of days. The money is not lost, but while the holding builds up, cash flow is squeezed. Below, a merchant with RM 40,000 of card sales a day is simulated: the gateway pays out 97% two days later, costs are 75% of sales and normal refunds 3%; from day 300, refunds run at three times normal for 14 days; and the random shocks above come on top.

Calculation

# 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

With no reserve held, keeping cash above zero in 99% of cases over two years needs RM 109,668. Holding 10% for 90 days, the gateway sits on up to RM 349,200, but the merchant needs only a little more cash, RM 154,991, because after the 10% is held each day’s cash flow is still positive. Holding 20% is a different matter: each day more is held back than the net margin, so cash drains every day while the holding builds; held for 90 days the need is RM 428,954, for 180 days RM 706,439.

Note

Compare the reserve rate with the net margin rate. A reserve rate below the net margin rate is mainly money held up; above it, the reserve drains cash every day of the holding period, and the cash needed grows in step with the number of days held.

Summary

In the Cramér-Lundberg model “zero ruin” is impossible; a reserve can only make the ruin probability small, and each tenfold cut needs only a fixed further amount; with illustrative parameters, 1% needs RM 175,281. Whether a rolling reserve is dangerous depends on whether it exceeds the net margin rate: if it does, the longer the holding period, the more cash is needed.

References

Asmussen, Søren, and Hansjörg Albrecher. 2010. Ruin Probabilities. 2nd ed. World Scientific.
Cramér, Harald. 1930. “On the Mathematical Theory of Risk.” In Skandia Jubilee Volume. Stockholm.
Lundberg, Filip. 1903. “I. Approximerad Framställning Af Sannolikhetsfunktionen. II. Återförsäkring Af Kollektivrisker.” PhD thesis, Uppsala University.

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).