diff --git a/PresentValueSeries/Dimensions.xlsx b/PresentValueSeries/Dimensions.xlsx index 0fd16d7d..44ba3f6d 100644 Binary files a/PresentValueSeries/Dimensions.xlsx and b/PresentValueSeries/Dimensions.xlsx differ diff --git a/PresentValueSeries/InitializeData.ipynb b/PresentValueSeries/InitializeData.ipynb index f7baba98..eacf5385 100644 --- a/PresentValueSeries/InitializeData.ipynb +++ b/PresentValueSeries/InitializeData.ipynb @@ -40,7 +40,7 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17/v1.0.0/CalculationEngine\"" + "#!import \"//ifrs17/v1.1.0/CalculationEngine\"" ], "metadata": {}, "execution_count": 0, diff --git a/PresentValueSeries/PresentValue - Episode 2.ipynb b/PresentValueSeries/PresentValue - Episode 2.ipynb index 37e9ce42..70a4c51a 100644 --- a/PresentValueSeries/PresentValue - Episode 2.ipynb +++ b/PresentValueSeries/PresentValue - Episode 2.ipynb @@ -99,7 +99,7 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17/v1.0.0/CalculationEngine\"" + "#!import \"//ifrs17/v1.1.0/CalculationEngine\"" ], "metadata": {}, "execution_count": 0, @@ -168,10 +168,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"YieldCurve.xlsx\")", - "\n .WithType()", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"YieldCurve.xlsx\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -180,10 +177,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"Cashflows.xlsx\")", - "\n .WithFormat(\"Cashflow\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"Cashflows.xlsx\").WithFormat(\"Cashflow\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -507,4 +501,4 @@ "outputs": [] } ] -} +} \ No newline at end of file diff --git a/PresentValueSeries/PresentValue - Episode 3.ipynb b/PresentValueSeries/PresentValue - Episode 3.ipynb index 16605c69..0c3d4211 100644 --- a/PresentValueSeries/PresentValue - Episode 3.ipynb +++ b/PresentValueSeries/PresentValue - Episode 3.ipynb @@ -99,7 +99,7 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17/v1.0.0/CalculationEngine\"" + "#!import \"//ifrs17/v1.1.0/CalculationEngine\"" ], "metadata": {}, "execution_count": 0, @@ -168,10 +168,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"DataNodes_CH.xlsx\")", - "\n .WithFormat(\"DataNode\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"DataNodes_CH.xlsx\").WithFormat(\"DataNode\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -180,10 +177,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"DataNodes_DE.xlsx\")", - "\n .WithFormat(\"DataNode\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"DataNodes_DE.xlsx\").WithFormat(\"DataNode\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -192,10 +186,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"YieldCurve.xlsx\")", - "\n .WithType()", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"YieldCurve.xlsx\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -204,10 +195,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"Cashflows.xlsx\")", - "\n .WithFormat(\"Cashflow\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"Cashflows.xlsx\").WithFormat(\"Cashflow\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -216,10 +204,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"CF_CH_2021_12.xlsx\")", - "\n .WithFormat(\"Cashflow\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"CF_CH_2021_12.xlsx\").WithFormat(\"Cashflow\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -228,10 +213,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"CF_DE_2021_12.xlsx\")", - "\n .WithFormat(\"Cashflow\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"CF_DE_2021_12.xlsx\").WithFormat(\"Cashflow\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -240,10 +222,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"CF_DE_2022_12.xlsx\")", - "\n .WithFormat(\"Cashflow\")", - "\n .WithTarget(DataSource)", - "\n .ExecuteAsync()" + "await Import.FromFile(\"CF_DE_2022_12.xlsx\").WithFormat(\"Cashflow\").WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Constants/CalculationEngine.ipynb b/ifrs17-template/Constants/CalculationEngine.ipynb index af978b92..3b0bef01 100644 --- a/ifrs17-template/Constants/CalculationEngine.ipynb +++ b/ifrs17-template/Constants/CalculationEngine.ipynb @@ -19,7 +19,7 @@ "cell_type": "code", "source": [ "var projectName = \"ifrs17\";", - "\nvar environmentName = \"v1.0.0\";", + "\nvar environmentName = \"v1.1.0\";", "\nvar notebookName = \"CalculationEngine\";", "\nvar calculationEngine = $\"#!import \\\"//{projectName}/{environmentName}/{notebookName}\\\"\";" ], diff --git a/ifrs17-template/Export/MapTemplate.ipynb b/ifrs17-template/Export/MapTemplate.ipynb index dc792dba..eb986486 100644 --- a/ifrs17-template/Export/MapTemplate.ipynb +++ b/ifrs17-template/Export/MapTemplate.ipynb @@ -111,7 +111,7 @@ "source": [ "# Map Template: Data Node", "\n", - "\n[DataNodes](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node) defines the properties of [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#group-of-contracts)." + "\n[DataNodes](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node) defines the properties of [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#group-of-contracts)." ], "metadata": {}, "execution_count": 0, @@ -167,7 +167,7 @@ "source": [ "# Map Template: Data Node State", "\n", - "\n[Data Node State](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-state) defines whether the instance is active (used in import/output) or inactive (present in the DataSource but not used in input/output operations)." + "\n[Data Node State](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-state) defines whether the instance is active (used in import/output) or inactive (present in the DataSource but not used in input/output operations)." ], "metadata": {}, "execution_count": 0, @@ -253,7 +253,7 @@ "source": [ "# Map Template: Data Node Parameter", "\n", - "\n[Data Node Parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-parameters) are defined at the Group of Contract level and are used during the import calculation. " + "\n[Data Node Parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-parameters) are defined at the Group of Contract level and are used during the import calculation. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Files/Parameters/YieldCurve_2020_1.csv b/ifrs17-template/Files/Parameters/YieldCurve_2020_1.csv index c94e347e..c97a6549 100644 --- a/ifrs17-template/Files/Parameters/YieldCurve_2020_1.csv +++ b/ifrs17-template/Files/Parameters/YieldCurve_2020_1.csv @@ -1,6 +1,6 @@ @@Main Year,Month -2020,12 +2020,1 @@YieldCurve Currency,Values0,Values1,Values2,Values3 USD,0.002,0.002,0.002,0.002 diff --git a/ifrs17-template/Files/Parameters/YieldCurve_2020_12.csv b/ifrs17-template/Files/Parameters/YieldCurve_2020_12.csv index 48e9669d..b6fcb54c 100644 --- a/ifrs17-template/Files/Parameters/YieldCurve_2020_12.csv +++ b/ifrs17-template/Files/Parameters/YieldCurve_2020_12.csv @@ -1,6 +1,6 @@ @@Main Year,Month -2020,1 +2020,12 @@YieldCurve Currency,Values0,Values1,Values2,Values3 USD,0.002,0.002,0.002,0.002 diff --git a/ifrs17-template/Import/CloseImportTemplate.ipynb b/ifrs17-template/Import/CloseImportTemplate.ipynb index fc78fc44..4070701a 100644 --- a/ifrs17-template/Import/CloseImportTemplate.ipynb +++ b/ifrs17-template/Import/CloseImportTemplate.ipynb @@ -38,7 +38,7 @@ "source": [ "All imports are triggered via the Import command. Several options can be fluently appended to customize the import action:", "\n- FromFile() : accepts a string as input (eg. \"../Files/TransactionalData/Openings_CH_2020_12.csv\"). It corresponds the file to be imported complete with the path", - "\n- WithFormat() : accepts a string as input (eg. \"Cashflow\" or \"Actual\"). It is used to trigger the desired import logic for the current file. Full list of avalaible ImportFormat can be found [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Constants/Consts#import-formats)", + "\n- WithFormat() : accepts a string as input (eg. \"Cashflow\" or \"Actual\"). It is used to trigger the desired import logic for the current file. Full list of avalaible ImportFormats can be found [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Constants/Consts#import-formats)", "\n- WithFileStorage() : defined the drive from where the input files is retrieved. In this example we use the project file storage (new files have to be uploaded into the project), other options are SharePoint and OneDrive. ", "\n- WithTarget() : target drive where the results are stored. In this example we use our in-memory set up", "\n" @@ -88,9 +88,9 @@ "\nNew Data Nodes and Parameters are imported here.", "\n
To easily generate these files, please refer to the **Map Template** files exported [here](../Export/MapTemplate). Edit them at your wish and import them back into the solution through the following cells. ", "\n
For the **ImportFormat**, the following options are expected:", - "\n- ImportFormats.DataNode : [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#group-of-contracts)", - "\n- ImportFormats.DataNodeState : the [state of a data node](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-state) can be either active or inactive.", - "\n- ImportFormats.DataNodeParameter : parameters are described [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-parameters). For **Group of Insurance Contracts** a default [Premium Allocation factor](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Import/ImportScopeCalculation#experience-adjustment-on-premium) of 1 is applied if the parameter is not imported.", + "\n- ImportFormats.DataNode : [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#group-of-contracts)", + "\n- ImportFormats.DataNodeState : the [state of a data node](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-state) can be either active or inactive.", + "\n- ImportFormats.DataNodeParameter : parameters are described [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-parameters). For **Group of Insurance Contracts** a default [Premium Allocation factor](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Import/ImportScopeCalculation#experience-adjustment-on-premium) of 1 is applied if the parameter is not imported.", "\n" ], "metadata": {}, diff --git a/ifrs17-template/InputFormatDescription.ipynb b/ifrs17-template/InputFormatDescription.ipynb index 42f72726..1087fa85 100644 --- a/ifrs17-template/InputFormatDescription.ipynb +++ b/ifrs17-template/InputFormatDescription.ipynb @@ -39,18 +39,18 @@ "source": [ "A cash flow file is named **NominalCashflows** *\\_* *\\_* *\\_* and is composed of two sections: **Main** and **Cashflow**.", "\n", - "\nThe **Main** section contains information such as: Reporting Node, Year, Month and Scenario for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#partitions) to which the data belongs.", + "\nThe **Main** section contains information such as: Reporting Node, Year, Month and Scenario for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#partitions) to which the data belongs.", "\n", "\nThe **Cashflow** section contains the cash flow data. Several pieces of information are required to characterize a cash flow correctly:", - "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", - "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", - "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", - "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#aoc-type) : entered with its SystemName,", - "\n- [Novelty](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#novelty) : entered with its SystemName,", + "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", + "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", + "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", + "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#aoc-type) : entered with its SystemName,", + "\n- [Novelty](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#novelty) : entered with its SystemName,", "\n- AccidentYear : relevant for Data Node with Liability Type: Liability for Incurred Claims.", "\n", - "\nAll valid combinations of AocType and Novelty can be found in [AocConfiguration](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#aoc-configuration) with DataType Optional or Mandatory.", - "\n
The cash flow is entered in the columns named ValuesN where N goes from 0 to the lenght of cash flow. The Value0 corresponds to January of the Year entered in the **Main** section for every combination of AocType and Novelty. " + "\nAll valid combinations of AocType and Novelty can be found in [AocConfiguration](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#aoc-configuration) with DataType Optional or Mandatory.", + "\n
The cash flow is entered in the columns named ValuesN where N goes from 0 to the length of cash flow. The Value0 corresponds to January of the Year entered in the **Main** section for every combination of AocType and Novelty. " ], "metadata": {}, "execution_count": 0, @@ -74,13 +74,13 @@ "source": [ "An Actuals file is named **Actuals** *\\_* *\\_* *\\_* and is composed of two sections: **Main** and **Actual**.", "\n", - "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#partition) to which the data belong.", + "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#partition) to which the data belong.", "\n", "\nThe **Actual** section contains the actuals data. Several pieces of information are required to to characterize an Actuals amount correctly:", - "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", - "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#aoc-type) : entered with its SystemName,", - "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", - "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", + "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", + "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#aoc-type) : entered with its SystemName,", + "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", + "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", "\n- AccidentYear : relevant for Data Node with Liability Type: Liability for Incurred Claims." ], "metadata": {}, @@ -105,12 +105,12 @@ "source": [ "An Openings file is named **Openings** *\\_* *\\_* *\\_* and is composed of two sections: **Main** and **Opening**. In an AoC for one period, we only need one file with the year/month combination of the beginning of the period. Some GICs do not need any entries in Openings.", "\n", - "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#partition) to which the data belong.", + "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#partition) to which the data belong.", "\n", "\nThe **Opening** section contains values at opening of an analysis. Several pieces of information are required to to characterize an Opening amount correctly:", - "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", - "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", - "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", + "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", + "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", + "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", "\n- AccidentYear : relevant for Data Node with Liability Type: Liability for Incurred Claims." ], "metadata": {}, diff --git a/ifrs17-template/OverviewIFRS17Template.ipynb b/ifrs17-template/OverviewIFRS17Template.ipynb index 8afb4069..95a010d7 100644 --- a/ifrs17-template/OverviewIFRS17Template.ipynb +++ b/ifrs17-template/OverviewIFRS17Template.ipynb @@ -61,7 +61,7 @@ "\n", "\nIf the entered cash flows are nominal (the usual case), the the present value (PV) of each cash flow is computed using proper yield curves for discounting.", "\n", - "\nA central element of IFRS 17 is the Analysis of Change (AoC). The present value of the business (future cash flows) changes from the beginning to the end of the accounting period due to different effects, each of them constituting a modeled AoC step.", + "\nA central element of IFRS 17 is the Analysis of Change (AoC). The present value of the business (future cash flows) changes from the beginning to the end of the accounting period due to different effects, each of them constituting a modeled AoC Step.", "\n", "\nIn IFRS 17, the value of future profitable business has a component called the Contractual Service Margin (CSM), defined at GIC level. The profit measured as CSM is recognized slowly over time rather than immediately in financial performance statements. On the other hand, a GIC can be onerous and produce a Loss Component (LC) instead, which needs to be recognized immediately.", "\n", @@ -151,13 +151,13 @@ "\n## Data input: Groups of insurance and reinsurance contracts", "\n", "\nSee folder Files/TransactionalData.", - "\n- **Actuals** *\\_* *\\_* *\\_*: List of all actual amounts for those GICs and GRICs that are used by the given reporting node/year/month combination, for different amount types, AoC types and other attributes; we need at least two such files for the two dates of the Analysis of Change", + "\n- **Actuals** *\\_* *\\_* *\\_*: List of all actual amounts for those GICs and GRICs that are used by the given reporting node/year/month combination, for different amount types, AoC Types and other attributes; we need at least two such files for the two dates of the Analysis of Change", "\n$$", "\n$$", "\n- **Openings** *\\_* *\\_* *\\_*: List of the opening amounts for some GICs that are used by the given reporting node. The year/month combination corresponds to the beginning of the planned Analysis of Change period, so only one such file is required. The entries are by EstimateType and AmountType.", "\n$$", "\n$$", - "\n- **NominalCash flows** *\\_* *\\_* *\\_*: List of all projected cash flows for those GICs and GRICs that are used by the given reporting node/year/month combination, for different amount types, AoC types, novelty types and other attributes, where the cash flow amounts are given in a regular sequence extending as far as needed; we need at least two such files for the two dates of the Analysis of Change", + "\n- **NominalCash flows** *\\_* *\\_* *\\_*: List of all projected cash flows for those GICs and GRICs that are used by the given reporting node/year/month combination, for different amount types, AoC Types, novelty types and other attributes, where the cash flow amounts are given in a regular sequence extending as far as needed; we need at least two such files for the two dates of the Analysis of Change", "\n", "\nThe structure of the [Actuals](./InputFormatDescription#actual), [Openings](./InputFormatDescription#opening) and [Nominal Cash flows](./InputFormatDescription#cashflow) files is explained in a special [notebook](./InputFormatDescription).", "\n", @@ -203,7 +203,9 @@ "", "\n# Reports", "\n", - "\nAll the reports are produced by running a notebook such as **[Reports](./Report/Reports#report-production)**." + "\nAll the reports of the calculated IFRS 17 figures are produced by running a notebook such as **[Reports](./Report/Reports#report-production)**.", + "\n", + "\nAll the reports of the paramaters used in the calculation of the IFRS 17 figures are produced by running a notebook such as **[ParameterReports](./Report/ParameterReports)**." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/README.md b/ifrs17-template/README.md index 5e994ebe..e6033e6a 100644 --- a/ifrs17-template/README.md +++ b/ifrs17-template/README.md @@ -59,6 +59,30 @@ Follow step by step our [Get Started](https://youtu.be/WQFn58gFhaM) video and ex For more information on our IFRS 17 initiative check out our [IFRS 17 page](https://systemorph.com/). +## Practical Use Cases + +Interact with our IFRS 17 practical use cases. Analyze your data and create new use cases. + +
+ +
+ +### Actuals outside the period + +Compare use-cases of [actuals](./PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports) paid outside the reporting period. + +
+
+ +### Contractual service margin : single vs multiple switch + +Compare the effects of modelling the [CSM - LC switch](./PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports) with a single vs multiple switch logic. + +
+ +
+ +
## Got Questions? diff --git a/ifrs17-template/Report/ParameterReports.ipynb b/ifrs17-template/Report/ParameterReports.ipynb index b1823e77..8b1c6d9c 100644 --- a/ifrs17-template/Report/ParameterReports.ipynb +++ b/ifrs17-template/Report/ParameterReports.ipynb @@ -18,16 +18,36 @@ { "cell_type": "markdown", "source": [ - "# Data Initialization" + "", + "\n

Parameter Reports

" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "For demonstration purposes we import here data for some *Group of Insurance Contract* (GIC) and *Group of Reinsurance Contract* (GRIC) - the import is triggered in the [Set up data and configuration](#set-up-data-and-configuration) section.", + "\n
The imported data set consists of cash flows, actuals, and parameters.", + "\n
Input files can be found in the **File** directory. You are invited to change them or upload your own or add new data in the [CloseImportTemplate](../Import/CloseImportTemplate) notebook. ", + "\n", + "\nIn this notebook we show the parameters (provided to the calculation engine as inputs) used to performe the calculation of the reports shown in [Reports](Reports) notebook." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Set up data and configuration", + "\n", + "\nChoose to run the Reports notebook either with the set of Systemorph data in memory or with the data present in the Database: ", + "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", + "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", + "\n", + "\nWe use here the in-memory set up." ], "metadata": {}, "execution_count": 0, @@ -36,7 +56,7 @@ { "cell_type": "code", "source": [ - "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" + "#!eval-notebook \"../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -54,7 +74,9 @@ { "cell_type": "markdown", "source": [ - "# Args" + "# Args", + "\n", + "\nDefine the reporting node, year, month, and scenario for which the parameter reports should be loaded. " ], "metadata": {}, "execution_count": 0, @@ -63,7 +85,11 @@ { "cell_type": "code", "source": [ - "var args = new ImportArgs(\"CH\", 2021, 3, default, default , default);" + "var reportinNode = \"CH\";", + "\nvar year = 2021;", + "\nvar month = 3;", + "\nvar scenario = (string)default;", + "\nvar args = new ImportArgs(reportinNode, year, month, default, scenario, default);" ], "metadata": {}, "execution_count": 0, @@ -72,7 +98,10 @@ { "cell_type": "markdown", "source": [ - "# Data Node" + "# Retrieve data ", + "\n", + "\nThe parameters used for calculation of the provided period are here retrieved through queries.", + "\nThe queries and the data model of the reported objects can be foud in the [ParameterReportQueries](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ParameterReportsQueries#queries)" ], "metadata": {}, "execution_count": 0, @@ -99,7 +128,7 @@ { "cell_type": "code", "source": [ - "var allYieldCurves = await Workspace.GetYieldCurveReportParametersAsync(args);;" + "var allYieldCurves = await Workspace.GetYieldCurveReportParametersAsync(args);" ], "metadata": {}, "execution_count": 0, @@ -108,7 +137,7 @@ { "cell_type": "code", "source": [ - "var singleDataNodeParameters = await Workspace.GetSingleDataNodeReportParametersAsync(args);;" + "var singleDataNodeParameters = await Workspace.GetSingleDataNodeReportParametersAsync(args);" ], "metadata": {}, "execution_count": 0, @@ -117,7 +146,7 @@ { "cell_type": "code", "source": [ - "var interDataNodeParameters = await Workspace.GetInterDataNodeParametersAsync(args);;" + "var interDataNodeParameters = await Workspace.GetInterDataNodeParametersAsync(args);" ], "metadata": {}, "execution_count": 0, @@ -135,7 +164,7 @@ { "cell_type": "code", "source": [ - "var partnerDefaultRates = await Workspace.GetCreditDefaultRatesReportParametersAsync(args);;" + "var partnerDefaultRates = await Workspace.GetCreditDefaultRatesReportParametersAsync(args);" ], "metadata": {}, "execution_count": 0, @@ -154,7 +183,7 @@ "cell_type": "markdown", "source": [ "## Data node", - "\nProperties of the Group of Contracts and corresponding Portfolios are merged to provide a full description of the [Data Node](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructureDataStructure#data-node)" + "\nProperties of the Group of Contracts and corresponding Portfolios are merged to provide a full description of the [Data Node](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructureDataStructure#data-node)" ], "metadata": {}, "execution_count": 0, @@ -178,7 +207,7 @@ "source": [ "## Data node state", "\n", - "\nCurrent and previous period [data node state](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-state)." + "\nCurrent and previous period [data node state](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-state)." ], "metadata": {}, "execution_count": 0, @@ -203,7 +232,7 @@ "cell_type": "markdown", "source": [ "## Yield curve", - "\n[Yield Curve](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#yield-curve) used for locked-in discounting and current rating discouning (curret period and previous period) are shown." + "\n[Yield Curve](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#yield-curve) used for locked-in discounting and current rating discouning (curret period and previous period) are shown." ], "metadata": {}, "execution_count": 0, @@ -227,7 +256,7 @@ "cell_type": "markdown", "source": [ "## Single data node parameter", - "\n[Single data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-parameters) for current and previous period. " + "\n[Single data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-parameters) for current and previous period. " ], "metadata": {}, "execution_count": 0, @@ -251,7 +280,7 @@ "cell_type": "markdown", "source": [ "## Inter data node parameter", - "\n[Inter data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#data-node-parameters) for current and previous period. " + "\n[Inter data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#data-node-parameters) for current and previous period. " ], "metadata": {}, "execution_count": 0, @@ -275,7 +304,7 @@ "cell_type": "markdown", "source": [ "## Partner ratings", - "\n[Partner ratings](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#partner-rating) for current and previous period." + "\n[Partner ratings](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#partner-rating) for current and previous period." ], "metadata": {}, "execution_count": 0, @@ -299,7 +328,7 @@ "cell_type": "markdown", "source": [ "## Partner default rates", - "\n[Partner default rates](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/DataModel/DataStructure#credit-default-rate) for current and previous period." + "\n[Partner default rates](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/DataModel/DataStructure#credit-default-rate) for current and previous period." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/Reports.ipynb b/ifrs17-template/Report/Reports.ipynb index 12250b90..d22f25e8 100644 --- a/ifrs17-template/Report/Reports.ipynb +++ b/ifrs17-template/Report/Reports.ipynb @@ -30,7 +30,7 @@ { "cell_type": "markdown", "source": [ - "For demonstration purposes we import here data for some *Group of Insurance Contract* (GIC) and *Group of Reinsurance Contract* (GRIC) - the import is triggered in the [Set up data and configuration](#set-up-data-and-configuration).", + "For demonstration purposes we import here data for some *Group of Insurance Contract* (GIC) and *Group of Reinsurance Contract* (GRIC) - the import is triggered in the [Set up data and configuration](#set-up-data-and-configuration) section.", "\n
The imported data set consists of cash flows, actuals, and parameters.", "\n
Input files can be found in the **File** directory. You are invited to change them or upload your own or add new data in the [CloseImportTemplate](../Import/CloseImportTemplate) notebook. ", "\n
For simplicity, we import similar transactional data for all GICs and GRICs. Each *Group of Contracts* produces different figures due to differences in parameters such as *Liability Type*, *Oci type* or *Premium allocation factor* to Contractual Service Margin.", @@ -80,7 +80,7 @@ "source": [ "# Best Estimate", "\n", - "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", + "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", "\n", "\nThe granularity of the reported figures can be modified by changing the Column Slices options.", "\nFor example one can add \"GroupOfContract\" to separate the contributions of the individual Group of Contracts.", @@ -111,7 +111,7 @@ "source": [ "# Risk Adjustment", "\n", - "\nPresent values of the [risk adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#risk-adjustment) future cash flows are shown here.", + "\nPresent values of the [risk adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#risk-adjustment) future cash flows are shown here.", "\n", "\nThe additional ColumnSlices are added to the view as the inner column. This can dicrease the readability of the report. For example, adding the slice by \"GroupOfContract\" leaves the lock-in and current rate contributions far apart and difficult to compare. The re-order of default slices with custom slices is achieved by esplicitly add the default slice among the custom slices. In our case, you can try entering both \"GroupOfContract\" and \"EconomicBasis\" separated by a comma in the ColumnSlices." ], @@ -138,7 +138,7 @@ "source": [ "# Written Actuals", "\n", - "\n[Written Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#written-accrual-deferral) are shown here. ", + "\n[Written Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#written-accrual-deferral) are shown here. ", "\n", "\nIn this case, the analysis of change view is replaced with a default slice by the **AmountTypes**. Only the amount type with non zero value are displayed. ", "\n
Filters can be applied to reports in order to isolate a sub-set of the data. They are specified by the name of the dimension to filter and the system name of the desired value. For example, to investigate the contribution of a single Group of Contract the following filter can be applied: new [] {(\"GroupOfContract\", \"DT1.1\")}." @@ -166,8 +166,8 @@ "source": [ "## Advance, Overdue Actuals", "\n", - "\nActuals payed in [Advance](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#written-accrual-deferral)", - "\nor [Overdue](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#written-accrual-deferral) are shown here together in a simplified Analysis of Change. ", + "\nActuals payed in [Advance](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#written-accrual-deferral)", + "\nor [Overdue](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#written-accrual-deferral) are shown here together in a simplified Analysis of Change. ", "\n", "\nCombining Filters and ColumnSlices facilitate the report analysis. For example, you can select \"GroupOfContract\" as column slices with a Filter on EstimateType \"AA\" to analyse the Advance Actuals for all Group of Contract. " ], @@ -194,7 +194,7 @@ "source": [ "## Deferrable Actuals", "\n", - "\n[Deferrable Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#written-accrual-deferral) are shown here. Amortization of the deferrable amount is computed using the Coverage Unit pattern. " + "\n[Deferrable Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#written-accrual-deferral) are shown here. Amortization of the deferrable amount is computed using the Coverage Unit pattern. " ], "metadata": {}, "execution_count": 0, @@ -219,7 +219,7 @@ "source": [ "# Fulfilment Cash flow", "\n", - "\nPresent Value of the [Fulfilment Cash flow](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#fulfillment-cash-flows) are shown here. ", + "\nPresent Value of the [Fulfilment Cash flow](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#fulfillment-cash-flows) are shown here. ", "\n
The individual contributions from Best Estimate and Risk Adjustment can be visualized slicing by **EstimateType**.", "\n", "\nFilters can be applied to report to isolate a sub-set of the data. For example you can Filter by a specific Group of Contract using its system name using : new [] {(\"GroupOfContract\", \"DT1.1\")}.", @@ -248,7 +248,7 @@ "source": [ "# Actuarial Experience Adjustment", "\n", - "\nA comparison between [Written Actual](#written-actual) and the Releases of the [Best Estimate](#present-value) is reported in the [Actuarial Experience Adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#experience-adjustment)." + "\nA comparison between [Written Actual](#written-actual) and the Releases of the [Best Estimate](#present-value) is reported in the [Actuarial Experience Adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#experience-adjustment)." ], "metadata": {}, "execution_count": 0, @@ -273,7 +273,7 @@ "source": [ "# LRC Technical Margin", "\n", - "\nIn the [Technical Margin](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#technical-margin) report we present a unified view on the figures that are allocated to either Contractual Service Margin or to Loss Component. ", + "\nIn the [Technical Margin](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#technical-margin) report we present a unified view on the figures that are allocated to either Contractual Service Margin or to Loss Component. ", "\n
The Analysis of Change is expanded with few more steps such as **Experience Adjustment** and **Amortization**." ], "metadata": {}, @@ -299,7 +299,7 @@ "source": [ "# Contractual Service Margin / Loss Component / Loss Recovery Component", "\n", - "\nThe Contractual Service Margin (CSM) / Loss Component (LC) / Loss Recovery Component (LR) [report](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#technical-margin) are here shown side by side as the allocation to profit or loss is done at each step of the Analysis of Change. ", + "\nThe Contractual Service Margin (CSM) / Loss Component (LC) / Loss Recovery Component (LR) [report](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#technical-margin) are here shown side by side as the allocation to profit or loss is done at each step of the Analysis of Change. ", "\n", "\nA default slice by EstimateType - which distinguish between CSM, LC and LR contributions - is automatically enforced. " ], @@ -326,7 +326,7 @@ "source": [ "# LRC Actuarial", "\n", - "\nThe [Actuarial Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#lrc-actuarial-actuarial-liability-for-remaining-coverage) report shows figures from Fulfilment Cash flow discounted with current yield curve, and the allocated techinical margin. " + "\nThe [Actuarial Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#lrc-actuarial-actuarial-liability-for-remaining-coverage) report shows figures from Fulfilment Cash flow discounted with current yield curve, and the allocated techinical margin. " ], "metadata": {}, "execution_count": 0, @@ -351,7 +351,7 @@ "source": [ "# LRC", "\n", - "\nThe [Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#lrc-liability-for-remaining-coverage) report adds to the [Actuarial Liability for Remaining Coverage](#lrc-actuarial) the contribution of and accrual actuals. A simplified AoC Chain is used to allow comparison of the balance change between Actuals and Present Values. " + "\nThe [Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#lrc-liability-for-remaining-coverage) report adds to the [Actuarial Liability for Remaining Coverage](#lrc-actuarial) the contribution of and accrual actuals. A simplified AoC Chain is used to allow comparison of the balance change between Actuals and Present Values. " ], "metadata": {}, "execution_count": 0, @@ -376,7 +376,7 @@ "source": [ "# LIC Actuarial", "\n", - "\nThe [Actuarial Liability of Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#lic-actuarial-actuarial-liability-for-incurred-claims) report shows figures from Fulfilment Cash flow discounted with current yield curve. " + "\nThe [Actuarial Liability of Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#lic-actuarial-actuarial-liability-for-incurred-claims) report shows figures from Fulfilment Cash flow discounted with current yield curve. " ], "metadata": {}, "execution_count": 0, @@ -401,7 +401,7 @@ "source": [ "# LIC", "\n", - "\nThe [Liability for Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#lic-liability-for-incurred-claims) adds to the [Actuarial Liability for Incurred Claims](#lic-actuarial) the contribution of and accrual actuals." + "\nThe [Liability for Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#lic-liability-for-incurred-claims) adds to the [Actuarial Liability for Incurred Claims](#lic-actuarial) the contribution of and accrual actuals." ], "metadata": {}, "execution_count": 0, @@ -426,7 +426,7 @@ "source": [ "# Financial Performance", "\n", - "\nThe [Financial Performance](https://portal.systemorph.cloud/project/ifrs17/env/v1.0.0/Report/ReportScopes#ifrs-17-financial-performance) report discloses the Change in Estimate of the IFRS 17 balance sheet items ([LRC](#lrc) and [LIC](#lic)) and the relevant incurred cash flows (Premiums, Claims, Expenses, etc...) for the given period.", + "\nThe [Financial Performance](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#ifrs-17-financial-performance) report discloses the Change in Estimate of the IFRS 17 balance sheet items ([LRC](#lrc) and [LIC](#lic)) and the relevant incurred cash flows (Premiums, Claims, Expenses, etc...) for the given period.", "\n", "\nUse the expand and collapse buttons in the report rows to change the granularity of the figures displayed." ], diff --git a/ifrs17-template/Test/Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv b/ifrs17-template/Test/Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv new file mode 100644 index 00000000..885890c3 --- /dev/null +++ b/ifrs17-template/Test/Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv @@ -0,0 +1,11 @@ +@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,,, +CH,2020,12,,,,,,,,,,,,,,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +DataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 +DT1.1,NIC,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +DT1.1,,CU,BOP,N,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3 +DT1.1,,RA,BOP,N,,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5 +DT1.1,NIC,BE,CL,C,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +DT1.1,,CU,CL,C,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3 +DT1.1,,RA,CL,C,,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5 diff --git a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb new file mode 100644 index 00000000..7e911369 --- /dev/null +++ b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb @@ -0,0 +1,198 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Reimport With Different Scope Test

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Cash flow Import", + "\n", + "\nImporting a file with N GICs and GRICs." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", + "\n .WithFormat(ImportFormats.Cashflow)", + "\n .WithTarget(DataSource)", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ifrsVars1 = await DataSource.Query().ToArrayAsync();", + "\nvar dn1 = ifrsVars1.Select(x => x.DataNode).ToHashSet();", + "\nvar dt11Prem1 = ifrsVars1.Where(x => x.DataNode == \"DT1.1\" && x.AmountType == \"PR\");", + "\n(ifrsVars1.Count(), dn1.Count(), dt11Prem1.Count())" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Cash flow Import - restatement", + "\nImporting a file for the same period as previous import but it only contains 1 GIC: DT1.1 where one amount type (Premium) has been removed" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv\")", + "\n .WithFormat(ImportFormats.Cashflow)", + "\n .WithTarget(DataSource)", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ifrsVars2 = await DataSource.Query().ToArrayAsync();", + "\nvar dn2 = ifrsVars2.Select(x => x.DataNode).ToHashSet();", + "\nvar dt11Prem2 = ifrsVars2.Where(x => x.DataNode == \"DT1.1\" && x.AmountType == \"PR\");", + "\n(ifrsVars2.Count(), dn2.Count(), dt11Prem2.Count())" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Import generate variables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrsVars1.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrsVars2.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Count of data nodes does not change" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "dn2.Count().Should().Be(dn1.Count());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Premiums are present with the first import and then deleted" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "dt11Prem1.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "dt11Prem2.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Test/ScenarioDataImportTest.ipynb b/ifrs17-template/Test/ScenarioDataImportTest.ipynb index c372ff33..e6603fef 100644 --- a/ifrs17-template/Test/ScenarioDataImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioDataImportTest.ipynb @@ -42,16 +42,49 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Setting Constants" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "var ws = Workspace.CreateNew();", - "\nws.InitializeFrom(DataSource);", - "\nvar argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", - "\nvar argsScenario = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"Test\", ImportFormats.Cashflow);", - "\nvar initStorage = new ImportStorage(argsBestEstimate, DataSource, ws);", - "\nawait initStorage.InitializeAsync();", - "\nvar actualETs = initStorage.EstimateTypesByImportFormat[ImportFormats.Actual];", + "\nws.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", + "\nvar argsScenario = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"Test\", ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var initStorage = new ImportStorage(argsBestEstimate, DataSource, ws);", + "\nawait initStorage.InitializeAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actualETs = initStorage.EstimateTypesByImportFormat[ImportFormats.Actual];", "\nvar cashflowETs = initStorage.EstimateTypesByImportFormat[ImportFormats.Cashflow];", "\nvar actualOrCashflowETs = actualETs.Intersect(cashflowETs);", "\nvar onlyActualETs = actualETs.Except(cashflowETs);", @@ -192,9 +225,11 @@ { "cell_type": "code", "source": [ - "actualVars.Length.Should().Be(0);", - "\ncashflowVars.Length.Should().NotBe(0);", - "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);" + "if(EnableScenario) {", + "\n actualVars.Length.Should().Be(0);", + "\n cashflowVars.Length.Should().NotBe(0);", + "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -250,9 +285,11 @@ { "cell_type": "code", "source": [ - "actualVars.Length.Should().NotBe(0);", - "\ncashflowVars.Length.Should().Be(0);", - "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);" + "if(EnableScenario) {", + "\n actualVars.Length.Should().NotBe(0);", + "\n cashflowVars.Length.Should().Be(0);", + "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -317,9 +354,11 @@ { "cell_type": "code", "source": [ - "actualVars.Length.Should().Be(0);", - "\ncashflowVars.Length.Should().NotBe(0);", - "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);" + "if(EnableScenario) {", + "\n actualVars.Length.Should().Be(0);", + "\n cashflowVars.Length.Should().NotBe(0);", + "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -376,9 +415,11 @@ { "cell_type": "code", "source": [ - "diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", - "\ndiffs.Where(x => x.EstimateType == EstimateTypes.F).ToArray().Length.Should().Be(0);", - "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);" + "if(EnableScenario) {", + "\n diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", + "\n diffs.Where(x => x.EstimateType == EstimateTypes.F).ToArray().Length.Should().Be(0);", + "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -441,9 +482,11 @@ { "cell_type": "code", "source": [ - "diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", - "\nivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.F).Count().Should().NotBe(0);", - "\nivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.DA && Math.Abs(x.Value) > Precision).Count().Should().Be(0);" + "if(EnableScenario) {", + "\n diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", + "\n ivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.F).Count().Should().NotBe(0);", + "\n ivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.DA && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -525,7 +568,7 @@ { "cell_type": "code", "source": [ - "diffs.Count().Should().Be(0);" + "if(EnableScenario) diffs.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -619,8 +662,10 @@ { "cell_type": "code", "source": [ - "diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType) && x.EstimateType != EstimateTypes.F && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", - "\ndiffs.Where(x => onlyActualETs.Contains(x.EstimateType) && Math.Abs(x.Value) > Precision).Count().Should().Be(0);" + "if(EnableScenario) {", + "\n diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType) && x.EstimateType != EstimateTypes.F && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", + "\n diffs.Where(x => onlyActualETs.Contains(x.EstimateType) && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -680,9 +725,11 @@ { "cell_type": "code", "source": [ - "cashflowVars.Length.Should().NotBe(0);", - "\nactualVars.Length.Should().Be(0);", - "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);" + "if(EnableScenario) {", + "\n cashflowVars.Length.Should().NotBe(0);", + "\n actualVars.Length.Should().Be(0);", + "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -762,9 +809,11 @@ { "cell_type": "code", "source": [ - "actualVars.Length.Should().Be(0);", - "\ncashflowVars.Length.Should().NotBe(0);", - "\ncashflowVars.Where(x => x.EstimateType == EstimateTypes.DA).Count().Should().Be(0);" + "if(EnableScenario) {", + "\n actualVars.Length.Should().Be(0);", + "\n cashflowVars.Length.Should().NotBe(0);", + "\n cashflowVars.Where(x => x.EstimateType == EstimateTypes.DA).Count().Should().Be(0);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -877,8 +926,28 @@ { "cell_type": "code", "source": [ - "actualVars.Length.Should().Be(0);", - "\ncashflowVars.Length.Should().NotBe(0);" + "if(EnableScenario) {", + "\n actualVars.Length.Should().Be(0);", + "\n cashflowVars.Length.Should().NotBe(0);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb new file mode 100644 index 00000000..002c811c --- /dev/null +++ b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb @@ -0,0 +1,513 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Scenario Yield Curve Import Test

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "DataSource.Reset(x => x.ResetType().ResetType().ResetType());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Setting Constants" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws = Workspace.CreateNew();", + "\nws.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", + "\nvar argsScenarioYieldCurve = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"YCUP1.0pct\", ImportFormats.Cashflow);", + "\nvar argsScenarioTransactionalData = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"SRUP1.0pct\", ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var initStorage = new ImportStorage(argsBestEstimate, DataSource, ws);", + "\nawait initStorage.InitializeAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actualEstimateTypes = initStorage.EstimateTypesByImportFormat[ImportFormats.Actual];", + "\nvar cashflowEstimateTypes = initStorage.EstimateTypesByImportFormat[ImportFormats.Cashflow];", + "\nvar actualAndCashflowEstimateTypes = actualEstimateTypes.Intersect(cashflowEstimateTypes);", + "\nvar onlyActualEstimateTypes = actualEstimateTypes.Except(cashflowEstimateTypes);", + "\nvar onlyCashflowEstimateTypes = cashflowEstimateTypes.Except(actualEstimateTypes);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Best Estimate Initialization" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var basicYieldCurve = @\"", + "\n@@Main", + "\nYear,Month,Scenario", + "\n2020,1,", + "\n@@YieldCurve", + "\nCurrency,Values0,Values1,Values2,Values3", + "\nUSD,0.002,0.002,0.002,0.002\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(basicYieldCurve).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflowBestEstimateInit = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,", + "\n@@Cashflow", + "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,BE,CL,C,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0", + "\nDT1.1,NIC,BE,CL,C,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25", + "\nDT1.1,,CU,CL,C,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3", + "\nDT1.1,,RA,CL,C,,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5", + "\nDTR1.1,PR,BE,CL,C,,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0", + "\nDTR1.1,NIC,BE,CL,C,,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5", + "\nDTR1.1,,CU,CL,C,,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5", + "\nDTR1.1,,RA,CL,C,,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actualsBestEstimateInit = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,", + "\n@@Actual", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDT1.1,CF,ACA,A,,-10", + "\nDT1.1,CF,AEA,A,,-5", + "\nDT1.1,CF,NIC,A,,-280", + "\nDT1.1,CF,PR,A,,400", + "\nDTR1.1,CF,PR,A,,-200", + "\nDTR1.1,CF,NIC,A,,140\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflowBestEstimateInit).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(actualsBestEstimateInit).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimate);", + "\nvar ivsBestEstimateInit = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Scenario Yield Curve Import" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var yieldCurveScenario = @\"", + "\n@@Main", + "\nYear,Month,Scenario", + "\n2020,12,YCUP1.0pct", + "\n@@YieldCurve", + "\nCurrency,Values0,Values1,Values2,Values3", + "\nEUR,0.108,0.108,0.118,0.119", + "\nCHF,0.102,0.102,0.102,0.102", + "\nUSD,0.102,0.102,0.102,0.102\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(yieldCurveScenario).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioYieldCurve);", + "\nvar ivsScenarioYieldCurve = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioYieldCurve.Where(x => Math.Abs(x.Value) > Precision).Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());", + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "if(EnableScenario) {", + "\n actualVars.Length.Should().Be(0);", + "\n cashflowVars.Length.Should().NotBe(0);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Re-Import of the same Yield Curve does not trigger IFRS17 Calculations" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(yieldCurveScenario).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioYieldCurve);", + "\nvar ivsScenarioYieldCurveReimport = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioYieldCurve.Except(ivsScenarioYieldCurve, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "if(EnableScenario) diffs.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Multiple Scenarios ", + "\n", + "\nIn this example, a new Cashflow for a different Scenario - SRUP1.0pct - is imported. ", + "\nThe aim is to check how the Yield Curve importer behaves when a new Best Estimate Yield Curve is imported. ", + "\nWe can identify the following two cases: ", + "\n - a Scenario including a dedicated Yield Curve: only the Best Estimate variables are re-calculated;", + "\n - a Scenario including only transactional data: re-calculation is needed to account for the updated Best Estimate Yield Curve. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflowScenario = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,SRUP1.0pct", + "\n@@Cashflow", + "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,BE,CL,C,,110,0,0,110,0,0,110,0,0,110,0,0,0,110,0,0,110,0,0,110,0,0,110,0", + "\nDT1.1,NIC,BE,CL,C,,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5", + "\nDT1.1,,RA,CL,C,,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflowScenario).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioTransactionalData);", + "\nvar ivsScenarioTransactionalData = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var bestEstimateYieldCurve = @\"", + "\n@@Main", + "\nYear,Month", + "\n2020,12", + "\n@@YieldCurve", + "\nCurrency,Values0,Values1,Values2,Values3", + "\nEUR,0.108,0.108,0.118,0.119", + "\nCHF,0.103,0.103,0.103,0.103", + "\nUSD,0.903,0.103,0.103,0.103\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(bestEstimateYieldCurve).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate variables are re-calculated" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimate);", + "\nvar ivsBestEstimateUpdated = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsBestEstimateUpdated.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "if(EnableScenario) if(EnableScenario) diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario with dedicated Yield Curve does not change" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioYieldCurve);", + "\nvar ivsScenarioYieldCurveUpdated = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioYieldCurveUpdated.Where(x => Math.Abs(x.Value) > Precision).Except(ivsScenarioYieldCurve, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "if(EnableScenario) diffs.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario including Transactional Data solely is re-calculated" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioTransactionalData);", + "\nvar ivsScenarioTransactionalDataUpdated = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioTransactionalDataUpdated.Where(x => Math.Abs(x.Value) > Precision).Except(ivsScenarioTransactionalData, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "if(EnableScenario) diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index c493097e..cf5f7611 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -30,7 +30,7 @@ "cell_type": "markdown", "source": [ "Comprehensive collection of tests executed on top of the Systemorph use cases (initialization).", - "\n
Execute this Notebook using at least 16Gb RAM." + "\n
Execute this Notebook using at least 14Gb RAM." ], "metadata": {}, "execution_count": 0, @@ -48,25 +48,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"ImportStorageTest\"" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "#!eval-notebook \"ReportStorageTest\"" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "#!eval-notebook \"AocStructureTest\"" + "#!eval-notebook \"SequenceImportTest\"" ], "metadata": {}, "execution_count": 0, @@ -75,7 +57,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"TechnicalMarginTest\"" + "#!eval-notebook \"ReimportWithDifferentScopeTest\"" ], "metadata": {}, "execution_count": 0, @@ -84,7 +66,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"SequenceImportTest\"" + "#!eval-notebook \"ScenarioDataImportTest\"" ], "metadata": {}, "execution_count": 0, @@ -93,7 +75,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"ScenarioDataImportTest\"" + "#!eval-notebook \"ScenarioYieldCurveImportTest\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 08842d5a..23d90c66 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -27,6 +27,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public const bool EnableScenario = false;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index 5f22aca2..3fdcf95e 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -51,7 +51,7 @@ "source": [ "public enum Warning {", "\n // Import", - "\n ActiveDataNodeWithCashflowBOPI, VariablesAlreadyImported, VariablesAlreadyCalculated, ScenarioReCalculations,", + "\n ActiveDataNodeWithCashflowBOPI, VariablesAlreadyImported, VariablesAlreadyCalculated, ScenarioReCalculations, MandatoryAocStepMissing,", "\n // Default", "\n Generic", "\n}; " @@ -158,7 +158,7 @@ "\n (Error.CreditDefaultRateNotFound , 1) => $\"Credit Default Rate not found for rating {s[0]}.\",", "\n (Error.MissingPremiumAllocation , 1) => $\"Premium Allocation Rate not found for Group of Contract {s[0]}.\", // TODO: this is now a warning to be produced by a validation in the importers (default is 1)", "\n (Error.ReinsuranceCoverage , 1) => $\"Reinsurance Allocation Rate not found for Group of Insurance Contract {s[0]}.\",", - "\n (Error.YieldCurveNotFound , 3) => $\"Yield Curve not found for currency {s[0]}, year {s[1]}, and month {s[2]}.\",", + "\n (Error.YieldCurveNotFound , 5) => $\"Yield Curve not found for Currency {s[0]}, Year {s[1]}, Month {s[2]}, Scenario {(s[3] == null ? \"Best Estimate\" : s[3])} and Name {s[4]}.\",", "\n (Error.YieldCurvePeriodNotApplicable , 2) => $\"YieldCurve period NotApplicable not valid for AoC Step with AoC Type {s[0]} and Novelty {s[1]}.\",", "\n (Error.EconomicBasisNotFound , 1) => $\"EconomicBasis not valid for DataNode {s[0]}.\",", "\n (Error.AccountingVariableTypeNotFound , 1) => $\"AccountingVariableType {s[0]} not found.\",", @@ -184,7 +184,9 @@ "public static string Get (Warning w, params string[] s) => (w, s.Length) switch {", "\n // Import", "\n (Warning.ActiveDataNodeWithCashflowBOPI , 1) => $\"Cash flow with AoC Type: {AocTypes.BOP} and Novelty: {Novelties.I} for Group of Contract {s[0]} is not allowed because previous period data are available.\",", - "\n (Warning.ScenarioReCalculations , 1) => $\"The import of the current file for the Best Estimate scenario makes the result of dependent Scenarios out of date. Hence, the following Scenarios are recalculated: {s[0]}.\", ", + "\n (Warning.VariablesAlreadyImported , 0) => $\"The import of the current file does not contain any new data. Hence, no data will be saved or calculations will be performed.\",", + "\n (Warning.MandatoryAocStepMissing , 3) => $\"The AoC step ({s[0]}, {s[1]}) is not imported for ({s[2]}).\",", + "\n (Warning.ScenarioReCalculations , 1) => $\"The present Best Estimate import makes the result of dependent Scenarios out of date. Hence, the following Scenarios are re-calculated: {s[0]}.\", ", "\n // Default", "\n (Warning.Generic , _) => $\"{s[0]}\",", "\n (_ , _) => $\"Warning not found.\"", diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index f6fca951..e5136298 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -145,7 +145,7 @@ "\n await hierarchyCache.InitializeAsync();", "\n ", "\n //EstimateType to load and to update", - "\n EstimateTypesByImportFormat = new InputSource[] { InputSource.Opening, InputSource.Actual, InputSource.Cashflow,}", + "\n EstimateTypesByImportFormat = new InputSource[] { InputSource.Opening, InputSource.Actual, InputSource.Cashflow }", "\n .ToDictionary(x => x.ToString(), ", "\n x => estimateTypes", "\n .Where(et => et.InputSource.Contains(x))", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 52c5a764..fe8f34ec 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -69,6 +69,7 @@ "\n // Dimensions", "\n public Dictionary EstimateType;", "\n public Dictionary AmountType; ", + "\n public HashSet MandatoryAocSteps;", "\n public HashSet AocTypeMap;", "\n private HashSet estimateTypes;", "\n private HashSet amountTypes;", @@ -100,7 +101,8 @@ "\n await workspace.Partition.SetAsync(TargetPartitionByReportingNode.Id);", "\n await dataSource.Partition.SetAsync(TargetPartitionByReportingNode.Id);", "\n ", - "\n if(args.Year != default(int) && args.Month != default(int))", + "\n if(args.ImportFormat == ImportFormats.Cashflow || args.ImportFormat == ImportFormats.Actual || ", + "\n args.ImportFormat == ImportFormats.SimpleValue || args.ImportFormat == ImportFormats.Opening)", "\n {", "\n TargetPartitionByReportingNodeAndPeriod = (await workspace.Query()", "\n .Where(p => p.ReportingNode == args.ReportingNode &&", @@ -124,6 +126,7 @@ "\n ReportingNode = reportingNodes.First();", "\n", "\n var aocConfigurationByAocStep = await dataSource.LoadAocStepConfigurationAsync(args.Year, args.Month);", + "\n MandatoryAocSteps = aocConfigurationByAocStep.Where(x => x.DataType == DataType.Mandatory).Select(x => new AocStep(x.AocType, x.Novelty)).ToHashSet();", "\n AocTypeMap = args.ImportFormat switch {", "\n ImportFormats.Cashflow => aocConfigurationByAocStep.Where(x => x.InputSource.Contains(InputSource.Cashflow) &&", "\n !new DataType[]{DataType.Calculated, DataType.CalculatedTelescopic}.Contains(x.DataType) )", @@ -135,10 +138,8 @@ "\n ImportFormats.Opening => aocConfigurationByAocStep.Where(x => x.InputSource.Contains(InputSource.Opening) && x.DataType == DataType.Optional).GroupBy(x => new AocStep(x.AocType, x.Novelty), (k,v) => k).ToHashSet(),", "\n ImportFormats.SimpleValue => aocConfigurationByAocStep.GroupBy(x => new AocStep(x.AocType, x.Novelty), (k,v) => k).Concat((await dataSource.Query().ToArrayAsync())", "\n .Select(vt => new AocStep(vt.SystemName,null))).ToHashSet(),", - "\n _ => Enumerable.Empty().ToHashSet(),", + "\n _ => Enumerable.Empty().ToHashSet(),", "\n };", - "\n ", - "\n //DataNodes", "\n DataNodeDataBySystemName = args.ImportFormat == ImportFormats.Opening ", "\n ? (await LoadDataNodesAsync(dataSource, args)).Where(kvp => kvp.Value.Year == args.Year).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)", "\n : await LoadDataNodesAsync(dataSource, args);", @@ -253,9 +254,11 @@ { "cell_type": "code", "source": [ - "public static async Task CleanAsync (this IDataSource dataSource, Expression> filter = null) where T : class", + "public static async Task CleanAsync (this IDataSource dataSource, Guid partitionId = default, Expression> filter = null) where T : class, IPartitioned", "\n{", - "\n var loadData = await dataSource.Query().Where(filter?? (Expression>)(x => true)).ToListAsync();", + "\n var loadData = partitionId != (Guid)default", + "\n ? await dataSource.Query().Where(x => x.Partition == partitionId ).Where(filter?? (Expression>)(x => true)).ToListAsync()", + "\n : await dataSource.Query().Where(filter ?? (Expression>)(x => true)).ToListAsync();", "\n await dataSource.DeleteAsync(loadData);", "\n}" ], @@ -281,11 +284,11 @@ "\nwhere TData : class, IPartitioned", "\nwhere TPartition : IfrsPartition", "\n{", - "\n if(partitionId != new Guid()) {", + "\n if(partitionId != (Guid)default) {", "\n await target.Partition.SetAsync(partitionId);", "\n await source.Partition.SetAsync(partitionId);", "\n }", - "\n if(snapshot) await CleanAsync(target, filter);", + "\n if(snapshot) await CleanAsync(target, partitionId, filter);", "\n await target.UpdateAsync( await source.Query().ToArrayAsync() );", "\n await target.CommitAsync();", "\n}" @@ -326,10 +329,10 @@ "\n if(ApplicationMessage.HasErrors()) return null;", "\n", "\n var main = mainTab.Rows.First();", - "\n var reportingNode = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.ReportingNode)) ? (string)main[nameof(ReportingNode)] : default(string);", - "\n var scenario = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.Scenario)) ? (string)main[nameof(Scenario)] : default(string);", - "\n var year = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.Year)) ? (int)Convert.ChangeType(main[nameof(Args.Year)], typeof(int)) : default(int);", - "\n var month = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.Month)) ? (int)Convert.ChangeType(main[nameof(Args.Month)], typeof(int)) : default(int);", + "\n var reportingNode = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.ReportingNode)) && main[nameof(Args.ReportingNode)] != null ? (string)main[nameof(ReportingNode)] : default(string);", + "\n var scenario = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.Scenario)) && main[nameof(Args.Scenario)] != null ? (string)main[nameof(Scenario)] : default(string);", + "\n var year = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.Year)) && main[nameof(Args.Year)] != null ? (int)Convert.ChangeType(main[nameof(Args.Year)], typeof(int)) : default(int);", + "\n var month = mainTab.Columns.Any(x => x.ColumnName == nameof(Args.Month)) && main[nameof(Args.Month)] != null ? (int)Convert.ChangeType(main[nameof(Args.Month)], typeof(int)) : default(int);", "\n", "\n return new ImportArgs(reportingNode, year, month, default(Periodicity), scenario, default(string));", "\n}" @@ -362,9 +365,57 @@ { "cell_type": "markdown", "source": [ - "## Get Args and commit Partition", + "## Create Partition", + "\n", + "\nThese are the methods used to create the partition if not already existing in the DataSource. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public async Task CommitPartitionAsync(ImportArgs args, params IDataSource[] dataSources)", + "\n{", + "\n foreach (var dataSource in dataSources) {", + "\n switch(typeof(IPartition).Name) {", + "\n case nameof(PartitionByReportingNode) : {", + "\n await dataSource.UpdateAsync( new[] { new PartitionByReportingNode { ", + "\n Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = args.ReportingNode } } );", + "\n break;", + "\n }", + "\n case nameof(PartitionByReportingNodeAndPeriod) : {", + "\n args.ValidateArgsForPeriod();", + "\n if(ApplicationMessage.HasErrors()) return;", + "\n await dataSource.UpdateAsync( new[]{ new PartitionByReportingNodeAndPeriod { ", + "\n Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n ReportingNode = args.ReportingNode, ", + "\n Scenario = args.Scenario } } );", + "\n break;", + "\n }", + "\n default : {", + "\n ApplicationMessage.Log(Error.PartitionTypeNotFound, typeof(IPartition).Name); ", + "\n return;", + "\n }", + "\n }", + "\n await dataSource.CommitAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Get Args and create Partition", "\n", - "\nThis is the main method to get Args which reference a specific data partition. All validations are triggered after parsing and if the partition is not already existing in the DataSource it is created and committed. " + "\nThis is the main method to get Args which reference a specific data partition. All validations are triggered after parsing and if the partition is not already existing in the DataSource it is created. " ], "metadata": {}, "execution_count": 0, @@ -378,32 +429,7 @@ "\n var args = GetArgsFromMain(dataSet);", "\n if(ApplicationMessage.HasErrors()) return null;", "\n if(args.ReportingNode == default(string)) { ApplicationMessage.Log(Error.ReportingNodeInMainNotFound); return null; }", - "\n", - "\n switch(typeof(IPartition).Name) {", - "\n case nameof(PartitionByReportingNode) : {", - "\n await DataSource.UpdateAsync( new[] { new PartitionByReportingNode { ", - "\n Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = args.ReportingNode } } );", - "\n break;", - "\n }", - "\n case nameof(PartitionByReportingNodeAndPeriod) : {", - "\n args.ValidateArgsForPeriod();", - "\n if(ApplicationMessage.HasErrors()) return null;", - "\n await DataSource.UpdateAsync( new[]{ new PartitionByReportingNodeAndPeriod { ", - "\n Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n ReportingNode = args.ReportingNode, ", - "\n Scenario = args.Scenario } } );", - "\n break;", - "\n }", - "\n default : {", - "\n ApplicationMessage.Log(Error.PartitionTypeNotFound, typeof(IPartition).Name); ", - "\n return null;", - "\n }", - "\n }", - "\n ", - "\n await DataSource.CommitAsync();", + "\n await CommitPartitionAsync(args, DataSource);", "\n return args;", "\n}" ], @@ -449,30 +475,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "## Validation for Active Data Node States" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public async Task ValidateForDataNodeStateActiveAsync(IWorkspace workspace, Dictionary dataNodes) where T : BaseDataRecord", - "\n{ ", - "\n foreach(var item in (await workspace.Query().ToArrayAsync()).GroupBy(x => x.DataNode))", - "\n if(!dataNodes.ContainsKey(item.First().DataNode))", - "\n ApplicationMessage.Log(Error.InactiveDataNodeState, item.First().DataNode);", - "\n}", - "\n" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -481,6 +483,7 @@ "\nThe following methods are used in the different importers to compute the [IfrsVariables](../DataModel/DataStructure#ifrs-variable).", "\n", "\nGetAllArgsAsync retrieves the partitions or Args that require computation. They are the union of the primary args (the one read from the main tab of the imported file) with the secondary args (senarios which depends on the best estimate data).", + "\n", "\nComputeAsync computes the IfrsVariables for a given partition (identified by its ImportArgs) and stores the results in a disposable workspace. This then serves as DataSource in the calculation of the secondary partitions (identified by the secondary args)." ], "metadata": {}, @@ -490,19 +493,42 @@ { "cell_type": "code", "source": [ - "public async Task GetAllArgsAsync(ImportArgs primaryArgs)", + "public async Task GetAllArgsAsync(ImportArgs args, IDataSource dataSource, string format)", "\n{", - "\n if (primaryArgs.Scenario != null)", - "\n return primaryArgs.RepeatOnce().ToArray();", - "\n", - "\n var secondaryArgs = await DataSource.Query() ", - "\n .Where(x => x.ReportingNode == primaryArgs.ReportingNode && x.Year == primaryArgs.Year && x.Month == primaryArgs.Month && x.Scenario != null)", - "\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArrayAsync();", + "\n ImportArgs[] allArgs;", + "\n switch(format)", + "\n {", + "\n case ImportFormats.YieldCurve : ", + "\n {", + "\n if(args.Scenario == null) {", + "\n var scenariosWithYieldCurves = await dataSource.Query().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null)", + "\n .Select(x => x.Scenario).Distinct().ToArrayAsync();", + "\n var targetPartitions = await dataSource.Query()", + "\n .Where(x => x.Year == args.Year && x.Month == args.Month && !scenariosWithYieldCurves.Contains(x.Scenario)).OrderBy(x => x.Scenario).ToArrayAsync();", + "\n var targetScenarios = targetPartitions.Where(x => x.Scenario != null).Select(x => x.Scenario);", + "\n if(targetScenarios.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", targetScenarios));", + "\n allArgs = targetPartitions.Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArray();", + "\n }", + "\n else {", + "\n allArgs = (await dataSource.Query()", + "\n .Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario == null).ToArrayAsync())", + "\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), args.Scenario, ImportFormats.Cashflow)).ToArray();", + "\n }", + "\n break;", + "\n }", + "\n default : ", + "\n {", + "\n if(args.Scenario != null) return args.RepeatOnce().ToArray();", + "\n var secondaryArgs = await DataSource.Query() ", + "\n .Where(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && x.Month == args.Month && x.Scenario != null)", + "\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArrayAsync();", "\n ", - "\n if (secondaryArgs.Any())", - "\n ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", secondaryArgs.Select(x => x.Scenario)));", - "\n ", - "\n return primaryArgs.RepeatOnce().Concat(secondaryArgs).ToArray();", + "\n if(secondaryArgs.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", secondaryArgs.Select(x => x.Scenario)));", + "\n allArgs = args.RepeatOnce().Concat(secondaryArgs).ToArray();", + "\n break;", + "\n }", + "\n }", + "\n return allArgs.Where(x => (!EnableScenario && x.Scenario == null) || EnableScenario).ToArray();", "\n}" ], "metadata": {}, @@ -525,7 +551,7 @@ "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n if(storage.DefaultPartition != storage.TargetPartition){", - "\n var bestEstimateIvs = await DataSource.LoadPartitionedDataAsync(storage.DefaultPartition, storage.TargetPartition);", + "\n var bestEstimateIvs = await DataSource.LoadPartitionedDataAsync(storage.DefaultPartition);", "\n ivs = ivs.Where(iv => Math.Abs(iv.Value) >= Precision).ToArray().Concat(", "\n ivs.Where(iv => Math.Abs(iv.Value) < Precision).Intersect(bestEstimateIvs, EqualityComparer.Instance).Select(iv => iv with {Value = 0.0}).ToArray());", "\n }", @@ -547,6 +573,102 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Validations" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Validation for Active Data Node States" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public async static Task ValidateForDataNodeStateActiveAsync(this IWorkspace workspace, Dictionary dataNodes) where T : BaseDataRecord", + "\n{ ", + "\n foreach(var item in (await workspace.Query().ToArrayAsync()).GroupBy(x => x.DataNode))", + "\n if(!dataNodes.ContainsKey(item.First().DataNode))", + "\n ApplicationMessage.Log(Error.InactiveDataNodeState, item.First().DataNode);", + "\n}", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Validate for Data Node States Logic" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public async static Task ValidateDataNodeStatesAsync(this IWorkspace workspace, Dictionary persistentDataNodeByDataNode)", + "\n{", + "\n foreach(var importedDataNodeState in await workspace.Query().ToArrayAsync())", + "\n {", + "\n if(persistentDataNodeByDataNode.TryGetValue(importedDataNodeState.DataNode, out var currentPersistentDataNode))", + "\n {", + "\n if(importedDataNodeState.State < currentPersistentDataNode.State)", + "\n ApplicationMessage.Log(Error.ChangeDataNodeState, importedDataNodeState.DataNode, ", + "\n currentPersistentDataNode.State.ToString(), ", + "\n importedDataNodeState.State.ToString());", + "\n", + "\n if(importedDataNodeState.State == currentPersistentDataNode.State)", + "\n await workspace.DeleteAsync(importedDataNodeState);", + "\n }", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Validate for Mandatory Aoc Steps" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using static Systemorph.Vertex.Equality.IdentityPropertyExtensions;", + "\npublic async static Task ValidateForMandatoryAocSteps(this IWorkspace workspace, IDataSet dataSet, HashSet mandatoryAocSteps)", + "\n{ ", + "\n var excludedProperties = new[]{nameof(AocType), nameof(Novelty)};", + "\n var includingProperties = typeof(RawVariable).GetIdentityProperties().Select(x=>x.Name).Except(excludedProperties).ToArray();", + "\n var missingAocStepsByIdentityProperties = (await workspace.Query().ToListAsync())", + "\n .GroupBy(x => x.ToStringWith(properties: includingProperties),", + "\n x => new AocStep(x.AocType, x.Novelty),", + "\n (properties, parsedAocSteps) => (properties, mandatoryAocSteps.Except(parsedAocSteps))", + "\n );", + "\n foreach((var properties, var missingSteps) in missingAocStepsByIdentityProperties) ", + "\n foreach(var missingStep in missingSteps) ApplicationMessage.Log(Warning.MandatoryAocStepMissing, missingStep.AocType, missingStep.Novelty, properties);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -678,44 +800,66 @@ "source": [ "Import.DefineFormat(ImportFormats.YieldCurve, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = GetArgsFromMain(dataSet) with {ImportFormat = ImportFormats.YieldCurve};", - "\n args.ValidateArgsForPeriod();", - "\n if(ApplicationMessage.HasErrors()) return Activity.Finish();", - "\n", + "\n var primaryArgs = GetArgsFromMain(dataSet) with {ImportFormat = ImportFormats.YieldCurve};", + "\n primaryArgs.ValidateArgsForPeriod();", + "\n if(ApplicationMessage.HasErrors()) return Activity.Finish();", "\n var workspace = Workspace.CreateNew();", - "\n workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());", + "\n workspace.Initialize(x => x.FromSource(options.TargetDataSource).DisableInitialization()", + "\n .DisableInitialization().DisableInitialization());", "\n", - "\n var committedYieldCurves = await DataSource.Query().ToArrayAsync();", + "\n var committedYieldCurves = await options.TargetDataSource.Query().ToArrayAsync();", "\n var hasNameColumn = dataSet.Tables[ImportFormats.YieldCurve].Columns.Any(x => x.ColumnName == nameof(YieldCurve.Name));", - "\n var importLog = await Import.FromDataSet(dataSet).WithType((dataset, datarow) => { ", - "\n var yieldCurve = new YieldCurve {", - "\n Currency = datarow.Field(nameof(YieldCurve.Currency)),", - "\n Year = args.Year,", - "\n Month = args.Month, ", - "\n Scenario = args.Scenario,", - "\n Values = datarow.Table.Columns.Where(c => c.ColumnName.StartsWith(nameof(YieldCurve.Values))).OrderBy(c => c.ColumnName.Length).ThenBy(c => c.ColumnName)", - "\n .Select(x => datarow.Field(x.ColumnName).CheckStringForExponentialAndConvertToDouble()).ToArray(),", - "\n Name = hasNameColumn", - "\n ? datarow.Field(nameof(YieldCurve.Name))", - "\n : default(string)", - "\n };", - "\n return committedYieldCurves.Contains(yieldCurve, YieldCurveComparer.Instance())", - "\n ? null", - "\n : yieldCurve;", - "\n }", - "\n ).WithTarget(workspace).ExecuteAsync(); ", - "\n ", + "\n var importLog = await Import.FromDataSet(dataSet).WithType((dataset, datarow) => { ", + "\n var yieldCurve = new YieldCurve { ", + "\n Currency = datarow.Field(nameof(YieldCurve.Currency)),", + "\n Year = primaryArgs.Year,", + "\n Month = primaryArgs.Month, ", + "\n Scenario = primaryArgs.Scenario,", + "\n Values = datarow.Table.Columns.Where(c => c.ColumnName.StartsWith(nameof(YieldCurve.Values))).OrderBy(c => c.ColumnName.Length).ThenBy(c => c.ColumnName)", + "\n .Select(x => datarow.Field(x.ColumnName).CheckStringForExponentialAndConvertToDouble()).ToArray(),", + "\n Name = hasNameColumn ? datarow.Field(nameof(YieldCurve.Name)) : default(string)", + "\n };", + "\n return committedYieldCurves.Contains(yieldCurve, YieldCurveComparer.Instance()) ? null : yieldCurve;", + "\n }).WithTarget(workspace).ExecuteAsync(); ", + "\n", "\n if(importLog.Errors.Any()) return Activity.Finish().Merge(importLog); ", - "\n ", - "\n var toCommitYieldCurves = await workspace.Query().ToArrayAsync();", - "\n if (!toCommitYieldCurves.Any()){", + "\n var toCommitYieldCurves = await workspace.Query().ToArrayAsync();", + "\n if (!toCommitYieldCurves.Any()) {", "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported); ", "\n return Activity.Finish().Merge(importLog);", "\n }", - "\n ", - "\n await DataSource.UpdateAsync(toCommitYieldCurves);", - "\n await DataSource.CommitAsync();", + "\n", + "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.YieldCurve);", + "\n var updatedCurrencies = toCommitYieldCurves.Select(x => x.Currency).Distinct();", + "\n var dataNodesToUpdate = await workspace.Query().Where(x => updatedCurrencies.Contains(x.ContractualCurrency)).Select(x => x.SystemName).ToArrayAsync();", + "\n var workspaceToCompute = Workspace.CreateNew();", + "\n workspaceToCompute.Initialize(x => x.FromSource(options.TargetDataSource));", "\n ", + "\n foreach (var args in allArgs) {", + "\n await CommitPartitionAsync(args, workspace, workspaceToCompute);", + "\n var targetPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(args));", + "\n var defaultPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(", + "\n new ImportArgs(args.ReportingNode, args.Year, args.Month, default(Periodicity), null, ImportFormats.Cashflow) ));", + "\n if(ApplicationMessage.HasErrors()) return Activity.Finish().Merge(importLog);", + "\n ", + "\n // Avoid starting the computation if no best estimate cash flow has ever been imported ", + "\n if(args.Scenario == null) {", + "\n await options.TargetDataSource.Partition.SetAsync(null);", + "\n if(!(await options.TargetDataSource.Query().Where(x => x.Partition == targetPartition).Take(1).ToArrayAsync()).Any()) continue;", + "\n }", + "\n", + "\n // Remove data nodes which are unaffected by the updated yield curves", + "\n // TODO : Reintroduce this functionality. Note all UpdateAsync/DeleteAsync performed to the workspaceToCompute are then trasferred to the DataSource.", + "\n // This is way this functionality should be written in a different way. ", + "\n // await workspaceToCompute.DeleteAsync( await workspaceToCompute.Query()", + "\n // .Where(x => !(dataNodesToUpdate.Contains(x.DataNode) && (x.Partition == targetPartition || x.Partition == defaultPartition))).ToArrayAsync() );", + "\n", + "\n importLog = importLog.Merge(await ComputeAsync(args, workspace, workspaceToCompute, false));", + "\n if(importLog.Errors.Any()) return Activity.Finish().Merge(importLog);", + "\n }", + "\n", + "\n await workspaceToCompute.UpdateAsync(toCommitYieldCurves);", + "\n await workspaceToCompute.CommitToTargetAsync(options.TargetDataSource);", "\n return Activity.Finish().Merge(importLog);", "\n});" ], @@ -880,22 +1024,7 @@ { "cell_type": "code", "source": [ - "public async static Task ValidateDataNodeStatesAsync(this IWorkspace workspace, Dictionary persistentDataNodeByDataNode)", - "\n{", - "\n foreach(var importedDataNodeState in await workspace.Query().ToArrayAsync())", - "\n {", - "\n if(persistentDataNodeByDataNode.TryGetValue(importedDataNodeState.DataNode, out var currentPersistentDataNode))", - "\n {", - "\n if(importedDataNodeState.State < currentPersistentDataNode.State)", - "\n ApplicationMessage.Log(Error.ChangeDataNodeState, importedDataNodeState.DataNode, ", - "\n currentPersistentDataNode.State.ToString(), ", - "\n importedDataNodeState.State.ToString());", - "\n", - "\n if(importedDataNodeState.State == currentPersistentDataNode.State)", - "\n await workspace.DeleteAsync(importedDataNodeState);", - "\n }", - "\n }", - "\n}" + "" ], "metadata": {}, "execution_count": 0, @@ -1121,11 +1250,10 @@ "\n var values = datarow.Table.Columns.Where(c => c.ColumnName.StartsWith(nameof(RawVariable.Values))).OrderBy(c => c.ColumnName.Length).ThenBy(c => c.ColumnName)", "\n .Select(x => datarow.Field(x.ColumnName).CheckStringForExponentialAndConvertToDouble()).ToArray();", "\n ", - "\n // Filter out empty raw variables for AocType != CL", - "\n //TODO: extend this check for all mandatory step and not just for CL", + "\n // Filter out empty raw variables for AocStep \\not\\in MandatoryAocSteps", "\n if(args.Scenario == null) {", "\n values = values.Prune();", - "\n if(values.Length == 0 && aocType != AocTypes.CL) return null;", + "\n if(values.Length == 0 && !parsingStorage.MandatoryAocSteps.Contains(new AocStep(aocType, novelty))) return null;", "\n }", "\n ", "\n var item = new RawVariable {", @@ -1138,13 +1266,14 @@ "\n ? accidentYear", "\n : (int?)null,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", - "\n Values = Multiply(GetSign((ImportFormats.Cashflow, aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache), values)", + "\n Values = Multiply(GetSign(ImportFormats.Cashflow, (aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache), values)", "\n };", "\n return item;", "\n }, ImportFormats.Cashflow", "\n ).WithTarget(workspace).ExecuteAsync();", "\n ", - "\n await ValidateForDataNodeStateActiveAsync(workspace, parsingStorage.DataNodeDataBySystemName);", + "\n await workspace.ValidateForMandatoryAocSteps(dataSet, parsingStorage.MandatoryAocSteps);", + "\n await workspace.ValidateForDataNodeStateActiveAsync(parsingStorage.DataNodeDataBySystemName);", "\n return Activity.Finish().Merge(importLog);", "\n}" ], @@ -1160,7 +1289,7 @@ "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.Cashflow};", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", - "\n var allArgs = await GetAllArgsAsync(primaryArgs);", + "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Cashflow);", "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Cashflow, primaryArgs);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", @@ -1239,13 +1368,13 @@ "\n AmountType = valueType.AmountType,", "\n EstimateType = valueType.EstimateType,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", - "\n Value = GetSign((ImportFormats.Actual, aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache) * datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble()", + "\n Value = GetSign(ImportFormats.Actual, (aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache) * datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble()", "\n };", "\n return item;", "\n }, ImportFormats.Actual", "\n ).WithTarget(workspace).ExecuteAsync();", "\n ", - "\n await ValidateForDataNodeStateActiveAsync(workspace, parsingStorage.DataNodeDataBySystemName);", + "\n await workspace.ValidateForDataNodeStateActiveAsync(parsingStorage.DataNodeDataBySystemName);", "\n return Activity.Finish().Merge(importLog);", "\n}" ], @@ -1261,7 +1390,7 @@ "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.Actual};", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", - "\n var allArgs = await GetAllArgsAsync(primaryArgs);", + "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Actual);", "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Actual, primaryArgs);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", @@ -1275,7 +1404,7 @@ "\n log = log.Merge(await ComputeAsync(args, workspace, workspaceToCompute, false)); ", "\n if(log.Errors.Any()) return Activity.Finish().Merge(log);", "\n }", - "\n if (!log.Errors.Any()) await workspaceToCompute.CommitToTargetAsync(DataSource);", + "\n await workspaceToCompute.CommitToTargetAsync(DataSource);", "\n return Activity.Finish().Merge(log);", "\n});" ], @@ -1335,7 +1464,7 @@ "\n EstimateType = estimateType,", "\n EconomicBasis = economicBasis,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", - "\n Value = GetSign((importFormat, aocStep.AocType, amountType, estimateType, parsingStorage.IsDataNodeReinsurance(dataNode)), parsingStorage.HierarchyCache) * datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble()", + "\n Value = GetSign(importFormat, (aocStep.AocType, amountType, estimateType, parsingStorage.IsDataNodeReinsurance(dataNode)), parsingStorage.HierarchyCache) * datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble()", "\n };", "\n return iv;", "\n }, importFormat // This should indicate the table name, not the input format", @@ -1353,7 +1482,7 @@ "\n foreach (var iv in invalidVariables)", "\n ApplicationMessage.Log(Error.MultipleTechnicalMarginOpening, $\"{iv.DataNode},{iv.AocType},{iv.Novelty}\");", "\n ", - "\n await ValidateForDataNodeStateActiveAsync(workspace, parsingStorage.DataNodeDataBySystemName);", + "\n await workspace.ValidateForDataNodeStateActiveAsync(parsingStorage.DataNodeDataBySystemName);", "\n targetPartitionByReportingNodeAndPeriodId = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id;", "\n return Activity.Finish().Merge(importLog);", "\n}" @@ -1382,7 +1511,6 @@ "\n var targetDataNodes = workspace.Query().Select(v => v.DataNode).Distinct().ToArray();", "\n await workspace.CommitToAsync(DataSource, partitionId, snapshot : true,", "\n filter : x => targetDataNodes.Contains(x.DataNode));", - "\n ", "\n return Activity.Finish().Merge(parsingLog);", "\n});" ], @@ -1420,9 +1548,9 @@ "\n workspaceToCompute.Initialize(x => x.FromSource(DataSource));", "\n var calculationLog = await ComputeAsync(args, workspace, workspaceToCompute, false); ", "\n if(calculationLog.Errors.Any()) return Activity.Finish().Merge(calculationLog);", - "\n await workspaceToCompute.CommitToAsync(DataSource, partitionId);", + "\n await workspaceToCompute.CommitToTargetAsync(DataSource, x => x.SnapshotMode());", "\n return Activity.Finish().Merge(parsingLog).Merge(calculationLog);", - "\n});" + "\n})" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/OverviewCalculationEngine.ipynb b/ifrs17/OverviewCalculationEngine.ipynb index c4d85c77..482b71d8 100644 --- a/ifrs17/OverviewCalculationEngine.ipynb +++ b/ifrs17/OverviewCalculationEngine.ipynb @@ -189,7 +189,8 @@ "\n", "\nSome reports of ReportScopes just present existing data from the database, namely the imported data and the results already calculated using the methods of [ImportScopes](#model-calc).", "\n", - "\nSome other reports related to **[Financial Performance](./Report/ReportScopes#ifrs-17-financial-performance)** (profit & loss) require further calculations provided by ReportScopes. An IFRS 17 financial performance report has at least four sections: Insurance Revenue, Insurance Service Expense, Insurance Finance Income/Expense and Other Comprehensive Income. Formulas are provided [here](./Report/ReportScopes#ifrs-17-financial-performance)." + "\nSome other reports related to **[Financial Performance](./Report/ReportScopes#ifrs-17-financial-performance)** (profit & loss) require further calculations provided by ReportScopes. An IFRS 17 financial performance report has at least four sections: Insurance Revenue, Insurance Service Expense, Insurance Finance Income/Expense and Other Comprehensive Income. Formulas are provided [here](./Report/ReportScopes#ifrs-17-financial-performance).", + "\n" ], "metadata": {}, "execution_count": 0, @@ -220,15 +221,6 @@ "metadata": {}, "execution_count": 0, "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Report/ParameterReportsQueries.ipynb b/ifrs17/Report/ParameterReportsQueries.ipynb index 8f0d6f4a..229d5ae6 100644 --- a/ifrs17/Report/ParameterReportsQueries.ipynb +++ b/ifrs17/Report/ParameterReportsQueries.ipynb @@ -15,6 +15,15 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Parameter Report Queries

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -167,7 +176,16 @@ { "cell_type": "markdown", "source": [ - "# Data Node" + "# Queries" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Data Node" ], "metadata": {}, "execution_count": 0, @@ -208,7 +226,7 @@ { "cell_type": "markdown", "source": [ - "# YieldCurve" + "## YieldCurve" ], "metadata": {}, "execution_count": 0, @@ -266,7 +284,7 @@ { "cell_type": "markdown", "source": [ - "# Single Data Node Parameters" + "## Single Data Node Parameters" ], "metadata": {}, "execution_count": 0, @@ -295,7 +313,7 @@ { "cell_type": "markdown", "source": [ - "# Inter Data Node Parameters" + "## Inter Data Node Parameters" ], "metadata": {}, "execution_count": 0, @@ -329,7 +347,7 @@ { "cell_type": "markdown", "source": [ - "# Partner Default Rates" + "## Partner Default Rates" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17/Test/AocStructureTest.ipynb similarity index 89% rename from ifrs17-template/Test/AocStructureTest.ipynb rename to ifrs17/Test/AocStructureTest.ipynb index b52e9153..a230366e 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17/Test/AocStructureTest.ipynb @@ -29,7 +29,8 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"../Import/Importers\"", + "\n#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -47,18 +48,49 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization()", - "\n .DisableInitialization());" + "await Import.FromString(novelties).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(canonicalAocTypes).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(canonicalAocConfig).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Test" + "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(new [] {dt11});", + "\nawait DataSource.UpdateAsync(new [] {dtr11});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new [ ] {dt11State,dtr11State});", + "\nawait DataSource.UpdateAsync(new [ ] {dt11Inter});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(estimateType).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new [ ] {yieldCurvePrevious});" ], "metadata": {}, "execution_count": 0, @@ -67,8 +99,7 @@ { "cell_type": "code", "source": [ - "var reportingNode = \"CH\";", - "\nvar scenario = (string)null;" + "Workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" ], "metadata": {}, "execution_count": 0, @@ -77,15 +108,17 @@ { "cell_type": "code", "source": [ - "//Define partition", - "\nvar args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", - "\n Year = args.Year,", - "\n Month = args.Month };", - "\nawait DataSource.UpdateAsync(new[]{partition});", - "\nawait DataSource.CommitAsync();" + "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", + "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" ], "metadata": {}, "execution_count": 0, @@ -259,24 +292,15 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var groupOfContract = \"DT1.1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "var inputRawVariables = new RawVariable[]{", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"EV\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"EV\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n};" ], "metadata": {}, @@ -354,7 +378,9 @@ "\n new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", "\n }},", "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", - "\n };" + "\n };", + "\nvar activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -363,7 +389,7 @@ { "cell_type": "code", "source": [ - "await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm)" + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -378,24 +404,15 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "groupOfContract = \"DTR1.1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "inputRawVariables = new RawVariable[]{", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"EV\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfReinsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfReinsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfReinsuranceContracts, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfReinsuranceContracts, AocType = \"EV\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfReinsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n};" ], "metadata": {}, @@ -529,22 +546,13 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var groupOfContract = \"DT1.1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "inputRawVariables = new RawVariable[]{", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n};" ], "metadata": {}, @@ -641,23 +649,14 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var groupOfContract = \"DT1.1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "var inputIfrsVariables = new IfrsVariable[]{", - "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"AA\"},", - "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfContract, AocType = \"CF\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"AA\"},", - "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfContract, AocType = \"CF\", Novelty = \"C\", AccidentYear = null, AmountType = \"ACA\", EstimateType = \"A\"},", - "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfContract, AocType = \"WO\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"OA\"},", + "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"AA\"},", + "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfInsuranceContracts, AocType = \"CF\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"AA\"},", + "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfInsuranceContracts, AocType = \"CF\", Novelty = \"C\", AccidentYear = null, AmountType = \"ACA\", EstimateType = \"A\"},", + "\n new IfrsVariable{Partition = partition.Id, Value = 1.0, DataNode = groupOfInsuranceContracts, AocType = \"WO\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"OA\"},", "\n};" ], "metadata": {}, diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17/Test/ImportStorageTest.ipynb similarity index 88% rename from ifrs17-template/Test/ImportStorageTest.ipynb rename to ifrs17/Test/ImportStorageTest.ipynb index 73c83161..67a9871f 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17/Test/ImportStorageTest.ipynb @@ -29,7 +29,8 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"../Import/Importers\"", + "\n#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -47,18 +48,21 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization()", - "\n .DisableInitialization());" + "await Import.FromString(novelties).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(canonicalAocTypes).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(canonicalAocConfig).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Test IfrsVariables Query" + "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(new [] {dt11});", + "\nawait DataSource.UpdateAsync(new [] {dtr11});" ], "metadata": {}, "execution_count": 0, @@ -67,10 +71,8 @@ { "cell_type": "code", "source": [ - "var gic = \"DT1.1\";", - "\nvar gric = \"DTR1.1\";", - "\nvar reportingNode = \"CH\";", - "\nvar scenario = (string)null;" + "await DataSource.UpdateAsync(new [ ] {dt11State, dtr11State});", + "\nawait DataSource.UpdateAsync(new [ ] {dt11Inter});" ], "metadata": {}, "execution_count": 0, @@ -79,21 +81,44 @@ { "cell_type": "code", "source": [ - "//Define partition", - "\nvar args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", - "\n Year = args.Year,", - "\n Month = args.Month };", - "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", - "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", - "\n Year = previousArgs.Year,", - "\n Month = previousArgs.Month };", - "\nawait DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", - "\nawait DataSource.CommitAsync();" + "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurvePrevious});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(estimateType).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", + "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" ], "metadata": {}, "execution_count": 0, @@ -144,7 +169,7 @@ "cell_type": "code", "source": [ "//There is a previous year, and it's the first time Actuals are imported for the current year", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gic, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", @@ -161,7 +186,6 @@ "\n basicIfrsVariable with {AocType = AocTypes.CF, Value = -10.0},", "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", - "\n", "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", "\nactivity" ], @@ -182,7 +206,7 @@ "cell_type": "code", "source": [ "//There is a previous year, and it's the second time Actuals are imported for the current year (reimport)", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gic, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", @@ -225,7 +249,7 @@ "cell_type": "code", "source": [ "//There is a previous year, Cash flows were already imported and Actuals are imported for the first time", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gic, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", + "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.AA, Novelty = Novelties.C, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 1000.0},", @@ -270,8 +294,8 @@ "cell_type": "code", "source": [ "//There is a previous year, Cash flows and Actuals were already imported and Actuals are imported again", - "\nvar basicAdvanceActualIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gic, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", - "\nvar basicBeIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gic, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", + "\nvar basicAdvanceActualIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\nvar basicBeIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicBeIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 1000.0},", "\n basicBeIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, Value = 1000.0},", @@ -326,19 +350,19 @@ "\n//There is a previous and current year for Secondary Scope (GIC10), ", "\n//It's the first time Actuals are imported for the current year", "\n", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gric, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfReinsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n //Year", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", - "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, DataNode = gic, EstimateType = EstimateTypes.DA, Value = 1000.0},", - "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 1000.0},", - "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.CL, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 666.0},", - "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 1000.0},", - "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.CL, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 666.0},", + "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 1000.0},", + "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.CL, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 666.0},", + "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 1000.0},", + "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.CL, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 666.0},", "\n //Year -1", - "\n basicIfrsVariable with {AocType = AocTypes.IA, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", - "\n basicIfrsVariable with {AocType = AocTypes.CF, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", + "\n basicIfrsVariable with {AocType = AocTypes.IA, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", + "\n basicIfrsVariable with {AocType = AocTypes.CF, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", "\n };", "\n", "\nvar inputDataSetForWorkspace = new IfrsVariable[]{", @@ -351,15 +375,15 @@ "\n //Actuals", "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, EstimateType = EstimateTypes.DA, Value = 1000.0},", "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, Value = 100.0},", - "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.DA, Value = 1000.0},", "\n //Cash flow", - "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 1000.0},", - "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 1000.0},", "\n ", "\n //From current Period", "\n //from DB", - "\n basicIfrsVariable with {AocType = AocTypes.IA, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", - "\n basicIfrsVariable with {AocType = AocTypes.CF, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", + "\n basicIfrsVariable with {AocType = AocTypes.IA, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", + "\n basicIfrsVariable with {AocType = AocTypes.CF, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", "\n ", "\n //from workspace", "\n basicIfrsVariable with {AocType = AocTypes.CF, Value = -10.0},", @@ -427,15 +451,15 @@ "cell_type": "code", "source": [ "var sampleGic = new GroupOfInsuranceContract(){Portfolio = \"P1\"};", - "\nvar inputDataGic = new GroupOfInsuranceContract[]{ sampleGic with {SystemName = \"Gross1\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"CHF\", ValuationApproach = \"BBA\"},", - "\n sampleGic with {SystemName = \"Gross2\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"CHF\", ValuationApproach = \"BBA\"},", - "\n sampleGic with {SystemName = \"Gross3\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"CHF\", ValuationApproach = \"BBA\"},", + "\nvar inputDataGic = new GroupOfInsuranceContract[]{ sampleGic with {SystemName = \"Gross1\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"USD\", ValuationApproach = \"BBA\"},", + "\n sampleGic with {SystemName = \"Gross2\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"USD\", ValuationApproach = \"BBA\"},", + "\n sampleGic with {SystemName = \"Gross3\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"USD\", ValuationApproach = \"BBA\"},", "\n };", "\n", "\nvar sampleGric = new GroupOfReinsuranceContract(){Portfolio = \"ReP1\"};", - "\nvar inputDataGric = new GroupOfReinsuranceContract[]{ sampleGric with {SystemName = \"Reins1\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"CHF\", ValuationApproach = \"BBA\"},", - "\n sampleGric with {SystemName = \"Reins2\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"CHF\", ValuationApproach = \"BBA\"},", - "\n sampleGric with {SystemName = \"Reins3\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"CHF\", ValuationApproach = \"BBA\"},", + "\nvar inputDataGric = new GroupOfReinsuranceContract[]{ sampleGric with {SystemName = \"Reins1\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"USD\", ValuationApproach = \"BBA\"},", + "\n sampleGric with {SystemName = \"Reins2\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"USD\", ValuationApproach = \"BBA\"},", + "\n sampleGric with {SystemName = \"Reins3\", LiabilityType = LiabilityTypes.LRC, ContractualCurrency = \"USD\", ValuationApproach = \"BBA\"},", "\n };", "\nvar sampleDnState = new DataNodeState {Partition = reportingNodePartition.Id, Year = args.Year, Month = args.Month, State = State.Active};", "\nvar inputDataState = new DataNodeState[]{ sampleDnState with {DataNode = \"Gross1\"} ,", diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index d48841bd..7e87e8b6 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -571,6 +571,43 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2020,12,Periodicity.Monthly,null);", + "\nvar testData = new YieldCurve[] {", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 12, Name = \"A\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 12, Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} }, ", + "\n ", + "\n };", + "\n", + "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2020, 12, \"A\", \"BBA\");", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 0.1, 0.1, 7.1);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", + "\nvar testData = new YieldCurve[] {", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 12, Name = \"A\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 12, Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Name = \"A\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Values = new double[]{0.01,0.02,0.03,0.04,0.05,0.06} },", + "\n };", + "\n", + "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2020, 1, \"A\", \"BBA\");", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 0.01, 0.01, 6.1);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -613,7 +650,7 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} }};", "\n", "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 6, \"A\", \"BBA\");", - "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 6.1, 0.1, 6.1);", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 9.1, 1.1, 6.1);", "\nactivity" ], "metadata": {}, @@ -634,20 +671,29 @@ "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 12, Name = \"A\", Values = new double[]{11.1,11.2,11.3,11.4,11.5,11.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 12, Values = new double[]{100.1,100.2,100.3,100.4,100.5,100.6} }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Name = \"A\", Values = new double[]{12.1,12.2,12.3,12.4,12.5,12.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Values = new double[]{90.1,90.2,90.3,90.4,90.5,90.6} }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"A\", Values = new double[]{13.1,13.2,13.3,13.4,13.5,13.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Values = new double[]{80.1,80.2,80.3,80.4,80.5,80.6} }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Name = \"A\", Values = new double[]{1.1,1.2,1.3,1.4,1.5,1.6} }, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Name = \"A\", Values = new double[]{9.1,9.2,9.3,9.4,9.5,9.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Values = new double[]{70.1,70.2,70.3,70.4,70.5,70.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Name = \"A\", Values = new double[]{9.1,9.2,9.3,9.4,9.5,9.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Values = new double[]{60.1,60.2,60.3,60.4,60.5,60.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Name = \"A\", Values = new double[]{10.1,10.2,10.3,10.4,10.5,10.6} }, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Name = \"A\", Values = new double[]{2.1,2.2,2.3,2.4,2.5,2.6} }, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 3, Name = \"A\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Values = new double[]{50.1,50.2,50.3,50.4,50.5,50.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Name = \"A\", Values = new double[]{2.1,2.2,2.3,2.4,2.5,2.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Values = new double[]{40.1,40.2,40.3,40.4,40.5,40.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 3, Name = \"A\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 3, Values = new double[]{30.1,30.2,30.3,30.4,30.5,30.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2018, Month = 6, Name = \"A\", Values = new double[]{3.1,3.2,3.3,3.4,3.5,3.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2018, Month = 6, Values = new double[]{20.1,20.2,20.3,20.4,20.5,20.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2017, Month = 6, Name = \"A\", Values = new double[]{4.1,4.2,4.3,4.4,4.5,4.6} }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 12, Name = \"A\", Values = new double[]{8.1,8.2,8.3,8.4,8.5,8.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"A\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 6, \"A\", \"BBA\");", - "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 9.1, 12.1, 8.1);", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 60.1, 90.1, 8.1);", "\nactivity" ], "metadata": {}, @@ -693,14 +739,56 @@ "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} }, ", + "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Values = new double[]{10.1,10.2,10.3,10.4,10.5,10.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{2.1,2.2,2.3,2.4,2.5,2.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"C\", Values = new double[]{4.1,4.2,4.3,4.4,4.5,4.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", + "\n", + "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 2, \"A\", \"BBA\");", + "\n", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 10.1, 10.1);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Failed);", + "\nactivity.Errors.Count().Should().Be(1)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"EUR\",\"2016\",\"12\",\"Best Estimate\",\"A\");", + "\nvar errorMessage = activity.Errors.First().ToString();", + "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2016,9,Periodicity.Monthly,null);", + "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Values = new double[]{10.1,10.2,10.3,10.4,10.5,10.6} }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{2.1,2.2,2.3,2.4,2.5,2.6} }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"C\", Values = new double[]{4.1,4.2,4.3,4.4,4.5,4.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 2, \"A\", \"BBA\");", "\n", - "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData);" + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 10.1, 10.1);", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -710,7 +798,18 @@ "cell_type": "code", "source": [ "activity.Status.Should().Be(ActivityLogStatus.Failed);", - "\nactivity.Errors.Select(x => x.ToString().Contains(Get(Error.YieldCurveNotFound)).Should().Be(true));" + "\nactivity.Errors.Count().Should().Be(1)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"EUR\",\"2016\",\"9\",\"Best Estimate\",\"A\");", + "\nvar errorMessage = activity.Errors.First().ToString();", + "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17/Test/ReportStorageTest.ipynb similarity index 83% rename from ifrs17-template/Test/ReportStorageTest.ipynb rename to ifrs17/Test/ReportStorageTest.ipynb index 0f49a5d2..277fca1c 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17/Test/ReportStorageTest.ipynb @@ -20,7 +20,8 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"../Report/ReportStorage\"", + "\n#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -29,7 +30,7 @@ { "cell_type": "markdown", "source": [ - "# Test Exchange Rate Query" + "# Initialization" ], "metadata": {}, "execution_count": 0, @@ -38,8 +39,25 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization());" + "await DataSource.UpdateAsync(reportingNodeG.RepeatOnce());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" ], "metadata": {}, "execution_count": 0, @@ -86,7 +104,16 @@ "\n new ExchangeRate{ Currency = \"USD\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 5 },", "\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Average, FxToGroupCurrency = 2 },", "\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Spot, FxToGroupCurrency = 0.5 }};", - "\nvar activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17-template/Test/TechnicalMarginTest.ipynb b/ifrs17/Test/TechnicalMarginTest.ipynb similarity index 81% rename from ifrs17-template/Test/TechnicalMarginTest.ipynb rename to ifrs17/Test/TechnicalMarginTest.ipynb index 8d0d4f34..1e60b92a 100644 --- a/ifrs17-template/Test/TechnicalMarginTest.ipynb +++ b/ifrs17/Test/TechnicalMarginTest.ipynb @@ -29,7 +29,8 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"../Import/Importers\"", + "\n#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -47,18 +48,31 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization()", - "\n .DisableInitialization());" + "await Import.FromString(novelties).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(canonicalAocTypes).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(canonicalAocConfig).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(new[]{dt11});", + "\nawait DataSource.UpdateAsync(new[]{dt11State});", + "\nawait DataSource.UpdateAsync(new[]{dt11SingleParameter});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", "source": [ - "# Test switch logic" + "await Import.FromString(amountType).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(estimateType).WithType().WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, @@ -67,8 +81,7 @@ { "cell_type": "code", "source": [ - "//define group of contract", - "\nvar groupOfContract = \"DT1.1\";" + "await Import.FromString(projectionConfiguration).WithType().WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, @@ -77,11 +90,35 @@ { "cell_type": "code", "source": [ - "//Define partition", - "\n var args = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Actual);", - "\n var partition = Workspace.Query().FirstOrDefault(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && ", - "\n x.Month == args.Month && x.Scenario == args.Scenario);", - "\n if(partition == null) ApplicationMessage.Log(Error.PartitionNotFound);" + "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurvePrevious});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(previousPeriodPartition.RepeatOnce());", + "\nawait DataSource.UpdateAsync(partitionReportingNode.RepeatOnce());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" ], "metadata": {}, "execution_count": 0, @@ -97,11 +134,11 @@ "\n await Workspace.UpdateAsync(inputDataSet);", "\n ", "\n //Set up import storage and test universe", - "\n var testStorage = new ImportStorage(args, DataSource, Workspace);", + "\n var testStorage = new ImportStorage(previousArgs, DataSource, Workspace);", "\n await testStorage.InitializeAsync();", "\n var testUniverse = Scopes.ForStorage(testStorage).ToScope();", "\n ", - "\n var identities = testUniverse.GetScopes(testStorage.DataNodesByImportScope[ImportScope.Primary].Where(dn => dn == groupOfContract)).SelectMany(s => s.Identities);", + "\n var identities = testUniverse.GetScopes(testStorage.DataNodesByImportScope[ImportScope.Primary].Where(dn => dn == groupOfInsuranceContracts)).SelectMany(s => s.Identities);", "\n var csm = testUniverse.GetScopes(identities, o => o.WithContext(\"C\")).Where(x => Math.Abs(x.Value) > Precision);", "\n var lc = testUniverse.GetScopes(identities, o => o.WithContext(\"L\")).Where(x => Math.Abs(x.Value) > Precision);", "\n //Clean up Workspace", @@ -165,7 +202,7 @@ { "cell_type": "code", "source": [ - "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfContract, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", + "var basicIfrsVariable = new IfrsVariable{Partition = previousPeriodPartition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", "\nvar inputDataSet = new IfrsVariable[]{", "\n basicIfrsVariable with {AocType = \"BOP\", Novelty = \"N\", Value = 100.0},", "\n basicIfrsVariable with {AocType = \"CF\", Novelty = \"N\", Value = -10.0},", @@ -186,7 +223,17 @@ "\n {new AocStep(\"EOP\",\"C\"),(0d, 153.5)},", "\n };", "\n", - "\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);" + "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -195,7 +242,7 @@ { "cell_type": "code", "source": [ - "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfContract, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", + "var basicIfrsVariable = new IfrsVariable{Partition = previousPeriodPartition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", "\nvar inputDataSet = new IfrsVariable[]{", "\n basicIfrsVariable with {AocType = \"BOP\", Novelty = \"N\", Value = 100.0},", "\n basicIfrsVariable with {AocType = \"CF\", Novelty = \"N\", Value = -10.0},", @@ -235,7 +282,7 @@ { "cell_type": "code", "source": [ - "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfContract, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", + "var basicIfrsVariable = new IfrsVariable{Partition = previousPeriodPartition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", "\nvar inputDataSet = new IfrsVariable[]{", "\n basicIfrsVariable with {AocType = \"BOP\", Novelty = \"N\", Value = 100.0},", "\n basicIfrsVariable with {AocType = \"CF\", Novelty = \"N\", Value = -10.0},", @@ -271,7 +318,7 @@ { "cell_type": "code", "source": [ - "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfContract, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", + "var basicIfrsVariable = new IfrsVariable{Partition = previousPeriodPartition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", "\nvar inputDataSet = new IfrsVariable[]{", "\n basicIfrsVariable with {AocType = \"BOP\", Novelty = \"I\", Value = 5010.0, EstimateType = \"L\", AmountType = null},", "\n basicIfrsVariable with {AocType = \"MC\", Novelty = \"I\", Value = -10.0},", diff --git a/ifrs17/Test/TestData.ipynb b/ifrs17/Test/TestData.ipynb new file mode 100644 index 00000000..1326997d --- /dev/null +++ b/ifrs17/Test/TestData.ipynb @@ -0,0 +1,398 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# AoC Structure" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string novelties = ", + "\n@\"@@Novelty", + "\nSystemName,DisplayName,Parent,Order", + "\nI,In Force,,1", + "\nN,New Business,,10", + "\nC,Combined,,20\";", + "\n", + "\nstring canonicalAocTypes = ", + "\n@\"@@AocType,,,,,,,,,,,", + "\nSystemName,DisplayName,Parent,Order,,,,,,,,", + "\nBOP,Opening Balance,,10,,,,,,,,", + "\nMC,Model Correction,,20,,,,,,,,", + "\nPC,Portfolio Changes,,30,,,,,,,,", + "\nRCU,Reinsurance Coverage Update,PC,40,,,,,,,,", + "\nCF,Cash flow,,50,,,,,,,,", + "\nIA,Interest Accretion,,60,,,,,,,,", + "\nAU,Assumption Update,,70,,,,,,,,", + "\nFAU,Financial Assumption Update,,80,,,,,,,,", + "\nYCU,Yield Curve Update,FAU,90,,,,,,,,", + "\nCRU,Credit Risk Update,FAU,100,,,,,,,,", + "\nEV,Experience Variance,,110,,,,,,,,", + "\nWO,Write-Off,,120,,,,,,,,", + "\nCL,Combined Liabilities,,130,,,,,,,,", + "\nEA,Experience Adjustment,,140,,,,,,,,", + "\nAM,Amortization,,150,,,,,,,,", + "\nFX,FX Impact,,160,,,,,,,,", + "\nEOP,Closing Balance,,170,,,,,,,,\";", + "\n", + "\nstring canonicalAocConfig = ", + "\n@\"@@AocConfiguration,,,,,,,,,,,", + "\nAocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month", + "\nBOP,I,Optional,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1", + "\nMC,I,Optional,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1", + "\nRCU,I,Calculated,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1", + "\nCF,I,Calculated,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1", + "\nIA,I,Calculated,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1", + "\nAU,I,Optional,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1", + "\nYCU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1", + "\nCRU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1", + "\nEV,I,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1", + "\nBOP,N,Optional,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,95,1900,1", + "\nCF,N,Calculated,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1", + "\nIA,N,Calculated,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1", + "\nAU,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1", + "\nEV,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1", + "\nCF,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,160,1900,1", + "\nWO,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,170,1900,1", + "\nCL,C,Mandatory,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1", + "\nEA,C,Calculated,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1", + "\nAM,C,Calculated,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1", + "\nFX,C,Calculated,0,NotApplicable,NotApplicable,NotApplicable,NotApplicable,NotApplicable,210,1900,1", + "\nEOP,C,Calculated,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Estimate Type" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var estimateType = ", + "\n@\"@@EstimateType,,,,,,,,,,,", + "\nSystemName,DisplayName,Order,StructureType,InputSource,PeriodType,ExternalId0,ExternalId1,ExternalId2,ExternalId3,ExternalId4,", + "\nBE,Best Estimate of Present Value,1,AoC,4,EndOfPeriod,,,,,,", + "\nAA,Advance Actuals,60,AoC,3,NotApplicable,PayablePR,ReceivableNIC,ReceivableICO,RiReceivablePR,RiPayableNIC,", + "\nOA,Overdue Actuals,70,AoC,3,NotApplicable,ReceivablePR,PayableNIC,PayableICO,RiPayablePR,RiReceivableNIC,", + "\nDA,Deferrable Actuals,80,AoC,7,NotApplicable,,,,,,", + "\nA,Actuals,90,None,2,NotApplicable,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Projection Configuration" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var projectionConfiguration = ", + "\n@\"@@ProjectionConfiguration,,,,,,,,,,,", + "\nSystemName,DisplayName,Shift,TimeStep,,,,,,,,", + "\nP0,End of January,0,1,,,,,,,,", + "\nP1,End of February,0,2,,,,,,,,", + "\nP2,End of March,0,3,,,,,,,,", + "\nP3,End of April,0,4,,,,,,,,", + "\nP4,End of May,0,5,,,,,,,,", + "\nP5,End of June,0,6,,,,,,,,", + "\nP6,End of July,0,7,,,,,,,,", + "\nP7,End of August,0,8,,,,,,,,", + "\nP8,End of September,0,9,,,,,,,,", + "\nP9,End of October,0,10,,,,,,,,", + "\nP10,End of November,0,11,,,,,,,,", + "\nP11,End of December,0,12,,,,,,,,", + "\nP12,End of Year+1,12,12,,,,,,,,", + "\nP13,End of Year+2,24,12,,,,,,,,", + "\nP14,End of Year+3,36,12,,,,,,,,", + "\nP15,End of Year+4,48,12,,,,,,,,", + "\nP16,Year+5 to Year+10,60,60,,,,,,,,", + "\nP17,Year+10 to Year+15,120,60,,,,,,,,", + "\nP18,Year+15 to Year+20,180,60,,,,,,,,", + "\nP19,Years Over +20,240,9999,,,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Amount Type" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var amountType = ", + "\n@\"@@AmountType,,,,,,,,,,,", + "\nSystemName,DisplayName,Parent,Order,PeriodType,,,,,,,", + "\nPR,Premiums,,10,BeginningOfPeriod,,,,,,,", + "\nCL,Claims,,20,EndOfPeriod,,,,,,,", + "\nNIC,Non Investment Component,CL,30,EndOfPeriod,,,,,,,", + "\nICO,Investment Component,CL,40,EndOfPeriod,,,,,,,", + "\nCDR,Credit Default Risk,CL,50,EndOfPeriod,,,,,,,", + "\nCE,Claim Expenses,CL,200,EndOfPeriod,,,,,,,", + "\nALE,Allocated Loss Adjustment Expenses,CE,210,EndOfPeriod,,,,,,,", + "\nULE,Unallocated Loss Adjustment Expenses,CE,220,EndOfPeriod,,,,,,,", + "\nAE,Attributable Expenses,,80,BeginningOfPeriod,,,,,,,", + "\nAEA,Aquisition,AE,90,BeginningOfPeriod,,,,,,,", + "\nAEM,Maintenance,AE,100,BeginningOfPeriod,,,,,,,", + "\nNE,Non Attributable Expenses,,110,BeginningOfPeriod,,,,,,,", + "\nAC,Attributable Commission,,120,BeginningOfPeriod,,,,,,,", + "\nACA,Aquisition,AC,130,BeginningOfPeriod,,,,,,,", + "\nACM,Maitenance,AC,140,BeginningOfPeriod,,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Reporting Nodes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var reportingNodeG = new ReportingNode() {", + "\n SystemName = \"G\",", + "\n DisplayName = \"Group\",", + "\n Currency = \"CHF\"", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Variables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var groupOfInsuranceContracts = \"DT1.1\";", + "\nvar groupOfReinsuranceContracts = \"DTR1.1\";", + "\nvar reportingNode = \"CH\";", + "\nvar scenario = (string)null;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", + "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Partitions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = reportingNode, ", + "\n Scenario = scenario, ", + "\n Year = args.Year,", + "\n Month = args.Month };", + "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", + "\n ReportingNode = reportingNode, ", + "\n Scenario = scenario, ", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month };", + "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = args.ReportingNode};", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# DataNodes and DataNodeData" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var dt1 = new Portfolio(){", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach =\"BBA\",", + "\n OciType = \"Default\",", + "\n SystemName = \"DT1\",", + "\n DisplayName = \"DT1 OCI\"", + "\n};", + "\n", + "\nvar dtr1 = new Portfolio(){", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach =\"BBA\",", + "\n OciType = \"Default\",", + "\n SystemName = \"DTR1\",", + "\n DisplayName = \"DTR1 OCI\"", + "\n};", + "\n", + "\nvar dt11 = new GroupOfInsuranceContract(){", + "\n Portfolio = \"DT1\",", + "\n Profitability = \"P\",", + "\n LiabilityType = \"LRC\",", + "\n AnnualCohort = 2020,", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach = \"BBA\",", + "\n OciType =\"Default\" ,", + "\n SystemName = \"DT1.1\",", + "\n DisplayName = \"DT1.1 OCI LRC PA 0.8\"", + "\n};", + "\n", + "\nvar dtr11 = new GroupOfReinsuranceContract(){", + "\n Portfolio = \"DTR1\",", + "\n Profitability = \"P\",", + "\n LiabilityType = \"LRC\",", + "\n AnnualCohort = 2020,", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach = \"BBA\",", + "\n OciType =\"Default\" ,", + "\n SystemName = \"DTR1.1\",", + "\n DisplayName = \"DTR1.1 OCI LRC PA 0.8\"", + "\n};", + "\nvar dt11State = new DataNodeState {", + "\n DataNode = \"DT1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dtr11State = new DataNodeState {", + "\n DataNode = \"DTR1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dt11SingleParameter = new SingleDataNodeParameter {", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n DataNode = \"DT1.1\",", + "\n PremiumAllocation = .8,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dt11Inter = new InterDataNodeParameter{", + "\n LinkedDataNode = \"DTR1.1\",", + "\n\tReinsuranceCoverage = 1,", + "\n\tYear = args.Year,", + "\n\tMonth = args.Month,", + "\n\tDataNode = \"DT1.1\",", + "\n\tScenario = args.Scenario,", + "\n Partition = partitionReportingNode.Id", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# YieldCurve" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var yieldCurve = new YieldCurve(){", + "\n Currency = \"USD\",", + "\n Year = 2021,", + "\n Month = 3,", + "\n Values = new []{0.005,0.005,0.005,0.005}", + "\n};", + "\n", + "\nvar yieldCurvePrevious = new YieldCurve(){", + "\n Currency = \"USD\",", + "\n Year = 2020,", + "\n Month = 12,", + "\n Values = new []{0.002, 0.002, 0.002, 0.002}", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Test/Tests.ipynb b/ifrs17/Test/Tests.ipynb index 7a5e9882..a52dc9e6 100644 --- a/ifrs17/Test/Tests.ipynb +++ b/ifrs17/Test/Tests.ipynb @@ -59,6 +59,42 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"AocStructureTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"ImportStorageTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"ReportStorageTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"TechnicalMarginTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Utils/Extensions.ipynb b/ifrs17/Utils/Extensions.ipynb index 9e335a22..d23cd61e 100644 --- a/ifrs17/Utils/Extensions.ipynb +++ b/ifrs17/Utils/Extensions.ipynb @@ -207,12 +207,12 @@ "cell_type": "code", "source": [ "using System.Text;", - "\npublic static string ToIdentityString(this T v) where T : class", + "\npublic static string ToIdentityString(this T v, params string[] excludingProperties) where T : class", "\n{", "\n StringBuilder sb = new StringBuilder();", "\n var propertyInfos = v.GetType()", "\n .GetProperties()", - "\n .Where(x => Attribute.IsDefined(x, typeof(IdentityPropertyAttribute)))", + "\n .Where(x => Attribute.IsDefined(x, typeof(IdentityPropertyAttribute)) && !excludingProperties.Contains(x.Name))", "\n .OrderByDescending(x => x.PropertyType.Name).ThenByDescending(x => x.Name)", "\n .Select(x => sb.Append(x.Name).Append(\":\").Append(v.GetType().GetProperty(x.Name)?.GetValue(v, null)).Append(\", \")).ToArray();", "\n return propertyInfos.Count() == 0? v.ToString() : propertyInfos.Select(p => p.ToString()).ToArray().Last();", @@ -222,6 +222,29 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# ToString with including properties" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static string ToStringWith(this T variable, string[] properties) where T : BaseVariableIdentity", + "\n{", + "\n var propertiesRead = variable.ToString().Split('{', '}')[1].Split(',');", + "\n var propertiesFiltered = propertiesRead.Where(x=> properties.Contains(x.Split('=')[0].Trim()));", + "\n return string.Join(\", \", propertiesFiltered).Trim();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Utils/ImportCalculationMethods.ipynb b/ifrs17/Utils/ImportCalculationMethods.ipynb index a380baa8..4e8270a2 100644 --- a/ifrs17/Utils/ImportCalculationMethods.ipynb +++ b/ifrs17/Utils/ImportCalculationMethods.ipynb @@ -219,7 +219,7 @@ { "cell_type": "code", "source": [ - "public static int GetSign((string importFormat, string AocType, string AmountType, string EstimateType, bool IsReinsurance) variable, Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchyCache) => 1;" + "public static int GetSign(string importFormat, (string AocType, string AmountType, string EstimateType, bool IsReinsurance) variable, Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchyCache) => 1;" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 2a102c0f..e82f52b9 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -189,11 +189,12 @@ "\n var lockedInYieldCurveByGoc = new Dictionary();", "\n foreach (var dn in dataNodes.Where(x => x.ValuationApproach == ValuationApproaches.BBA))", "\n {", - "\n var argsNew = args with {Year = dn.Year, Month = MonthInAYear, Scenario = args.Scenario};", + "\n var monthUpperLimit = args.Year == dn.Year ? args.Month : MonthInAYear;", + "\n var argsNew = args with {Year = dn.Year, Month = monthUpperLimit, Scenario = args.Scenario};", "\n var loadedYc = (await querySource.LoadCurrentParameterAsync(argsNew, x => x.Currency, x => x.Currency == dn.ContractualCurrency && x.Name == dn.YieldCurveName));", "\n ", "\n if (!loadedYc.TryGetValue(dn.ContractualCurrency, out var lockedYc))", - "\n ApplicationMessage.Log(Error.YieldCurveNotFound, dn.ContractualCurrency, argsNew.Year.ToString(), argsNew.Month.ToString());", + "\n ApplicationMessage.Log(Error.YieldCurveNotFound, dn.ContractualCurrency, argsNew.Year.ToString(), argsNew.Month.ToString(), argsNew.Scenario, dn.YieldCurveName);", "\n ", "\n lockedInYieldCurveByGoc[dn.DataNode] = lockedYc;", "\n }", @@ -232,10 +233,10 @@ "\n x => x.Currency == key.ContractualCurrency ", "\n && (key.ValuationApproach == ValuationApproaches.VFA", "\n ? x.Name == key.YieldCurveName", - "\n : true));", + "\n : x.Name == (string)null));", "\n ", "\n if (!loadedYc.TryGetValue(key.ContractualCurrency, out var currentYcDict))", - "\n ApplicationMessage.Log(Error.YieldCurveNotFound, key.ContractualCurrency, args.Year.ToString(), args.Month.ToString());", + "\n ApplicationMessage.Log(Error.YieldCurveNotFound, key.ContractualCurrency, args.Year.ToString(), args.Month.ToString(), args.Scenario, key.YieldCurveName);", "\n", "\n foreach(var dn in dnByValAppContrCurrYcName[key])", "\n {", @@ -432,15 +433,15 @@ { "cell_type": "code", "source": [ - "public static async Task LoadPartitionedDataAsync(this IDataSource querySource, Guid partition, Guid? partitionBackup = null)", + "public static async Task LoadPartitionedDataAsync(this IDataSource querySource, Guid partition)", "\n where T : IPartitioned", "\n where P : IPartition", - "\n", "\n{", + "\n var partitionBackup = (Guid)querySource.Partition.GetCurrent(typeof(P).Name);", "\n await querySource.Partition.SetAsync

(partition);", "\n // Temporary workaround for physical database: where clause is necessary", "\n var data = await querySource.Query().Where(x => x.Partition == partition).ToArrayAsync();", - "\n if(partitionBackup != null) await querySource.Partition.SetAsync

(partitionBackup);", + "\n await querySource.Partition.SetAsync

(partitionBackup);", "\n return data;", "\n}" ], @@ -455,19 +456,19 @@ "\n where T : IPartitioned", "\n where P : IPartition", "\n{", - "\n var isRelaxed = targetPartition != defaultPartition &&", - "\n ((format != ImportFormats.Cashflow && typeof(T).Name == nameof(IfrsVariable)) ||", + "\n var isRelaxed = ((format != ImportFormats.Cashflow && typeof(T).Name == nameof(IfrsVariable)) ||", "\n (format == ImportFormats.Cashflow && typeof(T).Name == nameof(RawVariable)));", "\n", "\n var variablesFromWorkspace = await workspace.LoadPartitionedDataAsync(targetPartition);", "\n if(!isRelaxed || variablesFromWorkspace.Any()) return variablesFromWorkspace;", "\n", - "\n // For scenario re-calculation", + "\n // This is for scenario re-calculation", "\n var variablesFromDataSource = await dataSource.LoadPartitionedDataAsync(targetPartition);", "\n if(variablesFromDataSource.Any()) return variablesFromDataSource;", "\n", - "\n // For scenarios related to parameters solely", - "\n return await dataSource.LoadPartitionedDataAsync(defaultPartition, targetPartition);", + "\n // This is for scenarios affecting parameters solely", + "\n // And for the best estimate when parameters are updated", + "\n return await dataSource.LoadPartitionedDataAsync(defaultPartition);", "\n}" ], "metadata": {},