Intro¶
Gaspatchio is a Python actuarial modelling framework. You build your projection vectors — survival, account values, cashflows, reserves — as columns on an ActuarialFrame. The whole projection runs across every policy together, and every output traces back to the inputs and steps that produced it.
The unit of work: ActuarialFrame¶
ActuarialFrame is what the model is built on. Column assignments are recorded, not executed, until you call .collect() — at which point the whole calculation runs as a single plan. Column lineage is tracked through that plan, so every output column traces back to the inputs and intermediate steps that produced it.
import datetime
from gaspatchio_core import ActuarialFrame
af = ActuarialFrame({
"policy_id": ["P001", "P002"],
"age": [35, 42],
"issue_date": [datetime.date(2022, 1, 15), datetime.date(2021, 6, 1)],
"valuation_date": [datetime.date(2024, 12, 31), datetime.date(2024, 12, 31)],
})
af.days_in_force = af.valuation_date.excel.days(af.issue_date)
af.years_in_force = af.issue_date.excel.yearfrac(af.valuation_date, basis="act/act").round(2)
df = af.collect()
How an actuary works in it¶
Four moves cover almost every model:
- Set the time axis. Declare the projection — how many periods, what frequency, which calendar, which day-count. Anniversary masks, year-fractions, and period dates all derive from it. See Schedules.
- Register assumptions. Mortality, lapse, expenses, economic curves. Tables sit in an in-memory registry with composite-key lookups that work on scalar columns and on list columns at projection time. See Assumptions.
- Write the projection. Express the calculation as column assignments and time-series operations. For pure cumulative accumulation (survival probabilities, discount factors, AV with pre-computable charges), use the cumulative ops on the Projections page. For state-dependent calculations (COI on net amount at risk, IUL floor/cap, GMDB ratchet), use Rollforward.
- Stress and run. Reuse the same calculation across shocked assumption tables and scenario configs to produce CTE, quantile, and other risk measures. See Scenarios.
What's next¶
Start with Schedules — every projection lives on a time axis, and getting that right is what everything else hangs off. From there, Projections walks the closed-form cumulative pattern through to the linear recurrence (accumulate()) and the handover to Rollforward for state-dependent products.