Skip to content

Nikkex1/risk-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Risk Pool

Python

Create risk pools of assets with similar value and risk for insurance finance applications, such as insurance portfolios.

Features

  • Create risk pool tables with step-by-step calculations
  • See summary statistics about the risk pool, such as expected loss, standard deviation, premium and Value at Risk (VaR)
  • Visualize the distribution of claim probabilities

Requirements & Usage

pip install numpy
pip install pandas
pip install matplotlib
pip install scipy

Copy the risk_pool.py file in your working directory.

Example

from risk_pool import RiskPool

There are 20 cottages, each valued at 50000 units of currency. The probability of a single cottage getting destroyed in a fire is 0.1 (asset losses are expected to be independent events):

# Risk pool parameters
number_of_assets = 20
asset_value = 50000
probability_of_loss = 0.1

# Using default p = 0.95 and multiplier = 1.00
rp = RiskPool(number_of_assets,asset_value,probability_of_loss)

The RiskPool class also has the following default parameters values:

  • p = 0.95
    • This is the probability corresponding to the z-value of a normal distribution (confidence level). It adjusts VaR calculations.
  • multiplier = 1.00
    • This is used to adjust risk tolerance levels; the higher the multiplier is, the higher the premium and VaR.
# Risk pool table
print(rp.table())
Number of claims P(i) Loss P(i)*Loss Sum of Squares Total Number of outcomes
0 0.121577 0 0 3.03942e+06 1
1 0.27017 2500 675.43 1.68856e+06 20
2 0.28518 5000 1425.9 2.12306e-24 190
3 0.19012 7500 1425.9 1.18825e+06 1140
4 0.089779 10000 897.79 2.24447e+06 4845
5 0.031921 12500 399.02 1.79558e+06 15504
6 0.008867 15000 133.01 886704 38760
7 0.00197 17500 34.48 307883 77520
8 0.000356 20000 7.12 80049.7 125970
9 5.3e-05 22500 1.19 16141.7 167960
10 6e-06 25000 0.16 2576.82 184756
11 1e-06 27500 0.02 329.423 167960
12 0 30000 0 33.8912 125970
13 0 32500 0 2.80399 77520
14 0 35000 0 0.185388 38760
15 0 37500 0 0.00966992 15504
16 0 40000 0 0.000389404 4845
17 0 42500 0 1.16868e-05 1140
18 0 45000 0 2.4624e-07 190
19 0 47500 0 3.25125e-09 20
20 0 50000 0 2.025e-11 1

Explanation:

  • Number of claims: the number of cottages destroyed in a fire in this example case
  • P(i): the probability of having i number of claims
  • Loss: the total loss corresponding to i number of claims
  • P(i)*Loss: the weighted expected loss for i number of claims
  • Sum of Squares Total: SST, a measure of variance of the loss distribution
  • Number of outcomes: the number of ways that i number of claims can happen
# Risk pool summary statistics
print(rp.stats())
Measure
Asset value 50000
P(loss) 0.1
Number of assets 20
Expected loss 5000
Stdev 3354.1
Z-score 1.64
Multiplier 1
Premium 250
VaR -517.01

Explanation:

  • Asset value: value of a single asset (cottage value)
  • P(loss): probability of loss for a single asset (cottage burning down)
  • Number of assets: the number of assets in the risk pool (total amount of cottages)
  • Expected loss: the expected total loss of the risk pool
  • Stdev: standard deviation; volatility of the risk pool
  • Z-score: the z-score corresponding to the chosen confidence level (p = 0.95)
  • Multiplier: premium and VaR adjustment factor (risk tolerance level)
  • Premium: the amount that should be charged to cover potential losses
  • VaR: Value at Risk, the loss in the worst case scenario at 95% confidence level (p = 0.95)
# Distribution of claim probabilities
print(rp.visualize())

Distribution of claim probabilities.

The picture above shows that the most likely scenario involves two cottages getting destroyed in a fire. The chance for this is 28.52%, as seen also from the risk pool table.

About

A tool for creating risk pools for insurance finance purposes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages