Skip to main content

C++ powered actuarial engine: FactorModel, Monte Carlo, Loss Triangle, Fourier aggregate loss, and batch Excel export.

Project description

RiskPY: Enterprise Actuarial Engine 🚀

A hyper-fast, C++ powered pricing framework for actuaries (P&C, Life, Health): declarative rating, Monte Carlo, chain-ladder reserving, Fourier aggregate loss, batch Excel export, and an optional desktop GUI.

pip install open-riskpy
from riskpy import FactorModel, FourierTransform

model = FactorModel(1000.0)
model.add_multiplier("state", "FL", 3.0)
print(model.calculate({"state": "FL"}))  # 3000.0

pmf = FourierTransform.compound_poisson_pmf([0.0, 1.0], expected_frequency=2.0, grid_size=64)

CI PyPI Python License: MIT

v0.2.6 — FourierTransform, hot-path performance, headless-safe imports, wheels via GitHub Actions → PyPI. See RELEASE_NOTES.md.


Install (end users)

pip install open-riskpy
# upgrade
pip install -U open-riskpy

# Optional GUI charts (Monte Carlo plots)
pip install "open-riskpy[gui]"

Pre-built wheels are published for common platforms. From source you need a C++17 compiler and CMake (pulled automatically by the build backend when missing).

Core install has no heavy Python deps (matplotlib is optional via [gui]).
import riskpy is headless-safe (no Tkinter required). The GUI (UnderwritingApp) loads only when you use it.


Install (developers)

git clone https://github.com/slimboi34/RiskPY.git
cd RiskPY
make install    # pip install -e ".[dev]"
make test       # pytest
make smoke      # quick import check
# or: make check

Without Make:

pip install -e ".[dev]"
pytest tests/

Core features

Module Role
FactorModel Multiplicative rating rules (exact + numeric bands)
MonteCarloSimulator P&C, life, health, GBM, catastrophe simulations
ActuarialMath PV, FV, loss ratio, mortality
LossTriangle Chain ladder, IBNR
ExperienceRating / ExposureRating Credibility, ILFs, layers
RateAnalyzer On-level, trend, combined ratio, indicated rate change
FourierTransform FFT / iFFT, convolution, compound-Poisson PMF
UnderwritingApp Tkinter GUI + CSV batch → Excel
RiskEngine / ExcelExporter Low-level orchestration & xlsx

Docs: docs/API_REFERENCE.md · docs/TUTORIALS.md · docs/PUBLISHING.md


Quick examples

Factor pricing

from riskpy import FactorModel

model = FactorModel(initial_base_rate=1000.0)
model.add_multiplier("state", "FL", 3.0)
model.add_numeric_band_multiplier("age", 16, 25, 2.0)
premium = model.calculate({"state": "FL", "age": 19.0})  # 6000.0

Fourier compound Poisson (no sampling error)

from riskpy import FourierTransform

# Severity always 1 → aggregate is Poisson(λ)
pmf = FourierTransform.compound_poisson_pmf(
    severity_pmf=[0.0, 1.0],
    expected_frequency=2.0,
    grid_size=64,
)

Monte Carlo

from riskpy import MonteCarloSimulator
import numpy as np

sim = MonteCarloSimulator(trials=100_000)
losses = sim.simulate_aggregate_loss(5.0, 10.0, 1.5)
print(np.percentile(losses, 99))

Batch CSV → Excel (needs Tk/desktop for the app wrapper)

from riskpy import UnderwritingApp, FactorModel

app = UnderwritingApp(title="Auto Rater", excel_template="template.xlsx")
app.add_field("state", "State", "A", choices=["NY", "CA", "FL"])
app.add_field("age", "Age", "B")
app.set_premium_column("C", "Premium")
app.set_factor_model(FactorModel(100.0))
total, n = app.calculate_batch("book.csv", "quotes.xlsx")

Releasing to GitHub + PyPI (maintainers)

One-time: configure PyPI Trusted Publishing for this repo (publish.yml, environment pypi). Details in docs/PUBLISHING.md.

# After merging to main and bumping version in pyproject.toml:
make release
gh release create v0.2.6 --generate-notes
# Actions → "Publish to PyPI" builds wheels + sdist and uploads
Workflow When What
CI every push/PR to main build + pytest (Linux/macOS)
Publish GitHub Release / manual wheels + sdist → PyPI

Building from source (details)

Tool Notes
C++17 compiler Apple Clang, GCC ≥ 9, MSVC 2019+
CMake ≥ 3.15 Injected by the build backend if needed
Python ≥ 3.8 3.10+ recommended
Ninja / ccache Optional; speeds CI and local rebuilds
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu 2>/dev/null || nproc)
pip install .
pytest tests/

License

MIT — free for personal and commercial use.

Project details


Download files

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

Source Distribution

open_riskpy-0.2.6.tar.gz (61.3 kB view details)

Uploaded Source

Built Distributions

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

