From ba42f6fcaacd4897b5545cec2eb78775e92b67d0 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Mon, 17 Apr 2023 16:57:01 +0200 Subject: [PATCH 1/8] paa exclude csm and AM definition --- ifrs17-template/Files/Dimensions.csv | 1 + ifrs17/Import/4ImportScope-TechnicalMargin.ipynb | 12 ++++++++++++ ifrs17/Import/5ImportScope-ToIfrsVar.ipynb | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ifrs17-template/Files/Dimensions.csv b/ifrs17-template/Files/Dimensions.csv index 85a30f1d..db0b638b 100644 --- a/ifrs17-template/Files/Dimensions.csv +++ b/ifrs17-template/Files/Dimensions.csv @@ -234,6 +234,7 @@ LICDW10pct,Lic Down 10pct,,,,,,,,,, @@ValuationApproach,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, BBA,Building Block Approach,,,,,,,,,, +PAA,Premium Allocation Approach,,,,,,,,,, ,,,,,,,,,,, @@ProjectionConfiguration,,,,,,,,,,, SystemName,DisplayName,Shift,TimeStep,,,,,,,, diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index 1b9b6d2f..3fd212a1 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -301,7 +301,19 @@ "\n", "\npublic interface TechnicalMarginForAM : TechnicalMargin", "\n{", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", + "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.ValuationApproach == ValuationApproaches.PAA)); ", + "\n ", "\n double TechnicalMargin.Value => -1d * AggregatedValue * GetScope(Identity, o => o.WithContext(EconomicBasis)).Value;", + "\n}", + "\n", + "\npublic interface TechnicalMarginForAmForPaa : TechnicalMargin", + "\n{", + "\n double TechnicalMargin.Value => GetScope(Identity.DataNode).BeAmountTypes", + "\n .Except(GetStorage().GetNonAttributableAmountType())", + "\n .Sum(at => GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.I}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value +", + "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.N}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value ) +", + "\n GetScope(Identity).Value;", "\n}" ], "metadata": {}, diff --git a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb index ac174b24..2b3f4d4e 100644 --- a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb +++ b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb @@ -277,7 +277,8 @@ "\n Partition = GetStorage().TargetPartition", "\n })", "\n : Enumerable.Empty();", - "\n IEnumerable Csms => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", + "\n IEnumerable Csms => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC || ", + "\n Identity.ValuationApproach == ValuationApproaches.PAA", "\n ? Enumerable.Empty()", "\n : GetScope(Identity).RepeatOnce()", "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", From 486edd94c0f514715a913c4ef0f3222580210333 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Mon, 24 Apr 2023 16:42:44 +0200 Subject: [PATCH 2/8] tm review reinsurance + fix typo in test --- ifrs17-template/Test/IfrsVariablesTest.ipynb | 2 +- .../Import/4ImportScope-TechnicalMargin.ipynb | 213 ++++++++++++++---- 2 files changed, 165 insertions(+), 50 deletions(-) diff --git a/ifrs17-template/Test/IfrsVariablesTest.ipynb b/ifrs17-template/Test/IfrsVariablesTest.ipynb index ebc28828..fbe4830a 100644 --- a/ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -202,7 +202,7 @@ "\n }", "\n if (computedNotExpected.Any()){", "\n foreach(var element in computedNotExpected){", - "\n errors.Add(new BenchmarkTestResult(\"Extra expected variable for: Partition \" + element.Partition + \", \" + element.ToIdentityString()));", + "\n errors.Add(new BenchmarkTestResult(\"Extra computed variable for: Partition \" + element.Partition + \", \" + element.ToIdentityString()));", "\n }", "\n }", "\n foreach(var benchmarkVariable in expected){", diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index 3fd212a1..101a7ee8 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -475,10 +475,11 @@ "\n //Switch", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s", - "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.AocType == AocTypes.CL)", - "\n .WithApplicability(x => x.Identity.IsReinsurance, ", - "\n p => p.ForMember(s => s.ComputedEstimateType)", - "\n .ForMember(s => s.HasSwitch))", + "\n // .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.ValuationApproach == ValuationApproaches.PAA)", + "\n // .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.AocType == AocTypes.CL)", + "\n // .WithApplicability(x => x.Identity.IsReinsurance, ", + "\n // p => p.ForMember(s => s.ComputedEstimateType)", + "\n // .ForMember(s => s.HasSwitch))", "\n .WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity.DataNode)) ", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.BOP)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.CL)", @@ -503,6 +504,14 @@ "\n string ComputeEstimateType(double aggregatedTechnicalMargin) => aggregatedTechnicalMargin > Precision ? EstimateTypes.L : EstimateTypes.C;", "\n}", "\n", + "\n// public interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMargin", + "\n// {", + "\n// double AllocateTechnicalMargin.Value => EstimateType switch {", + "\n// EstimateTypes.LR => -1d * GetScope(Identity).Value,", + "\n// _ => default", + "\n// };", + "\n// }", + "\n", "\npublic interface ComputeAllocateTechnicalMarginWithIfrsVariable : AllocateTechnicalMargin", "\n{ ", "\n double AllocateTechnicalMargin.TechnicalMargin => ComputeTechnicalMarginFromIfrsVariables(Identity);", @@ -517,50 +526,55 @@ "\n }", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsurance : AllocateTechnicalMargin", - "\n{ ", - "\n //TODO add Reinsurance Coverage Update (RCU, Novelty=I) AocStep", - "\n private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", + "\n// public interface AllocateTechnicalMarginForReinsurance : AllocateTechnicalMargin", + "\n// { ", + "\n// //TODO add Reinsurance Coverage Update (RCU, Novelty=I) AocStep", + "\n// /*private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", "\n ", - "\n private double weightedUnderlyingTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n GetScope(Identity with {DataNode = gic}).Value);", + "\n// private double weightedUnderlyingTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", + "\n// GetScope(Identity with {DataNode = gic}).Value);", "\n ", - "\n private double weightedUnderlyingAggregatedTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n GetScope(Identity with {DataNode = gic}).AggregatedValue);", + "\n// private double weightedUnderlyingAggregatedTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", + "\n// GetScope(Identity with {DataNode = gic}).AggregatedValue);*/", + "\n", + "\n// private double loReCoBoundaryValue => GetScope(Identity).Value;", + "\n// private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", "\n ", - "\n private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", + "\n// private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", "\n ", - "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(weightedUnderlyingAggregatedTM + weightedUnderlyingTM);", - "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(weightedUnderlyingAggregatedTM); ", - "\n}", - "\n", - "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMargin", - "\n{ ", - "\n //In common1", - "\n private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", + "\n// [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", + "\n// [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue); ", + "\n// }", + "\n", + "\n// public interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMargin", + "\n// { ", + "\n// //In common1", + "\n// /*private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", "\n ", - "\n private double weightedUnderlyingTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n GetScope(Identity with {DataNode = gic}).Value);", + "\n// private double weightedUnderlyingTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", + "\n// GetScope(Identity with {DataNode = gic}).Value);", "\n ", - "\n private double weightedUnderlyingAggregatedTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n GetScope(Identity with {DataNode = gic}).AggregatedValue);", - "\n private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", + "\n// private double weightedUnderlyingAggregatedTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", + "\n// GetScope(Identity with {DataNode = gic}).AggregatedValue);*/", + "\n// private double loReCoBoundaryValue => GetScope(Identity).Value;", + "\n// private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", + "\n// private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", "\n ", - "\n string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(weightedUnderlyingAggregatedTM + weightedUnderlyingTM);", - "\n //In common2", - "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", - "\n .Values", - "\n .GroupBy(x => x.Novelty)", - "\n .Select(g => g.Last())", - "\n .Sum(aoc => { ", - "\n var id = Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty};", - "\n return GetScope(id).ComputedEstimateType != ComputedEstimateType ? ", - "\n GetScope(id).TechnicalMargin + GetScope(id).AggregatedTechnicalMargin", - "\n : (double)default; });", + "\n// string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", + "\n// //In common2", + "\n// private double balancingValue => GetScope((Identity, InputSource.Cashflow))", + "\n// .Values", + "\n// .GroupBy(x => x.Novelty)", + "\n// .Select(g => g.Last())", + "\n// .Sum(aoc => { ", + "\n// var id = Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty};", + "\n// return GetScope(id).ComputedEstimateType != ComputedEstimateType ? ", + "\n// GetScope(id).TechnicalMargin + GetScope(id).AggregatedTechnicalMargin", + "\n// : (double)default; });", "\n ", - "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => Math.Abs(balancingValue) > Precision;", - "\n [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue; ", - "\n}", + "\n// [NotVisible] bool AllocateTechnicalMargin.HasSwitch => Math.Abs(balancingValue) > Precision;", + "\n// [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue; ", + "\n// }", "\n", "\npublic interface AllocateTechnicalMarginForCl : AllocateTechnicalMargin", "\n{", @@ -615,7 +629,7 @@ { "cell_type": "markdown", "source": [ - "# Contractual Service Margin" + "# Loss Component" ], "metadata": {}, "execution_count": 0, @@ -624,11 +638,11 @@ { "cell_type": "code", "source": [ - "public interface ContractualServiceMargin : IScope", + "public interface LossComponent : IScope", "\n{", - "\n [NotVisible]string EstimateType => EstimateTypes.C;", + "\n [NotVisible]string EstimateType => EstimateTypes.L;", "\n ", - "\n double Value => -1d * GetScope(Identity, o => o.WithContext(EstimateType)).Value;", + "\n double Value => GetScope(Identity, o => o.WithContext(EstimateType)).Value;", "\n}" ], "metadata": {}, @@ -638,7 +652,7 @@ { "cell_type": "markdown", "source": [ - "# Loss Component" + "# Technical Margin allocation for Reinsurance" ], "metadata": {}, "execution_count": 0, @@ -647,11 +661,112 @@ { "cell_type": "code", "source": [ - "public interface LossComponent : IScope", + "public interface LoReCoBoundary : IScope", "\n{", - "\n [NotVisible]string EstimateType => EstimateTypes.L;", + "\n private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", + "\n ", + "\n double Value => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", + "\n GetScope(Identity with {DataNode = gic}).Value);", + "\n ", + "\n", + "\n double AggregatedValue => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", + "\n GetScope((Identity, InputSource.Cashflow)).Values", + "\n .Sum(aoc => GetScope(Identity with {DataNode = gic, AocType = aoc.AocType, Novelty = aoc.Novelty}).Value));", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface AllocateTechnicalMarginForReinsurance: AllocateTechnicalMargin", + "\n{", + "\n //Switch", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", + "\n builder.ForScope(s => s", + "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.ValuationApproach == ValuationApproaches.PAA)", + "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.AocType == AocTypes.CL)", + "\n .WithApplicability(x => x.Identity.IsReinsurance, ", + "\n p => p.ForMember(s => s.ComputedEstimateType)", + "\n .ForMember(s => s.HasSwitch))", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", + "\n );", + "\n}", + "\n", + "\npublic interface AllocationForReinsurance : AllocateTechnicalMargin", + "\n{", + "\n private double loReCoBoundaryValue => GetScope(Identity).Value;", + "\n private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", "\n ", - "\n double Value => GetScope(Identity, o => o.WithContext(EstimateType)).Value;", + "\n private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", + "\n ", + "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", + "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue); ", + "\n}", + "\n", + "\npublic interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMargin", + "\n{", + "\n double AllocateTechnicalMargin.Value => EstimateType switch {", + "\n EstimateTypes.LR => -1d * GetScope(Identity).Value,", + "\n _ => default", + "\n };", + "\n}", + "\n", + "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMargin", + "\n{ ", + "\n private double loReCoBoundaryValue => GetScope(Identity).Value;", + "\n private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", + "\n private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", + "\n ", + "\n string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", + "\n //In common2", + "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", + "\n .Values", + "\n .GroupBy(x => x.Novelty)", + "\n .Select(g => g.Last())", + "\n .Sum(aoc => { ", + "\n var id = Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty};", + "\n return GetScope(id).ComputedEstimateType != ComputedEstimateType ? ", + "\n GetScope(id).TechnicalMargin + GetScope(id).AggregatedTechnicalMargin", + "\n : (double)default; });", + "\n ", + "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => Math.Abs(balancingValue) > Precision;", + "\n [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue; ", + "\n}", + "\n", + "\npublic interface AllocateTechnicalMarginForReinsuranceEop : AllocateTechnicalMargin", + "\n{", + "\n double AllocateTechnicalMargin.Value => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .Sum(aoc => GetScope(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);", + "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeEstimateType(AggregatedTechnicalMargin);", + "\n}", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Contractual Service Margin" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ContractualServiceMargin : IScope", + "\n{", + "\n [NotVisible]string EstimateType => EstimateTypes.C;", + "\n ", + "\n double Value => Identity.IsReinsurance ", + "\n ? -1d * GetScope(Identity, o => o.WithContext(EstimateType)).Value", + "\n : -1d * GetScope(Identity, o => o.WithContext(EstimateType)).Value;", "\n}" ], "metadata": {}, @@ -674,7 +789,7 @@ "\n{ ", "\n [NotVisible]string EstimateType => EstimateTypes.LR;", "\n ", - "\n double Value => GetScope(Identity, o => o.WithContext(EstimateType)).Value;", + "\n double Value => GetScope(Identity, o => o.WithContext(EstimateType)).Value;", "\n}" ], "metadata": {}, From 3cd72cfa6359195a15ccc7a7b9e8eb82bef6fac4 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Wed, 3 May 2023 10:31:25 +0200 Subject: [PATCH 3/8] clean ups --- .../ActualsUseCaseReports.ipynb | 4 +- .../Import/4ImportScope-TechnicalMargin.ipynb | 144 +++++++----------- ifrs17/Import/Importers.ipynb | 4 +- 3 files changed, 58 insertions(+), 94 deletions(-) diff --git a/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb b/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb index 8477b81d..a4081384 100644 --- a/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb +++ b/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb @@ -35,7 +35,7 @@ "\n", "\nIn this case study we look at the effects of cashflows happening outside the expected reporting period, also referred to as Payables and Receivables in accounting language. The reconciliation between the written and effective cashflows is usually handled by the Actuals. This reconciliation must be taken into account, since the IFRS 17 Standard requires insurance liabilities to be measured according to the effective cashflows.", "\n", - "\nWe can try to summarize the the cases for In Advance and Overdue actuals in a table. On the colums we define the due date of the payments in relation to the reporting period, and in the rows we define the effective date of the payments in relation to the reporting period. If we exclude the write off (WO) for now, we are left we the following possibilities:", + "\nWe can try to summarize the cases for In Advance and Overdue actuals in a table. On the colums we define the due date of the payments in relation to the reporting period, and in the rows we define the effective date of the payments in relation to the reporting period. If we exclude the write off (WO) for now, we are left with the following possibilities:", "\n", "\n
", "\n", @@ -481,7 +481,7 @@ { "cell_type": "markdown", "source": [ - "We are introducing In Advance and Overdue reserves for the scenarios described above (CF_A and CF_O cases in the table above), and it is important to note the sign convention (Receivables bear a negative sign, while Payables a positive sign). This convention becomes relavent when determining the Liability of Remaining Coverage below, as it will bring the LRC to either to a more Asset-like character (negative) or Liability-like character (positive)." + "We are introducing In Advance and Overdue reserves for the scenarios described above (CF_A and CF_O cases in the table above), and it is important to note the sign convention (Receivables bear a negative sign, while Payables a positive sign). This convention becomes relavent when determining the Liability of Remaining Coverage below, as it will bring the LRC to either a more Asset-like character (negative) or a more Liability-like character (positive)." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index 0f0ba912..edec5911 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -236,7 +236,8 @@ "\n double Value => GetScope(Identity.DataNode).BeAmountTypes", "\n .Except(GetStorage().GetNonAttributableAmountType())", "\n .Sum(at => GetScope((Identity, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value) +", - "\n GetScope(Identity).Value;", + "\n //GetScope(Identity).Value;", + "\n GetScope((Identity, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value;", "\n ", "\n double AggregatedValue => GetScope((Identity, InputSource.Cashflow)).Values", "\n .Sum(aoc => GetScope(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);", @@ -313,7 +314,8 @@ "\n .Except(GetStorage().GetNonAttributableAmountType())", "\n .Sum(at => GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.I}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value +", "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.N}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value ) +", - "\n GetScope(Identity).Value;", + "\n GetScope((Identity, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value;", + "\n //GetScope(Identity).Value;", "\n}" ], "metadata": {}, @@ -467,6 +469,27 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public interface AllocateTechnicalMarginWithIfrsVariable: IScope", + "\n{ ", + "\n double Value => ComputeTechnicalMarginFromIfrsVariables(Identity);", + "\n double AggregatedValue => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .Sum(aoc => ComputeTechnicalMarginFromIfrsVariables(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}));", + "\n ", + "\n private double ComputeTechnicalMarginFromIfrsVariables(ImportIdentity id)", + "\n {", + "\n return GetStorage().GetValue(Identity, null, EstimateTypes.LR, null, Identity.ProjectionPeriod) +", + "\n GetStorage().GetValue(Identity, null, EstimateTypes.L, null, Identity.ProjectionPeriod) - ", + "\n GetStorage().GetValue(Identity, null, EstimateTypes.C, null, Identity.ProjectionPeriod);", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -475,12 +498,7 @@ "\n //Switch", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s", - "\n // .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.ValuationApproach == ValuationApproaches.PAA)", - "\n // .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.AocType == AocTypes.CL)", - "\n // .WithApplicability(x => x.Identity.IsReinsurance, ", - "\n // p => p.ForMember(s => s.ComputedEstimateType)", - "\n // .ForMember(s => s.HasSwitch))", - "\n .WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity.DataNode)) ", + "\n .WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity.DataNode))", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.BOP)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.CL)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", @@ -504,78 +522,12 @@ "\n string ComputeEstimateType(double aggregatedTechnicalMargin) => aggregatedTechnicalMargin > Precision ? EstimateTypes.L : EstimateTypes.C;", "\n}", "\n", - "\n// public interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMargin", - "\n// {", - "\n// double AllocateTechnicalMargin.Value => EstimateType switch {", - "\n// EstimateTypes.LR => -1d * GetScope(Identity).Value,", - "\n// _ => default", - "\n// };", - "\n// }", - "\n", "\npublic interface ComputeAllocateTechnicalMarginWithIfrsVariable : AllocateTechnicalMargin", "\n{ ", - "\n double AllocateTechnicalMargin.TechnicalMargin => ComputeTechnicalMarginFromIfrsVariables(Identity);", - "\n double AllocateTechnicalMargin.AggregatedTechnicalMargin => GetScope((Identity, InputSource.Cashflow)).Values", - "\n .Sum(aoc => ComputeTechnicalMarginFromIfrsVariables(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}));", - "\n ", - "\n private double ComputeTechnicalMarginFromIfrsVariables(ImportIdentity id)", - "\n {", - "\n return GetStorage().GetValue(Identity, null, EstimateTypes.LR, null, Identity.ProjectionPeriod) +", - "\n GetStorage().GetValue(Identity, null, EstimateTypes.L, null, Identity.ProjectionPeriod) - ", - "\n GetStorage().GetValue(Identity, null, EstimateTypes.C, null, Identity.ProjectionPeriod);", - "\n }", + "\n double AllocateTechnicalMargin.TechnicalMargin => GetScope(Identity).Value;", + "\n double AllocateTechnicalMargin.AggregatedTechnicalMargin => GetScope(Identity).AggregatedValue;", "\n}", "\n", - "\n// public interface AllocateTechnicalMarginForReinsurance : AllocateTechnicalMargin", - "\n// { ", - "\n// //TODO add Reinsurance Coverage Update (RCU, Novelty=I) AocStep", - "\n// /*private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", - "\n ", - "\n// private double weightedUnderlyingTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n// GetScope(Identity with {DataNode = gic}).Value);", - "\n ", - "\n// private double weightedUnderlyingAggregatedTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n// GetScope(Identity with {DataNode = gic}).AggregatedValue);*/", - "\n", - "\n// private double loReCoBoundaryValue => GetScope(Identity).Value;", - "\n// private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", - "\n ", - "\n// private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", - "\n ", - "\n// [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", - "\n// [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue); ", - "\n// }", - "\n", - "\n// public interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMargin", - "\n// { ", - "\n// //In common1", - "\n// /*private IEnumerable underlyingGic => GetStorage().GetUnderlyingGic(Identity);", - "\n ", - "\n// private double weightedUnderlyingTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n// GetScope(Identity with {DataNode = gic}).Value);", - "\n ", - "\n// private double weightedUnderlyingAggregatedTM => underlyingGic.Sum(gic => GetStorage().GetReinsuranceCoverage(Identity, gic) * ", - "\n// GetScope(Identity with {DataNode = gic}).AggregatedValue);*/", - "\n// private double loReCoBoundaryValue => GetScope(Identity).Value;", - "\n// private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", - "\n// private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", - "\n ", - "\n// string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", - "\n// //In common2", - "\n// private double balancingValue => GetScope((Identity, InputSource.Cashflow))", - "\n// .Values", - "\n// .GroupBy(x => x.Novelty)", - "\n// .Select(g => g.Last())", - "\n// .Sum(aoc => { ", - "\n// var id = Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty};", - "\n// return GetScope(id).ComputedEstimateType != ComputedEstimateType ? ", - "\n// GetScope(id).TechnicalMargin + GetScope(id).AggregatedTechnicalMargin", - "\n// : (double)default; });", - "\n ", - "\n// [NotVisible] bool AllocateTechnicalMargin.HasSwitch => Math.Abs(balancingValue) > Precision;", - "\n// [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue; ", - "\n// }", - "\n", "\npublic interface AllocateTechnicalMarginForCl : AllocateTechnicalMargin", "\n{", "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", @@ -592,9 +544,16 @@ "\n [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue;", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForBop : AllocateTechnicalMargin", - "\n{ ", - "\n bool AllocateTechnicalMargin.HasSwitch => false;", + "\npublic interface AllocateTechnicalMarginForBop : AllocateTechnicalMargin {", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", + "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.ProjectionPeriod > 0));", + "\n ", + "\n bool AllocateTechnicalMargin.HasSwitch => false;", + "\n}", + "\n", + "\npublic interface AllocateTechnicalMarginForBopProjection: AllocateTechnicalMarginForBop{", + "\n double AllocateTechnicalMargin.TechnicalMargin => GetScope(Identity with {ProjectionPeriod = Identity.ProjectionPeriod - 1}).Value;", + "\n bool AllocateTechnicalMargin.HasSwitch => false;", "\n}", "\n", "\npublic interface AllocateTechnicalMarginForEop : AllocateTechnicalMargin", @@ -686,6 +645,9 @@ "\n //Switch", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s", + "\n ", + "\n // .WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity.DataNode))", + "\n // .WithApplicability(x => x.Identity.AocType == AocTypes.BOP)", "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.ValuationApproach == ValuationApproaches.PAA)", "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.AocType == AocTypes.CL)", "\n .WithApplicability(x => x.Identity.IsReinsurance, ", @@ -693,20 +655,24 @@ "\n .ForMember(s => s.HasSwitch))", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", "\n );", + "\n protected string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", + "\n", + "\n // private double loReCoBoundaryValue => GetScope(Identity).Value;", + "\n // private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", + "\n // [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", + "\n // [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue);", + "\n", "\n}", "\n", - "\npublic interface AllocationForReinsurance : AllocateTechnicalMargin", + "\npublic interface AllocationForReinsurance : AllocateTechnicalMarginForReinsurance", "\n{", "\n private double loReCoBoundaryValue => GetScope(Identity).Value;", "\n private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", - "\n ", - "\n private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", - "\n ", "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", - "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue); ", + "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue);", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMargin", + "\npublic interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMarginForReinsurance", "\n{", "\n double AllocateTechnicalMargin.Value => EstimateType switch {", "\n EstimateTypes.LR => -1d * GetScope(Identity).Value,", @@ -714,14 +680,12 @@ "\n };", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMargin", + "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMarginForReinsurance", "\n{ ", "\n private double loReCoBoundaryValue => GetScope(Identity).Value;", "\n private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", - "\n private string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", "\n ", "\n string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", - "\n //In common2", "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", "\n .Values", "\n .GroupBy(x => x.Novelty)", @@ -736,11 +700,11 @@ "\n [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue; ", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsuranceEop : AllocateTechnicalMargin", + "\npublic interface AllocateTechnicalMarginForReinsuranceEop : AllocateTechnicalMarginForReinsurance", "\n{", "\n double AllocateTechnicalMargin.Value => GetScope((Identity, InputSource.Cashflow)).Values", "\n .Sum(aoc => GetScope(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);", - "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeEstimateType(AggregatedTechnicalMargin);", + "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(AggregatedTechnicalMargin);", "\n}", "\n" ], diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 7e899cdb..0cb6b968 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -884,13 +884,13 @@ "\n (dataset, datarow) => {", "\n var values = datarow.Table.Columns.Where(c => c.ColumnName.StartsWith(nameof(YieldCurve.Values))).OrderBy(c => c.ColumnName.Length).ThenBy(c => c.ColumnName)", "\n .Select(x => datarow.Field(x.ColumnName).CheckStringForExponentialAndConvertToDouble()).ToArray().Prune();", - "\n if (!values.Any()) return null;", + "\n ", "\n return new YieldCurve {", "\n Currency = datarow.Field(nameof(YieldCurve.Currency)),", "\n Year = primaryArgs.Year,", "\n Month = primaryArgs.Month, ", "\n Scenario = primaryArgs.Scenario,", - "\n Values = values,", + "\n Values = values.Any() ? values : new double[]{0d},", "\n Name = hasNameColumn ? datarow.Field(nameof(YieldCurve.Name)) : default(string)", "\n };", "\n }", From 6fa1649a03771b43cf334b9a14a69785dccfc98e Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Thu, 4 May 2023 12:19:57 +0200 Subject: [PATCH 4/8] clean up TechnicalMargin and refactor TMtest --- .../Import/4ImportScope-TechnicalMargin.ipynb | 47 ++++++------------ ifrs17/Test/TechnicalMarginTest.ipynb | 49 +++++++++---------- 2 files changed, 38 insertions(+), 58 deletions(-) diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index edec5911..81ab1363 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -236,7 +236,6 @@ "\n double Value => GetScope(Identity.DataNode).BeAmountTypes", "\n .Except(GetStorage().GetNonAttributableAmountType())", "\n .Sum(at => GetScope((Identity, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value) +", - "\n //GetScope(Identity).Value;", "\n GetScope((Identity, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value;", "\n ", "\n double AggregatedValue => GetScope((Identity, InputSource.Cashflow)).Values", @@ -315,7 +314,6 @@ "\n .Sum(at => GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.I}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value +", "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.N}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value ) +", "\n GetScope((Identity, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value;", - "\n //GetScope(Identity).Value;", "\n}" ], "metadata": {}, @@ -546,8 +544,7 @@ "\n", "\npublic interface AllocateTechnicalMarginForBop : AllocateTechnicalMargin {", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", - "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.ProjectionPeriod > 0));", - "\n ", + "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.Novelty == Novelties.I && x.Identity.ProjectionPeriod > 0));", "\n bool AllocateTechnicalMargin.HasSwitch => false;", "\n}", "\n", @@ -645,46 +642,31 @@ "\n //Switch", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s", - "\n ", - "\n // .WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity.DataNode))", - "\n // .WithApplicability(x => x.Identity.AocType == AocTypes.BOP)", - "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.ValuationApproach == ValuationApproaches.PAA)", - "\n .WithApplicability(x => x.Identity.IsReinsurance && x.Identity.AocType == AocTypes.CL)", - "\n .WithApplicability(x => x.Identity.IsReinsurance, ", - "\n p => p.ForMember(s => s.ComputedEstimateType)", - "\n .ForMember(s => s.HasSwitch))", - "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", - "\n );", + "\n .WithApplicability(x => x.Identity.ValuationApproach == ValuationApproaches.PAA)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.CL)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", + "\n .WithApplicability(x => true, ", + "\n p => p.ForMember(s => s.ComputedEstimateType)", + "\n .ForMember(s => s.HasSwitch))", + "\n );", "\n protected string ComputeReinsuranceEstimateType(double aggregatedFcf) => aggregatedFcf > Precision ? EstimateTypes.LR : EstimateTypes.C;", - "\n", - "\n // private double loReCoBoundaryValue => GetScope(Identity).Value;", - "\n // private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", - "\n // [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", - "\n // [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue);", - "\n", + "\n protected double loReCoBoundaryValue => GetScope(Identity).Value;", + "\n protected double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", "\n}", "\n", - "\npublic interface AllocationForReinsurance : AllocateTechnicalMarginForReinsurance", - "\n{", - "\n private double loReCoBoundaryValue => GetScope(Identity).Value;", - "\n private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", + "\npublic interface AllocationForReinsurance : AllocateTechnicalMarginForReinsurance{", "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", "\n [NotVisible] bool AllocateTechnicalMargin.HasSwitch => ComputedEstimateType != ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue);", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMarginForReinsurance", - "\n{", + "\npublic interface AllocateTechnicalMarginForReinsurancePaa : AllocateTechnicalMarginForReinsurance{", "\n double AllocateTechnicalMargin.Value => EstimateType switch {", "\n EstimateTypes.LR => -1d * GetScope(Identity).Value,", "\n _ => default", "\n };", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMarginForReinsurance", - "\n{ ", - "\n private double loReCoBoundaryValue => GetScope(Identity).Value;", - "\n private double loReCoBoundaryAggregatedValue => GetScope(Identity).AggregatedValue;", - "\n ", + "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMarginForReinsurance{ ", "\n string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", "\n .Values", @@ -700,8 +682,7 @@ "\n [NotVisible] double AllocateTechnicalMargin.AggregatedTechnicalMargin => balancingValue; ", "\n}", "\n", - "\npublic interface AllocateTechnicalMarginForReinsuranceEop : AllocateTechnicalMarginForReinsurance", - "\n{", + "\npublic interface AllocateTechnicalMarginForReinsuranceEop : AllocateTechnicalMarginForReinsurance{", "\n double AllocateTechnicalMargin.Value => GetScope((Identity, InputSource.Cashflow)).Values", "\n .Sum(aoc => GetScope(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);", "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(AggregatedTechnicalMargin);", diff --git a/ifrs17/Test/TechnicalMarginTest.ipynb b/ifrs17/Test/TechnicalMarginTest.ipynb index 12c9df02..26c3e2b7 100644 --- a/ifrs17/Test/TechnicalMarginTest.ipynb +++ b/ifrs17/Test/TechnicalMarginTest.ipynb @@ -139,52 +139,52 @@ { "cell_type": "code", "source": [ - "public async Task> ErrorLoggerAsync(IEnumerable csm, ", - "\n IEnumerable loss, ", + "public async Task> ErrorLoggerAsync(IEnumerable csm, ", + "\n IEnumerable loss, ", "\n Dictionary csmBenchmark, ", "\n Dictionary lossBenchmark)", "\n{", "\n var errors = new List();", "\n if(csm.Count() > csmBenchmark.Count()) ", "\n {", - "\n var extraVariables = csm.Where(x => !csmBenchmark.Keys.Contains(new AocStep(x.Identity.AocType, x.Identity.Novelty)))", - "\n .Select(x => $\"AocType:{x.Identity.AocType}, Novelty:{x.Identity.Novelty}, EstimateType:{x.EstimateType}, Value:{x.Value}.\");", - "\n errors.Add( $\"{nameof(AllocateTechnicalMargin)} scope for CSM has more non zero items than benchmark. Extra computed variables : \\n {string.Join(\"\\n\", extraVariables)}.\" );", + "\n var extraVariables = csm.Where(x => !csmBenchmark.Keys.Contains(new AocStep(x.AocType, x.Novelty)))", + "\n .Select(x => $\"AocType:{x.AocType}, Novelty:{x.Novelty}, EstimateType:{x.EstimateType}, Value:{x.Values[0]}.\");", + "\n errors.Add( $\"Computed variable for CSM has more non zero items than benchmark. Extra computed variables : \\n {string.Join(\"\\n\", extraVariables)}.\" );", "\n }", "\n if(loss.Count() > lossBenchmark.Count()) ", "\n {", - "\n var extraVariables = loss.Where(x => !lossBenchmark.Keys.Contains(new AocStep(x.Identity.AocType, x.Identity.Novelty)))", - "\n .Select(x => $\"AocType:{x.Identity.AocType}, Novelty:{x.Identity.Novelty}, EstimateType:{x.EstimateType}, Value:{x.Value}, \");", - "\n errors.Add( $\"{nameof(AllocateTechnicalMargin)} scope for LOSS(LC/LoReCo) has more non zero items compared to benchmark: \\n {string.Join(\"\\n\", extraVariables)}.\" );", + "\n var extraVariables = loss.Where(x => !lossBenchmark.Keys.Contains(new AocStep(x.AocType, x.Novelty)))", + "\n .Select(x => $\"AocType:{x.AocType}, Novelty:{x.Novelty}, EstimateType:{x.EstimateType}, Value:{x.Values[0]}, \");", + "\n errors.Add( $\"Computed variable for LOSS(LC/LoReCo) has more non zero items compared to benchmark: \\n {string.Join(\"\\n\", extraVariables)}.\" );", "\n }", "\n ", "\n //Check ValueCsm", "\n foreach(var kvp in csmBenchmark)", "\n {", - "\n var scopeSwitch = csm.SingleOrDefault(y => y.Identity.AocType == kvp.Key.AocType && y.Identity.Novelty == kvp.Key.Novelty);", + "\n var variableSwitch = csm.SingleOrDefault(y => y.AocType == kvp.Key.AocType && y.Novelty == kvp.Key.Novelty);", "\n ", - "\n if(scopeSwitch == null)", + "\n if(variableSwitch == null)", "\n {", - "\n errors.Add( $\"Missing calculated scope for AocType and Novelty: {kvp.Key.AocType}, {kvp.Key.Novelty}.\" );", + "\n errors.Add( $\"Missing calculated variable for AocType and Novelty: {kvp.Key.AocType}, {kvp.Key.Novelty}.\" );", "\n continue;", "\n }", "\n ", - "\n if(Math.Abs(-1.0 * scopeSwitch.Value - kvp.Value.valueCsm) > Precision) ", - "\n errors.Add( $\"Values not matching for AocType {kvp.Key.AocType} and Novelty {kvp.Key.Novelty}. Scope: Csm {-1 * scopeSwitch.Value}; Benchmark: Csm {kvp.Value.valueCsm}.\" );", + "\n if(Math.Abs(variableSwitch.Values[0] - kvp.Value.valueCsm) > Precision) ", + "\n errors.Add( $\"Values not matching for AocType {kvp.Key.AocType} and Novelty {kvp.Key.Novelty}. Variable: Csm {variableSwitch.Values[0]}; Benchmark: Csm {kvp.Value.valueCsm}.\" );", "\n }", "\n //Check ValueLoss", "\n foreach(var kvp in lossBenchmark)", "\n {", - "\n var scopeSwitch = loss.SingleOrDefault(y => y.Identity.AocType == kvp.Key.AocType && y.Identity.Novelty == kvp.Key.Novelty);", + "\n var variableSwitch = loss.SingleOrDefault(y => y.AocType == kvp.Key.AocType && y.Novelty == kvp.Key.Novelty);", "\n ", - "\n if(scopeSwitch == null)", + "\n if(variableSwitch == null)", "\n {", - "\n errors.Add( $\"Missing calculated scope for AocType and Novelty: {kvp.Key.AocType}, {kvp.Key.Novelty}.\" );", + "\n errors.Add( $\"Missing calculated variable for AocType and Novelty: {kvp.Key.AocType}, {kvp.Key.Novelty}.\" );", "\n continue;", "\n }", "\n ", - "\n if(Math.Abs(scopeSwitch.Value - kvp.Value.valueLoss) > Precision) ", - "\n errors.Add( $\"Values not matching for AocType {kvp.Key.AocType} and Novelty {kvp.Key.Novelty}. Scope: Lc/LoReCo {scopeSwitch.Value}; Benchmark: Lc/LoReCo {kvp.Value.valueLoss}.\" );", + "\n if(Math.Abs(variableSwitch.Values[0] - kvp.Value.valueLoss) > Precision) ", + "\n errors.Add( $\"Values not matching for AocType {kvp.Key.AocType} and Novelty {kvp.Key.Novelty}. Variable: Lc/LoReCo {variableSwitch.Values[0]}; Benchmark: Lc/LoReCo {kvp.Value.valueLoss}.\" );", "\n }", "\n ", "\n return errors;", @@ -206,7 +206,7 @@ { "cell_type": "code", "source": [ - "public async Task<(IEnumerable,IEnumerable)> ComputeScopesAsync (IEnumerable inputDataSet,", + "public async Task<(IEnumerable,IEnumerable)> ComputeScopesAsync (IEnumerable inputDataSet,", "\n Guid partitionId, ", "\n string primaryDataNode)", "\n{", @@ -219,13 +219,12 @@ "\n await testStorage.InitializeAsync();", "\n var testUniverse = Scopes.ForStorage(testStorage).ToScope();", "\n var identities = testUniverse.GetScopes(testStorage.DataNodesByImportScope[ImportScope.Primary].Where(dn => dn == primaryDataNode)).SelectMany(s => s.Identities);", - "\n var csm = testUniverse.GetScopes(identities, o => o.WithContext(EstimateTypes.C)).Where(x => Math.Abs(x.Value) > Precision);", - "\n IEnumerable loss = Enumerable.Empty();", - "\n if (primaryDataNode == groupOfInsuranceContracts) loss = testUniverse.GetScopes(identities, o => o.WithContext(EstimateTypes.L)).Where(x => Math.Abs(x.Value) > Precision);", - "\n if (primaryDataNode == groupOfReinsuranceContracts) loss = testUniverse.GetScopes(identities, o => o.WithContext(EstimateTypes.LR)).Where(x => Math.Abs(x.Value) > Precision);", - "\n ", - "\n await Workspace.DeleteAsync(await Workspace.Query().ToArrayAsync());", "\n", + "\n var tmToIfrsVariable = testUniverse.GetScopes(identities);", + "\n var csm = tmToIfrsVariable.SelectMany(x => x.Csms).Where(x => Math.Abs(x.Values[0]) > Precision);", + "\n var loss = tmToIfrsVariable.SelectMany(x => x.Loss).Where(x => Math.Abs(x.Values[0]) > Precision);", + "\n ", + "\n await Workspace.DeleteAsync(await Workspace.Query().ToArrayAsync());", "\n return (csm, loss);", "\n}" ], From cf688ceed6c32af20cb40f0f545082359d2699cb Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Thu, 4 May 2023 15:31:53 +0200 Subject: [PATCH 5/8] doc + sketch proj --- .../Import/4ImportScope-TechnicalMargin.ipynb | 99 ++++++++++--------- ifrs17/OverviewCalculationEngine.ipynb | 2 +- 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index 81ab1363..38ada7ee 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -449,24 +449,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "", - "\n## Reinsurance case", - "\n", - "\nFor the reinsurance case, the switch logic is identical to the one described above, except that it uses the gross Technical Margins multiplied by the weights coming from the Reinsurance Coverage (RC) Parameter (see [Data Node Parameters](../DataModel/DataStructure#data-node-parameters)). In case a GRIC ($r$) has multiple GICs ($g$), then these weighted $TM$s are aggregated.", - "\n", - "\n$$", - "\n\\text{Weighted TM}(\\text{r}) = \\sum_{g~\\in~\\text{underlying GICs}} \\text{RC}_{g,r} \\text{TM}(g)", - "\n$$", - "\n", - "\nA Loss Recovery Component (LoReCo) for GRIC $r$ is going to be opened in case the $\\text{Weighted TM}(r)$ would be allocated to Loss Component following the above mentioned switch logic. The amount allocated to the Reinsurance CSM or LoReCo follows the computed Technical Margin computed for GRIC r as described in [Technical Margin](#technical-margin)." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -497,6 +479,7 @@ "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s", "\n .WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity.DataNode))", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.BOP && x.Identity.Novelty == Novelties.I && x.Identity.ProjectionPeriod > 0)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.BOP)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.CL)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", @@ -543,13 +526,6 @@ "\n}", "\n", "\npublic interface AllocateTechnicalMarginForBop : AllocateTechnicalMargin {", - "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", - "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.Novelty == Novelties.I && x.Identity.ProjectionPeriod > 0));", - "\n bool AllocateTechnicalMargin.HasSwitch => false;", - "\n}", - "\n", - "\npublic interface AllocateTechnicalMarginForBopProjection: AllocateTechnicalMarginForBop{", - "\n double AllocateTechnicalMargin.TechnicalMargin => GetScope(Identity with {ProjectionPeriod = Identity.ProjectionPeriod - 1}).Value;", "\n bool AllocateTechnicalMargin.HasSwitch => false;", "\n}", "\n", @@ -558,6 +534,11 @@ "\n double AllocateTechnicalMargin.Value => GetScope((Identity, InputSource.Cashflow)).Values", "\n .Sum(aoc => GetScope(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);", "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeEstimateType(AggregatedTechnicalMargin);", + "\n}", + "\n", + "\npublic interface AllocateTechnicalMarginForBopProjection: AllocateTechnicalMargin{", + "\n double AllocateTechnicalMargin.TechnicalMargin => GetScope(Identity with {AocType = AocTypes.EOP, Novelty = Novelties.C, ProjectionPeriod = Identity.ProjectionPeriod - 1}).Value;", + "\n bool AllocateTechnicalMargin.HasSwitch => false;", "\n}" ], "metadata": {}, @@ -567,16 +548,23 @@ { "cell_type": "markdown", "source": [ - "For the **Group of Reinsurance Contracts** (GRICs), the switch is computed within the underlying GIC context and $CSM$ and $LR$ are then computed in the same manner as for the underlying GICs CSM and LC." + "# Loss Component", + "\n", + "\nThe scope below is simply used to set the appropriate Estimate Type L for $LC$ :" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "The scopes below are simply used to set the appropriate Estimate Type (C for $CSM$, L for $LC$ and LR for $LoReCo$), as well as to set $CSM$ values to be positive:" + "public interface LossComponent : IScope", + "\n{", + "\n [NotVisible]string EstimateType => EstimateTypes.L;", + "\n ", + "\n double Value => GetScope(Identity, o => o.WithContext(EstimateType)).Value;", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -585,21 +573,9 @@ { "cell_type": "markdown", "source": [ - "# Loss Component" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface LossComponent : IScope", - "\n{", - "\n [NotVisible]string EstimateType => EstimateTypes.L;", - "\n ", - "\n double Value => GetScope(Identity, o => o.WithContext(EstimateType)).Value;", - "\n}" + "# Technical Margin allocation for Reinsurance", + "\n", + "\nIn the case of Reinsurance a Loss Recovery Component is computed when the underlying gross business opens a Loss component. Loss Recovery Component uses the notion of Loss Recovery Component Boundary ([LoReCo Boundary](#loreco-boundary)). " ], "metadata": {}, "execution_count": 0, @@ -608,7 +584,13 @@ { "cell_type": "markdown", "source": [ - "# Technical Margin allocation for Reinsurance" + "## LoReCo Boundary", + "\n", + "\nThe LoReCo Boundary is the underlying gross Loss Component multiplied by the weights coming from the Reinsurance Coverage (RC) Parameter (see [Data Node Parameters](../DataModel/DataStructure#data-node-parameters)). In case a GRIC ($r$) has multiple GICs ($g$), then these weighted $TM$s are aggregated.", + "\n", + "\n$$", + "\n\\text{LoReCo Boundary}(\\text{r}) = \\sum_{g~\\in~\\text{underlying GICs}} \\text{RC}_{g,r} \\text{LC}(g).", + "\n$$" ], "metadata": {}, "execution_count": 0, @@ -634,6 +616,22 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Reinsurance Switch Logic", + "\n", + "\nFor the **Group of Reinsurance Contracts** (GRICs), the switch is computed within the underlying GIC context and $CSM$ and $LR$ are then computed in a similar as for the underlying GICs CSM and LC. In the reinsurance case, the switch is controlled by the sign of the LoReCo Boundary rather than the reinsurance Technical Margin. This allows the reinsurance LoReCo allocation to be controlled by gross switch calculation. ", + "\nThe amount allocated to the Reinsurance CSM or LoReCo follows the computed Technical Margin computed for GRIC r as described in [Technical Margin](#technical-margin).", + "\n", + "\nFor the , the switch is computed within the underlying GIC context and $CSM$ and $LR$ are then computed in the same manner as for the underlying GICs CSM and LC.", + "\n", + "\nWithin the **Premium Allocation Approach** the LoReCo Component corresponds to the computed [LoReCo Boundary](loreco-boundary)." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -642,10 +640,11 @@ "\n //Switch", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.BOP && x.Identity.Novelty == Novelties.I && x.Identity.ProjectionPeriod > 0)", "\n .WithApplicability(x => x.Identity.ValuationApproach == ValuationApproaches.PAA)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.CL)", "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", - "\n .WithApplicability(x => true, ", + "\n .WithApplicability(x => true, //from here the applicabilities of the AllocateTechnicalMargin are applied with the following members redefined here.", "\n p => p.ForMember(s => s.ComputedEstimateType)", "\n .ForMember(s => s.HasSwitch))", "\n );", @@ -687,7 +686,11 @@ "\n .Sum(aoc => GetScope(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}).Value);", "\n [NotVisible] string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(AggregatedTechnicalMargin);", "\n}", - "\n" + "\n", + "\npublic interface AllocateTechnicalMarginForBopProjection: AllocateTechnicalMargin{", + "\n double AllocateTechnicalMargin.TechnicalMargin => GetScope(Identity with {AocType = AocTypes.EOP, Novelty = Novelties.C, ProjectionPeriod = Identity.ProjectionPeriod - 1}).Value;", + "\n bool AllocateTechnicalMargin.HasSwitch => false;", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -696,7 +699,9 @@ { "cell_type": "markdown", "source": [ - "# Contractual Service Margin" + "# Contractual Service Margin", + "\n", + "\nThe scopes below are simply used to set the appropriate Estimate Type (C for $CSM$, and LR for $LoReCo$), as well as to set $CSM$ values to be positive:" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/OverviewCalculationEngine.ipynb b/ifrs17/OverviewCalculationEngine.ipynb index 46e44c4c..01d19248 100644 --- a/ifrs17/OverviewCalculationEngine.ipynb +++ b/ifrs17/OverviewCalculationEngine.ipynb @@ -170,7 +170,7 @@ "\n$$", "\n- **[Contractual Service Margin (CSM), Loss Component LC) and Loss Recovery Component (LoReCo)](./Import/4ImportScope-TechnicalMargin)**, modeling the treatment of unearned profits (CSM) and losses (LC, LRC) as required by the IFRS 17 standard, per GIC or GRIC:", "\n - [Technical Margin](./Import/4ImportScope-TechnicalMargin#technical-margin), which is the sum of best estimate and risk adjustment PV with special rules for different AoC steps including the Amortization step, also using and calculating the Interest Accretion Factor, Premiums, Deferrals and Investment Claims", - "\n - [Switch Logic for CSM and LC](./Import/4ImportScope-TechnicalMargin#switch-logic), switching between CSM and LC for a given AoC step in the AoC period; one of the two is always zero depending on the sign of the Technical Margin; distinguishing the [gross case](./Import/4ImportScope-TechnicalMargin#gross-case) (no reinsurance) from the [reinsurance case](./Import/4ImportScope-TechnicalMargin#reinsurance-case) which applies reinsurance coverage weights" + "\n - [Switch Logic for CSM and LC](./Import/4ImportScope-TechnicalMargin#switch-logic), switching between CSM and LC for a given AoC step in the AoC period; one of the two is always zero depending on the sign of the Technical Margin; distinguishing the [gross case](./Import/4ImportScope-TechnicalMargin#gross-case) (no reinsurance) from the [reinsurance case](./Import/4ImportScope-TechnicalMargin#technical-margin-allocation-for-reinsurance) which applies reinsurance coverage weights" ], "metadata": {}, "execution_count": 0, From 5514ee2f96044340d0ed4627224f4feb431c8196 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Thu, 4 May 2023 15:48:56 +0200 Subject: [PATCH 6/8] align to prevent conflicts --- ifrs17/Import/Importers.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 0cb6b968..abcf6b74 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -890,7 +890,7 @@ "\n Year = primaryArgs.Year,", "\n Month = primaryArgs.Month, ", "\n Scenario = primaryArgs.Scenario,", - "\n Values = values.Any() ? values : new double[]{0d},", + "\n Values = !values.Any() ? new [] {0d} : values,", "\n Name = hasNameColumn ? datarow.Field(nameof(YieldCurve.Name)) : default(string)", "\n };", "\n }", From 7dfaec5fe6b4070c32659ee9efe0b3443e7ed37e Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 5 May 2023 10:26:34 +0200 Subject: [PATCH 7/8] reset changes --- ifrs17-template/Files/Dimensions.csv | 1 - ifrs17/Import/Importers.ipynb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ifrs17-template/Files/Dimensions.csv b/ifrs17-template/Files/Dimensions.csv index db0b638b..85a30f1d 100644 --- a/ifrs17-template/Files/Dimensions.csv +++ b/ifrs17-template/Files/Dimensions.csv @@ -234,7 +234,6 @@ LICDW10pct,Lic Down 10pct,,,,,,,,,, @@ValuationApproach,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, BBA,Building Block Approach,,,,,,,,,, -PAA,Premium Allocation Approach,,,,,,,,,, ,,,,,,,,,,, @@ProjectionConfiguration,,,,,,,,,,, SystemName,DisplayName,Shift,TimeStep,,,,,,,, diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index abcf6b74..7e899cdb 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -884,13 +884,13 @@ "\n (dataset, datarow) => {", "\n var values = datarow.Table.Columns.Where(c => c.ColumnName.StartsWith(nameof(YieldCurve.Values))).OrderBy(c => c.ColumnName.Length).ThenBy(c => c.ColumnName)", "\n .Select(x => datarow.Field(x.ColumnName).CheckStringForExponentialAndConvertToDouble()).ToArray().Prune();", - "\n ", + "\n if (!values.Any()) return null;", "\n return new YieldCurve {", "\n Currency = datarow.Field(nameof(YieldCurve.Currency)),", "\n Year = primaryArgs.Year,", "\n Month = primaryArgs.Month, ", "\n Scenario = primaryArgs.Scenario,", - "\n Values = !values.Any() ? new [] {0d} : values,", + "\n Values = values,", "\n Name = hasNameColumn ? datarow.Field(nameof(YieldCurve.Name)) : default(string)", "\n };", "\n }", From 2c6990bd97f2d2f6c5e39e520d0f400d7afa38dd Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 5 May 2023 10:43:56 +0200 Subject: [PATCH 8/8] PR improvements --- .../Import/4ImportScope-TechnicalMargin.ipynb | 27 ++++++++----------- ifrs17/Import/ImportStorage.ipynb | 3 +-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index 38ada7ee..76305353 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -313,7 +313,8 @@ "\n .Except(GetStorage().GetNonAttributableAmountType())", "\n .Sum(at => GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.I}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value +", "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.N}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value ) +", - "\n GetScope((Identity, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value;", + "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.I}, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value +", + "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = Novelties.N}, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value;", "\n}" ], "metadata": {}, @@ -458,12 +459,10 @@ "\n double AggregatedValue => GetScope((Identity, InputSource.Cashflow)).Values", "\n .Sum(aoc => ComputeTechnicalMarginFromIfrsVariables(Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty}));", "\n ", - "\n private double ComputeTechnicalMarginFromIfrsVariables(ImportIdentity id)", - "\n {", - "\n return GetStorage().GetValue(Identity, null, EstimateTypes.LR, null, Identity.ProjectionPeriod) +", - "\n GetStorage().GetValue(Identity, null, EstimateTypes.L, null, Identity.ProjectionPeriod) - ", - "\n GetStorage().GetValue(Identity, null, EstimateTypes.C, null, Identity.ProjectionPeriod);", - "\n }", + "\n private double ComputeTechnicalMarginFromIfrsVariables(ImportIdentity id) =>", + "\n GetStorage().GetValue(Identity, null, EstimateTypes.LR, null, Identity.ProjectionPeriod) +", + "\n GetStorage().GetValue(Identity, null, EstimateTypes.L, null, Identity.ProjectionPeriod) - ", + "\n GetStorage().GetValue(Identity, null, EstimateTypes.C, null, Identity.ProjectionPeriod);", "\n}" ], "metadata": {}, @@ -511,10 +510,8 @@ "\n", "\npublic interface AllocateTechnicalMarginForCl : AllocateTechnicalMargin", "\n{", - "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", - "\n .Values", - "\n .GroupBy(x => x.Novelty)", - "\n .Select(g => g.Last())", + "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .GroupBy(x => x.Novelty, (k, v) => v.Last())", "\n .Sum(aoc => { ", "\n var id = Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty};", "\n return GetScope(id).ComputedEstimateType != ComputedEstimateType ? ", @@ -586,7 +583,7 @@ "source": [ "## LoReCo Boundary", "\n", - "\nThe LoReCo Boundary is the underlying gross Loss Component multiplied by the weights coming from the Reinsurance Coverage (RC) Parameter (see [Data Node Parameters](../DataModel/DataStructure#data-node-parameters)). In case a GRIC ($r$) has multiple GICs ($g$), then these weighted $TM$s are aggregated.", + "\nThe LoReCo Boundary is the underlying gross Loss Component multiplied by the weights coming from the Reinsurance Coverage (RC) Parameter (see [Data Node Parameters](../DataModel/DataStructure#data-node-parameters)). In case a GRIC ($r$) has multiple GICs ($g$), then the LoReCo Boundaries computed for each GIC-GRIC link are aggregated.", "\n", "\n$$", "\n\\text{LoReCo Boundary}(\\text{r}) = \\sum_{g~\\in~\\text{underlying GICs}} \\text{RC}_{g,r} \\text{LC}(g).", @@ -667,10 +664,8 @@ "\n", "\npublic interface AllocateTechnicalMarginForReinsuranceCL : AllocateTechnicalMarginForReinsurance{ ", "\n string AllocateTechnicalMargin.ComputedEstimateType => ComputeReinsuranceEstimateType(loReCoBoundaryAggregatedValue + loReCoBoundaryValue);", - "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow))", - "\n .Values", - "\n .GroupBy(x => x.Novelty)", - "\n .Select(g => g.Last())", + "\n private double balancingValue => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .GroupBy(x => x.Novelty, (k, v) => v.Last())", "\n .Sum(aoc => { ", "\n var id = Identity with {AocType = aoc.AocType, Novelty = aoc.Novelty};", "\n return GetScope(id).ComputedEstimateType != ComputedEstimateType ? ", diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index f566d2c0..b9f6aa7c 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -19,8 +19,7 @@ { "cell_type": "markdown", "source": [ - "", - "\n

Import Storage

", + "

Import Storage

", "\n", "\nThe Import Storage collects the following data upon import of a file:", "\n",