IFRS17 CSM Waterfall Chart Notebook#
To run this notebook and get all the outputs below, Go to the Cell menu above, and then click Run All.
About this notebook#
The primary purpose of this model is to showcase the capability of lifelib and its base system modelx, and less attention has been paid to the accuracy of the model or the compliance with the accounting standards. At very least, following items are identified as over-simplification or lack of implementation.
The timing of cashflows is either the beginning or end of each step.
All expenses are included in insurance cashflows.
Loss component logic is not yet incorporated, so
CSMcan be negative.
Coverage unit is set to sum assured
Amortization of acquisition cash flows is not yet implemented.
All insurance cashflows are considered non-market sensitive, i.e. no TVOG is considered.
Risk adjustment is not yet modeled.
How to use Jupyter Notebook#
Jupter notebook enables you to run a Python script piece by piece. You can run each piece of code (called a “cell”) by putting the cursor in the cell and pressing Shift + Enter, and get the output right below the input code of the cell.
If you want to learn more about Jupyter Notebook, this tutorial will help you. There are also plenty of other resources on the internet as Jupyter Notebook is quite popular.
The entire script#
Below is the entire script of this example. The enire scipt is broken down to several parts in differenc cells, and each part is explained below. The pieces of code in cells below are executable one after another from the top.
%matplotlib notebook import collections import pandas as pd from draw_charts import draw_waterfall, get_waterfalldata import modelx as mx model = mx.read_model("model") proj = model.OuterProj df = get_waterfalldata( proj, items=['CSM', 'IntAccrCSM', 'AdjCSM_FlufCF', 'TransServices'], length=15, reverseitems=['TransServices']) draw_waterfall(df)
The first line
%matplotlib notebook, is for specifying drawing mode.
The next few lines are import statements, by which functions defined in other modules become avaialbe in this script.
draw_charts modules are in the project directory of this project. To see what fiels are in the project directory, select Open from the File menu in the tool bar above.
%matplotlib notebook import collections import pandas as pd from draw_charts import draw_waterfall, get_waterfalldata
Building the model#
The next line is to create a model from
build function defined in
ifrs17sim module which has just been imported.
load_saved parameter of the
build function, the input data is read from
ifrs17sim.mx, the ‘pickled’ file to save loading time. To read input from
load_saved=False or without any parameter because
False is the default value of
If you run this code multiple time, the previous model is renamed to
ifrs17sim_BAK*, and a new model is created and returned as
import modelx as mx model = mx.read_model("model")
To see what space is inside
model.spaces in an empty cell.
model thre is a space called
OuterProj and other spaces.
OuterProj is parametrized by Policy ID, i.e. each of the spaces with parameters corresponds to a projection of one policy. For example,
model.OuterProj return the projection of policy ID 1,
model.OuterProj return the projection of policy ID 171.
The first line below sets
proj as a shorthand for the projection of Policy ID 1. To see what cells are in
proj.cells in an empty cell.
You can change the sample policy to output by supplying some other ID.
proj = model.OuterProj
Exporting values into DataFrame#
The code below is to construct a DataFrame object for drawing the waterfall chart, from the cells that make up bars in the waterfall chart.
TransServices is passed to
reverseitems parameter, to reverse the sign of its values, as we want to draw is as reduction that pushes down the CSM balance.
df = get_waterfalldata( proj, items=['CSM', 'IntAccrCSM', 'AdjCSM_FlufCF', 'TransServices'], length=15, reverseitems=['TransServices'])
Tha table below show the DataFrame values.
Draw waterfall chart#
The last line is to draw the waterfall graph. The function to draw the graph was imported from the separate module
draw_charts in this project directory, and was imported at the first part of this script.