{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# IFRS17 Simulation (Lapse Scenario)\n", "\n", "If you're viewing this page as a static HTML page on https://lifelib.io, the same contents are also available [here on binder] as Jupyter notebook executable online (it may take a while to load)\n", "\n", "To run this notebook and get all the outputs below, Go to the **Cell** menu above, and then click **Run All**.\n", "\n", "[here on binder]: https://mybinder.org/v2/gh/fumitoh/lifelib/binder?filepath=lifelib%2Fprojects%2Fifrs17sim%2Fifrs17sim_charts_lapsescen.ipynb\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## About this notebook\n", "\n", "This notebook draws several waterfall charts that show how sources of change in IFRS17 accounts emerge when the actual lapse rate changes at a future point in time and future lapse rate assumptions from that point change accordingly for current-estimate liability valuations at future points. \n", "\n", "Those charts are:\n", "* Actual cashflows\n", "* Present value of expected cashflows\n", "* CSM amortization\n", "* IFRS17 Financial performance\n", "\n", "\n", "A notebook for the baseline simulation is also available on [lifelib]. The baseline simulation assumes\n", "that actual cashflow emerge exacltly as esimated at the beginning of simulation.\n", "\n", "[ifrs17sim]: https://lifelib.io/projects/ifrs17sim.html\n", "[lifelib]: https://lifelib.io\n", "\n", "
\n", "\n", "**Warning:**\n", "\n", "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. \n", "At very least, following items are identified as over-simplification or lack of implementation.\n", "\n", "\n", "\n", "
\n", "\n", "[modelx]: http://docs.modelx.io" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How to use Jupyter Notebook\n", "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. 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.\n", "\n", "[this tutorial]: https://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/docs/source/examples/Notebook/Running%20Code.ipynb\n", "\n", "You can play around with this notebook, by changeng input values and formulas, re-running code and checking how output tables and charts change accodingly.\n", "Note that change in code in one cell may change the results of other cells. To reflect change in one cell on the output of other cells, the other cells need to be re-run after the change." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initial set-up\n", "\n", "The first line `%matplotlib notebook`, is for specifying drawing mode.\n", "\n", "The next few lines are import statements, by which functions defined in other modules become avaialbe in this script.\n", "\n", "`ifrs17sim` and `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." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "%matplotlib inline\n", "import pandas as pd\n", "import collections\n", "import matplotlib.pyplot as plt\n", "from lifelib.projects.ifrs17sim.draw_charts import draw_waterfall, get_waterfalldata, draw_actest_pairs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Building the model\n", "\n", "The next line is to create a model from `build` function defined in `ifrs17sim` module which has just been imported. \n", "\n", "By supplying `True` to `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 `input.xlsm`, call `build` with `load_saved=False` or without any parameter because `False` is the default value of `load_saved`. \n", "\n", "If you run this code multiple time, the previous model is renamed to `ifrs17sim_BAK*`, and a new model is created and returned as `model`.\n", "\n", "In `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[1]` return the projection of policy ID 1, `model.OuterProj[171]` return the projection of policy ID 171.\n", "\n", "The first line below sets `proj` as a shorthand for the projection of Policy ID 1. \n", "You can change the sample policy by supplying some other ID." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import modelx as mx\n", "model = mx.read_model(\"model\")\n", "proj = model.OuterProj[1]\n", "inner = proj.InnerProj" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adjusting lapse rates\n", "\n", "By defalut, base lapse rates are read in from the input file. The initial rates are constant at 8%." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.asmp.SurrRate.to_frame(range(6))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this model, adjustments to the base lapse rates can be made through the cells ``SurrRateMult``.\n", "The cells ``SurrRateMult`` in outer and in inner spaces have have different formulas. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the outer actual simulation, as seen in the formula below, ``SurrRateMult`` is set to 1 by default, but can be overwritten by user input. If the user overwrite ``SurrRateMult(t)``, then the new value applies from ``t`` goint forward." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.asmp.SurrRateMult.formula" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the inner projectins, ``SurrRateMult`` is set to the same value as the outer simulation at time 0.\n", "\n", "At each step of outer simulation(``t0``), the lapse rates for the inner projection starting at ``t0``, are set to the lapse rate of the actual(outer) simulation applied in the previos period (from ``t0-1`` to ``t0``)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "inner.asmp.SurrRateMult.formula" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We assumes that the actual lapse rate doubles from time 2, i.e. the beginning of the 3rd year, and continues to be doubled.\n", "Accordingly, we assume we double our lapse rate assumption from the end of the 3rd yer, one year later later than the change in actual lapse. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.asmp.SurrRateMult[1] = 1\n", "proj.asmp.SurrRateMult[2] = 2 # Actual lapse rate from t=2 \n", "\n", "inner[1].asmp.SurrRateMult[1] = 1\n", "inner[2].asmp.SurrRateMult[2] = 1\n", "inner[3].asmp.SurrRateMult[3] = 2 # The lapse assumption for estimated cashflows at t=3 and thereafter " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The figure below shows how underlying poicies change over time. \n", "The 3 columns in the fiture represents 3 cells, and filled lines denote actual(outer) while the dotted lines denote expected(inner). \n", "For each column, rows from the top to the bottom represent the time steps of the outer simulation, stating at time 0.\n", "\n", "The leftmost column is the graph of policies in-force at the end of each period.\n", "The column in the middle shows how ``SurrRateMult`` for actual lapse rate and estimated lapse rates change over time.\n", "``SurrRateMult`` stays at time 0 and 1 (1st and 2nd rows). Then it doubles for the acutal at time 2 (3rd row), while the estimate stays still at 1 for 1 year. Then the estimate catches up the actual at time 3 (4th row).\n", "\n", "The right most column show the movement in terms of the number of surrender policies.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "draw_actest_pairs(proj, inner, ['PolsIF_End', 'SurrRateMult', 'PolsSurr'], 5, 5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Actual cashflows\n", "\n", "The code below generates a waterfall chart that simulates actual insurance cashflows that are assumed to be equal to the expected. The net asset balance is reset to zero at the end of each period, so the assets are equal to the liabilities at the beginning of each period. \n", "The assets are held as cash, and bear interest at the same rate as discount rate." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.IntAccumCF.formula" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "actcf = get_waterfalldata(\n", " proj,\n", " items=['PremIncome',\n", " 'IntAccumCF',\n", " 'ExpsAcqTotal',\n", " 'BenefitTotal',\n", " 'ExpsMaintTotal',\n", " 'ActualNetCF'],\n", " length=4,\n", " reverseitems=['ExpsAcqTotal',\n", " 'BenefitTotal',\n", " 'ExpsMaintTotal'])\n", " \n", "actcf" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "draw_waterfall(actcf, stocks=[0, 5], title='Actual Cashflows')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Present value of expected cashflows\n", "\n", "The code below generate a waterfall chart that shows how the present value of expected insurance cashflows unwinds over time. \n", "\n", "The waterfall bars are disconected at t = 3, because we change the lapse assumption there. The present value of future cashflows decrease due to the decrease in future policies." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "estcf = get_waterfalldata(\n", " proj,\n", " items=['PV_FutureCF',\n", " 'EstPremIncome',\n", " 'EstIntOnCF',\n", " 'EstAcqCashflow',\n", " 'EstClaim',\n", " 'EstExps'],\n", " length=4,\n", " reverseitems=['EstPremIncome'])\n", "\n", "estcf" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "draw_waterfall(estcf, title='Expected Cashflows')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CSM amortization\n", "\n", "The CSM amortization chart below depicts items that increase/decrease CSM balance. \n", "\n", "The adjustment to CSM for changes in fulfilment cashflows (``AdjCSM_FlufCF``) is negative in the 3rd period.\n", "This offsets to a great extent the decrease in ``PV_FutureCF`` in the chart above (or increase in liability, if ``PV_FutureCF`` is negative unlike this sample, which is often the case) \n", "\n", "``AdjCSM_FlufCF`` takes the difference of ``PV_Cashflows`` with different parameters.\n", "\n", "``PV_Cashflow(t+1, t+1, 0)`` starts projection at ``t+1`` into the future using the lapse assumption updated at ``t+1``, and discount the cashflows using the discount rate fixed at time zero, back to time ``t+1``.\n", "\n", "\n", "``PV_Cashflow(t, t+1, 0)`` starts projection at ``t`` into the future using the lapse rate assumption before the change, and discount the cashflows using the discount rate fixed at time zero, back to time ``t+1``.\n", "\n", "The sources of difference between these valuese are the difference in the number of policies in-force, and the difference in future laps rates, which impact projected policies in-force and cashflows from ``t+1``.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.AdjCSM_FlufCF.formula" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "csmrf = get_waterfalldata(\n", " proj, \n", " items=['CSM',\n", " 'IntAccrCSM',\n", " 'AdjCSM_FlufCF',\n", " 'TransServices'],\n", " length=4,\n", " reverseitems=['TransServices'])\n", "\n", "csmrf" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "draw_waterfall(csmrf, title='CSM Amortization')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IFRS17 Financial performance\n", "\n", "The chart below simulates P&L accounts based on IFRS17 from the background data used to draw the charts above. The profit in each period is released and the outstanding net balance (`NetBalance`) is reset to zero.\n", "\n", "The profit in the 3rd period is decreased due to the adverse change in lapse assumption, but its impact on the current profit is limited because of the offset between the change in CSM and the PV of future cashflows." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.InsurRevenue.formula" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "proj.InsurServiceExps.formula" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ifrspl = get_waterfalldata(\n", " proj,\n", " items=['InsurRevenue',\n", " 'InsurServiceExps',\n", " 'InsurFinIncomeExps',\n", " 'ProfitBefTax'],\n", " length=5,\n", " reverseitems=['InsurServiceExps'])\n", "ifrspl" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "draw_waterfall(ifrspl, stocks=[0, 3], title='IFRS17 Profit/Loss')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }