Open-source Python library for P&C loss reserve estimation — chain-ladder, Bornhuetter-Ferguson, and Cape Cod with bootstrap confidence intervals.
pip install actuarial-reserving| Method | Description |
|---|---|
ChainLadder |
Projects losses to ultimate using volume-weighted age-to-age factors |
BornhuetterFerguson |
Blends chain-ladder development with an a priori expected loss ratio |
CapeCod |
Derives the expected loss ratio from the data — no external assumption required |
All three methods share a consistent API: fit(), ultimates(), ibnr(), summary().
import pandas as pd
import reserving as rv
import reserving.plot as rvplot
# Build a triangle from a pivot DataFrame
data = pd.DataFrame(
{1: [1000, 1200, 900],
2: [1100, 1300, None],
3: [1150, None, None]},
index=[2021, 2022, 2023]
)
tri = rv.Triangle(data)
# Or load from long-format CSV (e.g. CAS Loss Reserve Database)
tri = rv.Triangle.from_csv(
"wkcomp_pos.csv",
origin="AccidentYear",
dev="DevelopmentLag",
values="CumPaidLoss"
)cl = rv.ChainLadder(tri).fit()
cl.factors() # volume-weighted ATA development factors
cl.ultimates() # projected ultimate losses by accident year
cl.ibnr() # IBNR reserve by accident year
cl.total_ibnr() # total reserve
cl.summary() # ultimates + 95% bootstrap confidence intervalsbf = rv.BornhuetterFerguson(tri, apriori=0.65, premium=10000).fit()
bf.pct_reported() # % of ultimate losses already reported
bf.ultimates()
bf.summary()cc = rv.CapeCod(tri, premium=10000).fit()
cc.elr() # expected loss ratio derived from the data
cc.ultimates()
cc.summary()All methods support summary(alpha, n_boot):
# 95% CI with 999 bootstrap resamples (default)
print(cl.summary())
# 90% CI with 2000 resamples
print(cl.summary(alpha=0.10, n_boot=2000))rvplot.development_chart(tri) # loss development curves by accident year
rvplot.ultimates_chart(cl) # ultimate vs latest diagonal
rvplot.ibnr_chart(cc) # IBNR reserves with totals
rvplot.summary_chart(bf) # ultimates with CI bands
rvplot.comparison_chart({ # all three methods side by side
"Chain-ladder": cl,
"BF": bf,
"Cape Cod": cc,
})pip install actuarial-reservingRequires Python ≥ 3.9. Dependencies: pandas, numpy, matplotlib.
Full API reference and quickstart guide: dyjang83.github.io/reserving
reserving/
├── reserving/
│ ├── __init__.py
│ ├── triangle.py # Triangle data structure
│ ├── bootstrap.py # CI engine
│ ├── plot.py # visualization module
│ └── methods/
│ ├── chain_ladder.py
│ ├── bornhuetter_ferguson.py
│ └── cape_cod.py
├── tests/ # 103 passing tests
├── docs/ # MkDocs documentation source
├── pyproject.toml
└── README.md
git clone https://github.com/dyjang83/reserving.git
cd reserving
python3 -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest tests/MIT