From 32809add1cce993e6dabb9647d69820abce6c33a Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Tue, 20 Dec 2022 10:31:31 +0100 Subject: [PATCH 01/14] Adapting the tests (AocStructureTest, ImportStorageTest, ReportStorageTest, TechnicalMarginTest) so that they can be executed in the Engine. --- ifrs17-template/Test/AocStructureTest.ipynb | 134 +++--- ifrs17-template/Test/ImportStorageTest.ipynb | 423 +++++++++++++++-- ifrs17-template/Test/ReportStorageTest.ipynb | 73 ++- .../Test/TechnicalMarginTest.ipynb | 86 +++- ifrs17-template/Test/TestData.ipynb | 425 ++++++++++++++++++ 5 files changed, 1003 insertions(+), 138 deletions(-) create mode 100644 ifrs17-template/Test/TestData.ipynb diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index b52e9153..32e4aaa4 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -29,7 +29,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -47,18 +47,39 @@ { "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(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, @@ -67,8 +88,7 @@ { "cell_type": "code", "source": [ - "var reportingNode = \"CH\";", - "\nvar scenario = (string)null;" + "await DataSource.UpdateAsync(new [ ] {yieldCurvePrevious});" ], "metadata": {}, "execution_count": 0, @@ -77,20 +97,32 @@ { "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});", + "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});", "\nawait DataSource.CommitAsync();" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Test" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -259,24 +291,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": {}, @@ -378,24 +401,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 +543,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 +646,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-template/Test/ImportStorageTest.ipynb index 19b809b5..d75823e3 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -29,7 +29,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -47,18 +47,20 @@ { "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(new [] {dt11});", + "\nawait DataSource.UpdateAsync(new [] {dtr11});" ], "metadata": {}, "execution_count": 0, @@ -67,10 +69,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,26 +79,50 @@ { "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});", + "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});", "\nawait DataSource.CommitAsync();" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Test" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -144,7 +168,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,14 +185,325 @@ "\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);", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string importFormat = ImportFormats.Actual;", + "\n Activity.Start();", + "\n //Prepare Workspace and DataSource", + "\n await Workspace.UpdateAsync(inputDataSetForWorkspace);", + "\n await DataSource.UpdateAsync(inputDataSetForDataSource);", + "\n ", + "\n //Set up import storage and test universe", + "\n var testStorage = new ImportStorage(args with {ImportFormat = importFormat}, DataSource, Workspace);", + "\n await testStorage.InitializeAsync();", + "\n ", + "\n var ivs = testStorage.IfrsVariablesByImportIdentity.SelectMany(x => x.Value);", + "\n ", + "\n //Clean up Workspace", + "\n //Workspace.Reset(); ", + "\n await Workspace.DeleteAsync(inputDataSetForWorkspace); ", + "\n await DataSource.DeleteAsync(inputDataSetForDataSource); ", + "\n ", + "\n var errors = new List();", + "\n ", + "\n var extraVariablesInStorage = ivs.Except(ivsBenchmark).Select(x => x.ToIdentityString()).ToArray();", + "\n if(extraVariablesInStorage.Any()) errors.Add( $\"IfrsVariables in the storage contain the following items that are not present in the benchmark:\\n{string.Join(\"\\n\",extraVariablesInStorage)}.\" );", + "\n ", + "\n var extraVariablesInBenchmark = ivsBenchmark.Except(ivs).Select(x => x.ToIdentityString()).ToArray();", + "\n if(extraVariablesInBenchmark.Count() > 0) errors.Add( $\"IfrsVariables in the benchmark contain the following items that are not present in the storage:\\n{string.Join(\"\\n\",extraVariablesInBenchmark)}.\" );", + "\n ", + "\n //find duplicates in storage", + "\n var ivsByIdentityString = ivs.GroupBy(x => x.ToIdentityString()).Where(x => x.Count() > 1).Select(x => x.Key);", + "\n if(ivsByIdentityString.Any()) errors.Add($\"IfrsVariables in the storage have duplicated items for:\\n{string.Join(\"\\n\",ivsByIdentityString)}.\");", + "\n ", + "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Partition.GetCurrentPartitions()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Query()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string importFormat = ImportFormats.Actual;", + "\n Activity.Start();", + "\n //Prepare Workspace and DataSource", + "\n await Workspace.UpdateAsync(inputDataSetForWorkspace);", + "\n await DataSource.UpdateAsync(inputDataSetForDataSource);", + "\n ", + "\n //Set up import storage and test universe", + "\n var testStorage = new ImportStorage(args with {ImportFormat = importFormat}, DataSource, Workspace);", + "\n " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var workspace = Workspace;", + "\nvar querySource = DataSource;", + "\nvar ImportFormat = ImportFormats.Actual;", + "\nvar TargetPartition = partition.Id;", + "\nvar DefaultPartition = partition.Id;", + "\nvar estimateTypes = (await workspace.Query().ToArrayAsync());", + "\nvar EstimateTypesByImportFormat = new InputSource[] { InputSource.Opening, InputSource.Actual, InputSource.Cashflow,}", + "\n .ToDictionary(x => x.ToString(), ", + "\n x => estimateTypes", + "\n .Where(et => et.InputSource.Contains(x))", + "\n .Select(et => et.SystemName)", + "\n .ToHashSet());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parsedRawVariables = await workspace.Query().ToArrayAsync();", + "\n var parsedIfrsVariables = await workspace.Query().ToArrayAsync();", + "\n ", + "\n //DataNodes", + "\n var DataNodeDataBySystemName = await workspace.LoadDataNodesAsync(args);", + "\n ", + "\n //Accident Years", + "\n var AccidentYearsByDataNode = (IDictionary>)", + "\n (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => new {x.DataNode, x.AccidentYear}) : parsedIfrsVariables.Select(x => new {x.DataNode, x.AccidentYear}))", + "\n .ToDictionaryGrouped(x => x.DataNode, x => (ICollection)x.Select(y => y.AccidentYear).ToHashSet());", + "\n ", + "\n // Import Scopes and Data Node relationship parameters", + "\n var InterDataNodeParametersByGoc = await workspace.LoadInterDataNodeParametersAsync(args);", + "\n ", + "\n var primaryScopeFromParsedVariables = (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => x.DataNode) : parsedIfrsVariables.Select(x => x.DataNode)).ToHashSet();", + "\n var primaryScopeFromLinkedReinsurance = primaryScopeFromParsedVariables", + "\n .Where(goc => !DataNodeDataBySystemName[goc].IsReinsurance && DataNodeDataBySystemName[goc].LiabilityType == LiabilityTypes.LRC)", + "\n .SelectMany(goc => InterDataNodeParametersByGoc.TryGetValue(goc, out var interDataNodeParamByPeriod)", + "\n ? interDataNodeParamByPeriod[CurrentPeriod].Select(param => param.DataNode == goc ? param.LinkedDataNode : param.DataNode).Where(goc => !primaryScopeFromParsedVariables.Contains(goc))", + "\n : Enumerable.Empty())", + "\n .ToHashSet();", + "\n ", + "\n var primaryScope = primaryScopeFromParsedVariables.Concat(primaryScopeFromLinkedReinsurance).ToHashSet();", + "\n var secondaryScope = InterDataNodeParametersByGoc", + "\n .Where(kvp => primaryScope.Contains(kvp.Key))", + "\n .SelectMany(kvp => { var linkedGocs = kvp.Value[CurrentPeriod].Select(param => param.DataNode == kvp.Key ? param.LinkedDataNode : param.DataNode);", + "\n return linkedGocs.Where(goc => !primaryScope.Contains(goc));}).ToHashSet();", + "\n var allImportScopes = new HashSet(primaryScope.Concat(secondaryScope));", + "\n ", + "\n var DataNodesByImportScope = new Dictionary> { { ImportScope.Primary, primaryScope }, { ImportScope.Secondary, secondaryScope } };", + "\n ", + "\n // Parameters", + "\n var PartnerRating = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Partner);", + "\n var CreditDefaultRates = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.CreditRiskRating);", + "\n var SingleDataNodeParametersByGoc = await workspace.LoadSingleDataNodeParametersAsync(args);", + "\n var LockedInYieldCurve = await workspace.LoadLockedInYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn]));", + "\n var CurrentYieldCurve = await workspace.LoadCurrentYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn])); //TODO Rename this variable", + "\n ", + "\n var AocConfigurationByAocStep = await querySource.LoadAocStepConfigurationAsDictionaryAsync(args.Year, args.Month); ", + "\n var aocStepByInputSource = ((InputSource[])Enum.GetValues(typeof(InputSource))).ToDictionary(x => x,", + "\n x => AocConfigurationByAocStep", + "\n .Where(kvp => kvp.Value.InputSource.Contains(x))", + "\n .Select(kvp => kvp.Key)", + "\n .ToHashSet());", + "\n ", + "\n //Previous Period", + "\n var openingRawVariables = Enumerable.Empty();", + "\n var openingIfrsVariables = Enumerable.Empty();", + "\n", + "\n if(allImportScopes.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year < args.Year)) {", + "\n var PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == previousArgs.Year &&", + "\n p.Month == previousArgs.Month &&", + "\n p.Scenario == null).ToArrayAsync()).Single().Id;", + "\n ", + "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", + "\n ", + "\n //Perform queries to previous Period", + "\n openingRawVariables = (await querySource.Query()", + "\n .Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == AocTypes.CL)", + "\n .Where(v => primaryScope.Contains(v.DataNode))", + "\n .ToArrayAsync())", + "\n .Select(rv => rv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Values = rv.Values.Skip(MonthInAYear).ToArray(), Partition = TargetPartition});", + "\n ", + "\n openingIfrsVariables = (await querySource.Query()", + "\n .Where(iv => iv.Partition == PreviousPeriodPartition && iv.AocType == AocTypes.EOP)", + "\n .Where(v => allImportScopes.Contains(v.DataNode))", + "\n .ToArrayAsync())", + "\n .Select(iv => iv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Partition = TargetPartition});", + "\n ", + "\n // TODO: print error if ", + "\n //openingRawVariables.Select(x => x.DataNode).ToHashSet() != dataNodesWithPreviousPeriod", + "\n }", + "\n ", + "\n //SetPartition to current Period", + "\n await querySource.Partition.SetAsync(TargetPartition);", + "\n ", + "\n if(primaryScope.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year == args.Year) && ImportFormat != ImportFormats.Opening)", + "\n openingIfrsVariables = openingIfrsVariables.Concat(await querySource.Query()", + "\n .Where(iv => iv.Partition == TargetPartition && iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)", + "\n .Where(iv => primaryScope.Contains(iv.DataNode) && EstimateTypesByImportFormat[InputSource.Opening.ToString()].Contains(iv.EstimateType) || secondaryScope.Contains(iv.DataNode))", + "\n .ToArrayAsync());", + "\n ", + "\n //Variables", + "\n var rawVariables = parsedRawVariables.Concat(openingRawVariables)", + "\n .Concat(await querySource.Query()", + "\n .Where(rv => rv.Partition == TargetPartition)", + "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode)).ToArrayAsync()); ", + "\n ", + "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", + "\n .Concat(await querySource.Query()", + "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", + "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", + "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync());", + "\n", + "\n if(DefaultPartition != TargetPartition) {", + "\n await querySource.Partition.SetAsync(DefaultPartition);", + "\n var defaultRawVariables = await querySource.Query()", + "\n .Where(rv => rv.Partition == DefaultPartition)", + "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", + "\n var defaultIfrsVariables = await querySource.Query()", + "\n .Where(iv => iv.Partition == DefaultPartition)", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode)", + "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", + "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync();", + "\n rawVariables = rawVariables.Union(defaultRawVariables, EqualityComparer.Instance);", + "\n ifrsVariables = ifrsVariables.Union(defaultIfrsVariables, EqualityComparer.Instance);", + "\n await querySource.Partition.SetAsync(TargetPartition);", + "\n }", + "\n", + "\n var RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", + "\n var IfrsVariablesByImportIdentity = (IDictionary>)ifrsVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await testStorage.InitializeAsync();", + "\n ", + "\n var ivs = testStorage.IfrsVariablesByImportIdentity.SelectMany(x => x.Value);", + "\n ", + "\n //Clean up Workspace", + "\n //Workspace.Reset(); ", + "\n await Workspace.DeleteAsync(inputDataSetForWorkspace); ", + "\n await DataSource.DeleteAsync(inputDataSetForDataSource); ", + "\n ", + "\n var errors = new List();", + "\n ", + "\n var extraVariablesInStorage = ivs.Except(ivsBenchmark).Select(x => x.ToIdentityString()).ToArray();", + "\n if(extraVariablesInStorage.Any()) errors.Add( $\"IfrsVariables in the storage contain the following items that are not present in the benchmark:\\n{string.Join(\"\\n\",extraVariablesInStorage)}.\" );", + "\n ", + "\n var extraVariablesInBenchmark = ivsBenchmark.Except(ivs).Select(x => x.ToIdentityString()).ToArray();", + "\n if(extraVariablesInBenchmark.Count() > 0) errors.Add( $\"IfrsVariables in the benchmark contain the following items that are not present in the storage:\\n{string.Join(\"\\n\",extraVariablesInBenchmark)}.\" );", + "\n ", + "\n //find duplicates in storage", + "\n var ivsByIdentityString = ivs.GroupBy(x => x.ToIdentityString()).Where(x => x.Count() > 1).Select(x => x.Key);", + "\n if(ivsByIdentityString.Any()) errors.Add($\"IfrsVariables in the storage have duplicated items for:\\n{string.Join(\"\\n\",ivsByIdentityString)}.\");", + "\n ", + "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n errors" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "DataSource.Query()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -182,7 +517,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 +560,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 +605,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 +661,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 +686,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},", diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 0f49a5d2..655f8ed4 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -20,7 +20,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -29,7 +29,7 @@ { "cell_type": "markdown", "source": [ - "# Test Exchange Rate Query" + "# Initialization" ], "metadata": {}, "execution_count": 0, @@ -38,8 +38,34 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization());" + "await Import.FromString(currencies).WithType().WithTarget(DataSource).ExecuteAsync(); " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(reportingNodes).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "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 +112,44 @@ "\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": [ + "(string currentCurrency, string targetCurrency) = (\"EUR\", \"USD\");", + "\n(double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark) = (2, 10, 60);", + "\nawait Workspace.UpdateAsync(testData);", + "\n ", + "\n //Create report storage", + "\n var period = (2021, 6);", + "\n var reportStorage = new ReportStorage(Workspace, Report);", + "\n await reportStorage.InitializeReportIndependentCacheAsync();", + "\n await reportStorage.InitializeAsync(period, \"G\", null, CurrencyType.Contractual);/*", + "\n ", + "\n var fxBOP = reportStorage.GetFx(period, currentCurrency, targetCurrency, FxPeriod.BeginningOfPeriod);", + "\n var fxAVG = reportStorage.GetFx(period, currentCurrency, targetCurrency, FxPeriod.Average);", + "\n var fxEOP = reportStorage.GetFx(period, currentCurrency, targetCurrency, FxPeriod.EndOfPeriod);", + "\n ", + "\n //Check FX rates", + "\n fxBOP.Should().Be(fxBOPBenchmark);", + "\n fxAVG.Should().Be(fxAVGBenchmark);", + "\n fxEOP.Should().Be(fxEOPBenchmark);", + "\n ", + "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());*/" + ], + "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-template/Test/TechnicalMarginTest.ipynb index 8d0d4f34..376a52e1 100644 --- a/ifrs17-template/Test/TechnicalMarginTest.ipynb +++ b/ifrs17-template/Test/TechnicalMarginTest.ipynb @@ -29,7 +29,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + "#!import \"TestData\"" ], "metadata": {}, "execution_count": 0, @@ -47,18 +47,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 +80,7 @@ { "cell_type": "code", "source": [ - "//define group of contract", - "\nvar groupOfContract = \"DT1.1\";" + "await DataSource.UpdateAsync(projcetionConfigurationPrevious.RepeatOnce())" ], "metadata": {}, "execution_count": 0, @@ -77,11 +89,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 +133,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 +201,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 +222,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 +241,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 +281,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 +317,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-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb new file mode 100644 index 00000000..63959259 --- /dev/null +++ b/ifrs17-template/Test/TestData.ipynb @@ -0,0 +1,425 @@ +{ + "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": "code", + "source": [ + "#!import \"../../ifrs17/CalculationEngine\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "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 = /// there was a change in the DA inputSource 3->7", + "\n@\"@@EstimateType,,,,,,,,,,,", + "\nSystemName,DisplayName,Order,StructureType,InputSource,PeriodType,ExternalId0,ExternalId1,ExternalId2,ExternalId3,ExternalId4,", + "\nBE,Best Estimate of Present Value,1,AoC,4,EndOfPeriod,,,,,,", + "\nRA,Risk Adjustment,10,AoC,4,EndOfPeriod,,,,,,", + "\nCU,CoverageUnit,15,AoC,4,EndOfPeriod,,,,,,", + "\nC,Contractual Service Margin,20,AoC,7,NotApplicable,,,,,,", + "\nL,Loss Component,30,AoC,7,NotApplicable,,,,,,", + "\nLR,Loss Recovery Component,40,AoC,7,NotApplicable,,,,,,", + "\nPL,Profit and Loss,50,None,7,NotApplicable,,,,,,", + "\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,,,,,,", + "\nF,Factors,100,None,4,NotApplicable,,,,,,", + "\nAPA,Actuals,130,None,2,NotApplicable,,,,,,", + "\nBEPA,Best Estimate of Present Value,140,None,4,NotApplicable,,,,,,", + "\n,,,,,,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Projection Configuration" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var projcetionConfigurationPrevious = new ProjectionConfiguration(){", + "\n Shift = 0,", + "\n TimeStep = 12,", + "\n SystemName = \"P11\",", + "\n DisplayName = \"End of December\"", + "\n};" + ], + "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,ExternalId0,ExternalId1,ExternalId2,ExternalId3,,,", + "\nPR,Premiums,,10,BeginningOfPeriod,PayablePR,ReceivablePR,RiPayablePR,RiReceivablePR,,,", + "\nCL,Claims,,20,EndOfPeriod,,,,,,,", + "\nNIC,Non Investment Component,CL,30,EndOfPeriod,PayableNIC,ReceivableNIC,RiPayableNIC,RiReceivableNIC,,,", + "\nICO,Investment Component,CL,40,EndOfPeriod,PayableICO,ReceivableICO,,,,,", + "\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 reportingNodes = ", + "\n@\"@@ReportingNode,,,,", + "\nSystemName,DisplayName,Parent,Currency", + "\nG,Group,,CHF", + "\nCH,Switzerland,G,CHF", + "\nDE,Germany,G,EUR", + "\nES,Spain,G,EUR", + "\nFR,France,G,EUR", + "\nIT,Italy,G,EUR", + "\nUK,United Kingdom,G,GBP", + "\nSK,Slovakia,G,EUR\";", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Currencies" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var currencies = ", + "\n@\"@@Currency,,,,,,,,,,,", + "\nSystemName,DisplayName,,,,,,,,,,", + "\nUSD,United States Dollar,,,,,,,,,,", + "\nCHF,Swiss Franc,,,,,,,,,,", + "\nDKK,Danish Krone,,,,,,,,,,", + "\nEUR,Euro,,,,,,,,,,", + "\nGBP,British Pound,,,,,,,,,,", + "\nHKD,Hong Kong Dollar,,,,,,,,,,", + "\nITL,Italian Lira,,,,,,,,,,", + "\nPLN,Polish Zloty (since 01.01.95),,,,,,,,,,", + "\nSKK,Slovakian Krona,,,,,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Variables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var groupOfInsuranceContracts = \"DT1.1\"; //TODO", + "\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 Scenario = args.Scenario};", + "\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};", + "\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 = \"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 = \"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};", + "\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 From e6a15db2b6dd0daf730bd30f8e1b32cf060f4030 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Tue, 20 Dec 2022 10:58:18 +0100 Subject: [PATCH 02/14] Cleanup. --- ifrs17-template/Test/AocStructureTest.ipynb | 6 +- ifrs17-template/Test/ImportStorageTest.ipynb | 314 +------------------ ifrs17-template/Test/ReportStorageTest.ipynb | 28 -- 3 files changed, 5 insertions(+), 343 deletions(-) diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index 32e4aaa4..8500f9d4 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -377,7 +377,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, @@ -386,7 +388,7 @@ { "cell_type": "code", "source": [ - "await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm)" + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index d75823e3..fde7482a 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -185,325 +185,13 @@ "\n basicIfrsVariable with {AocType = AocTypes.CF, Value = -10.0},", "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", - "\n" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "string importFormat = ImportFormats.Actual;", - "\n Activity.Start();", - "\n //Prepare Workspace and DataSource", - "\n await Workspace.UpdateAsync(inputDataSetForWorkspace);", - "\n await DataSource.UpdateAsync(inputDataSetForDataSource);", - "\n ", - "\n //Set up import storage and test universe", - "\n var testStorage = new ImportStorage(args with {ImportFormat = importFormat}, DataSource, Workspace);", - "\n await testStorage.InitializeAsync();", - "\n ", - "\n var ivs = testStorage.IfrsVariablesByImportIdentity.SelectMany(x => x.Value);", - "\n ", - "\n //Clean up Workspace", - "\n //Workspace.Reset(); ", - "\n await Workspace.DeleteAsync(inputDataSetForWorkspace); ", - "\n await DataSource.DeleteAsync(inputDataSetForDataSource); ", - "\n ", - "\n var errors = new List();", - "\n ", - "\n var extraVariablesInStorage = ivs.Except(ivsBenchmark).Select(x => x.ToIdentityString()).ToArray();", - "\n if(extraVariablesInStorage.Any()) errors.Add( $\"IfrsVariables in the storage contain the following items that are not present in the benchmark:\\n{string.Join(\"\\n\",extraVariablesInStorage)}.\" );", - "\n ", - "\n var extraVariablesInBenchmark = ivsBenchmark.Except(ivs).Select(x => x.ToIdentityString()).ToArray();", - "\n if(extraVariablesInBenchmark.Count() > 0) errors.Add( $\"IfrsVariables in the benchmark contain the following items that are not present in the storage:\\n{string.Join(\"\\n\",extraVariablesInBenchmark)}.\" );", - "\n ", - "\n //find duplicates in storage", - "\n var ivsByIdentityString = ivs.GroupBy(x => x.ToIdentityString()).Where(x => x.Count() > 1).Select(x => x.Key);", - "\n if(ivsByIdentityString.Any()) errors.Add($\"IfrsVariables in the storage have duplicated items for:\\n{string.Join(\"\\n\",ivsByIdentityString)}.\");", - "\n ", - "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", - "\n return Activity.Finish();", - "\n" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "Workspace.Partition.GetCurrentPartitions()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "Workspace.Query()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "string importFormat = ImportFormats.Actual;", - "\n Activity.Start();", - "\n //Prepare Workspace and DataSource", - "\n await Workspace.UpdateAsync(inputDataSetForWorkspace);", - "\n await DataSource.UpdateAsync(inputDataSetForDataSource);", - "\n ", - "\n //Set up import storage and test universe", - "\n var testStorage = new ImportStorage(args with {ImportFormat = importFormat}, DataSource, Workspace);", - "\n " - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var workspace = Workspace;", - "\nvar querySource = DataSource;", - "\nvar ImportFormat = ImportFormats.Actual;", - "\nvar TargetPartition = partition.Id;", - "\nvar DefaultPartition = partition.Id;", - "\nvar estimateTypes = (await workspace.Query().ToArrayAsync());", - "\nvar EstimateTypesByImportFormat = new InputSource[] { InputSource.Opening, InputSource.Actual, InputSource.Cashflow,}", - "\n .ToDictionary(x => x.ToString(), ", - "\n x => estimateTypes", - "\n .Where(et => et.InputSource.Contains(x))", - "\n .Select(et => et.SystemName)", - "\n .ToHashSet());" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var parsedRawVariables = await workspace.Query().ToArrayAsync();", - "\n var parsedIfrsVariables = await workspace.Query().ToArrayAsync();", - "\n ", - "\n //DataNodes", - "\n var DataNodeDataBySystemName = await workspace.LoadDataNodesAsync(args);", - "\n ", - "\n //Accident Years", - "\n var AccidentYearsByDataNode = (IDictionary>)", - "\n (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => new {x.DataNode, x.AccidentYear}) : parsedIfrsVariables.Select(x => new {x.DataNode, x.AccidentYear}))", - "\n .ToDictionaryGrouped(x => x.DataNode, x => (ICollection)x.Select(y => y.AccidentYear).ToHashSet());", - "\n ", - "\n // Import Scopes and Data Node relationship parameters", - "\n var InterDataNodeParametersByGoc = await workspace.LoadInterDataNodeParametersAsync(args);", - "\n ", - "\n var primaryScopeFromParsedVariables = (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => x.DataNode) : parsedIfrsVariables.Select(x => x.DataNode)).ToHashSet();", - "\n var primaryScopeFromLinkedReinsurance = primaryScopeFromParsedVariables", - "\n .Where(goc => !DataNodeDataBySystemName[goc].IsReinsurance && DataNodeDataBySystemName[goc].LiabilityType == LiabilityTypes.LRC)", - "\n .SelectMany(goc => InterDataNodeParametersByGoc.TryGetValue(goc, out var interDataNodeParamByPeriod)", - "\n ? interDataNodeParamByPeriod[CurrentPeriod].Select(param => param.DataNode == goc ? param.LinkedDataNode : param.DataNode).Where(goc => !primaryScopeFromParsedVariables.Contains(goc))", - "\n : Enumerable.Empty())", - "\n .ToHashSet();", - "\n ", - "\n var primaryScope = primaryScopeFromParsedVariables.Concat(primaryScopeFromLinkedReinsurance).ToHashSet();", - "\n var secondaryScope = InterDataNodeParametersByGoc", - "\n .Where(kvp => primaryScope.Contains(kvp.Key))", - "\n .SelectMany(kvp => { var linkedGocs = kvp.Value[CurrentPeriod].Select(param => param.DataNode == kvp.Key ? param.LinkedDataNode : param.DataNode);", - "\n return linkedGocs.Where(goc => !primaryScope.Contains(goc));}).ToHashSet();", - "\n var allImportScopes = new HashSet(primaryScope.Concat(secondaryScope));", - "\n ", - "\n var DataNodesByImportScope = new Dictionary> { { ImportScope.Primary, primaryScope }, { ImportScope.Secondary, secondaryScope } };", - "\n ", - "\n // Parameters", - "\n var PartnerRating = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Partner);", - "\n var CreditDefaultRates = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.CreditRiskRating);", - "\n var SingleDataNodeParametersByGoc = await workspace.LoadSingleDataNodeParametersAsync(args);", - "\n var LockedInYieldCurve = await workspace.LoadLockedInYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn]));", - "\n var CurrentYieldCurve = await workspace.LoadCurrentYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn])); //TODO Rename this variable", - "\n ", - "\n var AocConfigurationByAocStep = await querySource.LoadAocStepConfigurationAsDictionaryAsync(args.Year, args.Month); ", - "\n var aocStepByInputSource = ((InputSource[])Enum.GetValues(typeof(InputSource))).ToDictionary(x => x,", - "\n x => AocConfigurationByAocStep", - "\n .Where(kvp => kvp.Value.InputSource.Contains(x))", - "\n .Select(kvp => kvp.Key)", - "\n .ToHashSet());", - "\n ", - "\n //Previous Period", - "\n var openingRawVariables = Enumerable.Empty();", - "\n var openingIfrsVariables = Enumerable.Empty();", - "\n", - "\n if(allImportScopes.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year < args.Year)) {", - "\n var PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == previousArgs.Year &&", - "\n p.Month == previousArgs.Month &&", - "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n ", - "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", - "\n ", - "\n //Perform queries to previous Period", - "\n openingRawVariables = (await querySource.Query()", - "\n .Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == AocTypes.CL)", - "\n .Where(v => primaryScope.Contains(v.DataNode))", - "\n .ToArrayAsync())", - "\n .Select(rv => rv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Values = rv.Values.Skip(MonthInAYear).ToArray(), Partition = TargetPartition});", - "\n ", - "\n openingIfrsVariables = (await querySource.Query()", - "\n .Where(iv => iv.Partition == PreviousPeriodPartition && iv.AocType == AocTypes.EOP)", - "\n .Where(v => allImportScopes.Contains(v.DataNode))", - "\n .ToArrayAsync())", - "\n .Select(iv => iv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Partition = TargetPartition});", - "\n ", - "\n // TODO: print error if ", - "\n //openingRawVariables.Select(x => x.DataNode).ToHashSet() != dataNodesWithPreviousPeriod", - "\n }", - "\n ", - "\n //SetPartition to current Period", - "\n await querySource.Partition.SetAsync(TargetPartition);", - "\n ", - "\n if(primaryScope.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year == args.Year) && ImportFormat != ImportFormats.Opening)", - "\n openingIfrsVariables = openingIfrsVariables.Concat(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)", - "\n .Where(iv => primaryScope.Contains(iv.DataNode) && EstimateTypesByImportFormat[InputSource.Opening.ToString()].Contains(iv.EstimateType) || secondaryScope.Contains(iv.DataNode))", - "\n .ToArrayAsync());", - "\n ", - "\n //Variables", - "\n var rawVariables = parsedRawVariables.Concat(openingRawVariables)", - "\n .Concat(await querySource.Query()", - "\n .Where(rv => rv.Partition == TargetPartition)", - "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode)).ToArrayAsync()); ", - "\n ", - "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", - "\n .Concat(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", - "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", - "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", - "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", - "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync());", - "\n", - "\n if(DefaultPartition != TargetPartition) {", - "\n await querySource.Partition.SetAsync(DefaultPartition);", - "\n var defaultRawVariables = await querySource.Query()", - "\n .Where(rv => rv.Partition == DefaultPartition)", - "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", - "\n var defaultIfrsVariables = await querySource.Query()", - "\n .Where(iv => iv.Partition == DefaultPartition)", - "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode)", - "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", - "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", - "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync();", - "\n rawVariables = rawVariables.Union(defaultRawVariables, EqualityComparer.Instance);", - "\n ifrsVariables = ifrsVariables.Union(defaultIfrsVariables, EqualityComparer.Instance);", - "\n await querySource.Partition.SetAsync(TargetPartition);", - "\n }", - "\n", - "\n var RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", - "\n var IfrsVariablesByImportIdentity = (IDictionary>)ifrsVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await testStorage.InitializeAsync();", - "\n ", - "\n var ivs = testStorage.IfrsVariablesByImportIdentity.SelectMany(x => x.Value);", - "\n ", - "\n //Clean up Workspace", - "\n //Workspace.Reset(); ", - "\n await Workspace.DeleteAsync(inputDataSetForWorkspace); ", - "\n await DataSource.DeleteAsync(inputDataSetForDataSource); ", - "\n ", - "\n var errors = new List();", - "\n ", - "\n var extraVariablesInStorage = ivs.Except(ivsBenchmark).Select(x => x.ToIdentityString()).ToArray();", - "\n if(extraVariablesInStorage.Any()) errors.Add( $\"IfrsVariables in the storage contain the following items that are not present in the benchmark:\\n{string.Join(\"\\n\",extraVariablesInStorage)}.\" );", - "\n ", - "\n var extraVariablesInBenchmark = ivsBenchmark.Except(ivs).Select(x => x.ToIdentityString()).ToArray();", - "\n if(extraVariablesInBenchmark.Count() > 0) errors.Add( $\"IfrsVariables in the benchmark contain the following items that are not present in the storage:\\n{string.Join(\"\\n\",extraVariablesInBenchmark)}.\" );", - "\n ", - "\n //find duplicates in storage", - "\n var ivsByIdentityString = ivs.GroupBy(x => x.ToIdentityString()).Where(x => x.Count() > 1).Select(x => x.Key);", - "\n if(ivsByIdentityString.Any()) errors.Add($\"IfrsVariables in the storage have duplicated items for:\\n{string.Join(\"\\n\",ivsByIdentityString)}.\");", - "\n ", - "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", - "\n errors" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "DataSource.Query()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 655f8ed4..0040ac0c 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -118,34 +118,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "(string currentCurrency, string targetCurrency) = (\"EUR\", \"USD\");", - "\n(double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark) = (2, 10, 60);", - "\nawait Workspace.UpdateAsync(testData);", - "\n ", - "\n //Create report storage", - "\n var period = (2021, 6);", - "\n var reportStorage = new ReportStorage(Workspace, Report);", - "\n await reportStorage.InitializeReportIndependentCacheAsync();", - "\n await reportStorage.InitializeAsync(period, \"G\", null, CurrencyType.Contractual);/*", - "\n ", - "\n var fxBOP = reportStorage.GetFx(period, currentCurrency, targetCurrency, FxPeriod.BeginningOfPeriod);", - "\n var fxAVG = reportStorage.GetFx(period, currentCurrency, targetCurrency, FxPeriod.Average);", - "\n var fxEOP = reportStorage.GetFx(period, currentCurrency, targetCurrency, FxPeriod.EndOfPeriod);", - "\n ", - "\n //Check FX rates", - "\n fxBOP.Should().Be(fxBOPBenchmark);", - "\n fxAVG.Should().Be(fxAVGBenchmark);", - "\n fxEOP.Should().Be(fxEOPBenchmark);", - "\n ", - "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());*/" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ From a47ea067e7597627c766839a556e27f3fbab792e Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Tue, 20 Dec 2022 14:11:34 +0100 Subject: [PATCH 03/14] Enhancements - reducing import string sizes. --- ifrs17-template/Test/ReportStorageTest.ipynb | 11 +--- ifrs17-template/Test/TestData.ipynb | 66 +++----------------- 2 files changed, 8 insertions(+), 69 deletions(-) diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 0040ac0c..3b02039b 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -38,16 +38,7 @@ { "cell_type": "code", "source": [ - "await Import.FromString(currencies).WithType().WithTarget(DataSource).ExecuteAsync(); " - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(reportingNodes).WithType().WithTarget(DataSource).ExecuteAsync();" + "await DataSource.UpdateAsync(reportingNode.RepeatOnce());" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index 63959259..9b6e278a 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -105,23 +105,14 @@ { "cell_type": "code", "source": [ - "var estimateType = /// there was a change in the DA inputSource 3->7", + "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,,,,,,", - "\nRA,Risk Adjustment,10,AoC,4,EndOfPeriod,,,,,,", - "\nCU,CoverageUnit,15,AoC,4,EndOfPeriod,,,,,,", - "\nC,Contractual Service Margin,20,AoC,7,NotApplicable,,,,,,", - "\nL,Loss Component,30,AoC,7,NotApplicable,,,,,,", - "\nLR,Loss Recovery Component,40,AoC,7,NotApplicable,,,,,,", - "\nPL,Profit and Loss,50,None,7,NotApplicable,,,,,,", "\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,,,,,,", - "\nF,Factors,100,None,4,NotApplicable,,,,,,", - "\nAPA,Actuals,130,None,2,NotApplicable,,,,,,", - "\nBEPA,Best Estimate of Present Value,140,None,4,NotApplicable,,,,,,", "\n,,,,,,,,,,,\";" ], "metadata": {}, @@ -168,19 +159,12 @@ "\nSystemName,DisplayName,Parent,Order,PeriodType,ExternalId0,ExternalId1,ExternalId2,ExternalId3,,,", "\nPR,Premiums,,10,BeginningOfPeriod,PayablePR,ReceivablePR,RiPayablePR,RiReceivablePR,,,", "\nCL,Claims,,20,EndOfPeriod,,,,,,,", - "\nNIC,Non Investment Component,CL,30,EndOfPeriod,PayableNIC,ReceivableNIC,RiPayableNIC,RiReceivableNIC,,,", "\nICO,Investment Component,CL,40,EndOfPeriod,PayableICO,ReceivableICO,,,,,", - "\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,,,,,,,\";" + "\nACA,Aquisition,AC,130,BeginningOfPeriod,,,,,,,\";" ], "metadata": {}, "execution_count": 0, @@ -198,47 +182,11 @@ { "cell_type": "code", "source": [ - "var reportingNodes = ", - "\n@\"@@ReportingNode,,,,", - "\nSystemName,DisplayName,Parent,Currency", - "\nG,Group,,CHF", - "\nCH,Switzerland,G,CHF", - "\nDE,Germany,G,EUR", - "\nES,Spain,G,EUR", - "\nFR,France,G,EUR", - "\nIT,Italy,G,EUR", - "\nUK,United Kingdom,G,GBP", - "\nSK,Slovakia,G,EUR\";", - "\n" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Currencies" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var currencies = ", - "\n@\"@@Currency,,,,,,,,,,,", - "\nSystemName,DisplayName,,,,,,,,,,", - "\nUSD,United States Dollar,,,,,,,,,,", - "\nCHF,Swiss Franc,,,,,,,,,,", - "\nDKK,Danish Krone,,,,,,,,,,", - "\nEUR,Euro,,,,,,,,,,", - "\nGBP,British Pound,,,,,,,,,,", - "\nHKD,Hong Kong Dollar,,,,,,,,,,", - "\nITL,Italian Lira,,,,,,,,,,", - "\nPLN,Polish Zloty (since 01.01.95),,,,,,,,,,", - "\nSKK,Slovakian Krona,,,,,,,,,,\";" + "var reportingNode = new ReportingNode() {", + "\n SystemName = \"G\",", + "\n DisplayName = \"Group\",", + "\n Currency = \"CHF\"", + "\n};" ], "metadata": {}, "execution_count": 0, From 8aadb7a374e5365297388e304af58f1fb0ea67b9 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Wed, 21 Dec 2022 08:46:40 +0100 Subject: [PATCH 04/14] Optimizing data. --- ifrs17-template/Test/TestData.ipynb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index 9b6e278a..5ee6bb9b 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -159,12 +159,7 @@ "\nSystemName,DisplayName,Parent,Order,PeriodType,ExternalId0,ExternalId1,ExternalId2,ExternalId3,,,", "\nPR,Premiums,,10,BeginningOfPeriod,PayablePR,ReceivablePR,RiPayablePR,RiReceivablePR,,,", "\nCL,Claims,,20,EndOfPeriod,,,,,,,", - "\nICO,Investment Component,CL,40,EndOfPeriod,PayableICO,ReceivableICO,,,,,", - "\nAE,Attributable Expenses,,80,BeginningOfPeriod,,,,,,,", - "\nAEA,Aquisition,AE,90,BeginningOfPeriod,,,,,,,", - "\nNE,Non Attributable Expenses,,110,BeginningOfPeriod,,,,,,,", - "\nAC,Attributable Commission,,120,BeginningOfPeriod,,,,,,,", - "\nACA,Aquisition,AC,130,BeginningOfPeriod,,,,,,,\";" + "\nICO,Investment Component,CL,40,EndOfPeriod,PayableICO,ReceivableICO,,,,,\";" ], "metadata": {}, "execution_count": 0, From 8eca198ed32a67f99cca057567476158e315eafa Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Wed, 21 Dec 2022 09:55:14 +0100 Subject: [PATCH 05/14] Bug fix, and updating the data to the newest changes in the develop. --- ifrs17-template/Test/TestData.ipynb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index 5ee6bb9b..95ca8537 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -177,7 +177,7 @@ { "cell_type": "code", "source": [ - "var reportingNode = new ReportingNode() {", + "var reportingNodeG = new ReportingNode() {", "\n SystemName = \"G\",", "\n DisplayName = \"Group\",", "\n Currency = \"CHF\"", @@ -241,9 +241,7 @@ "\n Year = previousArgs.Year,", "\n Month = previousArgs.Month };", "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = args.ReportingNode, ", - "\n Scenario = args.Scenario};", - "\n" + "\n ReportingNode = args.ReportingNode};" ], "metadata": {}, "execution_count": 0, From 87307d63406d3c63ae9a088c946ff077ac8412cd Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Wed, 18 Jan 2023 10:15:33 +0100 Subject: [PATCH 06/14] Davide's feedback. --- ifrs17-template/Test/AocStructureTest.ipynb | 1 + ifrs17-template/Test/TestData.ipynb | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index 8500f9d4..4515930a 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -59,6 +59,7 @@ "cell_type": "code", "source": [ "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", "\nawait DataSource.UpdateAsync(new [] {dt11});", "\nawait DataSource.UpdateAsync(new [] {dtr11});" ], diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index 95ca8537..c62915eb 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -199,7 +199,7 @@ { "cell_type": "code", "source": [ - "var groupOfInsuranceContracts = \"DT1.1\"; //TODO", + "var groupOfInsuranceContracts = \"DT1.1\";", "\nvar groupOfReinsuranceContracts = \"DTR1.1\";", "\nvar reportingNode = \"CH\";", "\nvar scenario = (string)null;" @@ -241,7 +241,8 @@ "\n Year = previousArgs.Year,", "\n Month = previousArgs.Month };", "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = args.ReportingNode};" + "\n ReportingNode = args.ReportingNode};", + "\n" ], "metadata": {}, "execution_count": 0, @@ -268,6 +269,17 @@ "\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\",", @@ -283,7 +295,7 @@ "\n};", "\n", "\nvar dtr11 = new GroupOfReinsuranceContract(){", - "\n Portfolio = \"DT1\",", + "\n Portfolio = \"DTR1\",", "\n Profitability = \"P\",", "\n LiabilityType = \"LRC\",", "\n AnnualCohort = 2020,", From f33e832a8d640b411995951ea265990f9489333c Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Wed, 18 Jan 2023 10:19:22 +0100 Subject: [PATCH 07/14] More Davide's feedback. --- ifrs17-template/Test/ImportStorageTest.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index 48e56cde..da16a523 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -59,6 +59,7 @@ "cell_type": "code", "source": [ "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", "\nawait DataSource.UpdateAsync(new [] {dt11});", "\nawait DataSource.UpdateAsync(new [] {dtr11});" ], From 8f4f3c12f4808d9b56faeca9302feb998c659812 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Mon, 23 Jan 2023 10:24:50 +0100 Subject: [PATCH 08/14] Importing entire ProjectionConfiguration instead. --- .../Test/TechnicalMarginTest.ipynb | 2 +- ifrs17-template/Test/TestData.ipynb | 29 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ifrs17-template/Test/TechnicalMarginTest.ipynb b/ifrs17-template/Test/TechnicalMarginTest.ipynb index 376a52e1..cf5ca2a8 100644 --- a/ifrs17-template/Test/TechnicalMarginTest.ipynb +++ b/ifrs17-template/Test/TechnicalMarginTest.ipynb @@ -80,7 +80,7 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(projcetionConfigurationPrevious.RepeatOnce())" + "await Import.FromString(projectionConfiguration).WithType().WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index c62915eb..f8a6bfda 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -131,12 +131,29 @@ { "cell_type": "code", "source": [ - "var projcetionConfigurationPrevious = new ProjectionConfiguration(){", - "\n Shift = 0,", - "\n TimeStep = 12,", - "\n SystemName = \"P11\",", - "\n DisplayName = \"End of December\"", - "\n};" + "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, From a7c8bb2b5b3e2b71cd997542f6701c3f397fd260 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Mon, 23 Jan 2023 11:43:14 +0100 Subject: [PATCH 09/14] Proper import of the CE --- ifrs17-template/Test/TestData.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index f8a6bfda..9642260f 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -18,7 +18,8 @@ { "cell_type": "code", "source": [ - "#!import \"../../ifrs17/CalculationEngine\"" + "#!import \"../Constants/CalculationEngine\"", + "\n#!eval calculationEngine" ], "metadata": {}, "execution_count": 0, From a4c1c07ed17e343ede69c87cbc2887462d832391 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Mon, 23 Jan 2023 13:56:54 +0100 Subject: [PATCH 10/14] Solving an issue with yield curve changes. --- ifrs17-template/Test/ImportStorageTest.ipynb | 2 +- ifrs17-template/Test/TestData.ipynb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index da16a523..935e8105 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -80,7 +80,7 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurvePrevious});" + "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurveCHF, yieldCurvePrevious});" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index 9642260f..13e47349 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -381,6 +381,14 @@ "\n Month = 3,", "\n Values = new []{0.005,0.005,0.005,0.005}", "\n};", + "\n", + "\nvar yieldCurveCHF = new YieldCurve(){", + "\n Currency = \"CHF\",", + "\n Year = 2020,", + "\n Month = 12,", + "\n Values = new []{0.01, 0.02, 0.025, 0.025}", + "\n};", + "\n", "\nvar yieldCurvePrevious = new YieldCurve(){", "\n Currency = \"USD\",", "\n Year = 2020,", From 0b788c9ec359ecaa2f6168f2ec892f04025aeaab Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Mon, 23 Jan 2023 14:27:01 +0100 Subject: [PATCH 11/14] better way of solving the issue with the yield curve change. --- ifrs17-template/Test/ImportStorageTest.ipynb | 14 +++++++------- ifrs17-template/Test/TestData.ipynb | 7 ------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index 935e8105..b77452ee 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -80,7 +80,7 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurveCHF, yieldCurvePrevious});" + "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurvePrevious});" ], "metadata": {}, "execution_count": 0, @@ -451,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-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index 13e47349..b5b78c66 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -382,13 +382,6 @@ "\n Values = new []{0.005,0.005,0.005,0.005}", "\n};", "\n", - "\nvar yieldCurveCHF = new YieldCurve(){", - "\n Currency = \"CHF\",", - "\n Year = 2020,", - "\n Month = 12,", - "\n Values = new []{0.01, 0.02, 0.025, 0.025}", - "\n};", - "\n", "\nvar yieldCurvePrevious = new YieldCurve(){", "\n Currency = \"USD\",", "\n Year = 2020,", From c847454d459a2c9d73d2d4ec1bb70421c1ba75b6 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Mon, 23 Jan 2023 15:03:27 +0100 Subject: [PATCH 12/14] Removing commits, as the tests now run in memory. --- ifrs17-template/Test/AocStructureTest.ipynb | 3 +-- ifrs17-template/Test/ImportStorageTest.ipynb | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index 4515930a..1d74e862 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -108,8 +108,7 @@ "cell_type": "code", "source": [ "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", - "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});", - "\nawait DataSource.CommitAsync();" + "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index b77452ee..acf5e5f1 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -108,8 +108,7 @@ "cell_type": "code", "source": [ "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", - "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});", - "\nawait DataSource.CommitAsync();" + "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" ], "metadata": {}, "execution_count": 0, From e0e6f19af0db091d4b8ca75e6a2967e5b82d0736 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Wed, 25 Jan 2023 11:00:30 +0100 Subject: [PATCH 13/14] Fixing a bugg in ReportStorageTest and making the tests run in the tests file --- ifrs17-template/Test/AocStructureTest.ipynb | 10 ++++++++++ ifrs17-template/Test/ImportStorageTest.ipynb | 10 ++++++++++ ifrs17-template/Test/ReportStorageTest.ipynb | 12 +++++++++++- ifrs17-template/Test/TechnicalMarginTest.ipynb | 10 ++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index 1d74e862..c13eee40 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -44,6 +44,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index acf5e5f1..985ef965 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -44,6 +44,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 3b02039b..21d410fb 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -38,7 +38,17 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(reportingNode.RepeatOnce());" + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(reportingNodeG.RepeatOnce());" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/TechnicalMarginTest.ipynb b/ifrs17-template/Test/TechnicalMarginTest.ipynb index cf5ca2a8..537208b5 100644 --- a/ifrs17-template/Test/TechnicalMarginTest.ipynb +++ b/ifrs17-template/Test/TechnicalMarginTest.ipynb @@ -44,6 +44,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ From 1b278037004a2589983c1e0ccc4c175952cc512b Mon Sep 17 00:00:00 2001 From: Teo Kukuljan Date: Wed, 25 Jan 2023 11:20:02 +0100 Subject: [PATCH 14/14] Fixing the amount types --- ifrs17-template/Test/TestData.ipynb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ifrs17-template/Test/TestData.ipynb b/ifrs17-template/Test/TestData.ipynb index b5b78c66..66b22324 100644 --- a/ifrs17-template/Test/TestData.ipynb +++ b/ifrs17-template/Test/TestData.ipynb @@ -113,8 +113,7 @@ "\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,,,,,,", - "\n,,,,,,,,,,,\";" + "\nA,Actuals,90,None,2,NotApplicable,,,,,,\";" ], "metadata": {}, "execution_count": 0, @@ -174,10 +173,22 @@ "source": [ "var amountType = ", "\n@\"@@AmountType,,,,,,,,,,,", - "\nSystemName,DisplayName,Parent,Order,PeriodType,ExternalId0,ExternalId1,ExternalId2,ExternalId3,,,", - "\nPR,Premiums,,10,BeginningOfPeriod,PayablePR,ReceivablePR,RiPayablePR,RiReceivablePR,,,", + "\nSystemName,DisplayName,Parent,Order,PeriodType,,,,,,,", + "\nPR,Premiums,,10,BeginningOfPeriod,,,,,,,", "\nCL,Claims,,20,EndOfPeriod,,,,,,,", - "\nICO,Investment Component,CL,40,EndOfPeriod,PayableICO,ReceivableICO,,,,,\";" + "\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,