LifeFlow
  • Home
  • Tutorial
  • Guide
  • Reference
  • Changelog
  • Author
  • GitHub
  • PyPI

LifeFlow.

Project life-insurance cash flows and compute the reserves. Write your own flows as plain Python; LifeFlow vectorizes them across the whole portfolio as N × T grids and compiles the hot paths with numba.

Get started → GitHub PyPI
pip install lifeflow
reserve.py
import lifeflow as lf

port = lf.Portfolio(df, "id")
prob = lf.Probabilities(port, [qx])

@lf.grid(port, tl)
def death_benefit(t, capital):
    return capital

# reserve = amount × probability × discount
reserve = (death_benefit()
           * prob.exit_by(qx)
           * discount).sum(axis=1)

LifeFlow computes reserves for life-insurance portfolios

Easy to write, flexible to your product, and fast at scale.

Easy to code

Object-oriented — the repetitive calculations are automated inside objects, so your own code stays clean.
Decorators — ready-made decorators simplify building each calculation and guide you through defining the flows.

Yours to shape

Your flows, your rules — define the shape of every flow yourself: use conditions and any portfolio variable you need.
You stay in control — LifeFlow expects you to drive. It hands you the tools and gets out of the way, so you can fit it to your exact product.

Computationally efficient

Fast foundations — built on powerful Python libraries designed for fast, parallelizable numerical work.
Speed without losing clarity — the grid design keeps calculations fast and easy to audit and review.
Rust modules for a few specific processes are on the roadmap.
complement · not a replacement

LifeFlow works with numpy, not instead of it

LifeFlow doesn't box you into closed-form formulas. It gives the actuary a small set of tools — an object-oriented engine for in-force and exit probabilities, and decorators to project cash flows — so you keep total control of the numbers while the boilerplate and the performance are taken care of.

numpy

The arrays and the maths.

+
LifeFlow

The actuarial structure and the speed.

Ideal for moving Excel calculations to Python and standardizing them into a calculation flow that is easy to design, reproducible and fast.

SA
The author

Built by SergiActuary

Actuary from Barcelona who likes to build things. LifeFlow is my project to bring life-insurance calculations out of Excel and into fast, easy and scalable Python.

Visit my site

lifeflow · MIT License

 

Built by Sergi López Vergara