A framework for actuarial modelling.
Project description
Predictable
What is it?
A framework for actuarial modelling.
Installation
pip install predictable
Quick start example
A model.py
file will be used to house the modelling logic which will be applied to each modelpoint.
# import the library
from predictable import CashFlow, DiscountFactors, Model, StaticFlow
# Create new model instance
model = Model()
# Add a premium component
model.add_component(
CashFlow(
input_array=[100], formula=lambda prev: prev * 1.05, label="premium"
)
)
# Add a sum assured component
model.add_component(CashFlow(label="cover", input_array=[1_000_000]))
# Add an expense component
model.add_component(
StaticFlow(
input_array=[10, 10, 10, 10, 10],
label="expense",
)
)
# Add discounting component
model.add_component(DiscountFactors(interest_rate=0.05, label="V"))
# Project cashflows over term
# Results return a pandas df object
df = model.project(term=10)
# Perform linear combination style manipulations
# Discounting the components
components = ["premium", "cover", "expense"]
for component in components:
df[f"V_{component}"] = df[component] * df["V"]
# Define reserving relationship
df["Reserve"] = df["V_cover"] + df["V_expense"] - df["V_premium"]
# Results get returned as a pandas dataframe
print(df)
License
Documentation
This project is documented using sphinx and the full documentation can be found at predictable.readthedocs.io.
Development & Contibutions
The following steps can be followed to set up a development environment.
- Clone the project:
git clone https://github.com/RatulMaharaj/predictable.git
cd predictable
- Create a virtual environment and activate it using:
python -m venv venv
source venv/bin/activate # mac
venv\Scripts\activate # windows
- Install the project dependencies:
pip install -r requirements-dev.txt
In development mode, the package can be installed by running:
pip install -e .
- Install the pre-commit hooks
pre-commit install
Testing
The tests for this project can be found in the predictable/tests
directory. Tests will run after every commit (locally) and on every push (using github actions) but can also be run manually using:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
predictable-0.0.0a0.tar.gz
(17.4 kB
view hashes)
Built Distribution
Close
Hashes for predictable-0.0.0a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8f0e05bdd4e3c0c385614c2ec4dfbb7dee0cb82a0286bfd41a08fb32ea58620 |
|
MD5 | bed410c4e9aa0be4436bcfcb26c776c8 |
|
BLAKE2b-256 | 20f653b7bf4419c4a82149401c3a929c069085611db3da9dd3f47a9fa9cd321e |