open_riskpy-0.2.6-cp313-cp313-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.13Windows x86-64

open_riskpy-0.2.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

open_riskpy-0.2.6-cp313-cp313-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

open_riskpy-0.2.6-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

open_riskpy-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

open_riskpy-0.2.6-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

open_riskpy-0.2.6-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

open_riskpy-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

open_riskpy-0.2.6-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

open_riskpy-0.2.6-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

open_riskpy-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

open_riskpy-0.2.6-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file open_riskpy-0.2.6.tar.gz.

File metadata

  • Download URL: open_riskpy-0.2.6.tar.gz
  • Upload date:
  • Size: 61.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for open_riskpy-0.2.6.tar.gz
Algorithm Hash digest
SHA256 9900800b170f7d651445e9f4c9ee821c03ebfa9e65d60e9e0202867d6d3a2b5a
MD5 ab120c3e59a48b3257139084b1d23a08
BLAKE2b-256 0acf92c3af5847c10f1696fc0a8e25ea9019c6889cc020b37d7e00b0d5a675ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6.tar.gz:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1f92835c9a28a93b35bba5b8da854f34dc1f61c71a00e3867015821b37f9f344
MD5 99839cc1d972a4e6440505e487b1c26a
BLAKE2b-256 9f7019683fcbe076fd6e6d36bd18e26c35068361203033a58492e39e9e4e894a

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f5ddb33ed0ebc101b31fe7935c1eab68b230d01f1493b09b4067915bb67a084
MD5 a33b9c0ed310b332f15e25fc7b538f8a
BLAKE2b-256 fb6025dc834887a27d81e231de8c321dbddbb0d7ee6173568aed089341c19244

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d972e20a7716923d30c1e4e0948b030becfde40153e9d452ab43f8bb75f6c19c
MD5 7b4f6edb31b3516a1a6900a2f84e8eb7
BLAKE2b-256 56b77e97ee295adb948cd710a9a852f2dba0ee5a3e8bb5cd5e8e6baf581b58e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1e021c8b09002ebd9020c559e542d8a76149c7515a60991fc08249ddaa4544a4
MD5 489dd1f34c8c95c5a8878fcdb6fa0a20
BLAKE2b-256 8bd4c6834931c345e7ab0b69bc66714222adb5c39ee6b060a0288be1172f103c

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7e21845bd122b8e0034f69cf9aead3944505df38102a8629c1c2fbd3cba229c
MD5 ec518edef1d9e5b7bf63da7d645aa08d
BLAKE2b-256 82961b7eec56f6a65abbc76c866e7f0f2b9f565ea18863075dc19a00d1d3dcfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7c416a4abdd6afbcbad43b46e6d12d04f0400e6122df0ead12b9943b123e5e8
MD5 667f15b3ff37817d9325ff4a3cd628a2
BLAKE2b-256 2cc8897e35f48723208482bc3bda6311acef1710049fe3ee40faae01e21179df

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 061ed290c9b2e5dfb02e74804e1ab974ab3d922414fc68762840354da4a473c0
MD5 84c7fa0795f5e38c5c8683a64187a387
BLAKE2b-256 9868de17ff8a02df13a5f5f7f70dcfadce6cb0bc6b53c4630240d4ed35421e29

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85d4f7f438ac9e8549e0612e787024b464ef9d13f4a864d12d9a9520082d9392
MD5 29dbc69bd306f627bd75f1c76c37c787
BLAKE2b-256 909ff1fe5f1acb28ce18f36c16ee50b5bde1a89d10b73d1e6b984af4bad7c5b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8df6f0ff8252fc8469d14abe57d682661b14295f30d1b9bc7056c6326fa7af2
MD5 2329bc7bc162e7567bbd2d07d8e6b87a
BLAKE2b-256 8fd50a6752a28f2603b6e5e9404db1dc1a557b33ceea1aeafd89e7ca6e0a0223

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e5d079a47f88e984a9e3484bee1efcc49169cad1633ee2f88ed415f1ac015812
MD5 f1cc60a1fe3c0c9e62255a412e3735da
BLAKE2b-256 46300b18bf0692d311544c6359b5b1619b078ff3efd52d1861ab8f8c462979fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp310-cp310-win_amd64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b74711447c64f62c452be5656ddc65efd37618841f6e6c13f37a60db9978a13b
MD5 bf94dfca326617a1554f632569e5197b
BLAKE2b-256 279abe37567299608c2d23b6a863c3c4ab4720a526ab268d2f0b642a4baeb362

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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

File details

Details for the file open_riskpy-0.2.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_riskpy-0.2.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19149556a0b57562e52d63fca1587ab19f477b0c392e8e9b3587251a6d1613fc
MD5 4fbffbdba30da8cfce7ead5445c9a9ab
BLAKE2b-256 5b53a8e438ae8bb74f0837c7fbe3b856a82a59a78243d5ec0fa5924e6339b042

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_riskpy-0.2.6-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on slimboi34/RiskPY

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