lifelib: Actuarial models in Python

repository·main·Indexed 42 days ago

https://github.com/lifelib-dev/lifelib

An open-source Python library providing a collection of life actuarial models for pricing, risk modeling, and model validation. It integrates with the Python data science stack and includes implementations for economic curves such as the Smith & Wilson algorithm, Nelson-Siegel-Svensson, Black-Scholes stock price simulation, and Bayesian validation of Economic Scenario Generators using the Metropolis-Hastings algorithm.

Tokens
105.9K
Snippets
173
Records
471
Agent score
53%

What's inside lifelib

  1. Overview of the CashValue_SE Model

    main

    The CashValue_SE model projects monthly cashflows for generic hypothetical savings products. It can project both new business and in-force policies for a single sample model point at a time.

    Key features include:

    • Product Types: Supports 4 product specifications (A, B, C, D). A and B are single premium products (simulating variable annuities), while C and D are level premium whole life products (simulating variable life).
    • Cashflow Logic: Premiums (net of loadings) are added to the account value; maintenance fees and cost-of-insurance charges are deducted at the start of each month; investment returns are then applied.
    • Benefits:
      • Death Benefit: The greater of the sum assured or the account value.
      • Surrender Benefit: The account value net of surrender charges (if applicable).
      • Maturity Benefit: For types A and B, the remaining account value is paid at maturity.
    • Data Dependencies: Uses product_spec_table.xlsx for product parameters and std_norm_rand.csv for investment return calculations.
  2. Overview of the BasicTerm_ME model

    main

    The BasicTerm_ME model is a high-performance reimplementation of the BasicTerm_SE model. It is designed for speed by using vectorized operations with Numpy and Pandas, allowing formulas to be applied to the entire set of model points simultaneously rather than iterating through them individually.

    Key Advantages:

    • Speed: It is significantly faster than BasicTerm_SE. For example, processing 10,000 model points with BasicTerm_ME can be faster than processing just 100 model points with BasicTerm_SE.
    • Vectorization: Formulas operate on Series or DataFrame objects, enabling element-wise calculations across all model points at once.
  3. Overview of the appliedlife library

    main

    The appliedlife library is centered around the IntegratedLife model, which is designed for real-world actuarial projection tasks.

    Key capabilities include:

    • Multiple Product Support: Currently supports VA GMAB and GMDB products, with an architecture that allows for easy inheritance of new products.
    • Flexible Inputs: Projections can be configured using parameter files to specify different combinations of model point files and scenario files.
    • Multiple Run Definitions: Supports defining various runs (e.g., base cases vs. stressed cases) within the model.
    • Decoupled Data: All input files (assumptions, mortality tables, product specs, economic data, and model points) are stored externally from the model logic.
    • Excel Integration: Results for sample model points can be exported directly to Excel using xlwings via the ProductBase.excel_sample method.
  4. Overview of the ifrs17a library

    main

    The ifrs17a library provides Python modules to calculate IFRS 17 figures (such as present value of cashflows, contractual service margin, loss component, and loss recovery component) for sample input data.

    The calculation logic is based on the [IFRS 17 Calculation Engine] developed by Systemorph.

    Limitations:

    • Experimental: The library is in an early stage of development and has not been fully validated.
    • Performance: Because it is written in pure Python, it may not be suitable for very large datasets despite some caching mechanisms.
    • Error-proofing: Comprehensive error-proofing is not yet implemented.
  5. What is lifelib?

    main
    lifelib is a collection of Python libraries designed for actuaries. It provides a variety of actuarial models, tools, sample scripts, and Jupyter notebooks. It is intended to promote the use of Python in actuarial science for tasks such as model validation, pricing, valuation, risk modeling, and replacing spreadsheet-based models with more robust Python implementations.
  6. Overview of the CashValue_ME model

    main
    The savings.CashValue_ME model is a high-performance reimplementation of the savings.CashValue_SE model. While it reproduces the same results, it is optimized for processing large numbers of model points by using Numpy and Pandas to perform vector operations on the entire set of model points simultaneously. It uses the same default product specifications, assumptions, and input data as CashValue_SE.
  7. Overview of the jplib library

    main

    The jplib library provides nine reference liability cash flow projection models specifically for individual life insurance products in the Japanese market. These models are built using modelx and are designed to project gross liability cash flows, including premiums, claims, benefits, surrenders, expenses, and commission.

    Key Characteristics:

    • By-model-point projection: Each model projects cash flows based on the product's specific processing order and timing.
    • No discounting: The models output raw cash flows. Tasks such as discounting, current estimate (genzai suikei, 現在推計), MOCE, and required capital calculation must be performed by a consuming layer.
    • High Fidelity: Each model is designed to reproduce a documented worked example, asserted cell-by-cell. The models are backed by product-spec.md (contractual mechanics and parameters), technical-notes.md (mathematical recursions and state variables), and sources.md (source documentation).
    • Standardization: Quantitative parameters are either source-tagged or marked [std] (standardized) to distinguish between facts from source material and assumptions made for the reference implementation.
  8. Overview of jplib product models

    main

    The jplib library provides monthly-step (_S) models for various Japanese insurance products, categorized into Protection, Savings, Third Sector, and Annuity.

    Protection

    • Term Life (Term_JP_S): Fixed-year term that auto-renews (nen-manryō kōshin-gata) up to age 80.
    • Survivor Income Term (IncomeTerm_JP_S): A death benefit paid as a level annuity, implemented as a term extension to handle the minimum guarantee period (saitei shiharai hosho kikan).

    Savings

    • Whole Life (WholeLife_JP_S): The base chassis for other savings models. Includes policy reserves (hokenryō tsumitatekin) and surrender values (kaiyaku henreikin). Supports automatic premium loans (jidō furikae kashitsuke).
    • Endowment (Endowment_JP_S): Uses the whole life chassis; adds a maturity benefit and a student insurance (gakushi hoken) cell with premium waivers.
    • FX Whole Life (FXWholeLife_JP_S): Uses the whole life chassis; adds USD-denominated crediting rates, surrender charges with MVA (shijō kakaku chōsei), and currency layers.

    Third Sector (Medical/Care)

    • Medical (Medical_JP_S): The third-sector chassis. Features daily hospitalization benefits with specific caps (60 days per hospitalization, 1,095 days lifetime) and advanced medical rider (senshin iryō tokuyaku).
    • Cancer (Cancer_JP_S): Deltas off the medical model. Includes a 90-day waiting period (menseki kikan), repeating diagnosis benefits, and cancer hospitalization with no day limit.
    • Nursing Care (LTC_JP_S): A three-state model (healthy / in care / dead) based on the medical chassis, using public scheme care grading (yōkaigo).

    Annuity

    • Individual Annuity (Annuity_JP_S): Accumulates to annuity proceeds (nenkin genshi) followed by a 10-year fixed payout. Uses two different mortality tables: one for the deferral phase and one for the payment phase.
  9. Overview of lifelib

    main
    lifelib is an open-source collection of life actuarial models written in Python. It is designed to be versatile and transparent, allowing for customization in areas such as model validation, pricing, research, valuation, asset-liability modeling, and risk/capital modeling. Many models are built using modelx, an object-oriented modeling package, which enables fast execution, easy formula tracing, and seamless integration with the Python data science ecosystem (Pandas, Numpy, SciPy).
  10. Review primary product sources for Income Guarantee (jplib)

    main

    The jplib-income_guarantee product is built from seventeen documents across ten insurance carriers. These sources include:

    • Policy Conditions (約款, yakkan) or Booklets: Full contract terms and mechanics (e.g., S1, S3, S14, S15).
    • Pre-contract Disclosures: Key facts and cautionary information (e.g., S2, S4, S5).
    • Consumer/Specification Pages: Web pages containing rate cards, premium grids, or FAQs (e.g., S6–S12, S16, S17).
    • Rider Conditions: Specific terms for add-on benefits (e.g., S13).

    Key technical data points extracted from these sources include commutation factor tables (S13), premium grids (S6), and benefit illustrations (S5, S14, S17).