diff --git a/ifrs17-template/Files/Dimensions.csv b/ifrs17-template/Files/Dimensions.csv index da6e028c..e19aef07 100644 --- a/ifrs17-template/Files/Dimensions.csv +++ b/ifrs17-template/Files/Dimensions.csv @@ -45,28 +45,27 @@ EOP,Closing Balance,,170,,,,,,,, ,,,,,,,,,,, @@AocConfiguration,,,,,,,,,,, AocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month -BOP,I,Optional,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1 -MC,I,Optional,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1 -RCU,I,Calculated,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1 -CF,I,Calculated,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1 -IA,I,Calculated,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1 -AU,I,Optional,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1 -YCU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1 -CRU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1 -EV,I,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1 -BOP,N,Optional,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,100,1900,1 -MC,N,Optional,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,105,1900,1 -CF,N,Calculated,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1 -IA,N,Calculated,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1 -AU,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1 -EV,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1 -CF,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,160,1900,1 -WO,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,170,1900,1 -CL,C,Mandatory,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1 -EA,C,Calculated,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1 -AM,C,Calculated,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1 -FX,C,Calculated,0,NotApplicable,NotApplicable,NotApplicable,NotApplicable,NotApplicable,210,1900,1 -EOP,C,Calculated,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1 +BOP,I,1,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1 +MC,I,1,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1 +RCU,I,4,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1 +CF,I,4,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1 +IA,I,4,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1 +AU,I,1,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1 +YCU,I,8,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1 +CRU,I,8,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1 +EV,I,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1 +BOP,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,100,1900,1 +MC,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,105,1900,1 +CF,N,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1 +IA,N,4,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1 +AU,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1 +EV,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1 +CL,C,2,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1 +EA,C,4,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1 +CF,C,5,6,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,193,1900,1 +WO,C,1,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,195,1900,1 +AM,C,4,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1 +EOP,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1 ,,,,,,,,,,, @@CreditRiskRating,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, diff --git a/ifrs17/Constants/Enums.ipynb b/ifrs17/Constants/Enums.ipynb index d1f3e733..7046c0ca 100644 --- a/ifrs17/Constants/Enums.ipynb +++ b/ifrs17/Constants/Enums.ipynb @@ -277,7 +277,20 @@ { "cell_type": "code", "source": [ - "public enum DataType { Optional, Mandatory, Calculated, CalculatedTelescopic }" + "[Flags]", + "\npublic enum DataType {Optional = 1, Mandatory = 2, Calculated = 4, CalculatedTelescopic = 8}", + "\n//Optional = 1 : used for AoC Step provided in input files but are not mandatory (can be missing from the file)", + "\n//Mandatory = 2 : used for AoC Step that must be provided in input files", + "\n//Calculated = 4 : used for AoC Step that are not provided in input files but are Calculated by the calculation engine", + "\n//CalculatedTelescopic = 8 : used for AoC Step that are not provided in input files but are Calculated by the calculation engine through telescoping difference (Update of parameters YCU)", + "\n//Optional + Mandatory = 3 : not allowed.", + "\n//Optional + Calculated = 5 : used for AoC Step that are optional input for a certain scopes (Written Actual) and are computed for others (Deferral Actual) ", + "\n//Optional + Mandatory + Calculated = 7 : not allowed.", + "\n//Optional + CalculatedTelescopic = 9 : not allowed.", + "\n//Mandatory + Calculated = 6 : not allowed.", + "\n//Mandatory + CalculatedTelescopic = 10 : not allowed.", + "\n//Calculated + CalculatedTelescopic = 12 : not allowed.", + "\n//Optional + Mandatory + Calculated + CalculatedTelescopic = 15 : not allowed." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/1ImportScope-Identities.ipynb b/ifrs17/Import/1ImportScope-Identities.ipynb index 7a46a361..d42e71cb 100644 --- a/ifrs17/Import/1ImportScope-Identities.ipynb +++ b/ifrs17/Import/1ImportScope-Identities.ipynb @@ -113,14 +113,22 @@ { "cell_type": "code", "source": [ - "public interface AllCfIdentities : IScope // string represents a DataNode", + "public interface AllCfIdentities : IScope // Identity corresponds to the DataNode", "\n{", - "\n public IEnumerable ids => GetStorage().GetAllAocSteps(InputSource.Cashflow)", - "\n .Select(aocStep => new ImportIdentity {", - "\n AocType = aocStep.AocType,", - "\n Novelty = aocStep.Novelty,", - "\n DataNode = Identity", - "\n });", + "\n IEnumerable ids => GetStorage().GetAllAocSteps(InputSource.Cashflow)", + "\n .Select(aocStep => new ImportIdentity {AocType = aocStep.AocType, Novelty = aocStep.Novelty, DataNode = Identity });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface GetParsedAocSteps : IScope", + "\n{", + "\n IEnumerable Values => GetStorage().GetRawVariables(Identity).Select(x => new AocStep(x.AocType, x.Novelty)).Distinct();", "\n}" ], "metadata": {}, @@ -133,88 +141,25 @@ "public interface GetIdentities : IScope", "\n{", "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", - "\n builder.ForScope(s => s.WithApplicability(x => x.GetStorage().IsSecondaryScope(x.Identity))", - "\n .WithApplicability(x => x.GetStorage().ImportFormat == ImportFormats.Actual)", - "\n .WithApplicability(x => x.GetStorage().ImportFormat == ImportFormats.Cashflow)", - "\n .WithApplicability(x => x.GetStorage().ImportFormat == ImportFormats.Opening)", - "\n );", + "\n builder.ForScope(s => s.WithApplicability(x => x.GetStorage().ImportFormat == ImportFormats.Cashflow));", "\n ", - "\n private IEnumerable computedIdentities => new string[]{AocTypes.EA, AocTypes.AM, AocTypes.EOP}", - "\n .Select(aocType => new ImportIdentity {", - "\n AocType = aocType,", - "\n Novelty = Novelties.C,", - "\n DataNode = Identity", - "\n });", - "\n private IEnumerable allIdentities => ParsedIdentities.Concat(computedIdentities).Concat(SpecialIdentities).ToHashSet(); ", - "\n ", - "\n IEnumerable ParsedIdentities => Enumerable.Empty(); ", - "\n IEnumerable SpecialIdentities => Enumerable.Empty();", - "\n ", - "\n //Set DataNode properties and ProjectionPeriod", - "\n IEnumerable Identities => allIdentities.Select(id => id with { IsReinsurance = GetStorage().DataNodeDataBySystemName[id.DataNode].IsReinsurance,", - "\n ValuationApproach = GetStorage().DataNodeDataBySystemName[id.DataNode].ValuationApproach", - "\n });", - "\n /* .SelectMany(id => Enumerable.Range(0,GetStorage().GetProjectionCount() + 1)", - "\n .Select(pp => id with {ProjectionPeriod = pp })", - "\n );*/", - "\n}", - "\n", - "\npublic interface AllCashflowIdentities : GetIdentities", - "\n{", - "\n IEnumerable GetIdentities.SpecialIdentities => GetScope(Identity).ids;", - "\n}", + "\n protected IEnumerable allIdentities => GetStorage().AocConfigurationByAocStep.Values.Select(x => new ImportIdentity {AocType = x.AocType, Novelty = x.Novelty, DataNode = Identity });", "\n", - "\n", - "\npublic interface GetActualIdentities : GetIdentities", - "\n{", - "\n private IEnumerable actualEstimateTypes => GetStorage().EstimateTypesByImportFormat[ImportFormats.Actual];", - "\n ", - "\n IEnumerable GetIdentities.ParsedIdentities => GetStorage().GetIfrsVariables(Identity).Where(iv => actualEstimateTypes.Contains(iv.EstimateType)).Select(v => new ImportIdentity(v));", - "\n IEnumerable GetIdentities.SpecialIdentities => GetScope(Identity).ids", - "\n .Concat(GetStorage().GetAllAocSteps(InputSource.Opening)", - "\n .Select(aocStep => new ImportIdentity {AocType = aocStep.AocType, ", - "\n Novelty = aocStep.Novelty,", - "\n DataNode = Identity", - "\n }));", + "\n IEnumerable Identities => allIdentities.Select(id => id with { IsReinsurance = GetStorage().DataNodeDataBySystemName[id.DataNode].IsReinsurance,", + "\n ValuationApproach = GetStorage().DataNodeDataBySystemName[id.DataNode].ValuationApproach});", "\n}", "\n", "\npublic interface GetCashflowIdentities : GetIdentities", "\n{", - "\n private bool isReinsurance => GetStorage().DataNodeDataBySystemName[Identity].IsReinsurance; //clean up in the next PR", - "\n ", - "\n IEnumerable GetIdentities.ParsedIdentities => GetStorage().GetRawVariables(Identity).Select(v => new ImportIdentity(v));", - "\n ", - "\n IEnumerable GetIdentities.SpecialIdentities => ParsedIdentities.Where(id => id.Novelty != Novelties.C)", - "\n .Select(id => id.Novelty).ToHashSet()", - "\n .SelectMany(n => (n == Novelties.N ", - "\n ? new string[]{AocTypes.IA, AocTypes.CF} //Add IA, CF, for New Business", - "\n : isReinsurance ", - "\n ? new string[]{AocTypes.IA, AocTypes.CF, AocTypes.YCU, AocTypes.CRU, AocTypes.RCU} //Add IA, CF, YCU, CRU, RCU for in force", - "\n : new string[]{AocTypes.IA, AocTypes.CF, AocTypes.YCU}) //Add IA, CF, YCU,", - "\n .Select(aocType => new ImportIdentity {", - "\n AocType = aocType,", - "\n Novelty = n,", - "\n DataNode = Identity }))", - "\n .Concat(new ImportIdentity {", - "\n AocType = AocTypes.CF, //Add CF for Deferral", - "\n Novelty = Novelties.C,", - "\n DataNode = Identity", - "\n }.RepeatOnce()) ", - "\n .Concat(GetStorage().GetAllAocSteps(InputSource.Opening)", - "\n .Select(aocStep => new ImportIdentity {AocType = aocStep.AocType, ", - "\n Novelty = aocStep.Novelty,", - "\n DataNode = Identity", - "\n })); ", - "\n}", + "\n private bool isReinsurance => GetStorage().DataNodeDataBySystemName[Identity].IsReinsurance;", + "\n private IEnumerable ParsedIdentities => GetScope(Identity).Values.Select(aocStep => new ImportIdentity {AocType = aocStep.AocType, Novelty = aocStep.Novelty, DataNode = Identity});", + "\n private IEnumerable rawVariableNovelties => GetStorage().GetRawVariables(Identity).Select(rv => rv.Novelty).Concat(Novelties.C.RepeatOnce()).ToHashSet();", + "\n private IEnumerable calculatedAocSteps => GetStorage().AocConfigurationByAocStep.Values.Where(x => (x.DataType.Contains(DataType.Calculated) || x.DataType.Contains(DataType.CalculatedTelescopic) ) &&", + "\n (!isReinsurance ? !ComputationHelper.ReinsuranceAocType.Contains(x.AocType) : true) && rawVariableNovelties.Contains(x.Novelty) ).Select(x => new AocStep(x.AocType, x.Novelty));", + "\n private IEnumerable SpecialIdentities => calculatedAocSteps.Select(x => new ImportIdentity {AocType = x.AocType, Novelty = x.Novelty, DataNode = Identity })", + "\n .Concat(GetStorage().GetAllAocSteps(InputSource.Opening).Select(aocStep => new ImportIdentity {AocType = aocStep.AocType, Novelty = aocStep.Novelty, DataNode = Identity}));", "\n", - "\npublic interface GetAllIdentities : GetIdentities", - "\n{", - "\n IEnumerable GetIdentities.SpecialIdentities => GetScope(Identity).ids", - "\n .Concat(GetStorage().GetAllAocSteps(InputSource.Actual)", - "\n .Select(aocStep => new ImportIdentity {AocType = aocStep.AocType, ", - "\n Novelty = aocStep.Novelty,", - "\n DataNode = Identity,", - "\n }));", + "\n IEnumerable GetIdentities.allIdentities => ParsedIdentities.Concat(SpecialIdentities).Distinct(); ", "\n}" ], "metadata": {}, @@ -281,24 +226,30 @@ { "cell_type": "markdown", "source": [ - "## Parent AoC Step ", - "\nThe **ParentAocStep** scope computes and provides an important piece of information for each [Identity](../DataModel/DataStructure#import-identity), i.e. for a certain [AoC Type](../DataModel/DataStructure#aoc-type) and [Novelty](../DataModel/DataStructure#novelty).", + "## Previous AoC Steps", + "\nThe **PreviousAocSteps** scope computes and provides an important piece of information for each [Identity](../DataModel/DataStructure#import-identity), i.e. for a certain [AoC Type](../DataModel/DataStructure#aoc-type) and [Novelty](../DataModel/DataStructure#novelty).", "\n", - "\nIt provides the list of the adjacent AoC Steps prior to Identity one. It can be more than one only for the step **CL** where a parent for each novelty is considered.", - "\nParentAocStep is critical when computing the *telescoping* differences. ", + "\nIt provides the list of all previous AoC Steps up to the **BOP** step, whereby a Combined novelty will branch into the InForce and New Business (and all other novelties) AoC Types.", "\n", - "\nThey are defined as follows:", + "\nPreviousAocSteps is critical when computing aggregated values along the various dimensions (such as for example Line of Business) and ", + "\nis used to compute the Parent AoC Steps and the Reference AoC Steps.", + "\n", + "\nThe adjacent AoC Steps prior to Identity one is called Parent Aoc Step (PAS). Thus the PreviousAocSteps is the collection of the identity parents and their parents and so on until there is no parent.", "\n", "\n$$", - "\n\\text{ParentAocStep}(\\text{AoC Step}) = \\left\\{", - "\n\\begin{array}{cl}", - "\n\\text{AoC Step with AoC Type YCU and Novelty I} & \\text{if AoC Type CRU} \\\\", - "\n\\text{The last AoC Step with Data Type != Calculated and same Novelty as the AoC Step} & \\text{if AoC Type YCU} \\\\", - "\n\\text{The AoC Step which comes before in terms of order (as defined by AoC Type)} & \\text{otherwise} \\\\", - "\n\\end{array}", - "\n\\right.", + "\n\\text{PreviousAocSteps}(\\rm{AocStep}) = \\{PAS_1, PAS_2, \\ldots\\}", "\n$$", - "\n" + "\nwhere", + "\n$$", + "\n\\rm{PAS}_1 = \\rm{ParentAocStep}(\\rm{AoC Step})", + "\n$$", + "\n$$", + "\n\\rm{PAS}_2 = \\rm{ParentAocStep}(\\rm{PAS}_1).", + "\n$$", + "\n", + "\nThis scope depends on the InputSource (Actual or Cashflow) for which the PreviousSteps are requested due to the Aoc Chain differences between Actual reports and the rest.", + "\n", + "\nThe exact structure being return depends on the **order** of the AoC Steps (which is set by the [AoC Step Configuration](../DataModel/DataStructure#aoc-configuration)), and on which AoC steps exist." ], "metadata": {}, "execution_count": 0, @@ -307,32 +258,19 @@ { "cell_type": "code", "source": [ - "public interface ParentAocStep : IScope<(ImportIdentity Id, string AmountType), ImportStorage>", - "\n{", - "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", - "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.AmountType != AmountTypes.CDR));", - "\n ", - "\n private HashSet ParsedAocSteps => GetScope(Identity.Id.DataNode).ParsedIdentities.Select(id => new AocStep(id.AocType, id.Novelty)).ToHashSet();", - "\n private IEnumerable OrderedParsedAocSteps => ParsedAocSteps.Concat(CalculatedTelescopicAocStep).OrderBy(x => GetStorage().AocConfigurationByAocStep[x].Order);", - "\n ", - "\n private Dictionary> ParentParsedIdentities => GetPreviousIdentities(OrderedParsedAocSteps);", + "public interface PreviousAocSteps : IScope<(ImportIdentity Id, InputSource ScopeInputSource), ImportStorage> ", + "\n{ ", "\n private AocStep identityAocStep => new AocStep(Identity.Id.AocType, Identity.Id.Novelty);", - "\n ", - "\n IEnumerable CalculatedTelescopicAocStep => GetStorage().GetCalculatedTelescopicAocSteps();", - "\n ", - "\n IEnumerable Values => ", - "\n Identity.Id.AocType switch {", - "\n AocTypes.CRU => new AocStep(AocTypes.YCU, Novelties.I).RepeatOnce(),", - "\n AocTypes.YCU => OrderedParsedAocSteps.GetReferenceAocStepForCalculated(GetStorage().AocConfigurationByAocStep, identityAocStep).RepeatOnce(),", - "\n _ => ParentParsedIdentities.TryGetValue(identityAocStep, out var parents) ? parents : Enumerable.Empty(),", - "\n };", - "\n}", - "\n", - "\npublic interface ParentAocStepForCreditRisk : ParentAocStep", - "\n{", - "\n IEnumerable ParentAocStep.CalculatedTelescopicAocStep => ", - "\n GetStorage().GetCalculatedTelescopicAocSteps().Where(aoc => aoc.AocType != AocTypes.CRU);", - "\n}" + "\n private int aocStepOrder => GetStorage().AocConfigurationByAocStep[identityAocStep].Order;", + "\n private HashSet allAocSteps => GetStorage().GetAllAocSteps(Identity.ScopeInputSource).ToHashSet();", + "\n IEnumerable Values => allAocSteps.Contains(identityAocStep)", + "\n ? GetScope(Identity.Id.DataNode).Identities.Select(id => new AocStep(id.AocType, id.Novelty)).Distinct()", + "\n .Where(aoc => allAocSteps.Contains(aoc) && ", + "\n GetStorage().AocConfigurationByAocStep[aoc].Order < aocStepOrder && ", + "\n (Identity.Id.Novelty != Novelties.C ? aoc.Novelty == Identity.Id.Novelty : true) )", + "\n .OrderBy(aoc => GetStorage().AocConfigurationByAocStep[aoc].Order)", + "\n : Enumerable.Empty();", + "\n} " ], "metadata": {}, "execution_count": 0, @@ -341,26 +279,27 @@ { "cell_type": "markdown", "source": [ - "## Reference AoC Step", + "## Parent AoC Step ", + "\nThe **ParentAocStep** scope computes and provides an important piece of information for each [Identity](../DataModel/DataStructure#import-identity), i.e. for a certain [AoC Type](../DataModel/DataStructure#aoc-type) and [Novelty](../DataModel/DataStructure#novelty).", "\n", - "\nThe **ReferenceAocStep** scope provides the AoC Step from which to retrieve the data in order to compute its value (e.g. AoC Step EA retrieves Present Values, while AoC Step YCU retrieves Nominal).", + "\nIt provides the list of the adjacent AoC Steps prior to Identity one. It can be more than one only for the step **CL** where a parent for each novelty is considered.", + "\nParentAocStep is critical when computing the *telescoping* differences. ", "\n", "\nThey are defined as follows:", "\n", "\n$$", - "\n\\text{ReferenceAocStep}(\\text{AoC Step}) = \\left\\{", + "\n\\text{ParentAocStep}(\\text{AoC Step}) = \\left\\{", "\n\\begin{array}{cl}", - "\n\\text{self} & \\text{if AoC Step InputSource is not Calculated} \\\\", - "\n\\text{The last AoC Step with Data Type != Calculated and same Novelty as the input AoC Step} ~, & \\text{if AoC Type } \\in \\text{\\{RCU, CF, IA, YCU, CRU\\}} \\\\", - "\n\\text{AoC Step with AoC Type CF and Novelty as the AoC Step} & \\text{if AoC Type EA} \\\\", - "\n\\text{AoC Step with AoC Type CL and Novelty C} & \\text{if AoC Type $\\in$ \\{AM, EOP\\}} \\\\", - "\n\\text{empty} & \\text{if AoC Type is BOP} \\\\", - "\n\\text{log NotSupportedAocStepReference error} & \\text{otherwise} \\\\", + "\n\\text{empty} & \\text{if AoC Type BOP or is of DataType Calculated} \\\\", + "\n\\text{Last of previous AoC Step for each Novelty} & \\text{if not BOP or Calculated but it is the first Combined AoC Step} \\\\", + "\n\\text{Last of previous AoC Step of the same Novelty} & \\text{if not BOP or Calculated and not the first Combined AoC Step} \\\\", "\n\\end{array}", "\n\\right.", "\n$$", "\n", - "\nwhere the last AoC Step is obtained by ordering the AoC Steps according to their order (as defined by its AoC Type) and taking the last one." + "\nwhere the last AoC Step is obtained by ordering the AoC Steps according to their order (as defined by its AoC Type) and taking the last one.", + "\nNote that the DataType of an AocStep is defined in the [AoC Step Configuration](../DataModel/DataStructure#aoc-configuration) table.", + "\n" ], "metadata": {}, "execution_count": 0, @@ -369,28 +308,20 @@ { "cell_type": "code", "source": [ - "public interface ReferenceAocStep : IScope ", + "public interface ParentAocStep : IScope<(ImportIdentity Id, string AmountType, InputSource ScopeInputSource), ImportStorage>", "\n{", - "\n private IEnumerable OrderedParsedAocSteps => GetScope(Identity.DataNode).ParsedIdentities", - "\n .Select(id => new AocStep(id.AocType, id.Novelty))", - "\n .Distinct()", - "\n .OrderBy(aocStep => GetStorage().AocConfigurationByAocStep[aocStep].Order);", - "\n private AocStep identityAocStep => new AocStep(Identity.AocType, Identity.Novelty);", - "\n private AocStep GetReferenceAocStep(string aocType) {", - "\n return aocType switch {", - "\n AocTypes.RCU or AocTypes.CF or AocTypes.IA or AocTypes.YCU or AocTypes.CRU => OrderedParsedAocSteps.GetReferenceAocStepForCalculated(GetStorage().AocConfigurationByAocStep, identityAocStep),", - "\n AocTypes.EA => new AocStep(AocTypes.CF, Identity.Novelty),", - "\n AocTypes.AM or AocTypes.EOP => new AocStep(AocTypes.CL, Novelties.C),", - "\n AocTypes.BOP => GetStorage().GetShift(Identity.ProjectionPeriod) >= MonthInAYear && Identity.Novelty == Novelties.I ? new AocStep(AocTypes.CL, Novelties.C) : new AocStep(default, default), //BOP, C has DataType == Calculated. See ReferenceAocStep condition.", - "\n _ => (AocStep)ApplicationMessage.Log(Error.NotSupportedAocStepReference, Identity.AocType),", - "\n };", - "\n }", + "\n private IEnumerable CalculatedAocStep => GetStorage().AocConfigurationByAocStep.Where(kvp => kvp.Value.DataType.Contains(DataType.Calculated)).Select(kvp => kvp.Key);", + "\n ", + "\n private IEnumerable TelescopicStepToBeRemoved => Identity.AmountType == AmountTypes.CDR ? Enumerable.Empty() : GetStorage().AocConfigurationByAocStep.Where(kvp => kvp.Value.AocType == AocTypes.CRU).Select(kvp => kvp.Key);", + "\n private IEnumerable PreviousAocStepsNotCalculated => GetScope((Identity.Id, Identity.ScopeInputSource)).Values.Where(aoc => !CalculatedAocStep.Concat(TelescopicStepToBeRemoved).Contains(aoc));", + "\n private bool IsFirstCombinedStep => Identity.Id.Novelty == Novelties.C && !PreviousAocStepsNotCalculated.Any(aoc => aoc.Novelty == Novelties.C);", + "\n private bool IsCalculatedStep => CalculatedAocStep.Contains(new AocStep(Identity.Id.AocType, Identity.Id.Novelty));", "\n", - "\n // The Reference AocStep from which get data (Nominal or PV) to compute", - "\n AocStep Value => GetStorage().AocConfigurationByAocStep[identityAocStep].DataType == DataType.Calculated ", - "\n || GetStorage().AocConfigurationByAocStep[identityAocStep].DataType == DataType.CalculatedTelescopic ", - "\n ? GetReferenceAocStep(Identity.AocType)", - "\n : identityAocStep;", + "\n IEnumerable Values => (Identity.Id.AocType == AocTypes.BOP || IsCalculatedStep, IsFirstCombinedStep) switch {", + "\n (true, _ ) => Enumerable.Empty(),", + "\n (false, true) => PreviousAocStepsNotCalculated.GroupBy(g => g.Novelty, (g, val) => val.Last()),", + "\n (false, false) => PreviousAocStepsNotCalculated.Last(aoc => aoc.Novelty == Identity.Id.Novelty).RepeatOnce(),", + "\n };", "\n}" ], "metadata": {}, @@ -400,26 +331,24 @@ { "cell_type": "markdown", "source": [ - "## Previous AoC Steps", - "\nThe **PreviousAocSteps** scope computes and provides another important piece of information for each [Identity](../DataModel/DataStructure#import-identity), i.e. for a certain [AoC Type](../DataModel/DataStructure#aoc-type) and [Novelty](../DataModel/DataStructure#novelty).", + "## Reference AoC Step", "\n", - "\nIt provides the list of all previous AoC Steps up to the **BOP** step, whereby a Combined novelty will branch into the InForce and New Business AoC Types.", + "\nThe **ReferenceAocStep** scope provides the AoC Step from which to retrieve the data in order to compute its value (e.g. AoC Step EA retrieves Present Values, while AoC Step YCU retrieves Nominal).", "\n", - "\nPreviousAocSteps is critical when computing aggregated values along the various dimensions (such as for example Line of Business) and ", - "\nis formed by the ParentAocStep and its parent and so on until there is no parent.", + "\nThey are defined as follows:", "\n", "\n$$", - "\n\\text{PreviousAocSteps}(\\rm{AocStep}) = \\{PAS_1, PAS_2, \\ldots\\}", - "\n$$", - "\nwhere", - "\n$$", - "\n\\rm{PAS}_1 = \\rm{ParentAocStep}(\\rm{AoC Step})", - "\n$$", - "\n$$", - "\n\\rm{PAS}_2 = \\rm{ParentAocStep}(\\rm{PAS}_1).", + "\n\\text{ReferenceAocStep}(\\text{AoC Step}) = \\left\\{", + "\n\\begin{array}{cl}", + "\n\\text{The last AoC Step with Data Type != Calculated} ~, & \\text{if AoC Step is of DataType Calculated or CalculatedTelescopic} \\\\", + "\n\\text{As defined by a custom setting} & \\text{otherwise if provided custom settings} \\\\", + "\n\\text{self} & \\text{all other cases} \\\\", + "\n\\end{array}", + "\n\\right.", "\n$$", "\n", - "\nThis scope depends on the InputSource (Actual or Cashflow) for which the PreviousSteps are requested due to the AocChain differences between Actual reports and the rest." + "\nwhere the last AoC Step is obtained by ordering the AoC Steps according to their order (as defined by its AoC Type) and taking the last one.", + "\nCustom settings for the Reference AoC Step is given in [helper variables](../Utils/ImportCalculationMethods#helper-variables-used-in-calculation) and can be overwritten in custom projects. " ], "metadata": {}, "execution_count": 0, @@ -428,30 +357,25 @@ { "cell_type": "code", "source": [ - "public interface PreviousAocSteps : IScope<(ImportIdentity Id, InputSource ScopeInputSource), ImportStorage> ", - "\n{ ", - "\n private AocStep identityAocStep => new AocStep(Identity.Id.AocType, Identity.Id.Novelty);", - "\n private int aocStepOrder => GetStorage().AocConfigurationByAocStep[identityAocStep].Order;", - "\n private HashSet allAocSteps => GetStorage().GetAllAocSteps(Identity.ScopeInputSource).ToHashSet();", - "\n IEnumerable Values => allAocSteps.Contains(identityAocStep)", - "\n ? GetScope(Identity.Id.DataNode).Identities", - "\n .Select(id => new AocStep(id.AocType, id.Novelty))", - "\n .Distinct()", - "\n .Where(aoc => allAocSteps.Contains(aoc) && ", - "\n GetStorage().AocConfigurationByAocStep[aoc].Order < aocStepOrder && ", - "\n (Identity.Id.Novelty != Novelties.C ? aoc.Novelty == Identity.Id.Novelty : true) )", - "\n .OrderBy(aoc => GetStorage().AocConfigurationByAocStep[aoc].Order)", - "\n : Enumerable.Empty();", - "\n} " - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "The exact structure being return depends on the **order** of the AoC Steps (which is set by the [AoC Type](../DataModel/DataStructure#aoc-type)), and on which AoC steps exist." + "// The Reference AocStep from which the data (Nominal or PV) is retrieved to to compute the current AoC Step", + "\npublic interface ReferenceAocStep : IScope", + "\n{", + "\n private AocStep identityAocStep => new AocStep(Identity.AocType, Identity.Novelty);", + "\n", + "\n private IEnumerable referenceForCalculated => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .GroupBy(g => g.Novelty, (g, val) => val.Last(aocStep => GetStorage().AocConfigurationByAocStep[aocStep].DataType != DataType.Calculated", + "\n && GetStorage().AocConfigurationByAocStep[aocStep].DataType != DataType.CalculatedTelescopic));", + "\n private bool IsCalculatedAocStep => GetStorage().AocConfigurationByAocStep[identityAocStep].DataType == DataType.Calculated || GetStorage().AocConfigurationByAocStep[identityAocStep].DataType == DataType.CalculatedTelescopic;", + "\n private bool IsProjectionBopI => Identity.AocType == AocTypes.BOP && Identity.Novelty == Novelties.I && GetStorage().GetShift(Identity.ProjectionPeriod) >= MonthInAYear;", + "\n ", + "\n IEnumerable Values => ( IsCalculatedAocStep, ", + "\n ComputationHelper.ReferenceAocSteps.TryGetValue(identityAocStep, out IEnumerable CustomDefinedReferenceAocStep), //IsCustomDefined", + "\n IsProjectionBopI ) switch {", + "\n (true, false, _) => referenceForCalculated.Any(x => x.Novelty == Novelties.C) ? referenceForCalculated.Where(x => x.Novelty == Novelties.C) : referenceForCalculated,", + "\n (true, true, _) or (_, true, true)=> CustomDefinedReferenceAocStep,", + "\n (false, _, _) => identityAocStep.RepeatOnce(),", + "\n };", + "\n}" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/2ImportScope-PresentValue.ipynb b/ifrs17/Import/2ImportScope-PresentValue.ipynb index bdb574ec..52c9d4dd 100644 --- a/ifrs17/Import/2ImportScope-PresentValue.ipynb +++ b/ifrs17/Import/2ImportScope-PresentValue.ipynb @@ -166,16 +166,18 @@ "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", "\n builder.ForScope(s => s.WithApplicability(x => x.GetStorage().GetCdr().Contains(x.Identity.AmountType) && x.Identity.Id.AocType == AocTypes.CF)", "\n .WithApplicability(x => x.GetStorage().GetCdr().Contains(x.Identity.AmountType))", - "\n .WithApplicability(x => x.GetStorage().GetShift(x.Identity.Id.ProjectionPeriod) >= MonthInAYear && x.Identity.Id.AocType == AocTypes.BOP && x.Identity.Id.Novelty == Novelties.I));", + "\n );", "\n", - "\n AocStep referenceAocStep => GetScope(Identity.Id).Value;", - "\n double[] Values => GetStorage().GetValues(Identity.Id with {AocType = referenceAocStep.AocType, Novelty = referenceAocStep.Novelty}, Identity.AmountType, Identity.EstimateType, Identity.AccidentYear);", + "\n IEnumerable referenceAocSteps => GetScope(Identity.Id).Values;", + "\n double[] Values => referenceAocSteps.Select(refAocStep => GetStorage().GetValues(Identity.Id with {AocType = refAocStep.AocType, Novelty = refAocStep.Novelty}, Identity.AmountType, Identity.EstimateType, Identity.AccidentYear))", + "\n .AggregateDoubleArray();", "\n}", "\n", "\npublic interface CreditDefaultRiskNominalCashflow : NominalCashflow", "\n{", - "\n private double[] NominalClaimsCashflow => GetStorage().GetClaims()", - "\n .Select(claim => GetStorage().GetValues(Identity.Id with {AocType = referenceAocStep.AocType, Novelty = referenceAocStep.Novelty}, claim, Identity.EstimateType, Identity.AccidentYear))", + "\n private double[] NominalClaimsCashflow => referenceAocSteps.SelectMany(refAocStep =>", + "\n GetStorage().GetClaims()", + "\n .Select(claim => GetStorage().GetValues(Identity.Id with {AocType = refAocStep.AocType, Novelty = refAocStep.Novelty}, claim, Identity.EstimateType, Identity.AccidentYear)))", "\n .AggregateDoubleArray();", "\n ", "\n private string cdrBasis => Identity.AmountType == AmountTypes.CDR ? EconomicBases.C : EconomicBases.L;", @@ -192,15 +194,10 @@ "\n", "\npublic interface AllClaimsCashflow : NominalCashflow", "\n{", - "\n double[] NominalCashflow.Values => GetStorage().GetClaims()", - "\n .Select(claim => GetStorage().GetValues(Identity.Id with {AocType = referenceAocStep.AocType, Novelty = referenceAocStep.Novelty}, claim, Identity.EstimateType, Identity.AccidentYear))", + "\n double[] NominalCashflow.Values => referenceAocSteps.SelectMany(refAocStep =>", + "\n GetStorage().GetClaims()", + "\n .Select(claim => GetStorage().GetValues(Identity.Id with {AocType = refAocStep.AocType, Novelty = refAocStep.Novelty}, claim, Identity.EstimateType, Identity.AccidentYear)))", "\n .AggregateDoubleArray();", - "\n}", - "\n", - "\npublic interface ProjectionBopNominalCashflow : NominalCashflow", - "\n{ ", - "\n ImportIdentity subImportIdentity => Identity.Id with {AocType = AocTypes.CL, Novelty = Novelties.C};", - "\n double[] NominalCashflow.Values => GetStorage().GetValues(subImportIdentity, Identity.AmountType, Identity.EstimateType, Identity.AccidentYear);", "\n}" ], "metadata": {}, @@ -344,7 +341,7 @@ "\n string EconomicBasis => GetContext();", "\n private double[] CurrentValues => GetScope(Identity).Values;", "\n ", - "\n private double[] PreviousValues => (GetScope((Identity.Id, Identity.AmountType)))", + "\n private double[] PreviousValues => (GetScope((Identity.Id, Identity.AmountType, InputSource.Cashflow)))", "\n .Values", "\n .Select(aoc => GetScope((Identity.Id with {AocType = aoc.AocType, Novelty = aoc.Novelty}, Identity.AmountType, Identity.EstimateType, Identity.Accidentyear)).Values)", "\n .Where(cf => cf.Count() > 0)", @@ -528,7 +525,7 @@ "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.CF)", "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.IA)", "\n .WithApplicability(x => ComputationHelper.AocTypeWithNoPv.Contains(x.Identity.Id.AocType) ||", - "\n (x.Identity.Id.AocType == AocTypes.CRU && !x.GetStorage().GetCdr().Contains(x.Identity.AmountType)) ) ", + "\n (x.Identity.Id.AocType == AocTypes.CRU && !x.GetStorage().GetCdr().Contains(x.Identity.AmountType)) )", "\n );", "\n ", "\n [NotVisible][IdentityProperty][Dimension(typeof(EconomicBasis))]", diff --git a/ifrs17/Import/3ImportScope-Actuals.ipynb b/ifrs17/Import/3ImportScope-Actuals.ipynb index 241ef5f9..3df31969 100644 --- a/ifrs17/Import/3ImportScope-Actuals.ipynb +++ b/ifrs17/Import/3ImportScope-Actuals.ipynb @@ -439,7 +439,7 @@ "\n}", "\n", "\npublic interface DeferrableEa : DiscountedDeferrable {", - "\n private string referenceAocType => GetScope(Identity).Value.AocType;", + "\n private string referenceAocType => GetScope(Identity).Values.First().AocType;", "\n double DiscountedDeferrable.Value => GetStorage().GetDeferrableExpenses().Sum(at =>", "\n GetStorage().GetNovelties(referenceAocType, InputSource.Cashflow)", "\n .Sum(n => GetScope((Identity with {AocType = referenceAocType, Novelty = n}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value) -", @@ -551,13 +551,12 @@ "\n ", "\n double NominalDeferrable.Value => referenceCashflow >= Precision //if no previous RawVariable, use IfrsVariable", "\n ? referenceCashflow ", - "\n : GetScope((Identity.Id with {AocType = AocTypes.BOP, Novelty = Novelties.I}, Identity.MonthlyShift)).Value +", - "\n GetScope((Identity.Id with {AocType = AocTypes.BOP, Novelty = Novelties.N}, Identity.MonthlyShift)).Value;", + "\n : GetStorage().GetNovelties(AocTypes.BOP, InputSource.Cashflow).Sum(n => GetScope((Identity.Id with {AocType = AocTypes.BOP, Novelty = n}, Identity.MonthlyShift)).Value);", "\n}", "\n", "\npublic interface AmDeferrable : NominalDeferrable{", - "\n private AocStep referenceAocStep => GetScope(Identity.Id).Value; //CL,C", - "\n private double referenceCashflow => GetScope((Identity.Id with {AocType = referenceAocStep.AocType, Novelty = referenceAocStep.Novelty}, Identity.MonthlyShift)).Value;", + "\n private IEnumerable referenceAocSteps => GetScope(Identity.Id).Values; //Reference step of AM,C is CL,C", + "\n private double referenceCashflow => referenceAocSteps.Sum(refAocStep => GetScope((Identity.Id with {AocType = refAocStep.AocType, Novelty = refAocStep.Novelty}, Identity.MonthlyShift)).Value);", "\n", "\n double NominalDeferrable.Value => -1d * referenceCashflow * GetScope((Identity.Id, AmountTypes.DAE, Identity.MonthlyShift), o => o.WithContext(EconomicBasis)).Value;", "\n}", diff --git a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb index eaec870f..b2ca659d 100644 --- a/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb +++ b/ifrs17/Import/4ImportScope-TechnicalMargin.ipynb @@ -268,7 +268,7 @@ "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", "\n );", "\n ", - "\n private string estimateType => GetContext();", + "\n protected string estimateType => GetContext();", "\n [NotVisible] string EconomicBasis => EconomicBases.L;", "\n double Value => GetScope((Identity.DataNode, estimateType)).Values", "\n .Sum(at => GetScope((Identity, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value) +", @@ -315,7 +315,7 @@ "\n static ApplicabilityBuilder ScopeApplicabilityBuilderInner(ApplicabilityBuilder builder) => ", "\n builder.ForScope(s => s.WithApplicability(x => x.Identity.IsReinsurance));", "\n ", - "\n private string referenceAocType => GetScope(Identity).Value.AocType;", + "\n private string referenceAocType => GetScope(Identity).Values.First().AocType;// ReferenceAocStep of EA is CF", "\n ", "\n private double premiums => GetStorage().GetNovelties(referenceAocType, InputSource.Cashflow)", "\n .Sum(n => GetScope(Identity with {AocType = referenceAocType, Novelty = n}).ByAmountType.Sum(sc => sc.Value)) -", @@ -342,12 +342,10 @@ "\n}", "\n", "\npublic interface TechnicalMarginForAmForPaa : TechnicalMargin{", - "\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 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 private IEnumerable novelties => GetStorage().GetNovelties(AocTypes.CF).Where(novelty => novelty != Novelties.C);", + "\n double TechnicalMargin.Value => GetScope((Identity.DataNode, estimateType)).Values", + "\n .Sum(at => novelties.Sum(n => GetScope((Identity with {AocType = AocTypes.CF, Novelty = n}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value + ", + "\n GetScope((Identity with {AocType = AocTypes.CF, Novelty = n}, (string)null, EstimateTypes.RA, (int?)null), o => o.WithContext(EconomicBasis)).Value));", "\n}", "\n", "\npublic interface TechnicalMarginForEop : TechnicalMargin{", diff --git a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb index 01f3c41c..4b79c555 100644 --- a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb +++ b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb @@ -444,7 +444,7 @@ { "cell_type": "markdown", "source": [ - "## Tm" + "## Technical margin" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/6ImportScope-Compute.ipynb b/ifrs17/Import/6ImportScope-Compute.ipynb index eabcf6ad..3eb5c113 100644 --- a/ifrs17/Import/6ImportScope-Compute.ipynb +++ b/ifrs17/Import/6ImportScope-Compute.ipynb @@ -125,7 +125,7 @@ { "cell_type": "markdown", "source": [ - "# Chashflows with Projections" + "# Cashflows with Projections" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 9f417140..043c2961 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -796,10 +796,10 @@ "\n", "\n var aocTypes = await options.TargetDataSource.Query().OrderBy(x => x.Order).ToArrayAsync();", "\n var aocTypesCompulsory = typeof(AocTypes).GetFields().Select(x => (string)x.Name);", - "\n if(aocTypesCompulsory.Where(x => !aocTypes.Select(x => x.SystemName).Contains(x)).Any()) {", - "\n ApplicationMessage.Log(Error.AocTypeCompulsoryNotFound);", - "\n return Activity.Finish();", - "\n }", + "\n // if(aocTypesCompulsory.Where(x => !aocTypes.Select(x => x.SystemName).Contains(x)).Any()) { //aocTypes const are not to be considered compulsory steps. ", + "\n // ApplicationMessage.Log(Error.AocTypeCompulsoryNotFound);", + "\n // return Activity.Finish();", + "\n // }", "\n ", "\n var logConfig = await Import.FromDataSet(dataSet).WithType().WithTarget(workspace).ExecuteAsync();", "\n if(logConfig.Errors.Any()) return Activity.Finish().Merge(logConfig); ", diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index c7422c32..85793834 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -533,7 +533,7 @@ "\n private IDataCube licData => licActuarial + accrual;", "\n ", "\n private IDataCube bop => licData.Filter((\"VariableType\", AocTypes.BOP), (\"Novelty\", Novelties.I));", - "\n private IDataCube delta => (licData.Filter((\"VariableType\",\"!BOP\"),(\"VariableType\",\"!EOP\")) + licData.Filter((\"VariableType\", AocTypes.BOP), (\"Novelty\", Novelties.N)))", + "\n private IDataCube delta => (licData.Filter((\"VariableType\",\"!BOP\"),(\"VariableType\",\"!EOP\")) + licData.Filter((\"VariableType\", AocTypes.BOP), (\"Novelty\", \"!I\")))", "\n .AggregateOver(nameof(Novelty), nameof(VariableType))", "\n .SelectToDataCube(x => Math.Abs(x.Value) >= Precision, x => x with { Novelty = Novelties.C, VariableType = \"D\" });", "\n private IDataCube eop => licData.Filter((\"VariableType\",AocTypes.EOP));", @@ -594,7 +594,7 @@ "\n private IDataCube lrcData => lrcActuarial + accrual;", "\n ", "\n private IDataCube bop => lrcData.Filter((\"VariableType\", AocTypes.BOP), (\"Novelty\", Novelties.I));", - "\n private IDataCube delta => (lrcData.Filter((\"VariableType\",\"!BOP\"),(\"VariableType\",\"!EOP\")) + lrcData.Filter((\"VariableType\", AocTypes.BOP), (\"Novelty\", Novelties.N)))", + "\n private IDataCube delta => (lrcData.Filter((\"VariableType\",\"!BOP\"),(\"VariableType\",\"!EOP\")) + lrcData.Filter((\"VariableType\", AocTypes.BOP), (\"Novelty\", \"!I\")))", "\n .AggregateOver(nameof(Novelty), nameof(VariableType))", "\n .SelectToDataCube(x => Math.Abs(x.Value) >= Precision, x => x with { Novelty = Novelties.C, VariableType = \"D\" });", "\n private IDataCube eop => lrcData.Filter((\"VariableType\",AocTypes.EOP));", @@ -703,10 +703,14 @@ "source": [ "public interface FcfChangeInEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n private IDataCube FcfDeltas => GetScope(Identity).Fcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"))", + "\n .Where(x => string.IsNullOrWhiteSpace(x.AmountType) ? true : !GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.DE))", + "\n .ToDataCube();", "\n ", "\n private IDataCube CurrentFcfDeltas => GetScope(Identity).CurrentFcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).CurrentFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).CurrentFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"))", + "\n .Where(x => string.IsNullOrWhiteSpace(x.AmountType) ? true : !GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.DE))", + "\n .ToDataCube();", "\n", "\n // Non-Financial Fp", "\n private string variableTypeNonFinancial => Identity.Id switch {", @@ -800,7 +804,7 @@ "\n };", "\n ", "\n private IDataCube Csm => GetScope(Identity).Csm.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Csm.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Csm.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n IDataCube Amortization => -1 * Csm.Filter((\"VariableType\", AocTypes.AM)).SelectToDataCube(v => v with { VariableType = variableType.amortization });", "\n ", @@ -849,7 +853,7 @@ "public interface LcChangeInEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n ", "\n private IDataCube Lc => GetScope(Identity).Lc.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Lc.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Lc.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n IDataCube Amortization => -1 * Lc.Filter((\"VariableType\", AocTypes.AM)).SelectToDataCube(v => v with { VariableType = \"ISE9\" });", "\n ", @@ -902,7 +906,7 @@ "public interface LorecoChangeInEstimate: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n ", "\n private IDataCube Loreco => GetScope(Identity).Loreco.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Loreco.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Loreco.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n IDataCube Amortization => -1 * Loreco.Filter((\"VariableType\", AocTypes.AM)).SelectToDataCube(v => v with { VariableType = \"ISE8\" });", "\n ", @@ -1272,16 +1276,16 @@ "\n .SelectToDataCube(v => v with { VariableType = \"IR13\" });", "\n", "\n // Acquistion Expenses Release (Amortization)", - "\n private IDataCube AcquistionExpensesAmortization => GetScope(Identity)", + "\n private IDataCube AcquistionExpensesAmortization => -1 * GetScope(Identity)", "\n .Filter((\"VariableType\", AocTypes.AM))", "\n .SelectToDataCube(v => v with { VariableType = \"IR13\" });", "\n", "\n // FCF Locked-In Interest Rate Correction", "\n private IDataCube FcfDeltas => GetScope(Identity).Fcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n private IDataCube LockedFcfDeltas => GetScope(Identity).LockedFcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).LockedFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).LockedFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n", "\n private IDataCube NonFinancialFcfDeltas => FcfDeltas", "\n .Filter((\"VariableType\", \"!IA\"), (\"VariableType\", \"!YCU\"), (\"VariableType\", \"!CRU\"), (\"VariableType\", \"!FX\"));", @@ -1339,13 +1343,13 @@ "\n .SelectToDataCube(v => v with { VariableType = \"ISE41\" });", "\n", "\n // Acquistion Expenses Release (Amortization)", - "\n private IDataCube AcquistionExpensesAmortization => -1 * GetScope(Identity)", + "\n private IDataCube AcquistionExpensesAmortization => GetScope(Identity)", "\n .Filter((\"VariableType\", AocTypes.AM))", "\n .SelectToDataCube(v => v with { VariableType = \"ISE6\" });", "\n", "\n // Loss Component", "\n private IDataCube Lc => GetScope(Identity).Lc.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Lc.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Lc.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n private IDataCube LcAmortization => -1 * Lc.Filter((\"VariableType\", AocTypes.AM)).SelectToDataCube(v => v with { VariableType = \"ISE9\" });", "\n ", @@ -1362,7 +1366,7 @@ "\n", "\n // Change in LIC", "\n private IDataCube FcfDeltas => (GetScope(Identity).Fcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N)))", + "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\")))", "\n .Filter((\"LiabilityType\", \"LIC\")); // TODO, extract the LIC to a dedicated scope (whole thing, actually)", "\n ", "\n private IDataCube NonFinancialFcfDeltas => FcfDeltas", @@ -1414,7 +1418,7 @@ "\n ", "\n // Loss Recovery Component (Amortization)", "\n private IDataCube Loreco => GetScope(Identity).Loreco.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Loreco.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Loreco.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n", "\n private IDataCube LorecoAmortization => -1 * Loreco", "\n .Filter((\"VariableType\", AocTypes.AM))", @@ -1457,10 +1461,10 @@ "\n", "\n // FCF Locked-In Interest Rate Correction", "\n private IDataCube FcfDeltas => GetScope(Identity).Fcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n private IDataCube LockedFcfDeltas => GetScope(Identity).LockedFcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).LockedFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).LockedFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n", "\n private IDataCube NonFinancialFcfDeltas => FcfDeltas", "\n .Filter((\"VariableType\", \"!IA\"), (\"VariableType\", \"!YCU\"), (\"VariableType\", \"!CRU\"), (\"VariableType\", \"!FX\"));", @@ -1489,10 +1493,10 @@ "public interface InsuranceFinanceIncomeExpenseOci: IScope<(ReportIdentity Id, CurrencyType CurrencyType), ReportStorage>, IDataCube {", "\n //FCF", "\n private IDataCube FcfDeltas => GetScope(Identity).Fcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Fcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n private IDataCube CurrentFcfDeltas => GetScope(Identity).CurrentFcf.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).CurrentFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).CurrentFcf.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n // Financial Fp", "\n private string variableTypeFpFinancial => Identity.Id switch {", @@ -1530,7 +1534,7 @@ "\n", "\n // CSM", "\n private IDataCube Csm => GetScope(Identity).Csm.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Csm.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Csm.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n", "\n private IDataCube CsmFx => -1 * Csm.Filter((\"VariableType\", AocTypes.FX))", "\n .AggregateOver(nameof(Novelty))", @@ -1544,7 +1548,7 @@ "\n", "\n // LC", "\n private IDataCube Lc => GetScope(Identity).Lc.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Lc.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Lc.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n", "\n private IDataCube LcFx => -1 * Lc.Filter((\"VariableType\", AocTypes.FX))", "\n .AggregateOver(nameof(Novelty))", @@ -1558,7 +1562,7 @@ "\n", "\n // LoReCo", "\n private IDataCube Loreco => GetScope(Identity).Loreco.Filter((\"VariableType\", \"!BOP\"),(\"VariableType\", \"!EOP\")) +", - "\n GetScope(Identity).Loreco.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", Novelties.N));", + "\n GetScope(Identity).Loreco.Filter((\"VariableType\", AocTypes.BOP),(\"Novelty\", \"!I\"));", "\n ", "\n private IDataCube LorecoFx => -1 * Loreco.Filter((\"VariableType\", AocTypes.FX))", "\n .AggregateOver(nameof(Novelty))", diff --git a/ifrs17/Test/AocConfigurationTest.ipynb b/ifrs17/Test/AocConfigurationTest.ipynb index 16274ad5..61f308a0 100644 --- a/ifrs17/Test/AocConfigurationTest.ipynb +++ b/ifrs17/Test/AocConfigurationTest.ipynb @@ -421,6 +421,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "workspace.Dispose()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Test/AocStructureTest.ipynb b/ifrs17/Test/AocStructureTest.ipynb index 298a59d2..dd4af5a9 100644 --- a/ifrs17/Test/AocStructureTest.ipynb +++ b/ifrs17/Test/AocStructureTest.ipynb @@ -55,9 +55,21 @@ { "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();" + "await DataSource.DeleteAsync(DataSource.Query());", + "\nawait DataSource.DeleteAsync(DataSource.Query());", + "\n", + "\n((await Import.FromString(novelties).WithType().WithTarget(DataSource).ExecuteAsync()).Status,", + "\n(await Import.FromString(canonicalAocTypes).WithType().WithTarget(DataSource).ExecuteAsync()).Status,", + "\n(await Import.FromString(canonicalAocConfig).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync()).Status)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(projectionConfiguration).WithType().WithTarget(DataSource).ExecuteAsync();" ], "metadata": {}, "execution_count": 0, @@ -136,7 +148,7 @@ "source": [ "public async Task CheckAocStepStructureAsync(IEnumerable inputVariables, ", "\n Dictionary> parentBm, ", - "\n Dictionary referenceBm, ", + "\n Dictionary> referenceBm, ", "\n Dictionary> fullAocBm,", "\n Dictionary> parentBmCdr = null)", "\n{", @@ -155,25 +167,26 @@ "\n inputSource = InputSource.Actual;", "\n }", "\n ", + "\n ", "\n var newArgs = args with {ImportFormat = importFormat };", + "\n var goc = inputVariables.First().DataNode;", + "\n ", "\n //Set up import storage and test universe", "\n var testStorage = new ImportStorage(newArgs, DataSource, Workspace);", "\n await testStorage.InitializeAsync();", - "\n var isReinsurance = testStorage.DataNodeDataBySystemName[inputVariables.First().DataNode].IsReinsurance;", + "\n var isReinsurance = testStorage.DataNodeDataBySystemName[goc].IsReinsurance;", "\n var testUniverse = Scopes.ForStorage(testStorage).ToScope();", "\n //Clean up Workspace", "\n await Workspace.DeleteAsync(await Workspace.Query().ToArrayAsync()); ", "\n await Workspace.DeleteAsync(await Workspace.Query().ToArrayAsync()); ", "\n ", "\n var errors = new List();", - "\n ", - "\n var goc = inputVariables.First().DataNode;", "\n var identities = testUniverse.GetScopes(testStorage.DataNodesByImportScope[ImportScope.Primary].Where(dn => dn == goc)).SelectMany(s => s.Identities);", "\n ", "\n //Assert Parents", "\n if (importFormat != ImportFormats.Actual)", "\n {", - "\n var parents = testUniverse.GetScopes(identities.Select(id => (object)(id, \"PR\")), o => o.WithStorage(testStorage)).Where(x => x.Values != Enumerable.Empty()).ToArray();", + "\n var parents = testUniverse.GetScopes(identities.Select(id => (object)(id, \"PR\",inputSource)), o => o.WithStorage(testStorage)).Where(x => x.Values.Any()).ToArray();", "\n if (parentBm.Count() != parents.Count()) ", "\n {", "\n var computedIds = parents.Select(s => $\"AocType:{s.Identity.Id.AocType}, Novelty:{s.Identity.Id.Novelty}\");", @@ -200,9 +213,9 @@ "\n //Parents for CDR", "\n if(isReinsurance)", "\n {", - "\n var parentsCdr = testUniverse.GetScopes(identities.Select(id => (object)(id, AmountTypes.CDR)), o => o.WithStorage(testStorage));", + "\n var parentsCdr = testUniverse.GetScopes(identities.Select(id => (object)(id, AmountTypes.CDR,inputSource)), o => o.WithStorage(testStorage)).ToArray();", "\n ", - "\n var countP = parentsCdr.Where(x => x.Values != Enumerable.Empty()).Count();", + "\n var countP = parentsCdr.Where(x => x.Values.Any()).Count();", "\n if (parentBmCdr.Count() != countP) ", "\n errors.Add( $\"Parent count for AmountType CDR does not match expected: \\n Computed {countP} \\n Expected {parentBm.Count()}.\" );", "\n ", @@ -228,19 +241,23 @@ "\n if (importFormat != ImportFormats.Actual)", "\n {", "\n var reference = testUniverse.GetScopes(identities, o => o.WithStorage(testStorage)).ToArray();", - "\n var countR = reference.Select(x => x.Value).Count();", + "\n var countR = reference.Select(x => x.Values).Count();", "\n if (referenceBm.Count() != countR) ", "\n errors.Add( $\"Reference count does not match expected: \\n Computed {countR} \\n Expected {referenceBm.Count()}.\" );", "\n ", "\n foreach(var kvp in referenceBm)", "\n {", "\n var scopeReferences = reference.Where(y => y.Identity.AocType == kvp.Key.AocType && y.Identity.Novelty == kvp.Key.Novelty);", - "\n if(scopeReferences.Count() != 1)", + "\n if(!scopeReferences.Any())", "\n errors.Add( $\"Reference not found for AocStep: {kvp.Key.AocType}, {kvp.Key.Novelty}.\");", "\n else{", - "\n var scopeReference = scopeReferences.First();", - "\n if( kvp.Value.AocType != scopeReference.Value.AocType || kvp.Value.Novelty != scopeReference.Value.Novelty )", - "\n errors.Add( $\"Reference of {kvp.Key.AocType}, {kvp.Key.Novelty} do not match expected value: \\n Computed {scopeReference.Value} \\n Expected {kvp.Value}.\" );", + "\n var scopeReference = scopeReferences.First();", + "\n if( kvp.Value.Intersect(scopeReference.Values).Count() != kvp.Value.Count() || ", + "\n kvp.Value.Intersect(scopeReference.Values).Count() != scopeReference.Values.Count() ){", + "\n var computedAocSteps = scopeReference.Values.Select(aoc => $\"AocType:{aoc.AocType}, Novelty:{aoc.Novelty}\");", + "\n var expectedAocSteps = kvp.Value.Select(aoc => $\"AocType:{aoc.AocType}, Novelty:{aoc.Novelty}\"); ", + "\n errors.Add( $\"Reference of {kvp.Key.AocType}, {kvp.Key.Novelty} do not match expected value: \\n Computed: \\n {string.Join(\"\\n\", computedAocSteps)} \\n Expected: \\n {string.Join(\"\\n\", expectedAocSteps)}.\" );", + "\n }", "\n }", "\n }", "\n }", @@ -255,8 +272,7 @@ "\n errors.Add( $\"Full AoC count does not match expected: \\n Computed {count} \\n Expected {fullAocBm.Count()}.\" ); ", "\n errors.Add( $\"In particular, \\n Computed Identities \\n {string.Join(\"\\n\", computedAocSteps)} \\n Expected \\n {string.Join(\"\\n\", benchmarkKeys)}.\" ); ", "\n }", - "\n ", - "\n foreach(var kvp in fullAocBm)", + "\n else foreach(var kvp in fullAocBm)", "\n {", "\n var scopeAocFulls = fullAoc.Where(y => y.Identity.Id.AocType == kvp.Key.AocType && y.Identity.Id.Novelty == kvp.Key.Novelty);", "\n if(scopeAocFulls.Count() != 1){", @@ -332,22 +348,22 @@ { "cell_type": "code", "source": [ - "var referenceBm = new Dictionary()", + "var referenceBm = new Dictionary>()", "\n {", - "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", - "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"BOP\",\"N\"), new AocStep(\"BOP\",\"N\")},", - "\n {new AocStep(\"CF\",\"N\"), new AocStep(\"BOP\",\"N\")},", - "\n {new AocStep(\"IA\",\"N\"), new AocStep(\"BOP\",\"N\")},", - "\n {new AocStep(\"EV\",\"N\"), new AocStep(\"EV\",\"N\")},", - "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} },", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} },", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} },", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} }, ", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"EV\",\"N\")} },", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\")} },", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\")} },", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\")} },", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\")} },", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\")} },", "\n };" ], "metadata": {}, @@ -368,7 +384,7 @@ "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\")}},", "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\")}},", - "\n ", + "\n", "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", "\n }},", @@ -376,15 +392,18 @@ "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", "\n new AocStep(\"CL\",\"C\"),", "\n }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", + "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),}},", "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", - "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"CF\",\"C\")", "\n }},", + "\n", "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", - "\n new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", "\n }},", - "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", "\n };", "\n" ], @@ -470,24 +489,24 @@ { "cell_type": "code", "source": [ - "referenceBm = new Dictionary()", + "referenceBm = new Dictionary>()", "\n {", - "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", - "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"RCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"CRU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"BOP\",\"N\"), new AocStep(\"BOP\",\"N\")},", - "\n {new AocStep(\"CF\",\"N\"), new AocStep(\"BOP\",\"N\")},", - "\n {new AocStep(\"IA\",\"N\"), new AocStep(\"BOP\",\"N\")},", - "\n {new AocStep(\"EV\",\"N\"), new AocStep(\"EV\",\"N\")},", - "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"RCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"CRU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"EV\",\"N\") }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", "\n };" ], "metadata": {}, @@ -510,7 +529,6 @@ "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\")}},", "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\")}},", - "\n ", "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"RCU\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"CRU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", "\n }},", @@ -518,16 +536,17 @@ "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", "\n new AocStep(\"CL\",\"C\"),", "\n }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"RCU\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", + "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),}},", "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"RCU\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"),new AocStep(\"YCU\",\"I\"), new AocStep(\"CRU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", - "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),", "\n }},", "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"RCU\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"),new AocStep(\"YCU\",\"I\"), new AocStep(\"CRU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", - "\n new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", - "\n }},", - "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", - "\n ", + "\n new AocStep(\"CF\",\"C\"),new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n }}, ", "\n };" ], "metadata": {}, @@ -594,19 +613,19 @@ { "cell_type": "code", "source": [ - "referenceBm = new Dictionary()", + "referenceBm = new Dictionary>()", "\n {", - "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", - "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"EV\",\"I\"), new AocStep(\"EV\",\"I\")}, ", - "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"EV\",\"I\"), new AocStep[]{new AocStep(\"EV\",\"I\") }}, ", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", "\n };" ], "metadata": {}, @@ -624,16 +643,17 @@ "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\")}},", "\n {new AocStep(\"EV\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\")}},", - "\n ", + "\n ", "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", "\n }},", - "\n ", "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", - "\n new AocStep(\"CL\",\"C\"),}},", + "\n new AocStep(\"CL\",\"C\"),}},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", + "\n new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"),}},", "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", - "\n new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"),}},", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"),}},", "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", - "\n new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"),}},", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"),}},", "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", "\n };" ], @@ -684,28 +704,27 @@ "string newAocConfig = ", "\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", - "\nEV,C,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,175,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\";" + "\nBOP,I,1,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1", + "\nMC,I,1,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1", + "\nRCU,I,4,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1", + "\nCF,I,4,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1", + "\nIA,I,4,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1", + "\nAU,I,1,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1", + "\nYCU,I,8,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1", + "\nCRU,I,8,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1", + "\nEV,I,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1", + "\nBOP,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,95,1900,1", + "\nCF,N,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1", + "\nIA,N,4,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1", + "\nAU,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1", + "\nEV,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1", + "\nEV,C,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,175,1900,1", + "\nCL,C,2,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1", + "\nEA,C,4,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1", + "\nCF,C,5,6,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,192,1900,1", + "\nWO,C,1,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,195,1900,1", + "\nAM,C,4,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1", + "\nEOP,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1\";" ], "metadata": {}, "execution_count": 0, @@ -762,19 +781,20 @@ { "cell_type": "code", "source": [ - "referenceBm = new Dictionary()", + "referenceBm = new Dictionary>()", "\n {", - "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", - "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"EV\",\"C\"), new AocStep(\"EV\",\"C\")},", - "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"BOP\",\"I\"),new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"YCU\",\"I\"),new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\") }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n ", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"),new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", "\n };" ], "metadata": {}, @@ -790,17 +810,20 @@ "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\")}},", "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\")}},", - "\n ", + "\n ", "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", "\n }},", "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", - "\n new AocStep(\"EV\",\"C\"),}},", + "\n new AocStep(\"EV\",\"C\"),}},", "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"),}},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"),}}, ", "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", - "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\")}},", + "\n new AocStep(\"CF\",\"C\"),new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\")}},", + "\n ", "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", - "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\")}},", + "\n new AocStep(\"CF\",\"C\"),new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\")}},", "\n };" ], "metadata": {}, @@ -870,23 +893,23 @@ { "cell_type": "code", "source": [ - "referenceBm = new Dictionary()", + "referenceBm = new Dictionary>()", "\n {", - "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", - "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", - "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", - "\n {new AocStep(\"BOP\",\"N\"), new AocStep(\"BOP\",\"N\")}, ", - "\n {new AocStep(\"CF\",\"N\"), new AocStep(\"BOP\",\"N\")}, ", - "\n {new AocStep(\"IA\",\"N\"), new AocStep(\"BOP\",\"N\")}, ", - "\n {new AocStep(\"AU\",\"N\"), new AocStep(\"AU\",\"N\")}, ", - "\n {new AocStep(\"EV\",\"C\"), new AocStep(\"EV\",\"C\")},", - "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", - "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}}, ", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}}, ", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}}, ", + "\n {new AocStep(\"AU\",\"N\"), new AocStep[]{new AocStep(\"AU\",\"N\") }}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\") }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", "\n };" ], "metadata": {}, @@ -906,7 +929,7 @@ "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\")}},", "\n {new AocStep(\"AU\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\")}},", - "\n", + "\n ", "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", "\n }},", @@ -916,12 +939,15 @@ "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"),}},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\")}},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", + "\n new AocStep(\"CF\",\"C\"),new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\")}},", "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", - "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\")}},", + "\n new AocStep(\"CF\",\"C\"),new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\")}},", "\n };" ], "metadata": {}, @@ -1013,9 +1039,9 @@ "fullAocBm = new Dictionary>()", "\n {", "\n //{new AocStep(\"BOP\",\"I\"), Enumerable.Empty()},", - "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),}},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), }},", "\n {new AocStep(\"WO\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"CF\",\"C\"),}},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"CF\",\"C\"), new AocStep(\"WO\",\"C\"),}},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"WO\",\"C\"),new AocStep(\"CF\",\"C\"),}},", "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"CF\",\"C\"), new AocStep(\"WO\",\"C\"), new AocStep(\"AM\",\"C\"),}},", "\n };" ], @@ -1042,6 +1068,626 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Add a Novelty" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string newNovelties = ", + "\n@\"@@Novelty", + "\nSystemName,DisplayName,Parent,Order", + "\nI,In Force,,1", + "\nN,New Business,,10", + "\nA,Aquisition,,15", + "\nC,Combined,,20\";", + "\nstring newAocConfig = ", + "\n@\"@@AocConfiguration,,,,,,,,,,,", + "\nAocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month", + "\nBOP,I,1,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1", + "\nMC,I,1,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1", + "\nRCU,I,4,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1", + "\nCF,I,4,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1", + "\nIA,I,4,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1", + "\nAU,I,1,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1", + "\nYCU,I,8,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1", + "\nCRU,I,8,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1", + "\nEV,I,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1", + "\nBOP,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,95,1900,1", + "\nMC,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,100,1900,1", + "\nCF,N,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1", + "\nIA,N,4,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1", + "\nAU,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1", + "\nEV,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1", + "\nBOP,A,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,141,1900,1", + "\nMC,A,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,142,1900,1", + "\nCF,A,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,143,1900,1", + "\nIA,A,4,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,144,1900,1", + "\nAU,A,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,145,1900,1", + "\nEV,A,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,146,1900,1", + "\nCL,C,2,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1", + "\nEA,C,4,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1", + "\nCF,C,5,6,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,193,1900,1", + "\nWO,C,1,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,195,1900,1", + "\nAM,C,4,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1", + "\nEOP,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync(DataSource.Query());", + "\nawait DataSource.DeleteAsync(DataSource.Query());", + "\nawait Import.FromString(newNovelties).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(newAocConfig).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "inputRawVariables = new RawVariable[]{", + "\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 = \"BOP\", Novelty = \"A\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"AU\", Novelty = \"A\", 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": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parentBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")}}, ", + "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"AU\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"N\"), new AocStep(\"AU\",\"A\"),}},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var referenceBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} },", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} },", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} },", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")} }, ", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"EV\",\"N\")} },", + "\n {new AocStep(\"BOP\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\")}},", + "\n {new AocStep(\"CF\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\")}},", + "\n {new AocStep(\"IA\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\")}},", + "\n {new AocStep(\"AU\",\"A\"), new AocStep[]{new AocStep(\"AU\",\"A\")} },", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\")} },", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\")} },", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\")} },", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\")} },", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\")} },", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var fullAocBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\")}},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"IA\",\"I\"), new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\")}},", + "\n {new AocStep(\"EV\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\")}},", + "\n {new AocStep(\"CF\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\")}},", + "\n {new AocStep(\"IA\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\")}},", + "\n {new AocStep(\"AU\",\"A\"), new AocStep[]{new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\"), new AocStep(\"IA\",\"A\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", + "\n new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\"), new AocStep(\"IA\",\"A\"), new AocStep(\"AU\",\"A\"),", + "\n }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"),new AocStep(\"YCU\",\"I\"), ", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", + "\n new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\"), new AocStep(\"IA\",\"A\"), new AocStep(\"AU\",\"A\"), ", + "\n new AocStep(\"CL\",\"C\"),", + "\n }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", + "\n new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\"), new AocStep(\"IA\",\"A\"), new AocStep(\"AU\",\"A\"),", + "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),}},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"),", + "\n new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\"), new AocStep(\"IA\",\"A\"), new AocStep(\"AU\",\"A\"), ", + "\n new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"CF\",\"C\")", + "\n }},", + "\n", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), new AocStep(\"EV\",\"N\"), ", + "\n new AocStep(\"BOP\",\"A\"), new AocStep(\"CF\",\"A\"), new AocStep(\"IA\",\"A\"), new AocStep(\"AU\",\"A\"),", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n }},", + "\n };", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# New Aoc Configuration" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string newAocTypes = ", + "\n@\"@@AocType", + "\nSystemName,DisplayName,Parent,Order", + "\nBOP,Opening Balance,,10", + "\nMC,Model Correction,,20", + "\nCF,Cash flow,,30", + "\nIA,Interest Accretion,,40", + "\nAU,Assumption Update,,50", + "\nYCU,Yield Curve Update,,60", + "\nEV,Experience Variance,,70", + "\nCL,Combined Liabilities,,80", + "\nAM,Amortization,,85", + "\nEOP,Closing Balance,,90\";", + "\n", + "\nstring newAocConfiguration = ", + "\n@\"@@AocConfiguration,,,,,,,,,,,", + "\nAocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month", + "\nBOP,I,1,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,2017,12", + "\nMC,I,1,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,2017,12", + "\nCF,I,4,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,30,2017,12", + "\nIA,I,4,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,40,2017,12", + "\nBOP,N,1,4,Average,BeginningOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,50,2017,12", + "\nCF,N,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,60,2017,12", + "\nIA,N,4,4,Average,BeginningOfPeriod,EndOfPeriod,Delta,EndOfPeriod,70,2017,12", + "\nAU,C,1,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,80,2017,12", + "\nYCU,C,8,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,90,2017,12", + "\nEV,C,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,100,2017,12", + "\nCL,C,2,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,110,2017,12", + "\nCF,C,5,6,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,115,2017,12", + "\nAM,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,120,2017,12", + "\nEOP,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,2017,12", + "\n\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync(DataSource.Query());", + "\nawait DataSource.DeleteAsync(DataSource.Query());", + "\nawait Import.FromString(newAocTypes).WithType().WithTarget(DataSource).ExecuteAsync();", + "\nawait Import.FromString(newAocConfiguration).WithType().WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var inputVariables = new RawVariable[]{", + "\n new RawVariable{AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n new RawVariable{AocType = \"EV\", Novelty = \"C\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n new RawVariable{AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parentBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"BOP\",\"N\")}}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"C\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\"),}},", + "\n };", + "\nvar referenceBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\") }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\") , new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n {new AocStep(\"IA\",\"I\") , new AocStep[]{new AocStep(\"BOP\",\"I\") }},", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\") }},", + "\n };", + "\nvar fullAocBm = new Dictionary>()", + "\n {", + "\n //{new AocStep(\"BOP\",\"N\"), Enumerable.Empty()},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\")}},", + "\n ", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n }},", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"YCU\",\"C\"),", + "\n }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\")", + "\n }}, ", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\")", + "\n }}, ", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"CF\",\"C\"), new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"AM\",\"C\"),", + "\n }}, ", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputVariables, parentBm, referenceBm, fullAocBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## AU-C first C step" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var inputVariables = new RawVariable[]{", + "\n new RawVariable{AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n new RawVariable{AocType = \"AU\", Novelty = \"C\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n new RawVariable{AocType = \"EV\", Novelty = \"C\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n new RawVariable{AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"CL\", EstimateType = \"BE\", Partition = partition.Id, Values = new double[] {1.0}, DataNode = groupOfInsuranceContracts},", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parentBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"AU\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"BOP\",\"N\")}}, ", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"AU\",\"C\"),}}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"C\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\"),}},", + "\n };", + "\nvar referenceBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n", + "\n {new AocStep(\"AU\",\"C\"), new AocStep[]{new AocStep(\"AU\",\"C\")}},", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"AU\",\"C\") }},", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\") }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\") , new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n {new AocStep(\"IA\",\"I\") , new AocStep[]{new AocStep(\"BOP\",\"I\") }},", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\") }},", + "\n };", + "\nvar fullAocBm = new Dictionary>()", + "\n {", + "\n //{new AocStep(\"BOP\",\"N\"), Enumerable.Empty()},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\")}},", + "\n ", + "\n {new AocStep(\"AU\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n }},", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"AU\",\"C\"),}},", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"AU\",\"C\"),new AocStep(\"YCU\",\"C\"),", + "\n }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"AU\",\"C\"),new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\")", + "\n }}, ", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"AU\",\"C\"),new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"AU\",\"C\"),new AocStep(\"CF\",\"C\"), new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\")", + "\n }}, ", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"),new AocStep(\"IA\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"AU\",\"C\"),new AocStep(\"CF\",\"C\"), new AocStep(\"YCU\",\"C\"), new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"AM\",\"C\"),", + "\n }}, ", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputVariables, parentBm, referenceBm, fullAocBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reinsurance " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string newAocTypes = ", + "\n@\"@@AocType", + "\nSystemName,DisplayName,Parent,Order", + "\nBOP,Opening Balance,,10", + "\nMC,Model Correction,,20", + "\nCF,Cash flow,,30", + "\nIA,Interest Accretion,,40", + "\nCRU,Credit Risk Update,,45", + "\nAU,Assumption Update,,50", + "\nYCU,Yield Curve Update,,60", + "\nEV,Experience Variance,,70", + "\nCL,Combined Liabilities,,80", + "\nEA,Experience Adjustment,,81,", + "\nAM,Amortization,,85", + "\nEOP,Closing Balance,,90\";", + "\n", + "\nstring newAocConfiguration = ", + "\n@\"@@AocConfiguration,,,,,,,,,,,", + "\nAocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month", + "\nBOP,I,1,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,2017,12", + "\nMC,I,1,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,2017,12", + "\nCF,I,4,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,30,2017,12", + "\nIA,I,4,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,40,2017,12", + "\nCRU,I,8,4,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,45,1900,1", + "\nBOP,N,1,4,Average,BeginningOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,50,2017,12", + "\nCF,N,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,60,2017,12", + "\nIA,N,4,4,Average,BeginningOfPeriod,EndOfPeriod,Delta,EndOfPeriod,70,2017,12", + "\nAU,C,1,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,80,2017,12", + "\nYCU,C,8,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,90,2017,12", + "\nEV,C,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,100,2017,12", + "\nCL,C,2,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,110,2017,12", + "\nEA,C,4,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,112,1900,1", + "\nCF,C,5,6,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,115,2017,12", + "\nAM,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,120,2017,12", + "\nEOP,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,2017,12", + "\n\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync(DataSource.Query());", + "\nawait DataSource.DeleteAsync(DataSource.Query());", + "\n((await Import.FromString(newAocTypes).WithType().WithTarget(DataSource).ExecuteAsync()).Status,", + "\n(await Import.FromString(newAocConfiguration).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync()).Status)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "inputRawVariables = new RawVariable[]{", + "\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 = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parentBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"CRU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"MC\",\"I\"), new AocStep(\"BOP\",\"N\"),}}, ", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"C\"),}},", + "\n };", + "\nvar parentBm_CDR = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"CRU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")}}, ", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"CRU\",\"I\"), new AocStep(\"BOP\",\"N\")}}, ", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"C\"),}},", + "\n };", + "\nreferenceBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }},", + "\n {new AocStep(\"CRU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\") }}, ", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"MC\",\"I\"),new AocStep(\"BOP\",\"N\") }}, ", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"CL\",\"C\") }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"CF\",\"C\") }},", + "\n };", + "\nfullAocBm = new Dictionary>()", + "\n {", + "\n //{new AocStep(\"BOP\",\"I\"), Enumerable.Empty()},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{ new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\")}},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{ new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", + "\n {new AocStep(\"CRU\",\"I\"), new AocStep[]{new AocStep(\"IA\",\"I\"), new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", + "\n //{new AocStep(\"BOP\",\"N\"), Enumerable.Empty()},", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\")}},", + "\n ", + "\n {new AocStep(\"YCU\",\"C\"), new AocStep[]{new AocStep(\"IA\",\"I\"), new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"),new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"YCU\",\"C\"),", + "\n }},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"YCU\",\"C\"),new AocStep(\"CL\",\"C\"),", + "\n }},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"EA\",\"C\"), new AocStep(\"YCU\",\"C\"), new AocStep(\"CL\",\"C\"),}},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"),", + "\n new AocStep(\"YCU\",\"C\"),new AocStep(\"CF\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n }},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"CRU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"), new AocStep(\"CF\",\"N\"), new AocStep(\"IA\",\"N\"), ", + "\n new AocStep(\"YCU\",\"C\"),new AocStep(\"CF\",\"C\"),new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\"),", + "\n }}, ", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm, parentBm_CDR);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Test/TechnicalMarginTest.ipynb b/ifrs17/Test/TechnicalMarginTest.ipynb index f18841c3..5e599287 100644 --- a/ifrs17/Test/TechnicalMarginTest.ipynb +++ b/ifrs17/Test/TechnicalMarginTest.ipynb @@ -332,9 +332,16 @@ "\n {new AocStep(\"EA\",\"C\"), (0d, -8.0)},", "\n {new AocStep(\"AM\",\"C\"), (0d, -153.5)},", "\n {new AocStep(\"EOP\",\"C\"),(0d, 153.5)},", - "\n };", - "\n", - "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", "\nactivity" ], "metadata": {}, @@ -381,9 +388,16 @@ "\n {new AocStep(\"EA\",\"C\"), (8d, 0d)},", "\n {new AocStep(\"AM\",\"C\"), (-146.5d, 0d)},", "\n {new AocStep(\"EOP\",\"C\"),(146.5d, 0d)},", - "\n };", - "\n", - "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", "\nactivity" ], "metadata": {}, @@ -426,8 +440,16 @@ "\n {new AocStep(\"EA\",\"C\"), (8d, 0d)},", "\n {new AocStep(\"AM\",\"C\"), (-29d, 0d)},", "\n {new AocStep(\"EOP\",\"C\"),(29d, 0d)},", - "\n };", - "\n", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "", "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", "\nactivity" ], @@ -486,9 +508,16 @@ "\n {new AocStep(\"EA\",\"C\"), ( -8d, 0d)},", "\n {new AocStep(\"AM\",\"C\"), ( -11d, 0d)},", "\n {new AocStep(\"EOP\",\"C\"),( 11d, 0d)},", - "\n };", - "\n", - "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", "\nactivity" ], "metadata": {}, @@ -549,8 +578,7 @@ "\n {new AocStep(\"CL\",\"C\"), (+30d, 0d)},", "\n {new AocStep(\"AM\",\"C\"), (+30d, 0d)},", "\n {new AocStep(\"EOP\",\"C\"),(-30d, 0d)},", - "\n };", - "\n" + "\n };" ], "metadata": {}, "execution_count": 0, @@ -589,7 +617,7 @@ "source": [ "var reinsBasicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfReinsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", "\nvar grossBasicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = previousPeriodPartition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\", EconomicBasis = \"L\"};", + "\n", "\nvar inputDataSet = new IfrsVariable[]{", "\n grossBasicIfrsVariable with {AocType = \"BOP\", Novelty = \"N\", Values = new double[] {100.0}},", "\n grossBasicIfrsVariable with {AocType = \"CF\", Novelty = \"N\", Values = new double[] {-10.0}},", diff --git a/ifrs17/Test/TestData.ipynb b/ifrs17/Test/TestData.ipynb index 076f9df1..c148bb4a 100644 --- a/ifrs17/Test/TestData.ipynb +++ b/ifrs17/Test/TestData.ipynb @@ -59,28 +59,27 @@ "\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", - "\nMC,N,Optional,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,100,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\";" + "\nBOP,I,1,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1", + "\nMC,I,1,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1", + "\nRCU,I,4,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1", + "\nCF,I,4,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1", + "\nIA,I,4,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1", + "\nAU,I,1,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1", + "\nYCU,I,8,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1", + "\nCRU,I,8,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1", + "\nEV,I,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1", + "\nBOP,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,95,1900,1", + "\nMC,N,1,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,100,1900,1", + "\nCF,N,4,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1", + "\nIA,N,4,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1", + "\nAU,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1", + "\nEV,N,1,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1", + "\nCL,C,2,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1", + "\nEA,C,4,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1", + "\nCF,C,5,6,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,193,1900,1", + "\nWO,C,1,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,195,1900,1", + "\nAM,C,4,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1", + "\nEOP,C,4,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1\";" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Utils/ImportCalculationMethods.ipynb b/ifrs17/Utils/ImportCalculationMethods.ipynb index 28a9fe07..d93a9e5a 100644 --- a/ifrs17/Utils/ImportCalculationMethods.ipynb +++ b/ifrs17/Utils/ImportCalculationMethods.ipynb @@ -34,62 +34,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "# Get Previous Identities" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public static Dictionary> GetPreviousIdentities(IEnumerable aocSteps)", - "\n{", - "\n var bopNovelties = aocSteps.Where(id => id.AocType == AocTypes.BOP).Select(id => id.Novelty);", - "\n var previousStep = (new string[]{Novelties.N,Novelties.I,Novelties.C})", - "\n .ToDictionary(n => n, n => bopNovelties.Contains(n) ? new AocStep(AocTypes.BOP,n) : null);", - "\n return aocSteps.Where(id => id.AocType != AocTypes.BOP)", - "\n .ToDictionary(x => x, ", - "\n x => {var isFirstCombined = x.Novelty == Novelties.C && (previousStep[Novelties.C] == null || previousStep[Novelties.C].AocType == AocTypes.BOP);", - "\n var ret = isFirstCombined", - "\n ? previousStep.Where(kvp => kvp.Value != null).Select(kvp => kvp.Value).ToArray() ", - "\n : previousStep[x.Novelty].RepeatOnce();", - "\n previousStep[x.Novelty] = new AocStep(x.AocType, x.Novelty);", - "\n return ret;});", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Get Reference AoC Step for calculated steps" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public static AocStep GetReferenceAocStepForCalculated(this IEnumerable identities, Dictionary aocConfigurationByAocStep, AocStep identityAocStep)", - "\n{", - "\n return identities.LastOrDefault(aocStep => aocConfigurationByAocStep[aocStep].DataType != DataType.Calculated", - "\n && aocConfigurationByAocStep[aocStep].DataType != DataType.CalculatedTelescopic", - "\n && aocConfigurationByAocStep[aocStep].Order < aocConfigurationByAocStep[identityAocStep].Order", - "\n && aocStep.Novelty == identityAocStep.Novelty) ", - "\n ?? new AocStep(default, default);", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -412,7 +356,11 @@ { "cell_type": "markdown", "source": [ - "# Helper variables used in calculation" + "# Helper variables used in calculation", + "\n", + "\nVariables defined here and used in the calculation:", + "\n- AocTypeWithNoPv : used in [Present Value](../Import/2ImportScope-PresentValue#present-value-1) to trigger no calculation for some AoC Type.", + "\n- ReferenceAocSteps : used in [Reference AoC Step](../Import/1ImportScope-Identities#reference-aoc-step) to over rule the standard defition of reference AoC Step. " ], "metadata": {}, "execution_count": 0, @@ -423,6 +371,14 @@ "source": [ "public static class ComputationHelper{", "\n public static string [] AocTypeWithNoPv = new string[]{AocTypes.BOP, AocTypes.EA, AocTypes.AM, AocTypes.RCU};", + "\n public static Dictionary> ReferenceAocSteps => new Dictionary>()", + "\n {", + "\n {new AocStep(AocTypes.EA ,Novelties.C), new AocStep[]{new AocStep(AocTypes.CF,Novelties.C)}},", + "\n {new AocStep(AocTypes.AM ,Novelties.C), new AocStep[]{new AocStep(AocTypes.CL,Novelties.C)}}, ", + "\n {new AocStep(AocTypes.EOP ,Novelties.C), new AocStep[]{new AocStep(AocTypes.CL,Novelties.C)}}, ", + "\n {new AocStep(AocTypes.BOP ,Novelties.I), new AocStep[]{new AocStep(AocTypes.CL,Novelties.C)}},//for projections", + "\n };", + "\n public static HashSet ReinsuranceAocType = new []{AocTypes.CRU, AocTypes.RCU}.ToHashSet();", "\n} " ], "metadata": {},