diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index b52e9153..c13eee40 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,50 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization()", - "\n .DisableInitialization());" + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Test" + "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": "code", + "source": [ + "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(new [] {dt11});", + "\nawait DataSource.UpdateAsync(new [] {dtr11});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new [ ] {dt11State,dtr11State});", + "\nawait DataSource.UpdateAsync(new [ ] {dt11Inter});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(estimateType).WithType().WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, @@ -67,8 +99,7 @@ { "cell_type": "code", "source": [ - "var reportingNode = \"CH\";", - "\nvar scenario = (string)null;" + "await DataSource.UpdateAsync(new [ ] {yieldCurvePrevious});" ], "metadata": {}, "execution_count": 0, @@ -77,15 +108,26 @@ { "cell_type": "code", "source": [ - "//Define partition", - "\nvar args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", - "\n Year = args.Year,", - "\n Month = args.Month };", - "\nawait DataSource.UpdateAsync(new[]{partition});", - "\nawait DataSource.CommitAsync();" + "Workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", + "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" ], "metadata": {}, "execution_count": 0, @@ -259,24 +301,15 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var groupOfContract = \"DT1.1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "var inputRawVariables = new RawVariable[]{", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"EV\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", - "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfContract, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"EV\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n};" ], "metadata": {}, @@ -354,7 +387,9 @@ "\n new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", "\n }},", "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", - "\n };" + "\n };", + "\nvar activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -363,7 +398,7 @@ { "cell_type": "code", "source": [ - "await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm)" + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -378,24 +413,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 +555,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 +658,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 73c83161..985ef965 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,19 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization()", - "\n .DisableInitialization());" + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Test IfrsVariables Query" + "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, @@ -67,10 +68,10 @@ { "cell_type": "code", "source": [ - "var gic = \"DT1.1\";", - "\nvar gric = \"DTR1.1\";", - "\nvar reportingNode = \"CH\";", - "\nvar scenario = (string)null;" + "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(new [] {dt11});", + "\nawait DataSource.UpdateAsync(new [] {dtr11});" ], "metadata": {}, "execution_count": 0, @@ -79,21 +80,54 @@ { "cell_type": "code", "source": [ - "//Define partition", - "\nvar args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", - "\n Year = args.Year,", - "\n Month = args.Month };", - "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", - "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", - "\n Year = previousArgs.Year,", - "\n Month = previousArgs.Month };", - "\nawait DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", - "\nawait DataSource.CommitAsync();" + "await DataSource.UpdateAsync(new [ ] {dt11State, dtr11State});", + "\nawait DataSource.UpdateAsync(new [ ] {dt11Inter});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurvePrevious});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(estimateType).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", + "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" ], "metadata": {}, "execution_count": 0, @@ -144,7 +178,7 @@ "cell_type": "code", "source": [ "//There is a previous year, and it's the first time Actuals are imported for the current year", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = gic, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", @@ -161,7 +195,6 @@ "\n basicIfrsVariable with {AocType = AocTypes.CF, Value = -10.0},", "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", - "\n", "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", "\nactivity" ], @@ -182,7 +215,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 +258,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 +303,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 +359,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 +384,15 @@ "\n //Actuals", "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, EstimateType = EstimateTypes.DA, Value = 1000.0},", "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, Value = 100.0},", - "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.DA, Value = 1000.0},", "\n //Cash flow", - "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 1000.0},", - "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.C, Value = 1000.0},", "\n ", "\n //From current Period", "\n //from DB", - "\n basicIfrsVariable with {AocType = AocTypes.IA, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", - "\n basicIfrsVariable with {AocType = AocTypes.CF, Novelty = Novelties.I, DataNode = gic, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", + "\n basicIfrsVariable with {AocType = AocTypes.IA, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", + "\n basicIfrsVariable with {AocType = AocTypes.CF, Novelty = Novelties.I, DataNode = groupOfInsuranceContracts, EstimateType = EstimateTypes.BE, EconomicBasis = EconomicBases.L, Value = 10.0},", "\n ", "\n //from workspace", "\n basicIfrsVariable with {AocType = AocTypes.CF, Value = -10.0},", @@ -427,15 +460,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/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 0f49a5d2..21d410fb 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,35 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization());" + "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, + "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 +113,16 @@ "\n new ExchangeRate{ Currency = \"USD\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 5 },", "\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Average, FxToGroupCurrency = 2 },", "\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Spot, FxToGroupCurrency = 0.5 }};", - "\nvar activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17-template/Test/TechnicalMarginTest.ipynb b/ifrs17-template/Test/TechnicalMarginTest.ipynb index 8d0d4f34..537208b5 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 DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", + "source": [ + "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": "code", "source": [ - "# Test switch logic" + "await DataSource.UpdateAsync(dt1.RepeatOnce());", + "\nawait DataSource.UpdateAsync(new[]{dt11});", + "\nawait DataSource.UpdateAsync(new[]{dt11State});", + "\nawait DataSource.UpdateAsync(new[]{dt11SingleParameter});" ], "metadata": {}, "execution_count": 0, @@ -67,8 +80,8 @@ { "cell_type": "code", "source": [ - "//define group of contract", - "\nvar groupOfContract = \"DT1.1\";" + "await Import.FromString(amountType).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(estimateType).WithType().WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, @@ -77,11 +90,44 @@ { "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 Import.FromString(projectionConfiguration).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "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 +143,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 +211,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 +232,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 +251,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 +291,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 +327,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..66b22324 --- /dev/null +++ b/ifrs17-template/Test/TestData.ipynb @@ -0,0 +1,408 @@ +{ + "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 \"../Constants/CalculationEngine\"", + "\n#!eval 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 = ", + "\n@\"@@EstimateType,,,,,,,,,,,", + "\nSystemName,DisplayName,Order,StructureType,InputSource,PeriodType,ExternalId0,ExternalId1,ExternalId2,ExternalId3,ExternalId4,", + "\nBE,Best Estimate of Present Value,1,AoC,4,EndOfPeriod,,,,,,", + "\nAA,Advance Actuals,60,AoC,3,NotApplicable,PayablePR,ReceivableNIC,ReceivableICO,RiReceivablePR,RiPayableNIC,", + "\nOA,Overdue Actuals,70,AoC,3,NotApplicable,ReceivablePR,PayableNIC,PayableICO,RiPayablePR,RiReceivableNIC,", + "\nDA,Deferrable Actuals,80,AoC,7,NotApplicable,,,,,,", + "\nA,Actuals,90,None,2,NotApplicable,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Projection Configuration" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var projectionConfiguration = ", + "\n@\"@@ProjectionConfiguration,,,,,,,,,,,", + "\nSystemName,DisplayName,Shift,TimeStep,,,,,,,,", + "\nP0,End of January,0,1,,,,,,,,", + "\nP1,End of February,0,2,,,,,,,,", + "\nP2,End of March,0,3,,,,,,,,", + "\nP3,End of April,0,4,,,,,,,,", + "\nP4,End of May,0,5,,,,,,,,", + "\nP5,End of June,0,6,,,,,,,,", + "\nP6,End of July,0,7,,,,,,,,", + "\nP7,End of August,0,8,,,,,,,,", + "\nP8,End of September,0,9,,,,,,,,", + "\nP9,End of October,0,10,,,,,,,,", + "\nP10,End of November,0,11,,,,,,,,", + "\nP11,End of December,0,12,,,,,,,,", + "\nP12,End of Year+1,12,12,,,,,,,,", + "\nP13,End of Year+2,24,12,,,,,,,,", + "\nP14,End of Year+3,36,12,,,,,,,,", + "\nP15,End of Year+4,48,12,,,,,,,,", + "\nP16,Year+5 to Year+10,60,60,,,,,,,,", + "\nP17,Year+10 to Year+15,120,60,,,,,,,,", + "\nP18,Year+15 to Year+20,180,60,,,,,,,,", + "\nP19,Years Over +20,240,9999,,,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Amount Type" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var amountType = ", + "\n@\"@@AmountType,,,,,,,,,,,", + "\nSystemName,DisplayName,Parent,Order,PeriodType,,,,,,,", + "\nPR,Premiums,,10,BeginningOfPeriod,,,,,,,", + "\nCL,Claims,,20,EndOfPeriod,,,,,,,", + "\nNIC,Non Investment Component,CL,30,EndOfPeriod,,,,,,,", + "\nICO,Investment Component,CL,40,EndOfPeriod,,,,,,,", + "\nCDR,Credit Default Risk,CL,50,EndOfPeriod,,,,,,,", + "\nCE,Claim Expenses,CL,200,EndOfPeriod,,,,,,,", + "\nALE,Allocated Loss Adjustment Expenses,CE,210,EndOfPeriod,,,,,,,", + "\nULE,Unallocated Loss Adjustment Expenses,CE,220,EndOfPeriod,,,,,,,", + "\nAE,Attributable Expenses,,80,BeginningOfPeriod,,,,,,,", + "\nAEA,Aquisition,AE,90,BeginningOfPeriod,,,,,,,", + "\nAEM,Maintenance,AE,100,BeginningOfPeriod,,,,,,,", + "\nNE,Non Attributable Expenses,,110,BeginningOfPeriod,,,,,,,", + "\nAC,Attributable Commission,,120,BeginningOfPeriod,,,,,,,", + "\nACA,Aquisition,AC,130,BeginningOfPeriod,,,,,,,", + "\nACM,Maitenance,AC,140,BeginningOfPeriod,,,,,,,\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Reporting Nodes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var reportingNodeG = new ReportingNode() {", + "\n SystemName = \"G\",", + "\n DisplayName = \"Group\",", + "\n Currency = \"CHF\"", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Variables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var groupOfInsuranceContracts = \"DT1.1\";", + "\nvar groupOfReinsuranceContracts = \"DTR1.1\";", + "\nvar reportingNode = \"CH\";", + "\nvar scenario = (string)null;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", + "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Partitions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = reportingNode, ", + "\n Scenario = scenario, ", + "\n Year = args.Year,", + "\n Month = args.Month };", + "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", + "\n ReportingNode = reportingNode, ", + "\n Scenario = scenario, ", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month };", + "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = args.ReportingNode};", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# DataNodes and DataNodeData" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var dt1 = new Portfolio(){", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach =\"BBA\",", + "\n OciType = \"Default\",", + "\n SystemName = \"DT1\",", + "\n DisplayName = \"DT1 OCI\"", + "\n};", + "\n", + "\nvar dtr1 = new Portfolio(){", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach =\"BBA\",", + "\n OciType = \"Default\",", + "\n SystemName = \"DTR1\",", + "\n DisplayName = \"DTR1 OCI\"", + "\n};", + "\n", + "\nvar dt11 = new GroupOfInsuranceContract(){", + "\n Portfolio = \"DT1\",", + "\n Profitability = \"P\",", + "\n LiabilityType = \"LRC\",", + "\n AnnualCohort = 2020,", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach = \"BBA\",", + "\n OciType =\"Default\" ,", + "\n SystemName = \"DT1.1\",", + "\n DisplayName = \"DT1.1 OCI LRC PA 0.8\"", + "\n};", + "\n", + "\nvar dtr11 = new GroupOfReinsuranceContract(){", + "\n Portfolio = \"DTR1\",", + "\n Profitability = \"P\",", + "\n LiabilityType = \"LRC\",", + "\n AnnualCohort = 2020,", + "\n Partition = partitionReportingNode.Id,", + "\n ContractualCurrency = \"USD\",", + "\n LineOfBusiness = \"ANN\",", + "\n ValuationApproach = \"BBA\",", + "\n OciType =\"Default\" ,", + "\n SystemName = \"DTR1.1\",", + "\n DisplayName = \"DTR1.1 OCI LRC PA 0.8\"", + "\n};", + "\nvar dt11State = new DataNodeState {", + "\n DataNode = \"DT1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dtr11State = new DataNodeState {", + "\n DataNode = \"DTR1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dt11SingleParameter = new SingleDataNodeParameter {", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n DataNode = \"DT1.1\",", + "\n PremiumAllocation = .8,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dt11Inter = new InterDataNodeParameter{", + "\n LinkedDataNode = \"DTR1.1\",", + "\n\tReinsuranceCoverage = 1,", + "\n\tYear = args.Year,", + "\n\tMonth = args.Month,", + "\n\tDataNode = \"DT1.1\",", + "\n\tScenario = args.Scenario,", + "\n Partition = partitionReportingNode.Id", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# YieldCurve" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var yieldCurve = new YieldCurve(){", + "\n Currency = \"USD\",", + "\n Year = 2021,", + "\n Month = 3,", + "\n Values = new []{0.005,0.005,0.005,0.005}", + "\n};", + "\n", + "\nvar yieldCurvePrevious = new YieldCurve(){", + "\n Currency = \"USD\",", + "\n Year = 2020,", + "\n Month = 12,", + "\n Values = new []{0.002, 0.002, 0.002, 0.002}", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file