https://github.com/Oxylo/factors
Generates actuarial factors for premium calculations
https://github.com/Oxylo/factors
Last synced: 4 months ago
JSON representation
Generates actuarial factors for premium calculations
- Host: GitHub
- URL: https://github.com/Oxylo/factors
- Owner: Oxylo
- License: mit
- Created: 2016-07-10T10:31:16.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-10T07:11:46.000Z (about 1 year ago)
- Last Synced: 2024-12-02T12:58:10.348Z (4 months ago)
- Language: Python
- Size: 7.17 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.rst
- License: LICENSE.md
- Authors: AUTHORS.rst
Awesome Lists containing this project
- jimsghstars - Oxylo/factors - Generates actuarial factors for premium calculations (Python)
README
=======
factors
=======Generate actuarial factors and cashflows from several Dutch tables like AG2014, AG2016, AG2018, AG2020, AG2022, etc.
1. Installation
---------------Create a virtual environment:
.. code-block:: console
mkdir actfact
cd actfact
python3 -m venv venv
source venv/bin/activateInstall the factors package:
.. code-block:: console
pip install git+https://github.com/Oxylo/factors.git@master
And for running the code interactively, install Jupyter notebook:
.. code-block:: console
pip install notebook
2. Examples
-----------*2.1 Generate actuarial factors AG2022 at 2% fixed intrest rate*
.. code-block:: console
from factors import LifeTable
lifetab = LifeTable("AG2022", calc_year=2022)
all_tabs = lifetab.calculate_factors(intrest=2, pension_age=68)*2.2 Generate cash flows for AG2018, useful for discounting with yield curve*
.. code-block:: console
import pandas as pd
from factors import LifeTable
lifetab = LifeTable("AG2018", calc_year=2020)
opll = lifetab.cf_retirement_pension(age_insured=68, sex_insured='M', pension_age=68)
npll = lifetab.cf_defined_partner(age_insured=65,sex_insured='F',pension_age=68)
npll_od = lifetab.cf_undefined_partner(age_insured=65,sex_insured='F',pension_age=68)
cashflows = pd.DataFrame({'OPLL': opll['payments'], 'NPLL': npll['payments'], 'NPLL_ondefined': npll_od['payments']})
*2.3 Compare life expectancy of AG2014 and AG2016 at the calculation year of the most recent table*
.. code-block:: console
from factors import LifeTable
tab2014 = LifeTable("AG2014", calc_year=2016)
life_expectancy_ag2014 = tab2014.lx(current_age=0)['M'].sum() - 0.5
tab2016 = LifeTable("AG2016", calc_year=2016)
life_expectancy_ag2016 = tab2016.lx(current_age=0)['M'].sum() - 0.5
change = life_expectancy_ag2016 - life_expectancy_ag2014
*2.4 Run unit tests*
.. code-block:: console
from factors import LifeTable
tab = LifeTable("AG2014", calc_year=2017)
tab.run_test()3. Changelog and Contributions
------------------------------
For changelog, see CHANGELOG.md
If you would like to contribute, see CONTRIBUTING.rst