Day 130 — Risk of ruin, and the constraint that is not statistical
Monday, 14 December 2026 · Week 19 of 52 · Portfolios and risk · Study day · 65 min
Ruin is not the 99th percentile of a return distribution, it is an absorbing state, and the difference matters because leverage and margin can put you there before the statistics do.
What you should be able to do tonight
- Compute the probability of hitting a ruin threshold before a target, and connect it to the gambler’s ruin result you drilled in week 16.
- Say what a margin call does to the calculation, and why it makes the barrier higher than the one you chose.
Tasks 65 min
30 min Do the calculation both ways and reconcile them: the diffusion approximation for hitting a lower barrier before an upper one, and the direct simulation of your strategy’s returns. Report both for your chosen leverage.
25 min Add the mechanical barrier from day 13: at your leverage and your broker’s maintenance margin, compute the loss that triggers a call. That level is a hard barrier well above zero, and the ruin probability that matters is the probability of touching it, not of losing everything.
10 min Add risk_of_ruin() to qlib/portfolio.py taking leverage, maintenance margin and return parameters, with the barrier computed rather than passed in.
The running strategy
The book’s sizing now respects a hard barrier derived from maintenance margin rather than a soft statistical threshold, and qlib/portfolio.py computes the ruin probability from leverage and margin directly.
Resources
Deliverable
A risk of ruin function in qlib/portfolio.py, with the margin-implied barrier computed and the probability reported at your chosen leverage.
Checkpoint
At 2 to 1 leverage with 25 percent maintenance margin, what loss triggers a call, and what is the probability of touching it in a year?
Prepare for tomorrow
Ten minutes tonight so Day 131, Tuesday, 15 December 2026 starts clean. This is what the evening email sends you.
Collect the four sizing inputs: your Sharpe with its interval, your covariance estimator’s out-of-sample calibration, your chosen Kelly fraction, and your leverage cap.
Write them on one line each.
Tomorrow they become one set of positions.