Vectorized life actuarial cash-flow and BEL engine
Project description
lifeflow
Object-oriented Python library for life actuarial cash-flow calculations.
Built on numpy — all calculations are vectorized as N × T grids, where N is the number of policies and T is the time horizon.
What it does
lifeflow lets the actuary define their own cash flows using Python lambdas. The library then automates:
- tINFx derivation — policy in-force grid from any combination of decrement hypotheses, with exact multiple-decrement formulas under UDD
- Actuarial hypotheses — mortality, lapse, disability or any rate vector, indexed by age, duration or any policy variable
- Portfolio extension — all calculations broadcast automatically across the full portfolio
The result of every object is a plain numpy array of shape N × T, inspectable at any step.
Installation
pip install lifeflow
Usage
import lifeflow as lf
portfolio = lf.Portfolio(df, id_col="POLICY_ID")
tl = lf.Timeline("contract_end_months")
qx = lf.Hypothesis(values=qx_monthly, timeline=tl, index_var="age_months")
wx = lf.Hypothesis(values=wx_monthly, timeline=tl, index_var="age_months")
inforce = lf.Inforce([qx, wx])
exit_death = inforce.exit_by(qx, portfolio) # N × T
benefit = lf.Flow(lambda DEATH_PAY_SINGLE: DEATH_PAY_SINGLE, tl)
bel = (exit_death * benefit.grid(portfolio) * discount).sum(axis=1)
License
MIT
Project details
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 lifeflow-0.0.3.tar.gz.
File metadata
- Download URL: lifeflow-0.0.3.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f484df5c5d474a355c8ed115992e16de584a8175ab7eb0d6d77a9d62465bf0d
|
|
| MD5 |
6aa89aab9363796b828ac1da85fdac51
|
|
| BLAKE2b-256 |
8258796c9b733796d326a1f7d73ee3599c8e81426e7681ad74f4cfd5d3c40644
|
File details
Details for the file lifeflow-0.0.3-py3-none-any.whl.
File metadata
- Download URL: lifeflow-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dcffdd3e2ca7003b98c4a44a10596ce029cfa0a4883fdc18dd7cd70b4fda823
|
|
| MD5 |
6f8ff3852a16add92dabd0a25ab05b4b
|
|
| BLAKE2b-256 |
f2c1a9498654f39b7a47b75472e78439c54b89e0d00dcb00013d36046e06f13f
|