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
# trend claim severity to project future loss costs
monthly = pd.DataFrame({
"month": pd.date_range("2024-01-01", periods=24, freq="MS"),
"avg_severity": [5_000 * 1.004 ** i for i in range(24)],
"claim_count": [20] * 24,
})
severity_trend = ap.fit_trend(monthly, date_col="month", value_col="avg_severity")
# if severity trends at +0.4%/month and claim count stays flat,
# projected losses next quarter will be:
projected_severity = ap.project_forward(monthly["avg_severity"].iloc[-1],
severity_trend.annual_trend, months=3)
projected_losses = projected_severity * monthly["claim_count"].iloc[-1]
# 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.
Release files for actuarialpy 0.46.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| actuarialpy-0.46.3.tar.gz | 128.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| actuarialpy-0.46.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 202.6 kB
Release files / actuarialpy-0.46.3.tar.gz
| Download URL | actuarialpy-0.46.3.tar.gz |
|---|---|
| Size | 128.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9420ecbd8d122a2350e6e9a3d457796f9773ab433170b1e29fc24b48dbf93a4c
|
|
BLAKE2b-256 checksum How to use checksums |
cfe5313652891367a292c03d0ef67b7fd83f5f6a561740acc801a1a759148ac4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logRelease files / actuarialpy-0.46.3-py3-none-any.whl
| Download URL | actuarialpy-0.46.3-py3-none-any.whl |
|---|---|
| Size | 74.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3d49da355c563e0369d7d10ce21a0a1df2fce5e3482c347a26b9096c12faee4
|
|
BLAKE2b-256 checksum How to use checksums |
c2ef9fb70cd7a8e89ffc1540cdeda0c6de93de8b71c9d9d317172c4e251eac90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency log