actuarialpy
Purpose-neutral actuarial calculation primitives, plus the shared actuarial data contract — the foundation of the OpenActuarial ecosystem.
actuarialpy.Experienceis the ecosystem's canonical semantic wrapper for historical actuarial data: it binds column roles, grain metadata, and snapshot context. Its domain operations are immutable transformations; calculations and workflow outputs belong to consuming packages.
Overview
actuarialpy provides the atomic building blocks the rest of the ecosystem
is written against: ratios and per-exposure metrics, claim development and
completion, trend fitting and projection, credibility, large-claim pooling,
and financial mathematics. Everything operates on plain floats, NumPy arrays,
and pandas objects, with a consistent type-mirroring convention (scalar in,
float out; Series in, Series out with the index preserved).
The package deliberately contains no workflow orchestration and no domain-specific vocabulary — those belong to the workflow packages built on top of it. If a function here needs to know why you are calling it, it does not belong here.
Installation
pip install actuarialpy
Requires Python 3.10 or newer.
Quick start
import pandas as pd
import actuarialpy as ap
# ratios and per-exposure rates on any aggregate
print(ap.loss_ratio(1_240_000, 1_500_000)) # 0.8267
print(ap.per_exposure(1_240_000, 12_000)) # 103.33 per exposure unit
# fit a trend to a monthly series and project it forward
monthly = pd.DataFrame({
"month": pd.date_range("2024-01-01", periods=24, freq="MS"),
"loss_ratio": [0.80 * 1.004 ** i for i in range(24)],
})
fit = ap.fit_trend(monthly, date_col="month", value_col="loss_ratio")
print(f"annual trend: {fit.annual_trend:+.2%}")
print(round(ap.project_forward(monthly["loss_ratio"].iloc[-1],
fit.annual_trend, months=6), 4))
# cap large claims at a pooling point; the excess moves to its own column
claims = pd.DataFrame({"member": ["a", "b", "c"],
"paid": [612_000.0, 340_000.0, 96_500.0]})
pooled = ap.pool_losses(claims, loss_col="paid", pooling_point=250_000)
print(pooled)
What's inside
- Metrics — loss/expense ratios, per-exposure rates, weighted statistics, contribution and comparison helpers.
- Reserving — completion triangles, chain-ladder development factors, Mack standard errors, completion applied back to tidy data.
- Trend and seasonality — trend fitting, forward projection, seasonal adjustment.
- Credibility — Bühlmann, Bühlmann–Straub, and limited-fluctuation credibility.
- Pooling — large-claim capping and excess extraction.
- Financial — time-value-of-money primitives (present/future value, annuities, rate conversions).
- Data utilities — exposure handling, banding, period alignment, member lifecycle status, margins and adjustments.
The full API reference and end-to-end worked examples live at openactuarial.org/actuarialpy.html.
The OpenActuarial ecosystem
actuarialpy is one of seven packages that share conventions — tidy tables,
explicit distribution parameterizations, reproducible random-number handling —
and compose across package seams:
| Package | Role |
|---|---|
| actuarialpy | Calculation primitives the workflow packages build on |
| experiencestudies | Experience reporting, actual-vs-expected, claimant and concentration analysis |
| projectionmodels | Claim, premium, and expense projection over a renewal horizon |
| ratingmodels | Manual and experience rating, credibility, indication, GLM relativities |
| lossmodels | Severity and frequency fitting, aggregate loss distributions |
| extremeloss | Extreme-value tails: POT/GPD, GEV, return levels, splicing |
| risksim | Portfolio Monte Carlo, dependence, reinsurance contracts, risk measures |
Install everything at once with pip install openactuarial.
Development
git clone https://github.com/OpenActuarial/actuarialpy
cd actuarialpy
python -m pip install -e ".[dev]"
pytest
ruff check src tests
CI runs the same gate on Python 3.10–3.14 across Linux and Windows.
Versioning and stability
All ecosystem packages are pre-1.0: minor releases may change APIs, and every release is documented in CHANGELOG.md. Current per-package API stability is tracked at openactuarial.org/stability.html.
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file actuarialpy-0.45.0.tar.gz.
File metadata
- Download URL: actuarialpy-0.45.0.tar.gz
- Upload date:
- Size: 119.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1400f5e1344963c8f1618fab6decf7f27003f944f4959c2c79a30db66bbee5d9
|
|
| MD5 |
ec79f8f198e1f090e913fcbc79d6905c
|
|
| BLAKE2b-256 |
76ebbed8799d7ab212641cf0ae0658b1567e42f5e5fcb25a3312aa4bb026f101
|
Provenance
The following attestation bundles were made for actuarialpy-0.45.0.tar.gz:
Publisher:
release.yml on OpenActuarial/actuarialpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
actuarialpy-0.45.0.tar.gz -
Subject digest:
1400f5e1344963c8f1618fab6decf7f27003f944f4959c2c79a30db66bbee5d9 - Sigstore transparency entry: 2152288413
- Sigstore integration time:
-
Permalink:
OpenActuarial/actuarialpy@5684399292680dfa92130dd162e32950ef42af1b -
Branch / Tag:
refs/tags/v0.45.0 - Owner: https://github.com/OpenActuarial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5684399292680dfa92130dd162e32950ef42af1b -
Trigger Event:
push
-
Statement type:
File details
Details for the file actuarialpy-0.45.0-py3-none-any.whl.
File metadata
- Download URL: actuarialpy-0.45.0-py3-none-any.whl
- Upload date:
- Size: 67.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dde89cc7a59f4d81c0dc34c7e9c50e7adb2d431f40e5d87c21bce0123cbd2b27
|
|
| MD5 |
384364f1258de43bbae6e1d476ffc6d8
|
|
| BLAKE2b-256 |
4ad4cd9e450dc887f19ab9420c860af6797ffef1676bb39b5b5c11ede319d4b6
|
Provenance
The following attestation bundles were made for actuarialpy-0.45.0-py3-none-any.whl:
Publisher:
release.yml on OpenActuarial/actuarialpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
actuarialpy-0.45.0-py3-none-any.whl -
Subject digest:
dde89cc7a59f4d81c0dc34c7e9c50e7adb2d431f40e5d87c21bce0123cbd2b27 - Sigstore transparency entry: 2152288423
- Sigstore integration time:
-
Permalink:
OpenActuarial/actuarialpy@5684399292680dfa92130dd162e32950ef42af1b -
Branch / Tag:
refs/tags/v0.45.0 - Owner: https://github.com/OpenActuarial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5684399292680dfa92130dd162e32950ef42af1b -
Trigger Event:
push
-
Statement type: