Clone this repository
git clone https://github.com/xujiahuayz/premfin.gitNavigate to the directory of the cloned repo
cd premfinchmod +x setup_repo.sh
./setup_repo.sh
or follow the step-by-step instructions below
- MacOS
python3 -m venv venv- Windows
python -m venv venv
- MacOS
. venv/bin/activate- Windows (in Command Prompt, NOT Powershell)
venv\Scripts\activate.batpip install -e ".[dev]"
All files in data/ are stored with lfs.
To initialize Git LFS:
git lfs install
git lfs track data/**/*
To pull data files, use
git lfs pull
cd scriptsplot betas
python plot_betas.pycreate a clean mortality_experience_clean.xlsx:
python process_empirical_table.pycalculate standard LE (with mortality rate of 1) of each cohort
python get_le.pyget surrender value, max loan rate acceptable by policyholder, lender profit at max loan rate in one go:
python get_surrendervalue_maxloanrate_lenderprofit.pyget different untapped profit based on different VBT tables and mortality rates from the perspective of policyholder when their cost of capital is at various levels:
python get_untappedprofit_policyholder.pyplot life insurance value to policyholders by LE bin
python plot_le_distr.py- plot money left based on different VBT on the table from the perspective of policyholder in comparison with real estate value loss during the financial crisis:
- plot distribution of life insurance value to policyholders on gender and age:
- plot average value to policy holders of different face value amount:
python plot_moneyleft.py- get median value loss from common household mistakes
- And its distribution on age and gender:
python get_median.pyplot value to policy holders of different net worth band:
python plot_wealth_distr.pyplot health spending as a fraction of income by age
python fetch_fred.py
python plot_income_by_age.py- plot economic value to policy holders of different net worth based on Face Amount Band:
- plot economic value to policy holders of different net worth based on Face Amount Band, Attained age and Gender:
python plot_ecovalue.py- plot lapsed life inusrance economic value and Food stamp, Medicare and Medicaid.
- Break down the life insurance economic value and see its distribution on gender and age
python plot_wealthtransferprogram.pyAlways pull latest code first
git pullMake changes locally, save. And then add, commit and push
git add [file-to-add]
git commit -m "update message"
git pushWe follow PEP8 coding format. The most important rules above all:
- Keep code lines length below 80 characters. Maximum 120. Long code lines are NOT readable.
- We use snake_case to name function, variables. CamelCase for classes.
- We make our code as DRY (Don't repeat yourself) as possible.
- We give a description to classes, methods and functions.
- Variables should be self explaining and just right long:
implied_volatilityis preferred overimpl_vimplied_volatilityis preferred overimplied_volatility_from_broker_name
- Do not place .py files at root level (besides setup.py)!
- Do not upload big files > 100 MB.
- Do not upload log files.
- Do not declare constant variables in the MIDDLE of a function