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.6-cp314-cp314-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.14Windows x86-64

lactuca-0.1.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.0 MB view details)

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

lactuca-0.1.6-cp314-cp314-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

lactuca-0.1.6-cp313-cp313-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.13Windows x86-64

lactuca-0.1.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.0 MB view details)

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

lactuca-0.1.6-cp313-cp313-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lactuca-0.1.6-cp312-cp312-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.12Windows x86-64

lactuca-0.1.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.0 MB view details)

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

lactuca-0.1.6-cp312-cp312-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: lactuca-0.1.6-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 4.4 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.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3e44015ccfe6a723eb2291cb61257c378ee664940c64a2030eb4dfbe6ca50b8b
MD5 89a60549bc1f5afc831cd818425290bc
BLAKE2b-256 1b610ab30bb3e12b13ab28ec82934188f53235672f5496662273a7d1eaf007b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-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.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fac9d9f8dbaf82c4b330a8cf74d9de457142040960bd1f6f6cfe1de7ca13f63f
MD5 a4de1136675dde056986a485861e4ff1
BLAKE2b-256 6b845d26460634331a19186fa873c9e8b5fbbe30d6a9cf62213692177f8c0a77

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e229e6d475b239a7ccc1045ad054bf340e9a27e009c2f4562a0a517a7f1c97ab
MD5 4ff9bc29f0c6134c087fba3f35847e7e
BLAKE2b-256 26676d6e0e13cbac68d01f9388d637f17d338e201917fa814fb5d4cc191ad98a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: lactuca-0.1.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.3 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4ed82a0329462618f555e049f8a084d9501ddfb951a48b19560b674a15ed7ae7
MD5 6892f631523452b131276b6dbaa36cbb
BLAKE2b-256 bef2b5f8717506a65aec759a652afe7cc80da701edab2d26231bc6d8f3b8937b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-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.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d7f64015203b5a8cf80df72b43bf15d25380134e4a184090e28a7a7883a19e22
MD5 d79a05ed98312d42b53ef3b331921747
BLAKE2b-256 4244d68cad460bb06951b4e9e40854f3e3bf93c041c6842ef194d001634881ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 10beec8a59c9458e50bf1cbc763ab1721b3b1a8d012dfe65e739488f36656cd5
MD5 96a2b748cd04d5f1ba39f61b9fd8023b
BLAKE2b-256 b92cf42aa59901dad3d86e2e8d24f9ce82f2a3c486f6da00f298efcde91e80af

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: lactuca-0.1.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.3 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5a819177bcde4de3d91d428b5e5c56c75fdd0b31c92d0633d9ab280f2fd1a6db
MD5 ac26503cdad0da07ce795779f04bfdd5
BLAKE2b-256 c6813c1ce72b1f32c05da6bc224dc0da40425483931f42c1dc5a8423553f54d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-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.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 777fff4924ce9daa314a481b572196225184ed1a53d68208fab350305af94599
MD5 ecbb01cba28e16f08fa8729d4e4f986e
BLAKE2b-256 1b9f6f5db7aef38260d629ade5bb2d93f720f202603200d0428dab480efd8409

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lactuca-0.1.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e15740768c6b11c2af54d90fd685013c25af330471237d4df1dfc86cbf9cf5dd
MD5 0103d7472e596e4cd5ce153ccac25a36
BLAKE2b-256 0792117354559a8aac854e7aa1579052a2f04d50dec16750cdda111799516901

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.6-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