Skip to main content

Professional life actuarial library for Python with compiled performance and international tables

Project description

Lactuca

Professional life actuarial library for Python — life insurance, pensions, and disability: mortality and disability tables, annuities, insurances, commutation functions, and interest-rate scenarios, optimized for Spanish and international actuarial practice.

PyPI Python License Docs

Installation

pip install lactuca

Requires Python ≥ 3.12. Runs on Windows, Linux, and macOS (wheels for CPython 3.12–3.14). Core runtime dependencies include NumPy, SciPy, Pandas, Polars, msgpack, PyNaCl, requests, and platformdirs (see pyproject.toml for pinned ranges).

Bundled tables (one-time setup)

Table data ships inside the package but must be written to disk as .ltk files before use. Run this once per environment (or after upgrading Lactuca):

from lactuca.tables.data import Tables

Tables.install()  # all bundled tables → ./actuarial_tables/ by default

Install only what you need: Tables.install("PER2020_Ind_1o"). The default directory is actuarial_tables/ under your current working directory; change it with lactuca.config.tables_path. See the Bundled Tables guide for the full catalogue.

Activation

Proprietary software — a valid license key is required before calculations run.

On the first use (python -m lactuca or import lactuca), the library looks for a license in this order:

  1. LACTUCA_LICENSE_KEY environment variable (recommended for servers and CI/CD).
  2. Local license.json in your Lactuca config directory (offline use after first activation).
  3. Interactive prompt — enter an existing key or request a free 30-day trial.
# Interactive activation (same as omitting the subcommand)
python -m lactuca
python -m lactuca activate

# License maintenance (script-friendly)
python -m lactuca license status [--json]
python -m lactuca license refresh [--json]
python -m lactuca license doctor [--json]

Check the version

python -c "import lactuca; print(lactuca.__version__)"

The first import runs activation (see above). To read pip metadata without importing the package:

pip show lactuca
python -c "from importlib.metadata import version; print(version('lactuca'))"

Quick Start

Requires an activated license — see Activation above (LACTUCA_LICENSE_KEY, license.json, or the interactive trial).

Requires bundled tables on disk — run Tables.install() once (see Bundled tables).

Lactuca centres on three table classes — LifeTable (mortality), DisabilityTable (disability incidence), and ExitTable (withdrawals) — plus InterestRate, GrowthRate, and a global Config for calculation defaults. Generational tables require a cohort birth year; select-ultimate tables require a duration (select year, or "ult" for ultimate); some tables need both.

from lactuca import LifeTable, äx

# Static PASEM 2020 general table, 2nd order (Spanish best-estimate mortality)
lt = LifeTable("PASEM2020_Gen_2o", "m")

# Generational individual table with explicit cohort (PER 2020, male, born 1969)
lt_cohort = LifeTable("PER2020_Ind_1o", "m", cohort=1969)

# Select-ultimate table (UK AM92/AF92, male) — duration picks the select slice
# (AM92/AF92 uses Duration-0: first select year is duration=0)
lt_select = LifeTable("AM92_AF92", "m", duration=0)

# 15-year temporary life annuity-due, annual payments (m=1), 3% interest
# n = term in years, m = payment frequency per year (1=annual, 12=monthly)
annuity = lt.äx(x=50, n=15, m=1, ir=0.03)
print(f"Life annuity value: {annuity:.4f}")

# Identical result via the functional API:
annuity = äx(table=lt, x=50, n=15, m=1, ir=0.03)
print(f"Life annuity value: {annuity:.4f}")

Features

  • International actuarial tables — bundled and ready to install (see catalogue):
    • Spain (DGSFP): PASEM2010; PASEM2020 (Gen, Dec, Rel, NoRel, 1st/2nd order); PER2020 (Col/Ind, 1st/2nd); PEAI2007 (IAP Ind/Col)
    • Spain (SS): IASS90; SS90TOT; SS90ABS
    • Germany (DAV): DAV2004R aggregate and select-ultimate (1st/2nd order)
    • USA (SOA): GAM71, GAM83, GAM94_AA
    • UK (CMIB): AM92_AF92 (select-ultimate, Duration-0)
    • Switzerland (SOA): GRMF80, GRMF95, GKMF80, GKMF95
    • Chile (CMF NCG 305/2023): CB_H_2020, MI_H_2020, MI_M_2020, RV_M_2020, B_M_2020
  • Generational mortality with exponential, linear, and discrete improvement factors (cohort); select-ultimate tables with duration-dependent rates (duration or "ult")
  • LifeTable, DisabilityTable, and ExitTable — mortality, disability incidence, and exit/withdrawal decrements (including multiple-decrement combinations)
  • Custom tables — build proprietary .ltk tables with TableBuilder or load them via read_table
  • Annuities (discrete/continuous, immediate/due, fractional frequencies)
  • Life insurances (term, whole life, endowment)
  • Commutation functions (Dx, Nx, Cx, Mx, Rx, Sx, Lx, Tx, ex and joint-life variants)
  • Functional API (scalar and vectorized: ax, äx, Ax, tpx, ex, nEx; multi-life annuities axy/äxy (2), axyz/äxyz (3), ajoint/äjoint (N); pure endowments nExy/nExyz/nEjoint; first-death insurances Axy, Axyz, Afirst…)
  • Batch API — vectorized multi-policy calculations with scalar equivalence when N=1; Pandas and Polars Series supported on batch inputs
  • Flexible interest rates with InterestRate (flat rate, piecewise term structure, named scenarios)
  • Growth rate scenarios with GrowthRate for benefit escalation
  • Global Config — calculation modes (discrete_precision, continuous_precision, …), mortality placement, and interpolation defaults
  • Fractional time shifts (ts) with UDD/CFM interpolation methods
  • Actuarial date utilities (exact age, last/nearest/next birthday, anniversary dates)
  • Highly optimized with NumPy vectorization and Cython compilation
  • Type-safe with full type hint coverage and stub files (.pyi)

Documentation

📚 Full Documentation

Documentation is licensed under CC BY 4.0. The library code and binaries remain proprietary — see the EULA and LICENSE.

Contact

📧 support@lactuca.io
🌐 https://www.lactuca.io


Built with ❤️ for the actuarial community using Cython for maximum performance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lactuca-0.1.11-cp314-cp314-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.14Windows x86-64

lactuca-0.1.11-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

lactuca-0.1.11-cp314-cp314-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

lactuca-0.1.11-cp313-cp313-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.13Windows x86-64

lactuca-0.1.11-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

lactuca-0.1.11-cp313-cp313-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lactuca-0.1.11-cp312-cp312-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.12Windows x86-64

lactuca-0.1.11-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

lactuca-0.1.11-cp312-cp312-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file lactuca-0.1.11-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: lactuca-0.1.11-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lactuca-0.1.11-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b35052d6e936d431f7f25417ea6535635df80d4930760101af205a7057262c5a
MD5 723a6f1dec366b8ef4f263021066d9d8
BLAKE2b-256 b0aa1c53bdc027b00390cd51066355a258425dbc1c35499607f4d0a2085a8a38

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp314-cp314-win_amd64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.11-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4dcd69e522fd7461b09e589c717c371b545416fc078d33f5ea71b3d2b8832593
MD5 b5ef8df1cb955c88e556ad743cec0aad
BLAKE2b-256 fcdf2cd250081c13229ac7402cdb7beeac129fb86ffe26e181c24ede21d304da

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.11-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a12725f04b502d1f6468ef5f301fb981bb64e52a9bca90cec696ae2aed90e95
MD5 a7f5758e9df7830f25ee0a3c56046bca
BLAKE2b-256 78efbdc1ffbf5ad77464f5dbc4780f26b27ed5f465df030c57001723173bd367

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: lactuca-0.1.11-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lactuca-0.1.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9e4cb11ec52e8eea9d1f37d442e82dc8498bead26289b3b640c0c08bd5077139
MD5 319358bcda176d1288ee3ab55387add9
BLAKE2b-256 ae3a776a85ceefbbeabbe737871e1414b4a432e7aeb1ae8d06b820b8c4c707e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp313-cp313-win_amd64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.11-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 42506b47d4ae063eea6372e8cefec7e0ae7bfc96d35515909f94662770cde0a1
MD5 b4b6b3534c96db4c519bb48e2b248b5d
BLAKE2b-256 cc0b841c5e8b9b99c6e2637977b9ac32de17ba6780b40b8b66585778317d2a92

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6239c96e5069df8613695b3831c57b9dff98dd1922b7d3e9deb68aff28aac47b
MD5 cb8e8226476d226cf74d64ba69efabe8
BLAKE2b-256 f832a82b259e017c7d32ec50fb6a9a723627505810a21a47efa362e8dc93b085

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: lactuca-0.1.11-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lactuca-0.1.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e2eac893cbc633b1e2530fb0b96c14b25f42ee2bd91ae288d897455fcfe4a232
MD5 37d409b30cbd449a8a1687b71b9635fd
BLAKE2b-256 a3ad75fd82e768ec8166e92737f172bcfca7069117c3e5cf58cc6cf4c7fd29e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp312-cp312-win_amd64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.11-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f4f81b148eb84c5d8adb52a59734d1b5f9f19274c0c4e29a70bddd2fd136d4a
MD5 835c64c32ad09581c24fbe83a648057d
BLAKE2b-256 628f4eba8735ae67836892a1cee7cd076d914e7993cae760b24b71233fd5eace

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lactuca-0.1.11-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e91ee4dddc6757695121700e6cde1c691edc2137a9492390c0073b1fe1f0d1ee
MD5 8ad8259e601e3aea48e0fb2a158029ec
BLAKE2b-256 3228fe8540b27c988dcfe464cc3517c30025ccd8eecb935d82fe993274cbf7c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.11-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release-production.yml on actuaan/lactuca-dev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page