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

Uploaded CPython 3.14Windows x86-64

lactuca-0.1.0-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.0-cp314-cp314-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

lactuca-0.1.0-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.0-cp313-cp313-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

lactuca-0.1.0-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.0-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.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: lactuca-0.1.0-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.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 242a804373bd46d320250737beeb6504edb19a1da280ab95dd8bdb9804b7ca47
MD5 166b125c2b04b1df20506a0752a6fb3f
BLAKE2b-256 aeb67f77b8888ca227069dde151986cea6998e94999691e80bbc0563683243c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.0-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.0-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.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d261ab4e5c21439293c65f770a7f759b11b61bb85291d72bbb80ca11d7ce5289
MD5 052419f18edae9cbd71eb981ece92a40
BLAKE2b-256 e584dfe43000e38a69a524721d6409cec0949bf5b6995c5d353ddaa48e37ed9b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lactuca-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dec0bbec3dcce857a9e5a60581ff8dca283c9910f7faba067ecbc66a91851fb9
MD5 bee0d7bdf44dfe43df8d82544428ae44
BLAKE2b-256 f08174241726c44cbd7cd6ec2ed05c774628c1b7508e02df2864c3d315f64109

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lactuca-0.1.0-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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 023a12b0d89049d4aefed984bec76e4d0b782f64ebffe8ca9c63e53aa284f753
MD5 9b55872b3f2cea946d1db9740633b8b8
BLAKE2b-256 4f3c07bc1c373f93fa694152c49735dfb36137cea3fa1a06905cd6cdb08ca649

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.0-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.0-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.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ca461068a7506a03bcae66096ced3c13c8c33c7aff4a996bda9ba9c6b4209cc
MD5 aa1058f7cac47bef592703b683e12fe6
BLAKE2b-256 b2d74051ae062c7c6fd4f9dc65a16ff16dc9e9dd8b6cfd31dffeaa3100ca52de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lactuca-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc5e203c634e569d4d4d4a4a3e3b5681085298493d487540c37d3983989280d2
MD5 ca5b97b01ed139ed769918b9db23e2ff
BLAKE2b-256 854bbe1187b3f41f1a46480476898064e0fda25d4ae4654014bbe9e41cf66413

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lactuca-0.1.0-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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4fb58d3bfad185268f3336fff532918f168750fc929722cbca2ac0b6bc247f89
MD5 9ba65fc77eca489a2f84f6fe24d70e8a
BLAKE2b-256 9bc60aeffab94cd7e665742812940e951a0293933d3404cb0d88929163b46f16

See more details on using hashes here.

Provenance

The following attestation bundles were made for lactuca-0.1.0-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.0-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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76c9ceead7636e9943a312253dd45f6b9695c3b8f8a5db99873ee3b07e54f0d5
MD5 173def2a5043f66aaf34eeb8a7acfb05
BLAKE2b-256 c9f91fe5f9012a2aa98b5b5d46f2a0d631bb651bc77ba2d094cf66e5bcfdf686

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lactuca-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9118b2aff11803e71ec2b2b6d46f5b94bfd3cfd1b4912840a6c9811e2255079
MD5 b1c33c2362b2248b4cb1c5d25ca5c702
BLAKE2b-256 977c37a6e5dfae77c899dfe63bf202c3cf25da2d297cdfcdaee21b58bdb9a099

See more details on using hashes here.

Provenance

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