().ToArrayAsync();",
+ "\nifrsVars2.Count()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "# Test"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "ifrsVars1.Except(ifrsVars2, IfrsVariableComparer.Instance()).Count().Should().Be(0);"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ ""
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb b/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb
deleted file mode 100644
index 7016fa12..00000000
--- a/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb
+++ /dev/null
@@ -1,1461 +0,0 @@
-{
- "metadata": {
- "authors": [],
- "kernelspec": {
- "display_name": "Formula Framework",
- "language": "C#",
- "name": "C#"
- },
- "language_info": {
- "file_extension": ".cs",
- "mimetype": "text/plain",
- "name": "C#"
- },
- "toc-autonumbering": "True",
- "toc-showcode": "False"
- },
- "nbformat": 4,
- "nbformat_minor": 5,
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- " Financial Performance Specifications
"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The aim of this notebook is to document the Financial Performance reporting system. The process is pictorially explained in the following flowchart. ",
- "\n",
- "\n",
- "\n
",
- "\n",
- "\nThroughout this notebook we adopt the following variable notation: we use the words *computed* vs. *expected* to differentiate the results provided by the application vs. this test notebook, respectively."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the following the Dimensions, Parameters, Nominal Cashflows, and Actuals are imported from the corresponding csv files in Initialization/Systemorph/"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!eval-notebook \"../Initialization/InitSystemorphToMemory\""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "# Process Data"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Current Period, Reporting Node and Currency Type"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Please select the target period (i.e. year and month) and Reporting Node based on the imported data:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var year = 2021 ;",
- "\nvar month = 3 ;",
- "\nvar reportingNode = \"CH\" ;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "and the type of Currency among Contractual, Functional, and Group"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var currencyType = CurrencyType.Functional ;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Import the Report definitions, initialize the Workspace and the Test Suite:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Workspace.InitializeFrom(DataSource);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var period = (year, month) ;",
- "\nvar reportStorage = new ReportStorage(Workspace, Report) ;",
- "\nvar Test = Scopes.ForSingleton().WithStorage(reportStorage).ToScope();"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "await reportStorage.InitializeReportIndependentCacheAsync();",
- "\nawait reportStorage.InitializeAsync(period, reportingNode, null, currencyType);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## View list of Identities"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Based on the Cashflows imported, the list of all possible identities, i.e. combinations of valid Contractual and Functional Currencies, Liability Types, (Re)Insurance and Oci, is contructed and reported here below:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var identities = reportStorage.GetIdentities(period, reportingNode, null, currencyType);",
- "\nidentities"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Report"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Please select here below the target Data Node for executing the tests below:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var dataNode = \"DT1.1\";"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Group of Contract selected is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var groupOfContract = (await Workspace.Query().Where(x => x.SystemName == dataNode).ToArrayAsync()).FirstOrDefault();",
- "\ngroupOfContract"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "where ",
- "\n- the **OciType** can be Default for contracts with non-zero OCI, and null otherwise, ",
- "\n- the **Liability Type** can be LRC for Liability for Remaining Coverage, and LIC for Liability of Incurred Claims,",
- "\n- the **Partner** can be null for Insurance contracts, or equal to the Partner System Name for Reinsurance contracts."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The summary of the Financial Performance report is shown below"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Report.ForDataCube( Test.GetScopes(identities).Aggregate().FinancialPerformance.Filter((\"GroupOfContract\", dataNode)) )",
- "\n .WithQuerySource(DataSource)",
- "\n .SliceRowsBy(\"VariableType\", \"EstimateType\")",
- "\n .SliceColumnsBy(CurrencyGrouper(currencyType), \"LiabilityType\",\"GroupOfContract\")",
- "\n .WithGridOptions( o => o.WithDefaultColumn( c => c.WithWidth(260) ) with {GroupDefaultExpanded = 3, Height = 900, OnGridReady = null} )",
- "\n .ToReport()"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Inspection"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Fulfillment Cashflows"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Fulfillment Cashflow (FCF) corresponds to the sum of the Best Estimate [Present Value](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation#current-and-locked) (PV) and the [Risk Adjustment](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation#risk-adjustment) (RA), both summed over Amounty Types, and both discounted with the Locked-In curve in the BBA valuation approach:",
- "\n",
- "\n$$",
- "\n\\text{FCF}(\\text{AoC}) = \\text{PV Locked}(\\text{AoC})",
- "\n\\bigg|_{\\substack{\\text{Non Attributable} \\\\ \\text{Amount Types} \\\\ \\text{excluded}}} ",
- "\n+ \\text{RA Locked}(\\text{AoC}) ~.",
- "\n$$"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Non Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the non financial contribution to the FCF is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaFCF_nonFinancial = Test.GetScopes(identities).Aggregate()",
- "\n .FpNonFinancial.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaFCF_nonFinancial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the full list of FCFs"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var FCFs = Test.GetScopes(identities).Aggregate().Fcf.Filter((\"GroupOfContract\", dataNode));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deltaFCF = FCFs.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +",
- "\n FCFs.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "deltaFCF.Aggregate().Value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaFCF_nonFinancial = deltaFCF.Filter((\"VariableType\", \"!IA\"), ",
- "\n (\"VariableType\", \"!YCU\"), ",
- "\n (\"VariableType\", \"!CRU\"), ",
- "\n (\"VariableType\", \"!FX\") ).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_nonFinancial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "For consistency, this term is taken with the minus sign"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_nonFinancial.CheckEquality( -computedDeltaFCF_nonFinancial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Conversely, the computed value for the financial contribution to the Fulfillment Cashflows (FCF) is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaFCF_Financial = Test.GetScopes(identities).Aggregate()",
- "\n .FpFinancial.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaFCF_Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The independent recalculation of this value reads"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaFCF_Financial = (deltaFCF.Filter((\"VariableType\", \"IA\")) +",
- "\n deltaFCF.Filter((\"VariableType\", \"YCU\")) +",
- "\n deltaFCF.Filter((\"VariableType\", \"CRU\")) ).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "taking the minus sign into account"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_Financial.CheckEquality( -computedDeltaFCF_Financial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### FX"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the FX contribution to the Fulfillment Cashflows (FCF) is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaFCF_Fx = Test.GetScopes(identities).Aggregate()",
- "\n .FpFx.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaFCF_Fx"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The independent recalculation of this value reads"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaFCF_Fx = deltaFCF.Filter((\"VariableType\", \"FX\")).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_Fx"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "taking the minus sign into account"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_Fx.CheckEquality( -computedDeltaFCF_Fx ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n### Other Comprehensive Income"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Other Comprehensive Income (OCI) term is by definition the sum of the financial contributions not related to the insurance sector.",
- "\n",
- "\nThe Default method to compute the OCI term is by subtracting the FCF computed with the *Locked-In* rates and the FCF computed with the *Current* rates. In this way the non insurance financial volatiliy of the economic input is relegated to the OCI. "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaFCF_OCI = Test.GetScopes(identities).Aggregate()",
- "\n .OciFinancial.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaFCF_OCI"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The OCI contribution is zero when the OCI option is disabled for the [target Group of Contract](#report).",
- "\n",
- "\nHere below we follow the steps to calculate independently the OCI contribution "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var DeltaFCF_Locked = deltaFCF.Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var FCFs_current = Test.GetScopes(identities).Aggregate().CurrentFcf.Filter((\"GroupOfContract\", dataNode));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var DeltaFCF_Current = FCFs_current.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +",
- "\n FCFs_current.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaFCF_OCI = DeltaFCF_Locked - DeltaFCF_Current.Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "DeltaFCF_Locked"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "DeltaFCF_Current.Aggregate().Value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_OCI"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaFCF_OCI.CheckEquality( computedDeltaFCF_OCI ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### FX Other Comprehensive Income"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The FX impact on the Other Comprehensive Income is calculated using the same formulas defined [above](#oci) but is presented separately in the Financial Performance.",
- "\n",
- "\nThe computed value for the FX contribution to the Other Comprehensive Income (OCI) is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedFxFCF_OCI = Test.GetScopes(identities).Aggregate()",
- "\n .OciFx.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedFxFCF_OCI"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The OCI contribution is zero when the OCI option is disabled for the [target Group of Contract](#report).",
- "\n",
- "\nHere below we follow the steps to calculate independently the FX OCI contribution "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var FxFCF_Locked = deltaFCF.Filter((\"VariableType\", AocTypes.FX)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var FxFCF_Current = FCFs_current.Filter((\"VariableType\", AocTypes.FX)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedFxFCF_OCI = FxFCF_Locked - FxFCF_Current;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "FxFCF_Locked"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "FxFCF_Current"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedFxFCF_OCI"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedFxFCF_OCI.CheckEquality( computedFxFCF_OCI ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Contractual Service Margin"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Non Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the non financial change of the CSM is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaCSM_nonFinancial = Test.GetScopes(identities).Aggregate()",
- "\n .NonFinancialChanges.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaCSM_nonFinancial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the full CSM data from which the delta can be computed:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var CSM = Test.GetScopes(identities).Aggregate().Csm.Filter((\"GroupOfContract\", dataNode));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deltaCSM = CSM.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +",
- "\n CSM.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "deltaCSM.Aggregate().Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The non Financial contribution is calculated subtracting the Amortization and the Interest Accretion terms:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaCSM_nonFinancial = deltaCSM.Filter((\"VariableType\", \"!AM\"), (\"VariableType\", \"!IA\"), (\"VariableType\", \"!YCU\"), (\"VariableType\", \"!CRU\"), (\"VariableType\", \"!FX\")).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaCSM_nonFinancial"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaCSM_nonFinancial.CheckEquality( -computedDeltaCSM_nonFinancial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Conversely, the computed value for the financial change of the CSM is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaCSM_Financial = Test.GetScopes(identities).Aggregate()",
- "\n .FinancialChanges.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaCSM_Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the $\\Delta\\text{CSM}$, and considering only Interest Accretion, Yield Curve Update and Credit Risk Update terms"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaCSM_Financial = ( deltaCSM.Filter((\"VariableType\", \"IA\")) +",
- "\n deltaCSM.Filter((\"VariableType\", \"YCU\")) +",
- "\n deltaCSM.Filter((\"VariableType\", \"CRU\")) )",
- "\n .Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaCSM_Financial"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaCSM_Financial.CheckEquality( -computedDeltaCSM_Financial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### FX"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the FX change of the CSM is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaCSM_Fx = Test.GetScopes(identities).Aggregate()",
- "\n .Fx.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaCSM_Fx"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the $\\Delta\\text{CSM}$, and considering only the FX term"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaCSM_Fx = deltaCSM.Filter((\"VariableType\", AocTypes.FX)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaCSM_Fx"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaCSM_Fx.CheckEquality( -computedDeltaCSM_Fx ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Loss Component"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Non Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the non financial change of the LC is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaLC_nonFinancial = Test.GetScopes(identities).Aggregate()",
- "\n .NonFinancialChanges.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaLC_nonFinancial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the full CSM data from which the delta can be computed:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var LC = Test.GetScopes(identities).Aggregate().Lc.Filter((\"GroupOfContract\", dataNode));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deltaLC = LC.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +",
- "\n LC.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "deltaLC.Aggregate().Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The non Financial contribution is calculated subtracting the Amortization, Interest Accretion, Yield Curve Update, Credit Risk Update, Fx terms:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLC_nonFinancial = deltaLC.Filter((\"VariableType\", \"!AM\"), (\"VariableType\", \"!IA\"), (\"VariableType\", \"!YCU\"), (\"VariableType\", \"!CRU\"), (\"VariableType\", \"!FX\")).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLC_nonFinancial"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLC_nonFinancial.CheckEquality( -computedDeltaLC_nonFinancial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Conversely, the computed value for the financial change of the LC is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaLC_Financial = Test.GetScopes(identities).Aggregate()",
- "\n .FinancialChanges.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaLC_Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the $\\Delta\\text{LC}$, and considering only the Interest Accretion, Yield Curve Update, Credit Risk Update terms"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLC_Financial = ( deltaLC.Filter((\"VariableType\", \"IA\")) +",
- "\n deltaLC.Filter((\"VariableType\", \"YCU\")) +",
- "\n deltaLC.Filter((\"VariableType\", \"CRU\")) )",
- "\n .Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLC_Financial"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLC_Financial.CheckEquality( -computedDeltaLC_Financial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### FX"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the FX change of the LC is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaLC_Fx = Test.GetScopes(identities).Aggregate()",
- "\n .Fx.Filter((\"GroupOfContract\", dataNode)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaLC_Fx"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the $\\Delta\\text{LC}$, and considering only the FX term"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLC_Fx = deltaLC.Filter((\"VariableType\", AocTypes.FX)).Aggregate().Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLC_Fx"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLC_Fx.CheckEquality( -computedDeltaLC_Fx ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Loss Recovery Component"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Non Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "If the [target Group of Contract](#report) is not of type Re-Insurance, the result of the following will return null.",
- "\n",
- "\nThe computed value for the non financial change of the LoReCo is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaLORECO_nonFinancial = Test.GetScopes(identities).Aggregate()",
- "\n .NonFinancialChanges.Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaLORECO_nonFinancial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the full LoReCo data from which the delta can be computed:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var LORECO = Test.GetScopes(identities).Aggregate().Loreco.Filter((\"GroupOfContract\", dataNode));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deltaLORECO = LORECO.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +",
- "\n LORECO.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "deltaLORECO.Aggregate()?.Value?? 0"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The non Financial contribution is calculated subtracting the Amortization and the Interest Accretion terms:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLORECO_nonFinancial = deltaLORECO.Filter((\"VariableType\", \"!AM\"), (\"VariableType\", \"!IA\"), (\"VariableType\", \"!YCU\"), (\"VariableType\", \"!CRU\"), (\"VariableType\", \"!FX\")).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLORECO_nonFinancial"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLORECO_nonFinancial.CheckEquality( -computedDeltaLORECO_nonFinancial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Conversely, the computed value for the financial change of the LoReCo is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaLORECO_Financial = Test.GetScopes(identities).Aggregate()",
- "\n .FinancialChanges.Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaLORECO_Financial"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the $\\Delta\\text{LoReCo}$, and considering only the Interest Accretion, Yield Curve Update, Credit Risk Update terms"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLORECO_Financial = ( deltaLORECO.Filter((\"VariableType\", \"IA\")) +",
- "\n deltaLORECO.Filter((\"VariableType\", \"YCU\")) +",
- "\n deltaLORECO.Filter((\"VariableType\", \"CRU\")) )",
- "\n .Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLORECO_Financial"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLORECO_Financial.CheckEquality( -computedDeltaLORECO_Financial ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### FX"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value for the FX change of the LoReCo is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeltaLORECO_Fx = Test.GetScopes(identities).Aggregate()",
- "\n .Fx.Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeltaLORECO_Fx"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This value can be independently computed starting from the $\\Delta\\text{LoReCo}$, and considering only the FX term"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLORECO_Fx = deltaLORECO.Filter((\"VariableType\", AocTypes.FX)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLORECO_Fx"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDeltaLORECO_Fx.CheckEquality( -computedDeltaLORECO_Fx ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Reconciliation"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Based on the results calculated in Section 3, we check here the consistency of the [Financial Performance Report](#report). ",
- "\n",
- "\nFiner granular reconciliations can be performed by following the datails of how each report contributes to the Financial Performance Report. Please, refer to the [Report documentation](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#financial-performance) for all the details. "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Insurance Revenue"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Insurance Revenue (IR) contributions vary from Insurance to Re-Insurance and depend on the Liability Type of the [target Group of Contract](#report). This can be summarized by the formulas below",
- "\n",
- "\n$$",
- "\n\\text{IR} = \\left\\{ ",
- "\n\\begin{array}{ll}",
- "\n\\Delta\\text{FCF Gross Non Financial} + \\Delta\\text{CSM Non Financial} + \\Delta\\text{CSM Release} \\\\",
- "\n+ \\text{Incurred Incoming Cashflows} + \\text{Claims ICO} + \\text{Incurred Deferrals} \\\\",
- "\n+ \\text{Exc. Experience Adjustment on Premiums} ~~,",
- "\n& \\text{for LRC Insurance contracts} \\\\[0.2cm]",
- "\n\\Delta\\text{CSM Non Financial} + \\Delta\\text{CSM Release} \\\\",
- "\n+ \\text{Incurred Incoming Cashflows} + \\text{Claims ICO} + \\text{Incurred Deferrals} ~~,",
- "\n& \\text{for LIC Insurance contracts} \\\\[0.2cm]",
- "\n\\text{Claims ICO} + \\text{Incurred Deferrals} ~~,",
- "\n& \\text{for Re-Insurance contracts}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nHere below we recompute the IR term:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaCSM_release = deltaCSM.Filter((\"VariableType\", \"AM\")).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredIncomingCashflows = Test.GetScopes(identities).Aggregate().Premiums",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredDeferralsIr = Test.GetScopes(identities).Aggregate().AmortizationToIr",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedClaimsICO = Test.GetScopes(identities).Aggregate().ClaimsIcoToIr",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedExcExperienceAdjPremiums = Test.GetScopes(identities).Aggregate().ExperienceAdjustmentOnPremium",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "double IR = 0;",
- "\nif(groupOfContract.Partner == null && groupOfContract.LiabilityType == \"LRC\")",
- "\n IR = - expectedDeltaFCF_nonFinancial ",
- "\n - expectedDeltaCSM_nonFinancial ",
- "\n - expectedDeltaCSM_release ",
- "\n + expectedIncurredIncomingCashflows",
- "\n + expectedClaimsICO",
- "\n + expectedIncurredDeferralsIr",
- "\n + expectedExcExperienceAdjPremiums;",
- "\nelse if(groupOfContract.Partner == null && groupOfContract.LiabilityType == \"LIC\")",
- "\n IR = - expectedDeltaCSM_nonFinancial",
- "\n - expectedDeltaCSM_release",
- "\n + expectedIncurredIncomingCashflows",
- "\n + expectedClaimsICO",
- "\n + expectedIncurredDeferralsIr ",
- "\n + expectedExcExperienceAdjPremiums;",
- "\nelse if(groupOfContract.Partner != null)",
- "\n IR = + expectedClaimsICO",
- "\n + expectedIncurredDeferralsIr",
- "\n + expectedExcExperienceAdjPremiums;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "IR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Insurance Service Expenses"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Analogously, the Insurance Service Expenses (ISE) read",
- "\n",
- "\n$$",
- "\n\\text{ISE} = \\left\\{ ",
- "\n\\begin{array}{ll}",
- "\n\\Delta\\text{LC Non Financial}",
- "\n+ \\Delta\\text{LC Release}",
- "\n+ \\text{Incurred ClaimsNIC} \\\\",
- "\n+ \\text{Incurred Expenses}",
- "\n+ \\text{Incurred Commissions}",
- "\n+ \\text{Incurred Deferrals}",
- "\n& \\text{for LRC Insurance contracts} \\\\[0.2cm]",
- "\n\\Delta\\text{FCF Reinsurance Non Financial}",
- "\n+ \\Delta\\text{LC Non Financial}",
- "\n+ \\Delta\\text{LC Release}",
- "\n+ \\text{Incurred ClaimsNIC} \\\\",
- "\n+ \\text{Incurred Expenses} ",
- "\n+ \\text{Incurred Commissions}",
- "\n+ \\text{Incurred Deferrals}",
- "\n& \\text{for LIC Insurance contracts} \\\\[0.2cm]",
- "\n\\Delta\\text{FCF Reinsurance Non Financial} ",
- "\n+ \\Delta\\text{CSM Non Financial} ",
- "\n+ \\Delta\\text{CSM Release} \\\\",
- "\n+ \\Delta\\text{LC Non Financial} ",
- "\n+ \\Delta\\text{LC Release} ",
- "\n+ \\Delta\\text{LoReCo Non Financial} \\\\",
- "\n+ \\text{Incurred Incoming Cashflows} ",
- "\n+ \\text{Incurred ClaimsNIC} ",
- "\n+ \\text{Incurred Expenses} \\\\",
- "\n+ \\text{Incurred Commissions}",
- "\n+ \\text{Incurred Deferrals}",
- "\n& \\text{for Re-Insurance contracts}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nHere below we recompute the ISE term:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLC_release = deltaLC.Filter((\"VariableType\", \"AM\")).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeltaLoReCo_release = deltaLORECO.Filter((\"VariableType\", \"AM\")).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredClaimsNIC = Test.GetScopes(identities).Aggregate().ClaimsNic",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredExpenses = Test.GetScopes(identities).Aggregate().Expenses",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredCommissions = Test.GetScopes(identities).Aggregate().Commissions",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredClaimsICO = Test.GetScopes(identities).Aggregate().ClaimsIcoToIse",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedIncurredDeferralsIse = Test.GetScopes(identities).Aggregate().AmortizationToIse",
- "\n .Filter((\"GroupOfContract\", dataNode)).Aggregate()?.Value?? 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "double ISE = 0;",
- "\nif(groupOfContract.Partner == null && groupOfContract.LiabilityType == \"LRC\")",
- "\n ISE = - expectedDeltaLC_nonFinancial ",
- "\n - expectedDeltaLC_release",
- "\n + expectedIncurredClaimsNIC ",
- "\n + expectedIncurredExpenses ",
- "\n + expectedIncurredClaimsICO",
- "\n + expectedIncurredCommissions",
- "\n + expectedIncurredDeferralsIse;",
- "\nelse if(groupOfContract.Partner == null && groupOfContract.LiabilityType == \"LIC\")",
- "\n ISE = - expectedDeltaFCF_nonFinancial",
- "\n - expectedDeltaLC_nonFinancial ",
- "\n - expectedDeltaLC_release",
- "\n + expectedIncurredClaimsNIC ",
- "\n + expectedIncurredExpenses ",
- "\n + expectedIncurredClaimsICO",
- "\n + expectedIncurredCommissions",
- "\n + expectedIncurredDeferralsIse;",
- "\nelse if(groupOfContract.Partner != null)",
- "\n ISE = - expectedDeltaFCF_nonFinancial",
- "\n - expectedDeltaCSM_nonFinancial",
- "\n - expectedDeltaCSM_release",
- "\n - expectedDeltaLC_nonFinancial ",
- "\n - expectedDeltaLC_release",
- "\n - expectedDeltaLoReCo_release",
- "\n + expectedIncurredIncomingCashflows",
- "\n + expectedIncurredClaimsNIC ",
- "\n + expectedIncurredExpenses ",
- "\n + expectedIncurredClaimsICO",
- "\n + expectedIncurredCommissions",
- "\n + expectedIncurredDeferralsIse;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "ISE"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Insurance Finance Income/Expenses"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Financial part associated to the Insurance business encompassing both the Income and Expenses is denoted IFIE from the initials marked in capital letters. The ",
- "\n",
- "\n$$",
- "\n\\text{IFIE} = \\left\\{",
- "\n\\begin{array}{ll}",
- "\n\\Delta\\text{FCF Financial} + \\Delta\\text{CSM Financial} + \\Delta\\text{LC Financial} + \\Delta\\text{FCF FX} + \\Delta\\text{CSM FX} + \\Delta\\text{LC FX} ~~,",
- "\n& \\text{for Insurance contracts} \\\\[0.2cm]",
- "\n\\Delta\\text{FCF Financial} + \\Delta\\text{CSM Financial} + \\Delta\\text{LC Financial} ",
- "\n+ \\Delta\\text{LoReCo Financial} + \\Delta\\text{FCF FX} + \\Delta\\text{CSM FX} + \\Delta\\text{LC FX} ",
- "\n+ \\Delta\\text{LoReCo FX} ~~, ",
- "\n& \\text{for Re-Insurance contracts}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nHere below we recompute the IFIE term:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "double IFIE = 0;",
- "\nif(groupOfContract.Partner == null) ",
- "\n IFIE = - expectedDeltaFCF_Financial ",
- "\n - expectedDeltaCSM_Financial",
- "\n - expectedDeltaLC_Financial",
- "\n - expectedDeltaFCF_Fx ",
- "\n - expectedDeltaCSM_Fx",
- "\n - expectedDeltaLC_Fx;",
- "\nelse",
- "\n IFIE = - expectedDeltaFCF_Financial ",
- "\n - expectedDeltaCSM_Financial",
- "\n - expectedDeltaLC_Financial",
- "\n - expectedDeltaLORECO_Financial",
- "\n - expectedDeltaFCF_Fx ",
- "\n - expectedDeltaCSM_Fx",
- "\n - expectedDeltaLC_Fx",
- "\n - expectedDeltaLORECO_Fx;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "IFIE"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Other Comprehensive Income"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Other Comprehensive Income (OCI) can be non-zero only when the OCI is enabled for [target Group of Contract](#report), that is, Oci Type = Default.",
- "\n",
- "\n$$",
- "\n\\text{OCI} = \\Delta\\text{FCF} \\big|_{\\text{Locked-in}} - \\Delta\\text{FCF} \\big|_{\\text{Current}} ~~.",
- "\n$$",
- "\n",
- "\nHere below we recompute the OCI term:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var OCI = expectedDeltaFCF_OCI + expectedFxFCF_OCI;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "OCI"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- ""
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/full-ifrs17-template/Test/SpecificationsImportActuals.ipynb b/full-ifrs17-template/Test/SpecificationsImportActuals.ipynb
deleted file mode 100644
index 8993aa5c..00000000
--- a/full-ifrs17-template/Test/SpecificationsImportActuals.ipynb
+++ /dev/null
@@ -1,507 +0,0 @@
-{
- "metadata": {
- "authors": [],
- "kernelspec": {
- "display_name": "Formula Framework",
- "language": "C#",
- "name": "C#"
- },
- "language_info": {
- "file_extension": ".cs",
- "mimetype": "text/plain",
- "name": "C#"
- },
- "toc-autonumbering": "True",
- "toc-showcode": "False"
- },
- "nbformat": 4,
- "nbformat_minor": 5,
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- " Import Actuals Specifications
"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The aim of this notebook is to document the calculations taking place when importing the Actuals. For this documentation notebook the Data is imported from the corresponding csv files located in the following path Initialization/Systemorph/. The process is pictorially explained in the following flowchart. ",
- "\n",
- "\n",
- "\n
",
- "\n",
- "\nThroughout this notebook we adopt the following variable notation: we use the words *computed* vs. *expected* to differentiate the results provided by the application vs. this test notebook, respectively."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "# Import Data"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Current Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Please select the target period (i.e. year and month), Reporting Node, Economic Basis, and Data Node based on the imported data:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var year = 2021 ;",
- "\nvar month = 3 ;",
- "\nvar reportingNode = \"CH\" ;",
- "\nvar economicBasis = \"L\" ;",
- "\nvar dataNode = \"DT1.1\";"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Import the Dimensions, Yield Curves and Nominal Cashflows from the corresponding csv files in Initialization/Systemorph/"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!eval-notebook \"../Initialization/InitSystemorphToMemory\""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "[Setup IFRS17 Calculation Engine](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation):"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!import \"SpecificationsSetup\""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Initialization of the Test Suite: the data loaded from csv files are ready to be used by the Scopes for the calculations"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var Test = await StartCalculatorAsync(reportingNode, year, month, economicBasis, Periodicity.Quarterly, ImportFormats.Actual);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## View imported Actuals"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here the imported Actuals from csv are visualized "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetIfrsVariables(dataNode)",
- "\n .Where(x => new string[] {EstimateTypes.A, EstimateTypes.AA, EstimateTypes.OA}.Contains(x.EstimateType))",
- "\n .Where(x => x.AocType != \"EOP\")"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "where the filter is selecting only those *estimate types* associated to the imported Actuals, hence excluding the IFRS variables calculated when [importing the cashflows](SpecificationsImportCashflows)."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Base Actuals"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The following simplified AoC Chain applies for Advance and Overdue Actuals:",
- "\n1. Beginning of Period (BOP)",
- "\n2. Cash flow (CF)",
- "\n3. Amortization (AM) ",
- "\n4. End of Period (EOP) ",
- "\n",
- "\nWe consider 4 types of Actual values, which are distinguished through their [Estimate Type](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#estimate-type):",
- "\n- Actuals (A)",
- "\n- Advance Actuals (AA)",
- "\n- Overdue Actuals (OA)",
- "\n- Deferrable Actuals (DA)",
- "\n",
- "\nwith the Estimate Type's system name shown between parenthesis above.",
- "\nThey are computed by the so-called Actual Base **Scope**",
- "\n",
- "\n$$",
- "\n\\text{Actual Base} (\\text{AoC}) = \\left\\{",
- "\n\\begin{array}{cl}",
- "\n0 & \\text{if AoC step is AM,} \\\\",
- "\n\\text{Actual Base}(\\rm{BOP}) + \\text{Actual Base}(\\rm{CF}) + \\text{Actual Base}(\\rm{WO}) & \\text{if AoC step is EOP and Estimate Type is not A,} \\\\",
- "\n\\text{Imported Actual} & \\text{otherwise.}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nWe start by selecting one of the [imported Actual](#view-imported-actuals) and we pick up an available data node, novelty, and amount type. Then, we can retrieve the corresponding actual (if any) with AoC type BOP, R, and WO. ",
- "\n",
- "\nNote that the **Identity** for Actual Base contains information about the target data node, AoC type, novelty, amount type and estimate type."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## End of Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The imported actuals for the AoC steps BOP, CF, and WO are:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var actualBaseBOP = Test.GetScope( (new ImportIdentity {DataNode = \"DT1.1\", AocType = \"BOP\", Novelty = \"I\" }, \"PR\", \"AA\", (int?)null) ); ",
- "\nactualBaseBOP"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var actualBaseCF = Test.GetScope( (new ImportIdentity {DataNode = \"DT1.1\", AocType = \"CF\", Novelty = \"C\" }, \"PR\", \"AA\", (int?)null) );",
- "\nactualBaseCF"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var actualBaseWO = Test.GetScope( (new ImportIdentity {DataNode = \"DT1.1\", AocType = \"WO\", Novelty = \"C\" }, \"PR\", \"AA\", (int?)null) ); ",
- "\nactualBaseWO"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Based on the imported actuals and according to the [formula above](#base-actual), the computed actual for AoC step EOP reads"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedActualBaseEOP = Test.GetScope( (new ImportIdentity {DataNode = \"DT1.1\", AocType = \"EOP\", Novelty = \"C\" }, \"PR\", \"AA\", (int?)null) ); ",
- "\ncomputedActualBaseEOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed value can be compared with the expected value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedActualBaseEOP.Value == actualBaseBOP.Value + actualBaseCF.Value + actualBaseWO.Value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedActualBaseEOP.Value.Should().Be( actualBaseBOP.Value + actualBaseCF.Value + actualBaseWO.Value );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Deferrable Actuals"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Deferrable Actuals (DA) are computed as follows",
- "\n",
- "\n$$",
- "\n\\text{Deferrable Actual} (\\text{AoC}) = \\left\\{",
- "\n\\begin{array}{cl}",
- "\n\\text{Actual Base}_{\\substack{\\text{Estimate Type}=\\text{A} \\\\ \\text{Amount Type}=\\text{ACA}}} (\\text{CF})",
- "\n +\\text{Actual Base}_{\\substack{\\text{Estimate Type}=\\text{A} \\\\ \\text{Amount Type}=\\text{AEA}}} (\\text{CF}) & \\text{if AoC step is CF } \\\\",
- "\n-\\text{AMF} \\cdot \\big( \\text{Deferrable Actual}(\\rm{BOP}) + \\text{Deferrable Actual}(\\rm{CF}) \\big) & \\text{if AoC step is AM } \\\\",
- "\n\\text{Deferrable Actual}(\\rm{BOP}) + \\text{Deferrable Actual}(\\rm{CF}) + \\text{Deferrable Actual}(\\rm{AM}) & \\text{if AoC step is EOP } \\\\",
- "\n\\text{Input Actual}_{\\text{Estimate Type}=\\text{DA}} (\\text{BOP}) & \\text{if AoC step is BOP } \\\\",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nwhere ACA and AEA are *Aquisition* Amount Types from *Attributable Commission* and *Attributable Expenses*, respectively.",
- "\n",
- "\nNote that the **Identity** of Deferrable Actual is encompassing solely data node, Aoc type, and novelty."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Beginning of Period"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeferrableActualBOP = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"BOP\", Novelty = \"I\" } );",
- "\ncomputedDeferrableActualBOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The deferrable Actual for the AoC step being BOP is simply the EOP Actual of the previous period. In fact, if the latter exists among the [imported Actuals](#view-imported-actuals), it is reported here below as the BOP of the current period:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeferrableActualBOP = Test.GetStorage().GetValue(new ImportIdentity {DataNode = \"DT1.1\", AocType = \"BOP\", Novelty = \"I\" }, (string)null, EstimateTypes.DA, (int?)null);",
- "\nexpectedDeferrableActualBOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected value is compared with the computed result: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualBOP.Value == expectedDeferrableActualBOP"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualBOP.Value.Should().Be(expectedDeferrableActualBOP);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Cash flow"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeferrableActualCF = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"CF\", Novelty = \"C\" } );",
- "\ncomputedDeferrableActualCF"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The deferrable Actual for the AoC step being CF is the sum of the base Actuals with Amount Type ACA and AEA:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var actualBaseAEA = Test.GetScope( (new ImportIdentity {DataNode = \"DT1.1\", AocType = \"CF\", Novelty = \"C\" }, \"AEA\", \"A\", (int?)null) );",
- "\nactualBaseAEA"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var actualBaseACA = Test.GetScope( (new ImportIdentity {DataNode = \"DT1.1\", AocType = \"CF\", Novelty = \"C\" }, \"ACA\", \"A\", (int?)null) );",
- "\nactualBaseACA"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeferrableActualCF = actualBaseAEA.Value + actualBaseACA.Value;",
- "\nexpectedDeferrableActualCF"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected value is compared with the computed result: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualCF.Value == expectedDeferrableActualCF"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualCF.Value.Should().Be(expectedDeferrableActualCF);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Amortization"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeferrableActualAM = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"AM\", Novelty = \"C\" } );",
- "\ncomputedDeferrableActualAM"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The deferrable Actual for the AoC step being AM is the sum of the deferrable Actuals for AoC step BOP and CF multiplied by the current period amortization factor:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var currentPeriodAmortizationFactor = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"AM\", Novelty = \"C\" } );",
- "\ncurrentPeriodAmortizationFactor"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetValue(new ImportIdentity {DataNode = \"DT1.1\", AocType = \"AM\", Novelty = \"C\" }, (string)null, \"F\", \"L\", (int?)null)"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeferrableActualAM = -currentPeriodAmortizationFactor.Value * (expectedDeferrableActualBOP + expectedDeferrableActualCF);",
- "\nexpectedDeferrableActualAM"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected value is compared with the computed result: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualAM.Value == expectedDeferrableActualAM"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualAM.Value.Should().Be( expectedDeferrableActualAM );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## End of Period"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDeferrableActualEOP = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"EOP\", Novelty = \"C\" } );",
- "\ncomputedDeferrableActualEOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The deferrable Actual for the AoC step being EOP is the sum of the deferrable Actuals for AoC step BOP, CF, and AM:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deferrableActualBOP = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"BOP\", Novelty = \"I\" } );",
- "\ndeferrableActualBOP"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deferrableActualCF = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"CF\", Novelty = \"C\" } );",
- "\ndeferrableActualCF"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var deferrableActualAM = Test.GetScope( new ImportIdentity {DataNode = \"DT1.1\", AocType = \"AM\", Novelty = \"C\" } );",
- "\ndeferrableActualAM"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDeferrableActualEOP = deferrableActualBOP.Value + deferrableActualCF.Value + deferrableActualAM.Value;",
- "\nexpectedDeferrableActualEOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected value is compared with the computed result: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualEOP.Value == expectedDeferrableActualEOP"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDeferrableActualEOP.Value.Should().Be(expectedDeferrableActualEOP);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- ""
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb b/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb
deleted file mode 100644
index d75b5206..00000000
--- a/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb
+++ /dev/null
@@ -1,1996 +0,0 @@
-{
- "metadata": {
- "authors": [],
- "kernelspec": {
- "display_name": "Formula Framework",
- "language": "C#",
- "name": "C#"
- },
- "language_info": {
- "file_extension": ".cs",
- "mimetype": "text/plain",
- "name": "C#"
- },
- "toc-autonumbering": "True",
- "toc-showcode": "False",
- "toc-showmarkdowntxt": "False",
- "toc-showtags": "False"
- },
- "nbformat": 4,
- "nbformat_minor": 5,
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- " Import Cashflows Specifications
"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The aim of this notebook is to document the calculation of the Present Values and Amortization Factors starting from the nominal Cashflows and the Yearly Yield Curve. These starting data is imported from the corresponding csv files located in the following path Initialization/Systemorph/. The process is pictorially explained in the following flowchart. ",
- "\n",
- "\n",
- "\n
",
- "\n",
- "\nThroughout this notebook we adopt the following variable notation: we use the words *computed* vs. *expected* to differentiate the results provided by the application vs. this test notebook, respectively."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "# Import Data"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Current Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Please select the target period (i.e. year and month), Reporting Node, Economic Basis, and Data Node based on the imported data:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var year = 2021 ;",
- "\nvar month = 3 ;",
- "\nvar reportingNode = \"CH\" ;",
- "\nvar economicBasis = \"C\" ;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Import the Dimensions, Yield Curves and Nominal Cashflows from the corresponding csv files in Initialization/Systemorph/"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\""
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Workspace.InitializeFrom(DataSource);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "[Setup IFRS17 Calculation Engine](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation):"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!import \"SpecificationsSetup\""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "At this point reference data are loaded. Import now a cashfow file with a 720 elements."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var groupOfContract = \"GricComplex\";",
- "\nawait Import.FromFile(\"Data/CashflowComplex.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Initialization of the Test suite: the data loaded from csv files are ready to be used by the Scopes for the calculations"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var Test = await StartCalculatorAsync(reportingNode, year, month, economicBasis, Periodicity.Quarterly, ImportFormats.Cashflow);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## View loaded Data Nodes"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The imported active Data Nodes from Initialization/Systemorph/DataNodes.csv are "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().DataNodeDataBySystemName"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## View loaded Yearly Yield Curve"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here the correct Yield Curve is chosen among those imported from Initialization/Systemorph/Data.csv according to the [current period](#year-and-period) and the Aoc Step according the [Aoc Configuration](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#aoc-configuration). In the following we retrieve the desired identity."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var aocType = \"CL\";",
- "\nvar novelty = \"C\";"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id = Test.GetIdentity(groupOfContract, aocType, novelty);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var yearlyYieldCurve = Test.GetStorage().GetYearlyYieldCurve(id, economicBasis);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "yearlyYieldCurve"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## View loaded Nominal Cashflows"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The nominal Cashflows for the current period are loaded together with last period Cashflows for Group of Contract that were already existent. ",
- "\n",
- "\nThe relative files are located in: Files/.",
- "\n",
- "\nThe result is showed in the following list to be compared with the entries of the csv files"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetRawVariables(groupOfContract)"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Interest and Discount Rates"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Yield Curve ${\\text{YC}_i}$ associated to the the [selected period](#year-and-period) and target currency of the Group of Contract Reporting Node is [displayed above](#view-loaded-yearly-yield-curve) and used in this section to calculate the Interest and Discount factors",
- "\n",
- "\n$$",
- "\n\\text{Interest}_i = \\big( 1 + \\text{YC}_i \\big) ^{\\frac{1}{12}} ~,",
- "\n$$",
- "\n",
- "\nand",
- "\n",
- "\n\\begin{align}",
- "\n\\text{Discount}_i = \\big( 1 + \\text{YC}_i \\big) ^{-\\frac{1}{12}} ~.",
- "\n\\end{align}"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the Scope named *MonthlyRate* the Interest and Discount factors are computed"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedMonthlyRates = Test.GetScope( id );"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedMonthlyRates"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Interest"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the following, the Interest factors computed by the application are recalculated independently according to the formula above in two different ways"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedInterest = yearlyYieldCurve.Select( yc => Math.Pow(1 + yc, 1.0 / 12.0) );",
- "\nexpectedInterest"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "from yc in yearlyYieldCurve select Math.Pow(1 + yc, 1.0 / 12.0)"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedMonthlyRates.Interest.CheckEquality( expectedInterest ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Discount"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The following recalculates the Discount factors to be compared with the computed values"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDiscount = yearlyYieldCurve.Select( yc => Math.Pow(1 + yc, -1.0 / 12.0) );",
- "\nexpectedDiscount"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedMonthlyRates.Discount.CheckEquality( expectedDiscount ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Test method: Get Valid Element"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Given the present Yield Curve array has finite *length*, the extrapolation implemented is taking the last element for all successive years. This behavior is given by the function *GetValidElement*. The test in this section assures that constant extrapolation is taken for *index* > *length*"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDiscount.GetValidElement( 120 )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDiscount.GetValidElement( 120 ).Should().Be( expectedDiscount.Last() );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n# Cashflows"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This section deals with the calculation of the *Cumulated Discounted Cashflows* (CDC) starting from the nominal Cashflows. "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Choose identity"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Each loaded nominal Cashflows is assigned to a so-called *Identity* which uniquely identifies it based on the *Data Node*, *Aoc Type*, and *Novelty*. In the following cells we retrieve the desired Identity:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var aocType = \"CL\";",
- "\nvar novelty = \"C\";"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id = Test.GetIdentity(groupOfContract, aocType, novelty);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Nominal Cashflow"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Consider the two Amount Type *PR* and *NIC*, with Transaction Period being *Beginning of Period* (BOP) and *End of Period* (EOP), respectively. The corresponding nominal Cashflows are deposited in the Scopes named *NominalCashflow* with the Identity provided above, Calculation Type *BE*, and the aforementioned Amount Types. These nominal Cashflows correspond with those [loaded from the csv files](#view-loaded-nominal-cashflows). "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var amountTypePR = \"PR\";",
- "\nvar amountTypeNIC = \"NIC\";",
- "\nvar estimateType = \"BE\";",
- "\nvar accidentYear = (int?)null;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalPR = Test.GetScope((id, amountTypePR, estimateType, accidentYear));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "nominalPR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalNIC = Test.GetScope((id, amountTypeNIC, estimateType, accidentYear));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "nominalNIC"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Cumulated Discounted Cashflow"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The CDC is defined by the following recursive formulas",
- "\n",
- "\n$$",
- "\n\\text{CDC}_t = \\left\\{",
- "\n\\begin{array}{cl}",
- "\n\\text{Nominal}_t + \\text{CDC}_{t+1} \\cdot {\\text{Valid Discount}_{\\frac{t}{12}}} ~, & \\text{if Transaction Period is Beginning of Period} \\\\",
- "\n\\big( \\text{Nominal}_t + \\text{CDC}_{t+1} \\big) \\cdot {\\text{Valid Discount}_{\\frac{t}{12}}} ~, & \\text{if Transaction Period is End of Period}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nwhere the Transaction Period depends on the given cashflow Amount Type. "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Beginning of Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Amount Type **Premiums** (PR) has Transaction Period **Beginning of Period** (BOP). The corresponding CDC calculated by the application is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDiscountedPR = Test.GetScope((id, amountTypePR, estimateType, accidentYear));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedPR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the following cell we independently evaluate the expected discounted cashflow according to the formula above:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDiscountedPR = new double[nominalPR.Values.Length];",
- "\n",
- "\nEnumerable.Range(0, nominalPR.Values.Length).Reverse()",
- "\n .ForEach( i => expectedDiscountedPR[i] = nominalPR.Values[i] + expectedDiscountedPR.GetValidElement(i+1) * expectedDiscount.GetValidElement(i/12) );"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDiscountedPR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "(nominalPR.Values, nominalPR.Values.Length)"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected cumulated discount is compared with the computed values"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedPR.Values.CheckEquality( expectedDiscountedPR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedPR.Values.CheckEquality( expectedDiscountedPR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### End Of Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Amount Type **Non Investment Component** (NIC) has Transaction Period **End of Period** (EOP). The corresponding CDC calculated by the application is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDiscountedNIC = Test.GetScope((id, amountTypeNIC, estimateType, accidentYear));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedNIC"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the following cell we independently evaluate the expected discounted cashflow according to the formula above:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDiscountedNIC = new double[nominalNIC.Values.Length];",
- "\n",
- "\nEnumerable.Range(0, nominalNIC.Values.Length).Reverse()",
- "\n .ForEach( i => expectedDiscountedNIC[i] = ( nominalNIC.Values[i] + expectedDiscountedNIC.GetValidElement(i+1) ) * expectedDiscount.GetValidElement(i/12) );"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedDiscountedNIC"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected cumulated discount is compared with the computed values"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedNIC.Values.CheckEquality( expectedDiscountedNIC )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedNIC.Values.CheckEquality( expectedDiscountedNIC ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Non Performance Risk Adjustment"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In this section we treat the determination of the non-performance risk adjustment, an element offsetting partially future",
- "\nclaims according to the risk that the reinsurance company cannot fulfil the full extent of its obligations.",
- "\n",
- "\nFirstly, the discounting recursive relation can be written explicitly as",
- "\n",
- "\n$$",
- "\n\\begin{array}{l}",
- "\n\\text{CDC}_t = \\big( \\text{Nominal}_t + \\text{CDC}_{t+1} \\big) \\cdot {\\text{Valid Discount}_{\\frac{t}{12}}} \\\\",
- "\n\\Rightarrow \\text{CDC}_t = \\sum_{\\tau=t} \\big( \\text{Valid Discount}_{\\frac{t}{12}} \\big)^{\\tau-t+1} \\cdot \\text{Nominal}_\\tau ",
- "\n\\end{array}",
- "\n$$",
- "\n",
- "\nFor nominal Cashflows with Amount Type being *Claims*, the risk-adjusted Cumulated Discounted Cashflow ",
- "\nis assigned the Amount Type **Credit Default Risk** (CDR), ",
- "\nand is obtained by multiplying the right hand side of the latter formula by the corresponding risk factor",
- "\n",
- "\n$$",
- "\n\\text{CDC}_t^{\\text{Amount Type}=\\text{CDR}} = \\sum_{\\tau=t} \\big( \\text{Valid Discount}_{\\frac{t}{12}} \\big)^{\\tau-t+1} \\cdot \\text{Nominal}_\\tau^{\\text{Claim}} \\cdot \\big( e^{-\\gamma(\\tau-t)} -1 \\big)",
- "\n$$",
- "\n",
- "\nwhere $\\gamma$ is the assumed non-performance probability of the reinsurer to be provided as an [input parameter](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#credit-default-rate).",
- "\n",
- "\nThis rate is constant for the whole projection period, that is, $\\gamma$ is not a function of $t$. ",
- "\nIt effectively amounts to a constant increase in the continuous discount rate by $\\gamma$. "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Explicit vs recursive formula"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The explicit formula is tested versus the expected result obtained with the recursive formula"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDiscountedNICbis = new double[nominalNIC.Values.Length];",
- "\n",
- "\n//for(int t = 0; t < 12; t++)",
- "\n// for(int tau = t; tau < 12; tau++)",
- "\n// expectedDiscountedNICbis[t] += nominalNIC.Values[tau] * Math.Pow(expectedDiscount.GetValidElement(t/12), tau-t+1);",
- "\n",
- "\nEnumerable.Range(0, nominalNIC.Values.Length)",
- "\n .ForEach( i => expectedDiscountedNICbis[i] = ",
- "\n Enumerable.Range(i, nominalNIC.Values.Length-i).Select( tau => nominalNIC.Values[tau] * Math.Pow(expectedDiscount.GetValidElement(i/12), tau-i+1) ).Sum() );",
- "\n ",
- "\nexpectedDiscountedNIC.CheckEquality( expectedDiscountedNICbis )"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Risk Adjusted Claims "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed CDC with Amount Type being CDR reads"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedDiscountedCRD = Test.GetScope((id, \"CDR\", estimateType, accidentYear));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedCRD"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The starting point for the non performance risk adjustment is the computation of the sum of nominal Cashflows with Amount Type **Claims** listed below"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetClaims()"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "with the corresponding nominal Cashflows being"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalNIC = Test.GetScope((id, \"NIC\", estimateType, accidentYear));",
- "\nnominalNIC"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalICO = Test.GetScope((id, \"ICO\", estimateType, accidentYear));",
- "\nnominalICO"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalALE = Test.GetScope((id, \"ALE\", estimateType, accidentYear));",
- "\nnominalNIC"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalULE = Test.GetScope((id, \"ULE\", estimateType, accidentYear));",
- "\nnominalNIC"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalClaims = Sum( Sum(nominalICO.Values, nominalNIC.Values), Sum(nominalALE.Values, nominalULE.Values) );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Secondly, the correct credit risk rate (parameter $\\gamma$ in the [formula above](#non-performance-risk-adjustment)) is retrieved from the list of imported [Partner Rating](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure) and [Credit Default Rates](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure) relative to the target [Data Node](#year-and-period)'s Partner"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "groupOfContract"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var creditDefaultRate = Test.GetStorage().GetNonPerformanceRiskRate( id );",
- "\ncreditDefaultRate"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Lastly, using the [formula above](#non-performance-risk-adjustment), the expected CDR discounted Cashflow can be computed"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedDiscountedCDR = new double[nominalNIC.Values.Length];",
- "\n",
- "\nEnumerable.Range(0, nominalClaims.Length).ForEach( t => ",
- "\n expectedDiscountedCDR[t] = Enumerable.Range(t, nominalClaims.Length-t).Select( tau => ",
- "\n nominalClaims[tau] * Math.Pow(expectedDiscount.GetValidElement(t/12), tau-t+1) * (Math.Exp(-creditDefaultRate*(tau-t)) - 1)",
- "\n ).Sum() );",
- "\n",
- "\nexpectedDiscountedCDR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Finally, the expected cumulated discount is compared with the computed values"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedCRD.Values.CheckEquality( expectedDiscountedCDR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedDiscountedCRD.Values.CheckEquality( expectedDiscountedCDR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Present Values"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "For an implementation of these formulas refer to the [ImportScopeCalculation notebook](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation). "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The company portfolio value in one period is given by the following Analysis of Change AoC steps:",
- "\n1. Beginning of Period (BoP): starting value of the portfolio as of December last year (in the Year to Date view), ",
- "\n2. Model Corrections (MC): change of the portfolio value based on the model change,",
- "\n3. Cash Flow (CF):",
- "\n4. Interest Accretion (IA): ",
- "\n5. Assumption Update (AU): ",
- "\n6. Yield Curve Update (YCU): impact of yield curve update occured during the reporting period,",
- "\n7. Credit Risk Update (CRU): impact of credit default rate update occured during the reporting period,",
- "\n8. Experience Variance (EV): value adjustments following insurance related events which took place (e.g. mortality),",
- "\n9. Combined Liabilities (CL):",
- "\n10. End of Period (EOP): portfolio value at the end of the current period.",
- "\n",
- "\nNote: the AoC steps WO, EA and AM are not included in the Present Value calculation, hence their values if inquired is zero."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Present Value Base (PVB) values are valid for all [Economic Basis](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#economic-basis) and depends on the corresponding [AoCType](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#aoc-type):",
- "\n",
- "\n$$",
- "\n\\text{PVB}_t \\big(\\text{AoC}\\big) = ",
- "\n\\left\\{",
- "\n\\begin{array}{cl}",
- "\n\\text{CDC}_t & \\text{if AoC is Beginning of Period (BOP) } \\\\",
- "\n-\\text{Nominal}_t(\\text{Parent AoC}) & \\text{if AoC is Expected Cashflow (CF) } \\\\",
- "\n\\text{InterestAccretion}_t & \\text{if AoC is Interest Accretion (IA) } \\\\",
- "\n\\text{CDC}_t(\\text{Parent AoC}) & \\text{if AoC is End of Period (EOP) } \\\\",
- "\n\\text{CDC}_{t}(\\text{current AoC}) - \\text{CDC}_{t}(\\text{parent AoC}) & \\text{otherwise}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nand the Projected Present Value (PPV) reads",
- "\n",
- "\n$$",
- "\n\\text{PPV} \\big(\\text{AoC},\\text{TS},\\text{S}\\big) = \\left\\{",
- "\n\\begin{array}{cll}",
- "\n\\text{PVB}_{S} & \\text{if AoC Valuation Period is Beginning of Period } & \\text{ (e.g. BOP, MC) } \\\\",
- "\n\\text{PVB}_{S+TS/2 -1} & \\text{if AoC Valuation Period is Mid of Period } & \\text{ (no examples in current data model) } \\\\",
- "\n\\sum_{i=S}^{S + TS -1}\\text{PVB}_{i} & \\text{if AoC Valuation Period is Delta } & \\text{ (e.g. CF, IA) } \\\\",
- "\n\\text{PVB}_{S + TS} & \\text{if AoC Valuation Period is End of Period } & \\text{ (e.g. YCU, CRU, EV, CL, EOP) } \\\\",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nwhere the Shift (S) and Time Step (TS) are derived from the current [Year and Period](#year-and-period)"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var projectionPeriod = 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetShift(projectionPeriod)"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetTimeStep(projectionPeriod)"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Load Cashflow Data"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!eval-notebook \"../Initialization/InitSystemorphToMemory\""
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Workspace.InitializeFrom(DataSource);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "At this point standard Cashflows are loaded."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Initialization of the Test suite: the data loaded from csv files are ready to be used by the Scopes for the calculations"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var Test = await StartCalculatorAsync(reportingNode, year, month, economicBasis, Periodicity.Quarterly, ImportFormats.Cashflow);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Select Group of Contract",
- "\n",
- "\nHere, it is possible to select the Group of Contract used to run the next section of this Notebook."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "groupOfContract = \"DTR1.1\" ;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Beginning of Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type Beginning of Period is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idBoP = Test.GetIdentity(groupOfContract, \"BOP\", \"I\");",
- "\nidBoP"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueBoP_PR = Test.GetScope((idBoP, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueBoP_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#present-values) above, the expected BOP AoCType for PVB is defined to be equal to the discounted cashflows with the same Identity, Amount Type, and Calculation Type, whereas the PPV is the S-th element of the PVB."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedBoP_PR = Test.GetScope((idBoP, \"PR\", \"BE\", (int?)null));",
- "\ndiscountedBoP_PR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueBoP_PR = discountedBoP_PR.Values;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the following cell we check whether the expected values match the computed values"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueBoP_PR.Values.CheckEquality( expectedPresentValueBoP_PR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueBoP_PR.Values.CheckEquality( expectedPresentValueBoP_PR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Model Corrections"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type Model Corrections is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idMC = Test.GetIdentity(groupOfContract, \"MC\", \"I\");",
- "\nidMC"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueMC_PR = Test.GetScope((idMC, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueMC_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#present-values) above, for MC AoCType, the PVB is equal to the difference between the CDC of the current AoCType and the CDC of its parent. Additionally, the PPV is the S-th element of the PVB."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetScope((idMC, \"PR\")).Values"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedMC_PR = Test.GetScope((idMC, \"PR\", \"BE\", (int?)null));",
- "\ndiscountedMC_PR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueMC_PR = Subtract(discountedMC_PR.Values, discountedBoP_PR.Values);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected PVB and PPV are compared with the computed results in the following two cells: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueMC_PR.Values.CheckEquality( expectedPresentValueMC_PR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueMC_PR.Value == expectedPresentValueMC_PR[0]"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueMC_PR.Values.CheckEquality( expectedPresentValueMC_PR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueMC_PR.Value.Should().Be( expectedPresentValueMC_PR[0] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Cashflow"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type Cashflow is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idCF = Test.GetIdentity(groupOfContract, \"CF\", \"I\");",
- "\nidCF"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueCF_PR = Test.GetScope((idCF, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueCF_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#present-values) above, for CF AoCType, the PVB is equal to the nominal cashflow of its parent AoC step with opposite sign. The PPV is given by the sum of the first 3 elements."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cfReferenceAocStep = Test.GetScope(idCF).Value;",
- "\ncfReferenceAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cfNominalReference_PR = Test.GetScope((idCF with {AocType = cfReferenceAocStep.AocType}, \"PR\", \"BE\", (int?)null));",
- "\ncfNominalReference_PR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueCF_PR = Multiply(-1.0, cfNominalReference_PR.Values);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected PVB and PPV are compared with the computed results in the following two cells: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCF_PR.Values.CheckEquality( expectedPresentValueCF_PR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCF_PR.Values[0] + computedPresentValueCF_PR.Values[1] + computedPresentValueCF_PR.Values[2] == computedPresentValueCF_PR.Value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCF_PR.Values.CheckEquality( expectedPresentValueCF_PR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCF_PR.Value.Should().Be( computedPresentValueCF_PR.Values[0] + computedPresentValueCF_PR.Values[1] + computedPresentValueCF_PR.Values[2] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Interest Accretion"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "For IA AoCType, the PVB is given by the following relation ",
- "\n",
- "\n$$",
- "\n\\text{InterestAccretion}_i = \\left\\{",
- "\n\\begin{array}{cl}",
- "\n\\big(\\text{CDC}_i(\\text{Parent AoC}) - \\text{Nominal}_i(\\text{parent AoC}) \\big) \\cdot \\big({\\text{Valid Interest}_{\\frac{i}{12}}} - 1 \\big)~, ",
- "\n & \\text{if AmountType Transaction Period is Beginning of Period} \\\\",
- "\n\\text{CDC}_i(\\text{parent AoC}) \\cdot \\big({\\text{Valid Interest}_{\\frac{i}{12}}} - 1 \\big)~, ",
- "\n & \\text{otherwise}",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nwhile the PPV is given by the sum of the first S elements.",
- "\n",
- "\nWhen selecting the Identity, note that the Novelty *C* is not contemplated for Interest Accretion."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idIA = Test.GetIdentity(groupOfContract, \"IA\", \"I\");",
- "\nidIA"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Amount Type BOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Amount Type **Premiums** (PR) with Transaction Period **Beginning of Period** (BOP) is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueIA_PR = Test.GetScope((idIA, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueIA_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Present Value can be recomputed independently following the aforementioned [equation](#interest-accretion) starting from the interest factors, the nominal and discounted Cashflow of the parent Aoc Step"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var iaComputedMonthlyRates = Test.GetScope( idIA );",
- "\niaComputedMonthlyRates"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var iaReferenceAocStep = Test.GetScope(idIA).Value;",
- "\niaReferenceAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalIaReference_PR = Test.GetScope((idIA with {AocType = iaReferenceAocStep.AocType}, \"PR\", \"BE\", (int?)null));",
- "\nnominalIaReference_PR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedIaReference_PR = Test.GetScope((idIA with {AocType = iaReferenceAocStep.AocType}, \"PR\", \"BE\", (int?)null));",
- "\ndiscountedIaReference_PR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueIA_PR = discountedIaReference_PR.Values.Select((val, index) => ( val - nominalIaReference_PR.Values[index]) * ( iaComputedMonthlyRates.Interest.GetValidElement(index/12) -1));"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected PVB and PPV are compared with the computed results in the following two cells: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_PR.Values.CheckEquality( expectedPresentValueIA_PR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_PR.Values[0] + computedPresentValueIA_PR.Values[1] + computedPresentValueIA_PR.Values[2] == computedPresentValueIA_PR.Value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_PR.Values.CheckEquality( expectedPresentValueIA_PR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_PR.Value.Should().Be( computedPresentValueIA_PR.Values[0] + computedPresentValueIA_PR.Values[1] + computedPresentValueIA_PR.Values[2] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Amount Type EOP"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Amount Type **Non Investment Component** (NIC) with Transaction Period **End of Period** (EOP) is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueIA_NIC = Test.GetScope((idIA, \"NIC\", \"BE\", (int?)null));",
- "\ncomputedPresentValueIA_NIC"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Present Value can be recomputed independently following the aforementioned [equation](#interest-accretion) starting from the interest monthly rates, the discounted Cashflow of the parent Aoc Step"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var iaReferenceAocStep = Test.GetScope(idIA).Value;",
- "\niaReferenceAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedIaReference_NIC = Test.GetScope((idIA with {AocType = iaReferenceAocStep.AocType}, \"NIC\", \"BE\", (int?)null));",
- "\ndiscountedIaReference_NIC"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueIA_NIC = discountedIaReference_NIC.Values.Select((val, index) => val * ( iaComputedMonthlyRates.Interest.GetValidElement(index/12) -1));"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected PVB and PPV are compared with the computed results in the following two cells: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_NIC.Values.CheckEquality( expectedPresentValueIA_NIC )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_NIC.Values[0] + computedPresentValueIA_NIC.Values[1] + computedPresentValueIA_NIC.Values[2] == computedPresentValueIA_NIC.Value"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_NIC.Values.CheckEquality( expectedPresentValueIA_NIC ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueIA_NIC.Value.Should().Be( computedPresentValueIA_NIC.Values[0] + computedPresentValueIA_NIC.Values[1] + computedPresentValueIA_NIC.Values[2] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Yield Curve Update"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type Yield Curve Update is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idYcu = Test.GetIdentity(groupOfContract, \"YCU\", \"I\");",
- "\nidYcu"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueYCU_PR = Test.GetScope((idYcu, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueYCU_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Present Value can be recomputed independently following the aforementioned [equation](#interest-accretion) starting from the discount factors for beginning of period and for end of period applied to the reference Aoc step, followed by the difference between the CDC obtained with end of period discount factor and the CDC obtained with beginning of period discount factor. "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var ycReferenceAocStep = Test.GetScope(idYcu).Value;",
- "\nycReferenceAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var ycParentAocStep = Test.GetScope((idYcu, \"PR\")).Values.Single();",
- "\nycParentAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var ycParentId = idYcu with {AocType = ycParentAocStep.AocType, Novelty = ycParentAocStep.Novelty};",
- "\nycParentId"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here is the parent AocStep discounted with the beginning of period discount factor."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedYcParent = Test.GetScope((ycParentId, \"PR\", \"BE\", (int?)null));",
- "\ndiscountedYcParent"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here we independently compute the CDC of the parent AocStep discounted with end of period discount factor."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalYcParent = Test.GetScope((ycParentId, \"PR\", \"BE\", (int?)null));",
- "\nnominalYcParent"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var ycComputedMonthlyRates = Test.GetScope( idYcu );",
- "\nycComputedMonthlyRates"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var ycReferenceDiscountedEop = new double[nominalYcParent.Values.Length];",
- "\n",
- "\nEnumerable.Range(0, nominalYcParent.Values.Length).Reverse()",
- "\n .ForEach( i => ycReferenceDiscountedEop[i] = nominalYcParent.Values[i] + ycReferenceDiscountedEop.GetValidElement(i+1) * ycComputedMonthlyRates.Discount.GetValidElement(i/12) );",
- "\nycReferenceDiscountedEop"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueYCU_PR = Subtract(ycReferenceDiscountedEop, discountedYcParent.Values);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueYCU_PR.Values.CheckEquality( expectedPresentValueYCU_PR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueYCU_PR.Value == expectedPresentValueYCU_PR[3]"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueYCU_PR.Values.CheckEquality( expectedPresentValueYCU_PR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueYCU_PR.Value.Should().Be( expectedPresentValueYCU_PR[3] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Credit Risk Update"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "This Aoc Step is relevant only in the case of a Group of Reinsurance Contract."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type Credit Risk Update is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idCru = Test.GetIdentity(groupOfContract, \"CRU\", \"I\");",
- "\nidCru"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueCRU = Test.GetScope((idCru, \"CDR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueCRU"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Present Value can be recomputed independently starting as the difference between the CDC obtained with end of period credit default risk rate and the CDC obtained with beginning of period credit default risk rate, both computed using the Nominal cashflow of the reference Aoc Step and the End Of Period discounting factors. "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cruReferenceAocStep = Test.GetScope(idCru).Value;",
- "\ncruReferenceAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cruReferenceId = idCru with {AocType = cruReferenceAocStep.AocType, Novelty = cruReferenceAocStep.Novelty};",
- "\ncruReferenceId"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cruParentAocStep = Test.GetScope((idCru, \"CDR\")).Values.Single();",
- "\ncruParentAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cruParentId = idCru with {AocType = cruParentAocStep.AocType, Novelty = cruParentAocStep.Novelty};",
- "\ncruParentId"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here is the parent AocStep discounted with beginning of period credit default risk rate."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedCruParent = Test.GetScope((cruParentId, \"CDR\", \"BE\", (int?)null));",
- "\ndiscountedCruParent"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalCruReference = Test.GetScope((cruReferenceId, \"CDR\", \"BE\", (int?)null)).Values;",
- "\nnominalCruReference"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var creditDefaultRate = Test.GetStorage().GetNonPerformanceRiskRate( idCru );",
- "\ncreditDefaultRate"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cruComputedMonthlyRates = Test.GetScope( idCru );",
- "\ncruComputedMonthlyRates"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Lastly, using the [formula above](#non-performance-risk-adjustment), the expected CDR discounted Cashflow can be computed"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var cruExpectedDiscountedCDR = new double[nominalCruReference.Length];",
- "\n",
- "\nEnumerable.Range(0, nominalCruReference.Length).ForEach( t => ",
- "\n cruExpectedDiscountedCDR[t] = Enumerable.Range(t, nominalCruReference.Length-t).Select( tau => ",
- "\n nominalCruReference[tau] * ",
- "\n Math.Pow(cruComputedMonthlyRates.Discount.GetValidElement(t/12), tau-t+1) * ",
- "\n (Math.Exp(-creditDefaultRate*(tau-t)) - 1)",
- "\n ).Sum() );",
- "\n",
- "\ncruExpectedDiscountedCDR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueCRU = Subtract(cruExpectedDiscountedCDR, discountedCruParent.Values);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCRU.Values.CheckEquality( expectedPresentValueCRU )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCRU.Value == expectedPresentValueCRU[3]"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCRU.Values.CheckEquality( expectedPresentValueCRU ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCRU.Value.Should().Be( expectedPresentValueCRU[3] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Combined Liabilities"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type Combined Liabilities and Amount Type PR is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idCL = Test.GetIdentity(groupOfContract, \"CL\", \"C\");",
- "\nidCL"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueCL_PR = Test.GetScope((idCL, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueCL_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#present-values) above, for CL AoCType, the PVB is equal to the difference between the CDC of the current AoCType and the CDC of its parent(s). Additionally, the PPV is the $(\\text{S}+\\text{TS})$-th element of the PVB."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var clParents = Test.GetScope((idCL,\"PR\")).Values;",
- "\nclParents"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueCL_PR = Subtract(Test.GetScope((idCL, \"PR\", \"BE\", (int?)null)).Values,",
- "\n clParents.Select(aocStep => Test.GetScope((idCL with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}, \"PR\", \"BE\", (int?)null)).Values).Aggregate());"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected PVB and PPV are compared with the computed results in the following two cells: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCL_PR.Values.CheckEquality( expectedPresentValueCL_PR )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCL_PR.Value == expectedPresentValueCL_PR[3]"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCL_PR.Values.CheckEquality( expectedPresentValueCL_PR ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueCL_PR.Value.Should().Be( expectedPresentValueCL_PR[3] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## End of Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed Present Value for Aoc type End of Period is:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idEOP = Test.GetIdentity(groupOfContract, \"EOP\", \"C\");",
- "\nidEOP"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueEOP_NIC = Test.GetScope((idEOP, \"NIC\", \"BE\", (int?)null));",
- "\ncomputedPresentValueEOP_NIC"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#present-values) above, for EOP AoCType, the PVB is equal to the CDC of the parent AoC step, while the PPV is the $(\\text{S}+\\text{TS})$-th element of the PVB."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var eopReferenceAocStep = Test.GetScope(idEOP).Value;",
- "\neopReferenceAocStep"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedCL_NIC = Test.GetScope((idEOP with {AocType = eopReferenceAocStep.AocType, Novelty = eopReferenceAocStep.Novelty}, \"NIC\", \"BE\", (int?)null));",
- "\ndiscountedCL_NIC"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedPresentValueEOP_NIC = discountedCL_NIC.Values;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The expected PVB and PPV are compared with the computed results in the following two cells: "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueEOP_NIC.Values.CheckEquality( expectedPresentValueEOP_NIC )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueEOP_NIC.Value == expectedPresentValueEOP_NIC[3]"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueEOP_NIC.Values.CheckEquality( expectedPresentValueEOP_NIC ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedPresentValueEOP_NIC.Value.Should().Be( expectedPresentValueEOP_NIC[3] );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Check for zero PVB values"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "### Amortization"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "For AM AoCType, the PVB values are zero, i.e. Amortization is not part of the Present Value computation. In this subsection we check whether the corresponding values are zero accordingly. "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idAM = Test.GetIdentity(groupOfContract, \"AM\", \"C\");",
- "\nidAM"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueAM_PR = Test.GetScope((idAM, \"PR\", \"BE\", (int?)null));",
- "\ncomputedPresentValueAM_PR"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedPresentValueAM_PR = Test.GetScope((idAM, \"NIC\", \"BE\", (int?)null));",
- "\ncomputedPresentValueAM_PR"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Amortization Factors"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The amortization factors (AMF) are calculated from the corresponding Nominal and Discounted Cashflows with Calculation Type being *Coverage Units* (CU). ",
- "\nThe monthly AMF is",
- "\n",
- "\n$$",
- "\n\\text{AMF}^{\\text{Monthly}}_t = 1 - \\frac{ \\text{Nominal}^{\\text{Coverage Units}}_t } { \\text{CDC}^{\\text{Coverage Units}}_t } ~,",
- "\n$$",
- "\n",
- "\nwhile the AMF related to the current period is",
- "\n",
- "\n$$",
- "\n\\text{AMF} = 1 - \\prod _{t = \\text{S}}^{\\text{S}+\\text{TS}-1} \\text{AMF}^{\\text{Monthly}}_t ~.",
- "\n$$",
- "\n",
- "\nwhere the shift S and Time Step TS for the [current period](#year-and-period) are"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var projectionPeriod = 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var shift = Test.GetStorage().GetShift(projectionPeriod);",
- "\nshift"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var timeStep = Test.GetStorage().GetTimeStep(projectionPeriod);",
- "\ntimeStep"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Monthly Amortization"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed monthly and current period Amortization Factors derived from a non-zero [imported](#year-and-period) nominal cashflows and its corresponding discounted are shown in the following"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var idAM = Test.GetIdentity(groupOfContract, \"CL\", \"C\");",
- "\nidAM"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var nominalCashflowAmortizationFactorTest = Test.GetScope( (idAM, default(string), \"CU\", (int?)null) );",
- "\nnominalCashflowAmortizationFactorTest"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var discountedCashflowAmortizationFactorTest = Test.GetScope(idAM);",
- "\ndiscountedCashflowAmortizationFactorTest"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedMonthlyAmortizationFactor = Test.GetScope(idAM with {AocType = \"AM\"});",
- "\ncomputedMonthlyAmortizationFactor"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the following cell we independently evaluate the expected monthly amortization factor according to the [formula above](#amortization-factor) and we check whether expected vs computed match"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedMonthlyAmortizationFactor = nominalCashflowAmortizationFactorTest.Values.Zip(discountedCashflowAmortizationFactorTest.Values, ",
- "\n (nominal, discountedCumulated) => 1 - nominal / discountedCumulated ).ToArray();"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedMonthlyAmortizationFactor.RepeatOnce()"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedMonthlyAmortizationFactor.MonthlyAmortizationFactors.CheckEquality( expectedMonthlyAmortizationFactor )"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedMonthlyAmortizationFactor.MonthlyAmortizationFactors.CheckEquality( expectedMonthlyAmortizationFactor ).Should().Be(true);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Current Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The computed current period amortization factor is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedCurrentPeriodAmortizationFactor = Test.GetScope(idAM with {AocType = \"AM\"});",
- "\ncomputedCurrentPeriodAmortizationFactor"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Conversely, the current period Amortization factor can be independently computed using the [formula above](#amortization-factor) as"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedCurrentPeriodAmortizationFactor = 1d - expectedMonthlyAmortizationFactor.Skip(shift).Take(timeStep).Aggregate(1d, (x, y) => x * y);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedCurrentPeriodAmortizationFactor"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedCurrentPeriodAmortizationFactor.Value == expectedCurrentPeriodAmortizationFactor"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedCurrentPeriodAmortizationFactor.Value.Should().Be( expectedCurrentPeriodAmortizationFactor );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Results persisted"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The last step during the Cashflow import is to save, namely *persist* the Present Values computed with *locked* (L) and *current* (C) economic basis, and calculation type being *Best Estimate* (BE). ",
- "\n",
- "\nThese data is the starting point of the [Contractual Service Margin calculation](\"SpecificationsCSM\")."
- ]
- },
- {
- "cell_type": "code",
- "source": [
- ""
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/full-ifrs17-template/Test/SpecificationsSetup.ipynb b/full-ifrs17-template/Test/SpecificationsSetup.ipynb
deleted file mode 100644
index b9f1e2f4..00000000
--- a/full-ifrs17-template/Test/SpecificationsSetup.ipynb
+++ /dev/null
@@ -1,125 +0,0 @@
-{
- "metadata": {
- "authors": [],
- "kernelspec": {
- "display_name": "Formula Framework",
- "language": "C#",
- "name": "C#"
- },
- "language_info": {
- "file_extension": ".cs",
- "mimetype": "text/plain",
- "name": "C#"
- },
- "toc-autonumbering": "True",
- "toc-showcode": "False"
- },
- "nbformat": 4,
- "nbformat_minor": 5,
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- " Specifications Setup
"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "public interface Universe : IMutableScopeWithStorage{}",
- "\n",
- "\npublic async Task StartCalculatorAsync(string reportingNode, int year, int month, string economicBasis, Periodicity period, string format) ",
- "\n{",
- "\n ",
- "\n var importArgs = new ImportArgs(reportingNode, year, month, period, null, format);",
- "\n Workspace.Reset();",
- "\n Workspace.Initialize(x => x.FromSource(DataSource)",
- "\n .DisableInitialization()",
- "\n .DisableInitialization());",
- "\n",
- "\n var partition = (await DataSource.Query().Where(p => p.ReportingNode == importArgs.ReportingNode &&",
- "\n p.Year == importArgs.Year &&",
- "\n p.Month == importArgs.Month &&",
- "\n p.Scenario == importArgs.Scenario",
- "\n ).ToArrayAsync()).Single().Id;",
- "\n await DataSource.Partition.SetAsync(partition);",
- "\n",
- "\n //Set Workspace as when the parsing is completed.",
- "\n if(importArgs.ImportFormat == ImportFormats.Actual)",
- "\n { ",
- "\n await Workspace.UpdateAsync(await DataSource.Query()",
- "\n .Where(x => x.Partition == partition && ",
- "\n new string[]{EstimateTypes.A, EstimateTypes.AA, EstimateTypes.OA}.Contains(x.EstimateType) && ",
- "\n new string[]{AocTypes.CF, AocTypes.WO}.Contains(x.AocType))",
- "\n .ToArrayAsync());",
- "\n }",
- "\n else if(importArgs.ImportFormat == ImportFormats.Opening)",
- "\n { ",
- "\n await Workspace.UpdateAsync(await DataSource.Query()",
- "\n .Where(x => x.Partition == partition && ",
- "\n new string[]{ EstimateTypes.C, EstimateTypes.L, EstimateTypes.LR, EstimateTypes.AA, EstimateTypes.OA, EstimateTypes.DA}.Contains(x.EstimateType) && ",
- "\n x.AocType == AocTypes.BOP && x.Novelty == Novelties.I)",
- "\n .ToArrayAsync());",
- "\n }",
- "\n else",
- "\n {",
- "\n await Workspace.UpdateAsync(await DataSource.Query().Where(x => x.Partition == partition).ToArrayAsync());",
- "\n }",
- "\n var storage = new ImportStorage(importArgs, DataSource, Workspace);",
- "\n await storage.InitializeAsync();",
- "\n return Scopes.ForStorage(storage).WithContext(economicBasis).ToScope();",
- "\n}",
- "\n",
- "\npublic static ImportIdentity GetIdentity (this Universe universe, string dataNode, string aocType, string novelty) ",
- "\n => universe.GetScope(dataNode).Identities.Single( x => x.AocType == aocType && x.Novelty == novelty );",
- "\n",
- "\nstatic T GetValidElement(this IList array, int index) => GetElementOrDefault(array, index);",
- "\n",
- "\nstatic T GetValidElement(this IEnumerable array, int index) => GetElementOrDefault(array.ToArray(), index);",
- "\n",
- "\nstatic void ForEach(this IEnumerable self, Action action) => self.ToList().ForEach(action);",
- "\n",
- "\npublic static IfrsVariable FromPvToIfrsVariable(this PresentValue scope)",
- "\n => new IfrsVariable{ EconomicBasis = scope.EconomicBasis, ",
- "\n EstimateType = scope.Identity.EstimateType, ",
- "\n DataNode = scope.Identity.Id.DataNode, ",
- "\n AocType = scope.Identity.Id.AocType, ",
- "\n Novelty = scope.Identity.Id.Novelty, ",
- "\n AccidentYear = scope.Identity.AccidentYear,",
- "\n AmountType = scope.Identity.AmountType,",
- "\n Value = scope.Value,",
- "\n Partition = scope.GetStorage().TargetPartition };",
- "\n",
- "\npublic static IfrsVariable FromCsmToIfrsVariable(this ContractualServiceMargin scope)",
- "\n => new IfrsVariable{ EstimateType = scope.EstimateType, ",
- "\n DataNode = scope.Identity.DataNode, ",
- "\n AocType = scope.Identity.AocType, ",
- "\n Novelty = scope.Identity.Novelty, ",
- "\n Value = scope.Value,",
- "\n Partition = scope.GetStorage().TargetPartition };",
- "\n",
- "\npublic static IfrsVariable FromLcToIfrsVariable(this LossComponent scope)",
- "\n => new IfrsVariable{ EstimateType = scope.EstimateType, ",
- "\n DataNode = scope.Identity.DataNode, ",
- "\n AocType = scope.Identity.AocType, ",
- "\n Novelty = scope.Identity.Novelty, ",
- "\n Value = scope.Value,",
- "\n Partition = scope.GetStorage().TargetPartition };",
- "\n",
- "\npublic static IfrsVariable FromLoReCoToIfrsVariable(this LossRecoveryComponent scope)",
- "\n => new IfrsVariable{ EstimateType = scope.EstimateType, ",
- "\n DataNode = scope.Identity.DataNode, ",
- "\n AocType = scope.Identity.AocType, ",
- "\n Novelty = scope.Identity.Novelty, ",
- "\n Value = scope.Value,",
- "\n Partition = scope.GetStorage().TargetPartition };"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- ""
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb b/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb
deleted file mode 100644
index f8cc0f73..00000000
--- a/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb
+++ /dev/null
@@ -1,1768 +0,0 @@
-{
- "metadata": {
- "authors": [],
- "kernelspec": {
- "display_name": "Formula Framework",
- "language": "C#",
- "name": "C#"
- },
- "language_info": {
- "file_extension": ".cs",
- "mimetype": "text/plain",
- "name": "C#"
- },
- "toc-autonumbering": "True",
- "toc-showcode": "False"
- },
- "nbformat": 4,
- "nbformat_minor": 5,
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- " Technical Margin Specifications
"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The aim of this notebook is to document the Technical Margin (TM) and its allocation to the Contractual Service Margin (CSM), Loss Component (LC), or Loss Recovery Component (LoReCo). The process is pictorially explained in the following flowchart. ",
- "\n",
- "\n",
- "\n
",
- "\n",
- "\nThroughout this notebook we adopt the following variable notation: we use the words *computed* vs. *expected* to differentiate the results provided by the application vs. this test notebook, respectively."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "# Import Data"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Current Period"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Please select the target period (i.e. year and month) and Reporting Node based on the imported data:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var year = 2021 ;",
- "\nvar month = 3 ;",
- "\nvar reportingNode = \"CH\" ;",
- "\nvar economicBasis = \"L\" ;"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Import the Dimensions, Parameters, Nominal Cashflows, and Actuals from the corresponding csv files in Initialization/Systemorph/"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!eval-notebook \"../Initialization/InitSystemorphToMemory\""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "[Setup IFRS17 Calculation Engine](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation):"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "#!import \"SpecificationsSetup\""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Initialization of the Test Suite: the data loaded from csv files are ready to be used by the Scopes for the calculations"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var Test = await StartCalculatorAsync(reportingNode, year, month, economicBasis, Periodicity.Quarterly, ImportFormats.Cashflow);"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## View loaded Data Nodes"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The imported active Data Nodes from Initialization/Systemorph/DataNodes.csv are "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().DataNodeDataBySystemName"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "whereas the Data Nodes of your imported Cashflows are"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().DataNodesByImportScope[ImportScope.Primary]"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Please select here below the target Data Node for executing the tests below:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var dataNode = \"DT1.1\";"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## View list of Identities"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Based on the Cashflows imported, the list of all possible identities, i.e. combinations of valid Data Nodes, Aoc steps, and Novelties, is contructed and reported here below:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var allIdentities = Test.GetScopes(Test.GetStorage().DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities).ToArray();"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "allIdentities"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Present Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Projected Present Values (PPVs) are calculated for each Amount Type (AT) either with the *locked-in* (L) and with the *current* (C) Yield Curves. While the former is the latest available as per end of the DataNode's inception year, the latter is the latest available as per the current period. ",
- "\nPPVs for both Economic Basis L and C have been defined [here](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation#present-value) and tested [here](SpecificationsImportCashflows#present-values). ",
- "\n",
- "\nAccording to the BBA methodology, the CSM calculation uses the PV with locked-in Yield Curve simply defined as",
- "\n",
- "\n$$",
- "\n\\text{PV Locked}(\\text{AoC}, \\text{AT}) = \\text{PPV}(\\text{AoC}, \\text{AT}) \\big|_{\\substack{ \\text{Calculation Type = BE} \\\\ \\text{Economic Base = L} } }",
- "\n$$"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var pvsLocked = allIdentities.SelectMany(id => Test.GetScope(id).PresentValues",
- "\n .Where(x => Math.Abs(x.Value) >= Precision)",
- "\n .Select(x => x.FromPvToIfrsVariable())).ToArray();"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Below a view of the computed locked-in PV "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Report.ForObjects(pvsLocked)",
- "\n .WithQuerySource(Workspace)",
- "\n .GroupColumnsBy(x => x.EconomicBasis)",
- "\n .GroupColumnsBy(x => x.AmountType)",
- "\n .GroupRowsBy(x => x.Novelty)",
- "\n .GroupRowsBy(x => x.AocType)",
- "\n .WithGridOptionsForIfrsVariable()",
- "\n .ToReport()"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Aggregated values are also available as the sum over all [Amount Types](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#amount-type):",
- "\n",
- "\n$$",
- "\n\\text{PV Locked Value}(\\text{AoC}) = \\sum_{\\text{AT}} \\text{PV Locked}(\\text{AoC}, \\text{AT})",
- "\n$$"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here below an example"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_BoP_I = Test.GetIdentity(dataNode, \"BOP\", \"I\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_BoP_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetScope( id_BoP_I ).Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Risk Adjustment"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The CSM calculation also uses locked-in Risk Adjustment (RA Locked) which is retrieved from the corresponding Present Value with [Calculation Type](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#calculation-type) being RA defined [here](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation#present-value) and tested [here](SpecificationsImportCashflows#present-values). ",
- "\n",
- "\nRisk Adjustment values can be written as",
- "\n",
- "\n$$",
- "\n\\text{RA Locked Value}(\\text{AoC}) = \\text{PV}(\\text{AoC})|_{\\substack{ \\text{Calculation Type = RA} \\\\ \\text{Economic Base = L} }}",
- "\n$$",
- "\n",
- "\nwhere the imported Cashflows for the RA Calculation Type are already aggregated over all [Amount Types](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/DataModel/DataStructure#amount-type)."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Here below an example"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_BoP_I = Test.GetIdentity(dataNode, \"BOP\", \"I\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_BoP_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetScope( id_BoP_I ).Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The RA Locked per Data Node imported are"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var rasLocked = allIdentities.SelectMany(id => Test.GetScope(id).PresentValues",
- "\n .Where(x => Math.Abs(x.Value) >= Precision)",
- "\n .Select(x => x.FromPvToIfrsVariable())).ToArray();"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Report.ForObjects(rasLocked)",
- "\n .WithQuerySource(Workspace)",
- "\n .GroupColumnsBy(x => x.EconomicBasis)",
- "\n .GroupColumnsBy(x => x.DataNode)",
- "\n .GroupRowsBy(x => x.Novelty)",
- "\n .GroupRowsBy(x => x.AocType)",
- "\n .WithGridOptionsForIfrsVariable()",
- "\n .ToReport()"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "
",
- "\n",
- "\n# Technical Margin"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "For the computation of the CSM or LC components for each AoC step, it is convenient to introduce the notion of technical margin (TM).",
- "\n",
- "\nFirstly, it is useful to define the so-called Aggregated Technical Margin (ATM)",
- "\n",
- "\n$$",
- "\n\\text{ATM} (\\text{AoC}) = \\sum_{s\\in\\text{previous AoC steps}} \\text{TM}(s) ~,",
- "\n$$",
- "\n",
- "\nand the Interest Accretion Factor (IAF) ",
- "\n",
- "\n$$",
- "\n\\text{IAF} = \\prod_{i=1}^{\\text{TS}} (1 + \\text{YC}_i) - 1 ~.",
- "\n$$",
- "\n",
- "\nThe TM is defined as",
- "\n",
- "\n$$",
- "\n\\text{TM}(\\text{AoC}) = \\left\\{",
- "\n\\begin{array}{rl}",
- "\n\\text{TM}(\\rm{EOP}) \\text{ of the previous period} ~ & \\text{if }s = \\text{BOP and Novelty is In-Force}. \\\\",
- "\n0 ~ & \\text{if }s = \\text{CF}. \\\\",
- "\n\\text{IAF} \\cdot ~ \\text{ATM}(\\text{AoC}) ~ & \\text{if }s = \\text{IA}. \\\\",
- "\n\\rm{Premiums} + \\text{Attributable Expense and Commissions} + \\text{Investment Claims} ~ & \\text{if }s = \\text{EA}. \\\\",
- "\n-\\text{AMF} \\cdot ~ \\text{ATM}(\\text{AoC}) ~ & \\text{if }s = \\text{AM}. \\\\",
- "\n\\text{PV Locked Value}(\\text{AoC}) ",
- "\n\\bigg|_{\\substack{\\text{Non Attributable} \\\\ ",
- "\n \\text{Amount Types} \\\\ ",
- "\n \\text{excluded}}} ",
- "\n+ \\text{RA Locked Value}(\\text{AoC}) ~ & \\text{otherwise} ",
- "\n\\end{array}",
- "\n\\right.",
- "\n$$",
- "\n",
- "\nwhere AMF is the Amortization Factor that is defined [here](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation#amortization-factor) and tested [here](SpecificationsImportCashflows#amortization-factor), with YC being the [Yield Curve](#yield-curves) and TS is the Time-Step, ",
- "\nand the Premiums, Attributable Expense and Commissions and Investment Claims terms are given by:",
- "\n",
- "\n$$",
- "\n\\begin{array}{lcl}",
- "\n\\rm{Premiums} &=& \\text{Premium Allocation Factor} \\cdot \\sum_{\\text{Amount Type}\\in\\{\\text{PR and its children}\\}}",
- "\n \\big(\\text{PV}_{\\text{Novelty = I}} + \\text{PV}_{\\text{Novelty = N}} \\big) - ",
- "\n \\big(\\text{Actual}_{\\text{Novelty=C}} + \\text{Advance Actual}_{\\text{Novelty=C}} + \\text{Overdue Actual}_{\\text{Novelty=C}} \\big) ~, \\\\",
- "\n\\text{Attributable Expense and Commissions} &=& \\sum_{\\text{Amount Type}\\in\\{\\rm{ACA}, \\rm{AEA}\\}}",
- "\n \\big(\\text{PV}_{\\text{Novelty = I}} + \\text{PV}_{\\text{Novelty = N}} \\big) - \\text{Actual}_{\\text{Novelty=C}} ~, \\\\",
- "\n\\text{Investment Claims } &=& \\sum_{\\text{Amount Type}\\in\\{\\text{ICO and its children}\\}}",
- "\n \\big(\\text{PV}_{\\text{Novelty = I}} + \\text{PV}_{\\text{Novelty = N}} \\big) - ",
- "\n \\big( \\text{Actual}_{\\text{Novelty=C}} + \\text{Advance Actual}_{\\text{Novelty=C}} + \\text{Overdue Actual}_{\\text{Novelty=C}} \\big) ~.",
- "\n\\end{array}",
- "\n$$",
- "\n",
- "\nThe AoC Type **CF** is implicit for all formulas, PV is the [present value](#present-value) with Calculation Type **BE**, and Actuals have Estimate Types **A**, **OA** and **AA** (see details [here](https://portal.stage.systemorph.cloud/project/ifrs17ce/env/dev/Import/ImportScopeCalculation#actual-base))."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Beginning of Period"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_BoP_I = Test.GetIdentity(dataNode, \"BOP\", \"I\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_BoP_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedTM_BoP_I = Test.GetScope(id_BoP_I);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_BoP_I.Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The TM for BOP is equal to the TM for EOP of the previous period, that is, the sum of Csm, Loss Component and LoReCo as of at the end of last period (see the corresponding [formula](#technical-margins)). ",
- "\n",
- "\nThe corresponding **IFRS Variables** can be loaded directly from the *Storage*"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var valueCsm = Test.GetStorage().GetValue(id_BoP_I, null, EstimateTypes.C, null);",
- "\nvalueCsm"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var valueLc = Test.GetStorage().GetValue(id_BoP_I, null, EstimateTypes.L, null);",
- "\nvalueLc"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var valueLr = Test.GetStorage().GetValue(id_BoP_I, null, EstimateTypes.LR, null);",
- "\nvalueLr"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedTM_BoP_I = -valueCsm + valueLc + valueLr;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedTM_BoP_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_BoP_I.Value.Should().BeApproximately( expectedTM_BoP_I, Precision );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Model Corrections"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_MC_I = Test.GetIdentity(dataNode, \"MC\", \"I\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_MC_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedTM_MC_I = Test.GetScope(id_MC_I);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_MC_I.Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The TM for MC is given by the default [formula](#technical-margins), i.e. it is equal to the sum of PV and RA Locked, where the former does not encompass the *NonAttributable* Amount Types"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedTM_MC_I = Test.GetScope(id_MC_I).Value + Test.GetScope( id_MC_I ).Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedTM_MC_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_MC_I.Value.Should().BeApproximately( expectedTM_MC_I, Precision );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Cash Flow"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_CF_I = Test.GetIdentity(dataNode, \"CF\", \"I\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_CF_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedTM_CF_I = Test.GetScope(id_CF_I);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_CF_I.Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#technical-margins) above, the tecnical margin is 0 for the Cash Flow AoC step "
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_CF_I.Value.Should().BeApproximately( 0, Precision );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "",
- "\n## Interest Accretion"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_IA_I = Test.GetIdentity(dataNode, \"IA\", \"I\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_IA_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedTM_IA_I = Test.GetScope(id_IA_I);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_IA_I.Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#technical-margins) above, for the AoC step IA, the TM is equal to sum of the TMs of its previous AoC step multiplied by the IAF. "
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The IAF associated to the current period (i.e. shift and time step) can be calculated from the shift, the time Step, and the Interest Rates"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var projectionPeriod = 0;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var shift = Test.GetStorage().GetShift(projectionPeriod);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var timeStep = Test.GetStorage().GetTimeStep(projectionPeriod);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "(shift, timeStep)"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var monthlyRates = Test.GetScope(id_IA_I);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "monthlyRates"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var IAF = Enumerable.Range(shift,timeStep).Select(i => monthlyRates.Interest.GetValidElement(i/12)).Aggregate(1.0d, (x, y) => x * y ) - 1.0d;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "IAF"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Since the previous AoC steps are"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var previousAocStep = Test.GetScope((id_IA_I, InputSource.Cashflow)).Values;",
- "\npreviousAocStep"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "the expected TM for the Amortization step reads"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedTM_IA_I = IAF * previousAocStep.Sum(aoc => Test.GetScope(id_IA_I with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedTM_IA_I"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_IA_I.Value.Should().BeApproximately( expectedTM_IA_I, Precision );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Combined Liabilities"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_CL_C = Test.GetIdentity(dataNode, \"CL\", \"C\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_CL_C"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedTM_CL_C = Test.GetScope(id_CL_C);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_CL_C.Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the default TM [formula](#technical-margins), for the CL step the TM is equal to the sum of PV and RA Locked, where the former does not encompass the *NonAttributable* Amount Types"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var expectedTM_CL_C = Test.GetScope(id_CL_C).Value + Test.GetScope( id_CL_C ).Value;"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "expectedTM_CL_C"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_CL_C.Value.Should().BeApproximately( expectedTM_CL_C, Precision );"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Experience Adjustment"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var id_EA_C = Test.GetIdentity(dataNode, \"EA\", \"C\");"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "id_EA_C"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var computedTM_EA_C = Test.GetScope(id_EA_C);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "computedTM_EA_C.Value"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "According to the [formula](#technical-margins) above, for the AoC step EA, the TM is equal to sum of the Premiums, Attributable Expense and Commissions, and Investment Claims. Here below we calculate these terms individually."
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The Premiums, Attributable Expense and Commissions and Investment Claims Present Values and Actuals are calculated using the CF AoC step. Therefore, as first step we define the relevant AoC step and Novelties:"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var referenceAoCType = Test.GetScope(id_EA_C).Value.AocType;",
- "\nvar referenceAoC = Test.GetStorage().GetNovelties().Select(n => new AocStep(referenceAoCType, n));"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "referenceAoC"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "**Premiums**"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "The list of Premiums Amount Type defined in the imported dimensions and the Premium Allocation Factor can be retrieved"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "Test.GetStorage().GetPremiums()"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var premiumAllocationFactor = Test.GetStorage().GetPremiumAllocationFactor(id_EA_C);"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "premiumAllocationFactor"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "Lastly, the Premiums term is"
- ]
- },
- {
- "cell_type": "code",
- "source": [
- "var premiums = premiumAllocationFactor * Test.GetStorage().GetPremiums()",
- "\n .Sum(p => referenceAoC.Sum(aoc => Test.GetScope((Test.GetIdentity(dataNode, aoc.AocType, aoc.Novelty), p, EstimateTypes.BE, (int?)null), o => o.WithContext(economicBasis)).Value)",
- "\n -referenceAoC.Sum(aoc => Test.GetScope