From 14d5d3e7b35831f056e2b872947156671c3f29f1 Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Thu, 10 Aug 2023 11:05:09 +0200 Subject: [PATCH 1/2] Fix to P&L PAA --- ifrs17/Import/2ImportScope-PresentValue.ipynb | 2 +- ifrs17/Import/5ImportScope-ToIfrsVar.ipynb | 18 +++++------ ifrs17/Report/ReportScopes.ipynb | 31 +++++++++++++++++-- ifrs17/Utils/ImportCalculationMethods.ipynb | 3 +- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/ifrs17/Import/2ImportScope-PresentValue.ipynb b/ifrs17/Import/2ImportScope-PresentValue.ipynb index 9a7dd248..65f4017d 100644 --- a/ifrs17/Import/2ImportScope-PresentValue.ipynb +++ b/ifrs17/Import/2ImportScope-PresentValue.ipynb @@ -131,7 +131,7 @@ "\n private string EconomicBasis => GetContext();", "\n ", "\n private double[] YearlyYieldCurve => EconomicBasis switch {", - "\n EconomicBases.N => Enumerable.Empty().ToArray(),", + "\n EconomicBases.N => new [] { 0d },", "\n _ => GetStorage().GetYearlyYieldCurve(Identity, EconomicBasis),", "\n };", "\n ", diff --git a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb index fb55d548..ae06961f 100644 --- a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb +++ b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb @@ -437,12 +437,12 @@ "\n", "\n private string economicBasis => Identity.ValuationApproach == ValuationApproaches.VFA ? EconomicBases.C : EconomicBases.L;", "\n private IEnumerable amountTypesForTm => GetScope((Identity, EstimateTypes.C)).Values;", - "\n private bool hasTechnicalMargin => GetStorage().ImportFormat switch {", - "\n ImportFormats.Cashflow => GetStorage().GetRawVariables(Identity.DataNode).Any(x => x.EstimateType == EstimateTypes.RA || ", - "\n (x.EstimateType == EstimateTypes.BE && amountTypesForTm.Contains(x.AmountType))),", - "\n _ => GetStorage().GetIfrsVariables(Identity.DataNode).Any(x => !GetStorage().EstimateTypesByImportFormat[ImportFormats.Actual].Contains(x.EstimateType) && ", - "\n amountTypesForTm.Contains(x.AmountType))", - "\n };", + "\n // private bool hasTechnicalMargin => GetStorage().ImportFormat switch {", + "\n // ImportFormats.Cashflow => GetStorage().GetRawVariables(Identity.DataNode).Any(x => x.EstimateType == EstimateTypes.RA || ", + "\n // (x.EstimateType == EstimateTypes.BE && amountTypesForTm.Contains(x.AmountType))),", + "\n // _ => GetStorage().GetIfrsVariables(Identity.DataNode).Any(x => !GetStorage().EstimateTypesByImportFormat[ImportFormats.Actual].Contains(x.EstimateType) && ", + "\n // amountTypesForTm.Contains(x.AmountType))", + "\n // };", "\n", "\n IEnumerable Csms => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC || Identity.ValuationApproach == ValuationApproaches.PAA", "\n ? Enumerable.Empty()", @@ -456,8 +456,7 @@ "\n Partition = GetStorage().TargetPartition", "\n });", "\n", - "\n IEnumerable Loss => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC ||", - "\n (Identity.ValuationApproach == ValuationApproaches.PAA && !hasTechnicalMargin )", + "\n IEnumerable Loss => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", "\n ? Enumerable.Empty()", "\n : Identity.IsReinsurance ", "\n ? GetScope(Identity).RepeatOnce()", @@ -480,8 +479,7 @@ "\n });", "\n ", "\n IEnumerable AmortizationFactor => Identity.AocType == AocTypes.AM && Loss.Concat(Csms).Where(x => x.Values != null).Any(x => Math.Abs(x.Values.GetValidElement(Identity.ProjectionPeriod)) > Precision)", - "\n && GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LRC && ", - "\n (Identity.ValuationApproach != ValuationApproaches.PAA || hasTechnicalMargin )", + "\n && GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LRC", "\n ? GetScope((Identity, AmountTypes.CU, 0), o => o.WithContext(economicBasis)).RepeatOnce()", "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", "\n DataNode = x.Identity.Id.DataNode,", diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index 35326f84..f4ca2d7f 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -269,6 +269,7 @@ "source": [ "public interface BestEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n IDataCube BestEstimate => Identity.Id switch {", + "\n { ValuationApproach: ValuationApproaches.PAA } => GetScope(Identity).LockedBestEstimate,", "\n { ValuationApproach: ValuationApproaches.BBA, IsOci: true } => GetScope(Identity).LockedBestEstimate,", "\n _ => GetScope(Identity).CurrentBestEstimate };", "\n}", @@ -281,6 +282,11 @@ "\npublic interface CurrentBestEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n IDataCube CurrentBestEstimate => GetScope((Identity.Id, Identity.CurrencyType, EstimateTypes.BE)).FxData", "\n .Filter((\"LiabilityType\", Identity.Id.LiabilityType), (\"EconomicBasis\", EconomicBases.C), (\"AmountType\", \"!CDRI\"));", + "\n}", + "\n", + "\npublic interface NominalBestEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", + "\n IDataCube NominalBestEstimate => GetScope((Identity.Id, Identity.CurrencyType, EstimateTypes.BE)).FxData", + "\n .Filter((\"LiabilityType\", Identity.Id.LiabilityType), (\"EconomicBasis\", EconomicBases.N), (\"AmountType\", \"!CDRI\"));", "\n}" ], "metadata": {}, @@ -583,7 +589,11 @@ "\n}", "\n", "\npublic interface LrcActuarialPaa: LrcActuarial{", - "\n IDataCube LrcActuarial.LrcActuarial => -1d * GetScope(Identity).Revenues + GetScope(Identity).Deferrals + Loreco;", + "\n IDataCube LrcActuarial.LrcActuarial => -1d * GetScope(Identity).Revenues + -1d * GetScope(Identity).Deferrals + Loreco", + "\n + GetScope(Identity).BestEstimate", + "\n .Where(x => GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.PR) ||", + "\n GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.DE))", + "\n .ToDataCube();", "\n}" ], "metadata": {}, @@ -1433,6 +1443,14 @@ "\n private IDataCube CsmAmortization => -1 * GetScope(Identity).Csm", "\n .Filter((\"VariableType\", AocTypes.AM))", "\n .SelectToDataCube(v => v with { VariableType = \"ISE22\" });", + "\n", + "\n // Acquistion Expenses Release (Amortization)", + "\n private IDataCube AcquistionExpensesAmortization => Identity.Id switch {", + "\n { ValuationApproach: ValuationApproaches.PAA } => Enumerable.Empty().ToArray().ToDataCube(),", + "\n _ => -1 * GetScope(Identity)", + "\n .Filter((\"VariableType\", AocTypes.AM))", + "\n .SelectToDataCube(v => v with { VariableType = \"ISE22\" })", + "\n }; ", "\n ", "\n // Loss Recovery Component (Amortization)", "\n private IDataCube Loreco => GetScope(Identity).Loreco.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", @@ -1453,6 +1471,15 @@ "\n .AggregateOver(nameof(Novelty), nameof(VariableType))", "\n .SelectToDataCube(v => v with { Novelty = Novelties.C, VariableType = \"ISE11\" });", "\n", + "\n // PAA Premiums", + "\n private IDataCube Revenues => GetScope(Identity).Revenues.Filter((\"VariableType\", \"AM\"));", + "\n", + "\n private IDataCube PaaPremiums => Identity.Id switch {", + "\n { ValuationApproach: ValuationApproaches.PAA } => Revenues", + "\n .SelectToDataCube(v => v with { Novelty = Novelties.C, VariableType = \"ISE201\" }),", + "\n _ => Enumerable.Empty().ToArray().ToDataCube()", + "\n };", + "\n", "\n // Experience Adjustment On Premiums", "\n private IDataCube ReinsuranceActualPremiums => Identity.Id switch {", "\n { ValuationApproach: ValuationApproaches.PAA } => Enumerable.Empty().ToArray().ToDataCube(),", @@ -1497,7 +1524,7 @@ "\n .SelectToDataCube(rv => rv with { Novelty = Novelties.C, VariableType = \"ISE24\"});", "\n", "\n // Reinsurance", - "\n IDataCube InsuranceServiceExpense.Reinsurance => ExpectedClaims + ExpectedClaimsInvestmentComponent + ExpectedExpenses + ExpectedCommissions + RaRelease + CsmAmortization + LorecoAmortization + LorecoNonFinancialChanges + LorecoFinancialChanges + ExperienceAdjustmentOnPremiums + NonFinancialFcfDeltasCorrection;", + "\n IDataCube InsuranceServiceExpense.Reinsurance => ExpectedClaims + ExpectedClaimsInvestmentComponent + ExpectedExpenses + ExpectedCommissions + RaRelease + CsmAmortization + AcquistionExpensesAmortization + LorecoAmortization + LorecoNonFinancialChanges + LorecoFinancialChanges + PaaPremiums + ExperienceAdjustmentOnPremiums + NonFinancialFcfDeltasCorrection;", "\n}", "\n" ], diff --git a/ifrs17/Utils/ImportCalculationMethods.ipynb b/ifrs17/Utils/ImportCalculationMethods.ipynb index 3b8e7c6d..aa3d48a0 100644 --- a/ifrs17/Utils/ImportCalculationMethods.ipynb +++ b/ifrs17/Utils/ImportCalculationMethods.ipynb @@ -51,8 +51,7 @@ "public static double[] ComputeDiscountAndCumulate(this double[] nominalValues, double[] monthlyDiscounting, PeriodType periodType) ", "\n{ ", "\n if(nominalValues == null) return Enumerable.Empty().ToArray();", - "\n if(!monthlyDiscounting.Any()) monthlyDiscounting = new double[]{1d}; //Empty discounting array triggers Cumulation. ", - "\n", + "\n ", "\n var ret = new double[nominalValues.Length];", "\n ", "\n if(periodType == PeriodType.BeginningOfPeriod)", From 33f1fa97d6342d3e045cdd679c41fc89dc9081de Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Thu, 10 Aug 2023 12:29:44 +0200 Subject: [PATCH 2/2] Comments --- ifrs17/Import/5ImportScope-ToIfrsVar.ipynb | 1 + ifrs17/Report/ReportScopes.ipynb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb index ae06961f..fcf8696d 100644 --- a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb +++ b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb @@ -437,6 +437,7 @@ "\n", "\n private string economicBasis => Identity.ValuationApproach == ValuationApproaches.VFA ? EconomicBases.C : EconomicBases.L;", "\n private IEnumerable amountTypesForTm => GetScope((Identity, EstimateTypes.C)).Values;", + "\n // TODO: we need to think how to define the logic on when to compute LC for PAA-LRC", "\n // private bool hasTechnicalMargin => GetStorage().ImportFormat switch {", "\n // ImportFormats.Cashflow => GetStorage().GetRawVariables(Identity.DataNode).Any(x => x.EstimateType == EstimateTypes.RA || ", "\n // (x.EstimateType == EstimateTypes.BE && amountTypesForTm.Contains(x.AmountType))),", diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index f4ca2d7f..4fad9ffa 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -269,7 +269,7 @@ "source": [ "public interface BestEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n IDataCube BestEstimate => Identity.Id switch {", - "\n { ValuationApproach: ValuationApproaches.PAA } => GetScope(Identity).LockedBestEstimate,", + "\n { ValuationApproach: ValuationApproaches.PAA } => GetScope(Identity).LockedBestEstimate, //TODO we should use the economic basis driver to decide which Economic basis to use", "\n { ValuationApproach: ValuationApproaches.BBA, IsOci: true } => GetScope(Identity).LockedBestEstimate,", "\n _ => GetScope(Identity).CurrentBestEstimate };", "\n}",