From a63c846ee50452946699ad4f36c731fccd458911 Mon Sep 17 00:00:00 2001 From: Teo Kukuljan <116903719+tkukuljan@users.noreply.github.com> Date: Fri, 2 Dec 2022 09:59:02 +0100 Subject: [PATCH 01/11] Removing the display order attributes where needed. (#114) --- ifrs17/DataModel/DataStructure.ipynb | 52 +--------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index aa4cf4e1..3e6144ff 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -289,10 +289,8 @@ "\n [Key]", "\n [IdentityProperty]", "\n [StringLength(16)]", - "\n [Display(Order = 1)]", "\n public string SystemName { get; init; }", "\n ", - "\n [Display(Order = 2)]", "\n [NotVisible]", "\n public string DisplayName { get; init; }", "\n}" @@ -317,7 +315,6 @@ "cell_type": "code", "source": [ "public abstract record KeyedOrderedDimensionWithExternalId : KeyedOrderedDimension {", - "\n [Display(Order = 100)]", "\n [Conversion(typeof(JsonConverter))]", "\n public string[] ExternalId { get; init; }", "\n}" @@ -394,11 +391,9 @@ "source": [ "public record AmountType : KeyedOrderedDimensionWithExternalId, IHierarchicalDimension", "\n{", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(AmountType))]", "\n public string Parent { get; init; }", "\n ", - "\n [Display(Order = 20)]", "\n [Dimension(typeof(PeriodType))]", "\n public PeriodType PeriodType { get; init; }", "\n}" @@ -444,7 +439,6 @@ "source": [ "public record RiskDriver : KeyedOrderedDimension, IHierarchicalDimension", "\n{", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(RiskDriver))]", "\n public string Parent { get; init; }", "\n}" @@ -470,10 +464,8 @@ "source": [ "public record EstimateType : KeyedOrderedDimensionWithExternalId", "\n{", - "\n [Display(Order = 110)]", "\n public InputSource InputSource { get; init; }", "\n ", - "\n [Display(Order = 120)]", "\n public StructureType StructureType { get; init; }", "\n", "\n [Dimension(typeof(PeriodType))]", @@ -520,7 +512,6 @@ "source": [ "public record VariableType : KeyedOrderedDimension, IHierarchicalDimension", "\n{ ", - "\n [Display(Order = 10)]", "\n public string Parent { get; init; }", "\n}" ], @@ -552,7 +543,6 @@ "source": [ "public record AocType : VariableType", "\n{ ", - "\n [Display(Order = 30)]", "\n [Dimension(typeof(AocType))]", "\n public string Parent { get; init; }", "\n}" @@ -685,7 +675,6 @@ "source": [ "public record LineOfBusiness : KeyedOrderedDimension, IHierarchicalDimension", "\n{", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(LineOfBusiness))]", "\n public string Parent { get; init; }", "\n}" @@ -780,7 +769,6 @@ "source": [ "public record LiabilityType : KeyedDimension, IHierarchicalDimension", "\n{", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(LiabilityType))]", "\n public string Parent { get; init; }", "\n}" @@ -894,12 +882,10 @@ "source": [ "public record ReportingNode : KeyedDimension, IHierarchicalDimension ", "\n{", - "\n [Display(Order = 20)]", "\n [Dimension(typeof(ReportingNode))]", "\n public string Parent { get; init; }", "\n ", "\n [Required]", - "\n [Display(Order = 40)]", "\n [Dimension(typeof(Currency))]", "\n public virtual string Currency { get; init; }", "\n}" @@ -996,7 +982,6 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Year))]", "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 10)]", "\n public int Year { get; init; }", "\n ", "\n [Required]", @@ -1004,44 +989,34 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Month))]", "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 20)]", "\n public int Month { get; init; }", "\n ", "\n [IdentityProperty]", - "\n [Display(Order = 30)]", "\n [Dimension(typeof(AocType))]", "\n public string AocType { get; init; }", "\n ", "\n [IdentityProperty]", - "\n [Display(Order = 40)]", "\n [Dimension(typeof(Novelty))]", "\n public string Novelty { get; init; }", "\n ", - "\n [Display(Order = 50)]", "\n [Dimension(typeof(DataType))]", "\n public DataType DataType { get; init; }", "\n ", - "\n [Display(Order = 55)]", "\n [Dimension(typeof(InputSource))]", "\n public InputSource InputSource { get; init; }", "\n ", - "\n [Display(Order = 60)]", "\n [Dimension(typeof(FxPeriod))]", "\n public FxPeriod FxPeriod { get; init; }", "\n ", - "\n [Display(Order = 70)]", "\n [Dimension(typeof(PeriodType), nameof(YcPeriod))]", "\n public PeriodType YcPeriod { get; init; }", "\n ", - "\n [Display(Order = 80)]", "\n [Dimension(typeof(PeriodType), nameof(CdrPeriod))]", "\n public PeriodType CdrPeriod { get; init; }", "\n ", - "\n [Display(Order = 90)]", "\n [Dimension(typeof(ValuationPeriod))]", "\n public ValuationPeriod ValuationPeriod { get; init; }", "\n ", - "\n [Display(Order = 100)]", "\n [Dimension(typeof(PeriodType), nameof(RcPeriod))]", "\n public PeriodType RcPeriod { get; init; }", "\n ", @@ -1073,7 +1048,6 @@ "\n{ ", "\n [Required]", "\n [IdentityProperty]", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(Currency))]", "\n public string Currency { get; init; }", "\n", @@ -1082,7 +1056,6 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Year))]", "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 20)]", "\n public int Year { get; init; }", "\n ", "\n [Required]", @@ -1090,19 +1063,15 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Month))]", "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 30)]", "\n public int Month { get; init; }", "\n", "\n [IdentityProperty]", "\n [Required]", - "\n [Display(Order = 40)]", "\n public FxType FxType { get; init; }", "\n", - "\n [Display(Order = 50)]", "\n public double FxToGroupCurrency { get; init; }", "\n", "\n [IdentityProperty]", - "\n [Display(Order = 60)]", "\n [Dimension(typeof(Scenario))]", "\n public string Scenario { get; init; }", "\n}" @@ -1133,7 +1102,6 @@ "\n{ ", "\n [Required]", "\n [IdentityProperty]", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(CreditRiskRating))]", "\n public string CreditRiskRating { get; init; }", "\n", @@ -1142,7 +1110,6 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Year))]", "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 20)]", "\n public int Year { get; init; }", "\n ", "\n [Required]", @@ -1150,15 +1117,12 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Month))]", "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 30)]", "\n public int Month { get; init; }", "\n ", "\n [Conversion(typeof(PrimitiveArrayConverter))]", - "\n [Display(Order = 40)]", "\n public double[] Values { get; init; }", "\n", "\n [IdentityProperty]", - "\n [Display(Order = 50)]", "\n [Dimension(typeof(Scenario))]", "\n public string Scenario { get; init; }", "\n}" @@ -1190,7 +1154,6 @@ "\n{ ", "\n [Required]", "\n [IdentityProperty]", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(Currency))]", "\n public string Currency { get; init; }", "\n", @@ -1199,7 +1162,6 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Year))]", "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 20)]", "\n public int Year { get; init; }", "\n ", "\n [Required]", @@ -1207,11 +1169,9 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Month))]", "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 30)]", "\n public int Month { get; init; }", "\n", "\n [IdentityProperty]", - "\n [Display(Order = 35)]", "\n [Dimension(typeof(Scenario))]", "\n public string Scenario { get; init; }", "\n", @@ -1220,7 +1180,6 @@ "\n public string Name { get; init; }", "\n ", "\n [Conversion(typeof(PrimitiveArrayConverter))]", - "\n [Display(Order = 40)]", "\n public double[] Values { get; init; }", "\n}" ], @@ -1246,12 +1205,10 @@ "\n{ ", "\n [Required]", "\n [IdentityProperty]", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(Partner))]", "\n public string Partner { get; init; }", "\n", "\n [Required]", - "\n [Display(Order = 20)]", "\n [Dimension(typeof(CreditRiskRating))]", "\n public string CreditRiskRating { get; init; }", "\n", @@ -1260,7 +1217,6 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Year))]", "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 30)]", "\n public int Year { get; init; }", "\n ", "\n [Required]", @@ -1268,11 +1224,9 @@ "\n [NoArithmetics(ArithmeticOperation.Scale)]", "\n [Dimension(typeof(int), nameof(Month))]", "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]", - "\n [Display(Order = 40)]", "\n public int Month { get; init; }", "\n", "\n [IdentityProperty]", - "\n [Display(Order = 50)]", "\n [Dimension(typeof(Scenario))]", "\n public string Scenario { get; init; }", "\n}" @@ -1301,12 +1255,10 @@ "\n public Guid Id { get; init; }", "\n", "\n [Required]", - "\n [Display(Order = 10)]", "\n [Dimension(typeof(ReportingNode))]", "\n [IdentityProperty]", "\n public string ReportingNode { get; init; }", "\n", - "\n [Display(Order = 50)]", "\n [Dimension(typeof(Scenario))]", "\n [IdentityProperty]", "\n public string Scenario { get; init; }", @@ -1347,12 +1299,10 @@ "cell_type": "code", "source": [ "public record PartitionByReportingNodeAndPeriod : IfrsPartition {", - "\n [Display(Order = 30)]", "\n [Dimension(typeof(int), nameof(Year))]", "\n [IdentityProperty]", "\n public int Year { get; init; }", "\n", - "\n [Display(Order = 40)]", "\n [Dimension(typeof(int), nameof(Month))]", "\n [IdentityProperty]", "\n public int Month { get; init; }", @@ -1682,7 +1632,7 @@ "\npublic record InterDataNodeParameter : DataNodeParameter {", "\n [Required]", "\n [IdentityProperty]", - "\n [Display(Order = 20)]", + "\n [Display(Order = 10)]", "\n [Dimension(typeof(GroupOfContract))]", "\n public string LinkedDataNode { get; init; }", "\n ", From 320a73223ef83fb26adf17328f08296051caa2e4 Mon Sep 17 00:00:00 2001 From: nnikolopoulos <114566025+nnikolopoulos@users.noreply.github.com> Date: Thu, 8 Dec 2022 16:35:35 +0100 Subject: [PATCH 02/11] Split compute all scopes (#119) * First commit of potential scope names * Initial split for ComputeAllScopes * Break ComputeAllScopes into 5 scopes * Remove commented off cell * Create scopes for Actuals, Cashflows and Openings * Implement feedback * Change modifier of amortizationFactor to public * Implement feedbackx2 --- ifrs17/Import/ImportScopeCalculation.ipynb | 159 ++++++++++++++++----- ifrs17/Import/Importers.ipynb | 6 +- 2 files changed, 125 insertions(+), 40 deletions(-) diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index d41923e4..956e823e 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -2042,7 +2042,7 @@ "source": [ "## Computing All Scopes", "\n", - "\nSince all the calculations defined in the various scopes are to be performed together, it is useful to introduce the scope ComputeAllScopes below, which given a certain Import Identity and Import Storage, performs all the calculations (defined above) based on the corresponding data:" + "\nSince all the calculations defined in the various scopes are to be performed together, it is useful to introduce the scopes: ComputeIfrsVarsActuals, ComputeIfrsVarsCashflows and the ComputeIfrsVarsOpenings below, which given a certain Import Format and Import Storage, performs all the calculations (defined above) based on the corresponding data:" ], "metadata": {}, "execution_count": 0, @@ -2051,9 +2051,9 @@ { "cell_type": "code", "source": [ - "public interface ComputeAllScopes: IScope //ComputeIfrsVariable", + "public interface PvToIfrsVariable: IScope", "\n{", - "\n IEnumerable PvLocked => GetScope(Identity).PresentValues.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EconomicBasis = x.EconomicBasis, ", + "\n IEnumerable PvLocked => GetScope(Identity).PresentValues.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EconomicBasis = x.EconomicBasis, ", "\n EstimateType = x.Identity.EstimateType, ", "\n DataNode = x.Identity.Id.DataNode, ", "\n AocType = x.Identity.Id.AocType, ", @@ -2073,6 +2073,17 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface RaToIfrsVariable: IScope", + "\n{", "\n IEnumerable RaCurrent => GetScope(Identity).PresentValues.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EconomicBasis = x.EconomicBasis, ", "\n EstimateType = x.Identity.EstimateType, ", "\n DataNode = x.Identity.Id.DataNode, ", @@ -2093,20 +2104,17 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", - "\n private string EconomicBasis => Identity.ValuationApproach == ValuationApproaches.VFA ? EconomicBases.C : EconomicBases.L;", - "\n private IEnumerable amortizationFactor => Identity.AocType == AocTypes.AM", - "\n ? GetScope(Identity, o => o.WithContext(EconomicBasis))", - "\n .RepeatOnce()", - "\n .Where(x => Math.Abs(x.Value) >= Precision)", - "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", - "\n DataNode = x.Identity.DataNode,", - "\n AocType = x.Identity.AocType,", - "\n Novelty = x.Identity.Novelty,", - "\n EconomicBasis = x.EconomicBasis,", - "\n Value = x.Value,", - "\n Partition = GetStorage().TargetPartition", - "\n })", - "\n : Enumerable.Empty();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ActualToIfrsVariable: IScope", + "\n{", "\n IEnumerable Actual => GetScope(Identity).Actuals.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EstimateType = x.Identity.EstimateType,", "\n DataNode = x.Identity.Id.DataNode,", "\n AocType = x.Identity.Id.AocType,", @@ -2134,15 +2142,36 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface DeferrableToIfrsVariable: IScope", + "\n{", "\n IEnumerable DeferrableActual => GetScope(Identity).RepeatOnce().Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", - "\n DataNode = x.Identity.DataNode,", - "\n AocType = x.Identity.AocType,", - "\n Novelty = x.Identity.Novelty,", - "\n AccidentYear = null,", - "\n Value = x.Value,", - "\n Partition = GetStorage().TargetPartition", - "\n });", - "\n ", + "\n DataNode = x.Identity.DataNode,", + "\n AocType = x.Identity.AocType,", + "\n Novelty = x.Identity.Novelty,", + "\n AccidentYear = null,", + "\n Value = x.Value,", + "\n Partition = GetStorage().TargetPartition", + "\n });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface EaForPremiumToIfrsVariable: IScope", + "\n{", "\n IEnumerable BeEAForPremium => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", "\n || Identity.IsReinsurance", "\n ? Enumerable.Empty()", @@ -2174,7 +2203,31 @@ "\n AmountType = sc.Identity.AmountType,", "\n Value = sc.Value,", "\n Partition = GetStorage().TargetPartition });", - "\n ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface TmToIfrsVariable: IScope", + "\n{", + "\n private string EconomicBasis => Identity.ValuationApproach == ValuationApproaches.VFA ? EconomicBases.C : EconomicBases.L;", + "\n IEnumerable AmortizationFactor => Identity.AocType == AocTypes.AM", + "\n ? GetScope(Identity, o => o.WithContext(EconomicBasis))", + "\n .RepeatOnce()", + "\n .Where(x => Math.Abs(x.Value) >= Precision)", + "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", + "\n DataNode = x.Identity.DataNode,", + "\n AocType = x.Identity.AocType,", + "\n Novelty = x.Identity.Novelty,", + "\n EconomicBasis = x.EconomicBasis,", + "\n Value = x.Value,", + "\n Partition = GetStorage().TargetPartition", + "\n })", + "\n : Enumerable.Empty();", "\n IEnumerable Csms => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", "\n ? Enumerable.Empty()", "\n : GetScope(Identity).RepeatOnce()", @@ -2208,16 +2261,6 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", - "\n ", - "\n IEnumerable CalculatedIfrsVariables => GetStorage().ImportFormat switch {", - "\n ImportFormats.Actual => Actual.Concat(AdvanceActual).Concat(OverdueActual).Concat(ActEAForPremium)", - "\n .Concat(DeferrableActual).Concat(Csms).Concat(Loss),", - "\n ImportFormats.Cashflow => PvLocked.Concat(PvCurrent).Concat(RaCurrent).Concat(RaLocked)", - "\n .Concat(amortizationFactor).Concat(BeEAForPremium)", - "\n .Concat(DeferrableActual).Concat(Csms).Concat(Loss),", - "\n ImportFormats.Opening => AdvanceActual.Concat(OverdueActual).Concat(DeferrableActual)", - "\n .Concat(Csms).Concat(Loss),", - "\n };", "\n}" ], "metadata": {}, @@ -2227,7 +2270,49 @@ { "cell_type": "code", "source": [ - "" + "public interface ComputeIfrsVarsActuals : ActualToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable", + "\n{", + "\n IEnumerable CalculatedIfrsVariables => Actual.Concat(AdvanceActual)", + "\n .Concat(OverdueActual)", + "\n .Concat(ActEAForPremium)", + "\n .Concat(DeferrableActual)", + "\n .Concat(Csms)", + "\n .Concat(Loss);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ComputeIfrsVarsCashflows : PvToIfrsVariable, RaToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable", + "\n{", + "\n IEnumerable CalculatedIfrsVariables => PvLocked.Concat(PvCurrent)", + "\n .Concat(RaCurrent)", + "\n .Concat(RaLocked)", + "\n .Concat(amortizationFactor)", + "\n .Concat(BeEAForPremium)", + "\n .Concat(DeferrableActual)", + "\n .Concat(Csms)", + "\n .Concat(Loss);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ComputeIfrsVarsOpenings : ActualToIfrsVariable, DeferrableToIfrsVariable, TmToIfrsVariable", + "\n{", + "\n IEnumerable CalculatedIfrsVariables => AdvanceActual.Concat(OverdueActual)", + "\n .Concat(DeferrableActual)", + "\n .Concat(Csms)", + "\n .Concat(Loss);", + "\n} " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 9e10fe50..3ec5a6aa 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -998,7 +998,7 @@ "\n ", "\n var universe = Scopes.ForStorage(storage).ToScope();", "\n var identities = universe.GetScopes(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);", - "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", + "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n await workspace.UpdateAsync(ivs);", @@ -1120,7 +1120,7 @@ "\n", "\n var universe = Scopes.ForStorage(storage).ToScope();", "\n var identities = universe.GetScopes(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);", - "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", + "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n", "\n await workspace.UpdateAsync(ivs);", @@ -1275,7 +1275,7 @@ "\n ", "\n var universe = Scopes.ForStorage(storage).ToScope();", "\n var identities = universe.GetScopes(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);", - "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", + "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n", "\n await workspace.UpdateAsync(ivs);", From bdd0453e618bc0659dba5352fd91fced09ce27cd Mon Sep 17 00:00:00 2001 From: nnikolopoulos <114566025+nnikolopoulos@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:10:32 +0100 Subject: [PATCH 03/11] Fix amortization factor (#124) --- ifrs17/Import/ImportScopeCalculation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index 956e823e..59184a84 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -2292,7 +2292,7 @@ "\n IEnumerable CalculatedIfrsVariables => PvLocked.Concat(PvCurrent)", "\n .Concat(RaCurrent)", "\n .Concat(RaLocked)", - "\n .Concat(amortizationFactor)", + "\n .Concat(AmortizationFactor)", "\n .Concat(BeEAForPremium)", "\n .Concat(DeferrableActual)", "\n .Concat(Csms)", From 812b293d975bc6cebb1b8471f241f5e1f8f421fd Mon Sep 17 00:00:00 2001 From: Sara Busato Date: Mon, 12 Dec 2022 13:30:14 +0100 Subject: [PATCH 04/11] fixing double[] aggregation --- ifrs17/Import/ImportScopeCalculation.ipynb | 6 ++-- ifrs17/Utils/Extensions.ipynb | 38 +++++++++++++++++++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index 59184a84..097661f1 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -549,7 +549,7 @@ "\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 .Aggregate();", + "\n .AggregateDoubleArray();", "\n ", "\n private double nonPerformanceRiskRate => GetStorage().GetNonPerformanceRiskRate(Identity.Id);", "\n ", @@ -566,7 +566,7 @@ "\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 .Aggregate();", + "\n .AggregateDoubleArray();", "\n}" ], "metadata": {}, @@ -691,7 +691,7 @@ "\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)", - "\n .Aggregate();", + "\n .AggregateDoubleArray();", "\n ", "\n double[] Values => Subtract(CurrentValues, PreviousValues);", "\n}" diff --git a/ifrs17/Utils/Extensions.ipynb b/ifrs17/Utils/Extensions.ipynb index a403aeff..60ec432f 100644 --- a/ifrs17/Utils/Extensions.ipynb +++ b/ifrs17/Utils/Extensions.ipynb @@ -36,6 +36,33 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Loading external dependencies" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#r \"nuget:morelinq\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using static MoreLinq.Extensions.ZipLongestExtension;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -96,7 +123,16 @@ { "cell_type": "code", "source": [ - "public static double[] Prune (this IEnumerable source, double precision = Precision) => source.Reverse().SkipWhile(x => Math.Abs(x) < precision).Reverse().ToArray();" + "public static double[] Prune(this IEnumerable source, double precision = Precision) => source.Reverse().SkipWhile(x => Math.Abs(x) < precision).Reverse().ToArray();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static double[] AggregateDoubleArray(this IEnumerable> source) => source.Aggregate((x, y) => x.ZipLongest(y, (a, b) => a + b)).ToArray();" ], "metadata": {}, "execution_count": 0, From 623922693df89e70796386d790d753bee4b352c9 Mon Sep 17 00:00:00 2001 From: Sara Busato Date: Mon, 12 Dec 2022 16:25:17 +0100 Subject: [PATCH 05/11] Adding test for AggregateDoubleArray --- ifrs17/Test/AggregateDoubleArrayTest.ipynb | 73 ++++++++++++++++++++++ ifrs17/Test/Tests.ipynb | 9 +++ 2 files changed, 82 insertions(+) create mode 100644 ifrs17/Test/AggregateDoubleArrayTest.ipynb diff --git a/ifrs17/Test/AggregateDoubleArrayTest.ipynb b/ifrs17/Test/AggregateDoubleArrayTest.ipynb new file mode 100644 index 00000000..4958ce9c --- /dev/null +++ b/ifrs17/Test/AggregateDoubleArrayTest.ipynb @@ -0,0 +1,73 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"../Utils/Extensions\"", + "\n#!import \"../Utils/TestHelper\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public void CheckAggregateDoubleArray(double[][] arrayOfDoubleArrays)", + "\n{", + "\n var maxLength = arrayOfDoubleArrays.Select(x => x.Length).Max();", + "\n", + "\n var arraysWithMaxLength = arrayOfDoubleArrays.Where(x => x.Length == maxLength);", + "\n var remainingArrays = arrayOfDoubleArrays.Except(arraysWithMaxLength);", + "\n ", + "\n //Include arrays with max length as first", + "\n var aggregatedArrayMaxLengthFirst = arraysWithMaxLength.Concat(remainingArrays).AggregateDoubleArray();", + "\n aggregatedArrayMaxLengthFirst.Length.Should().Be(maxLength);", + "\n", + "\n //Include arrays with max length as last", + "\n var aggregatedArrayMaxLengthLast = remainingArrays.Concat(arraysWithMaxLength).AggregateDoubleArray();", + "\n aggregatedArrayMaxLengthLast.Length.Should().Be(maxLength);", + "\n", + "\n CheckEquality(aggregatedArrayMaxLengthFirst, aggregatedArrayMaxLengthLast).Should().Be(true);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var array = new double [] [] {new[] {-100d,-50d }, new[] {-100d,-50d,-50d,-50d,0d,0d,0d,0d, 0d,0d,}, new[] {-100d,-50d,-50d,-50d,0d,0d,0d,0d, 0d,0d,}, new[] {-100d,-50d,-50d,-50d,0d,0d,0d,0d, 0d,0d,} };", + "\nCheckAggregateDoubleArray(array)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Test/Tests.ipynb b/ifrs17/Test/Tests.ipynb index e2f0e955..ef37f404 100644 --- a/ifrs17/Test/Tests.ipynb +++ b/ifrs17/Test/Tests.ipynb @@ -41,6 +41,15 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"AggregateDoubleArrayTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file From 1b14d73d21b70fab6dcffefe6eace11f908b46a1 Mon Sep 17 00:00:00 2001 From: Sara Busato Date: Mon, 12 Dec 2022 17:30:18 +0100 Subject: [PATCH 06/11] fixed AggregateDoubleArray --- ifrs17/Utils/Extensions.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Utils/Extensions.ipynb b/ifrs17/Utils/Extensions.ipynb index 60ec432f..9e335a22 100644 --- a/ifrs17/Utils/Extensions.ipynb +++ b/ifrs17/Utils/Extensions.ipynb @@ -132,7 +132,7 @@ { "cell_type": "code", "source": [ - "public static double[] AggregateDoubleArray(this IEnumerable> source) => source.Aggregate((x, y) => x.ZipLongest(y, (a, b) => a + b)).ToArray();" + "public static double[] AggregateDoubleArray(this IEnumerable> source) => source.Where(x => x is not null).DefaultIfEmpty(Enumerable.Empty()).Aggregate((x, y) => x.ZipLongest(y, (a, b) => a + b)).ToArray();" ], "metadata": {}, "execution_count": 0, From 919eb9a8519b3693aa226fc55f8647c4881cbfa5 Mon Sep 17 00:00:00 2001 From: Sara Busato Date: Mon, 12 Dec 2022 17:38:18 +0100 Subject: [PATCH 07/11] AggregateDoubleArrayTest enhancement --- ifrs17/Test/AggregateDoubleArrayTest.ipynb | 90 ++++++++++++++++++---- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/ifrs17/Test/AggregateDoubleArrayTest.ipynb b/ifrs17/Test/AggregateDoubleArrayTest.ipynb index 4958ce9c..6849995e 100644 --- a/ifrs17/Test/AggregateDoubleArrayTest.ipynb +++ b/ifrs17/Test/AggregateDoubleArrayTest.ipynb @@ -28,22 +28,10 @@ { "cell_type": "code", "source": [ - "public void CheckAggregateDoubleArray(double[][] arrayOfDoubleArrays)", + "public void CheckAggregateDoubleArray(double[][] arrayOfDoubleArrays, double[] bmAggregatedArray)", "\n{", - "\n var maxLength = arrayOfDoubleArrays.Select(x => x.Length).Max();", - "\n", - "\n var arraysWithMaxLength = arrayOfDoubleArrays.Where(x => x.Length == maxLength);", - "\n var remainingArrays = arrayOfDoubleArrays.Except(arraysWithMaxLength);", - "\n ", - "\n //Include arrays with max length as first", - "\n var aggregatedArrayMaxLengthFirst = arraysWithMaxLength.Concat(remainingArrays).AggregateDoubleArray();", - "\n aggregatedArrayMaxLengthFirst.Length.Should().Be(maxLength);", - "\n", - "\n //Include arrays with max length as last", - "\n var aggregatedArrayMaxLengthLast = remainingArrays.Concat(arraysWithMaxLength).AggregateDoubleArray();", - "\n aggregatedArrayMaxLengthLast.Length.Should().Be(maxLength);", - "\n", - "\n CheckEquality(aggregatedArrayMaxLengthFirst, aggregatedArrayMaxLengthLast).Should().Be(true);", + "\n var aggregatedArray = arrayOfDoubleArrays.AggregateDoubleArray();", + "\n aggregatedArray.Should().BeEquivalentTo(bmAggregatedArray);", "\n}" ], "metadata": {}, @@ -54,7 +42,77 @@ "cell_type": "code", "source": [ "var array = new double [] [] {new[] {-100d,-50d }, new[] {-100d,-50d,-50d,-50d,0d,0d,0d,0d, 0d,0d,}, new[] {-100d,-50d,-50d,-50d,0d,0d,0d,0d, 0d,0d,}, new[] {-100d,-50d,-50d,-50d,0d,0d,0d,0d, 0d,0d,} };", - "\nCheckAggregateDoubleArray(array)" + "\nCheckAggregateDoubleArray(array, new[] {-400d,-200d,-150d,-150d,0d,0d,0d,0d, 0d,0d,})" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {null, new[] {-100d,-50d }};", + "\nCheckAggregateDoubleArray(array, new[] {-100d,-50d })" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {new[] {-100d,-50d }, null};", + "\nCheckAggregateDoubleArray(array, new[] {-100d,-50d })" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {Enumerable.Empty().ToArray(), new[] {-100d,-50d }};", + "\nCheckAggregateDoubleArray(array, new[] {-100d,-50d })" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {Enumerable.Empty().ToArray(), Enumerable.Empty().ToArray()};", + "\nCheckAggregateDoubleArray(array, Enumerable.Empty().ToArray())" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {new[] {-100d,-50d }};", + "\nCheckAggregateDoubleArray(array, new[] {-100d,-50d })" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {Enumerable.Empty().ToArray()};", + "\nCheckAggregateDoubleArray(array, Enumerable.Empty().ToArray())" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "array = new double [] [] {null};", + "\nCheckAggregateDoubleArray(array, Enumerable.Empty().ToArray())" ], "metadata": {}, "execution_count": 0, From a51130f42da691f5ee43b2af5cc6f633107a4e89 Mon Sep 17 00:00:00 2001 From: nnikolopoulos <114566025+nnikolopoulos@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:17:30 +0100 Subject: [PATCH 08/11] Test runners using ApplicationMessage.Log (#130) * Add non-zero count checks in SequenceImportTest * Empty cell * Add ApplicationMessage log in ReportVariablesTest * Implement ActivityLog in: ImportStorageTest, MapTemplateAndImportTest, ReportStorageTest * Undo year and month checking in MapTemplateAndImportTest * Check year and month entries in YieldCurves and apply ActivityLog in QueriesTest * Apply ActivityLogs in AocStructureTest, ReportStorageTest, ReportVariablesTest and TechnicalMarginTest * Implement feedback * fixed ImportStorageTest Co-authored-by: Sara Busato --- ifrs17-template/Test/AocStructureTest.ipynb | 40 ++- ifrs17-template/Test/ImportStorageTest.ipynb | 156 ++++++++-- .../Test/MapTemplateAndImportTest.ipynb | 13 +- ifrs17-template/Test/ReportStorageTest.ipynb | 16 +- .../Test/ReportVariablesTest.ipynb | 40 ++- .../Test/ReportVariablesTestBase.ipynb | 3 +- ifrs17-template/Test/SequenceImportTest.ipynb | 18 ++ .../Test/TechnicalMarginTest.ipynb | 40 ++- ifrs17/Test/QueriesTest.ipynb | 292 ++++++++++++++++-- ifrs17/Utils/ApplicationMessage.ipynb | 6 + 10 files changed, 559 insertions(+), 65 deletions(-) diff --git a/ifrs17-template/Test/AocStructureTest.ipynb b/ifrs17-template/Test/AocStructureTest.ipynb index 91bf53b8..b52e9153 100644 --- a/ifrs17-template/Test/AocStructureTest.ipynb +++ b/ifrs17-template/Test/AocStructureTest.ipynb @@ -94,12 +94,13 @@ { "cell_type": "code", "source": [ - "public async Task CheckAocStepStructureAsync(IEnumerable inputVariables, ", + "public async Task CheckAocStepStructureAsync(IEnumerable inputVariables, ", "\n Dictionary> parentBm, ", "\n Dictionary referenceBm, ", "\n Dictionary> fullAocBm,", "\n Dictionary> parentBmCdr = null)", "\n{", + "\n Activity.Start();", "\n //Save test input data", "\n var importFormat = ImportFormats.Cashflow;", "\n var inputSource = InputSource.Cashflow;", @@ -232,6 +233,7 @@ "\n }", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}", "\n" ], @@ -502,7 +504,17 @@ { "cell_type": "code", "source": [ - "await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm, parentBm_CDR)" + "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, @@ -604,7 +616,17 @@ { "cell_type": "code", "source": [ - "await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm)" + "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, @@ -679,7 +701,17 @@ { "cell_type": "code", "source": [ - "await CheckAocStepStructureAsync(inputIfrsVariables, parentBm, referenceBm, fullAocBm)" + "var activity = await CheckAocStepStructureAsync(inputIfrsVariables, parentBm, referenceBm, fullAocBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ImportStorageTest.ipynb b/ifrs17-template/Test/ImportStorageTest.ipynb index 24387d42..19b809b5 100644 --- a/ifrs17-template/Test/ImportStorageTest.ipynb +++ b/ifrs17-template/Test/ImportStorageTest.ipynb @@ -82,16 +82,16 @@ "//Define partition", "\nvar args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\nvar partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", "\n ReportingNode = reportingNode, ", "\n Scenario = scenario, ", "\n Year = args.Year,", "\n Month = args.Month };", - "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", + "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", "\n ReportingNode = reportingNode, ", "\n Scenario = scenario, ", - "\n Year = args.Year,", - "\n Month = args.Month };", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month };", "\nawait DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", "\nawait DataSource.CommitAsync();" ], @@ -102,8 +102,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckIfrsVariablesFromImportStorageAsync(string importFormat, IEnumerable inputDataSetForWorkspace, IEnumerable inputDataSetForDataSource, IEnumerable ivsBenchmark)", + "public async Task CheckIfrsVariablesFromImportStorageAsync(string importFormat, IEnumerable inputDataSetForWorkspace, IEnumerable inputDataSetForDataSource, IEnumerable ivsBenchmark)", "\n{", + "\n Activity.Start();", "\n //Prepare Workspace and DataSource", "\n await Workspace.UpdateAsync(inputDataSetForWorkspace);", "\n await DataSource.UpdateAsync(inputDataSetForDataSource);", @@ -132,6 +133,7 @@ "\n if(ivsByIdentityString.Any()) errors.Add($\"IfrsVariables in the storage have duplicated items for:\\n{string.Join(\"\\n\",ivsByIdentityString)}.\");", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -160,7 +162,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -193,7 +205,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = -20.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -228,7 +250,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, EstimateType = EstimateTypes.AA, Novelty = Novelties.C, Value = -20.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -271,7 +303,17 @@ "\n basicAdvanceActualIfrsVariable with {AocType = AocTypes.WO, Value = -20.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -324,7 +366,17 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", "\n", - "\nawait CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);" + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -455,8 +507,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckGetUnderlyingGicsAsync(RawVariable[] inputDataVariable, Dictionary> underlyingGicBm)", + "public async Task CheckGetUnderlyingGicsAsync(RawVariable[] inputDataVariable, Dictionary> underlyingGicBm)", "\n{", + "\n Activity.Start();", "\n var errors = new List();", "\n ", "\n await PrepareWorkspaceDataNodes();", @@ -476,6 +529,7 @@ "\n await Workspace.DeleteAsync(Workspace.Query());", "\n await CleanWorkspaceDataNodes();", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -493,7 +547,17 @@ "\n {\"Reins2\",new string[]{\"Gross1\",\"Gross2\"}},", "\n};", "\n", - "\nawait CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);" + "\nvar activity = await CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -508,7 +572,17 @@ "\n {\"Reins2\",new string[]{\"Gross1\",\"Gross2\"}},", "\n};", "\n", - "\nawait CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);" + "\nvar activity = await CheckGetUnderlyingGicsAsync(inputDataVariable, underlyingGicBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -526,10 +600,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckGetReinsuranceCoverageAsync(RawVariable[] inputDataVariable, ", + "public async Task CheckGetReinsuranceCoverageAsync(RawVariable[] inputDataVariable, ", "\n Dictionary<(string, string),double> reinsCovBoPBm, ", "\n Dictionary<(string, string),double> reinsCovEoPBm)", "\n{", + "\n Activity.Start();", "\n var errors = new List();", "\n", "\n await PrepareWorkspaceDataNodes();", @@ -566,6 +641,7 @@ "\n await Workspace.DeleteAsync(Workspace.Query());", "\n await CleanWorkspaceDataNodes();", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -590,7 +666,17 @@ "\n {(\"Reins2\",\"Gross2\"),0.7},", "\n};", "\n", - "\nawait CheckGetReinsuranceCoverageAsync(inputDataVariable, reinsCovBoPBm, reinsCovEoPBm);" + "\nvar activity = await CheckGetReinsuranceCoverageAsync(inputDataVariable, reinsCovBoPBm, reinsCovEoPBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -608,8 +694,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckSecondaryScopeAsync(RawVariable[] inputDataVariable, string[] primaryScopeBm, string[] secondaryScopeBm)", + "public async Task CheckSecondaryScopeAsync(RawVariable[] inputDataVariable, string[] primaryScopeBm, string[] secondaryScopeBm)", "\n{", + "\n Activity.Start();", "\n var errors = new List();", "\n ", "\n await PrepareWorkspaceDataNodes();", @@ -639,6 +726,7 @@ "\n await Workspace.DeleteAsync(Workspace.Query());", "\n await CleanWorkspaceDataNodes();", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -653,7 +741,17 @@ "\n };", "\nvar primaryScopeBm = new string[]{\"Reins1\", \"Reins2\"};", "\nvar secondaryScopeBm = new string[]{\"Gross1\", \"Gross2\"};", - "\nawait CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);" + "\nvar activity = await CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -666,7 +764,17 @@ "\n };", "\nvar primaryScopeBm = new string[]{\"Reins1\"};", "\nvar secondaryScopeBm = new string[]{\"Gross1\"};", - "\nawait CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);" + "\nvar activity = await CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -680,7 +788,17 @@ "\n };", "\nvar primaryScopeBm = new string[]{\"Reins1\",\"Gross1\",\"Reins2\"};", "\nvar secondaryScopeBm = new string[]{\"Gross2\"};", - "\nawait CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);" + "\nvar activity = await CheckSecondaryScopeAsync(inputDataVariable, primaryScopeBm, secondaryScopeBm);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index f06f2428..cd6603fd 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -537,11 +537,13 @@ { "cell_type": "code", "source": [ - "public async Task CheckErrors(string inputFileName, List errorBms)", + "public async Task CheckErrors(string inputFileName, List errorBms)", "\n{", + "\n Activity.Start();", "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(Workspace).ExecuteAsync();", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n errorBms.Intersect(log.Errors.Select(x => x.ToString().Substring(0,x.ToString().Length-2).Substring(40)).ToArray()).Count().Should().Be(errorBms.Count());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -555,7 +557,8 @@ "\nvar errorsBm = new List(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};", - "\nawait CheckErrors(inputFileName, errorsBm);" + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -567,7 +570,8 @@ "var inputFileName = \"Data/DataNodeParameter_Duplicate.csv\";", "\nvar errorsBm = new List(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),", "\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};", - "\nawait CheckErrors(inputFileName, errorsBm);" + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -578,7 +582,8 @@ "source": [ "var inputFileName = \"Data/DataNodeParameter_InvalidReinsCov.csv\";", "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};", - "\nawait CheckErrors(inputFileName, errorsBm);" + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nactivity" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ReportStorageTest.ipynb b/ifrs17-template/Test/ReportStorageTest.ipynb index 851ea575..0f49a5d2 100644 --- a/ifrs17-template/Test/ReportStorageTest.ipynb +++ b/ifrs17-template/Test/ReportStorageTest.ipynb @@ -48,8 +48,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckGetFx(string currentCurrency, string targetCurrency, int year, int month, IEnumerable testData, double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark)", + "public async Task CheckGetFx(string currentCurrency, string targetCurrency, int year, int month, IEnumerable testData, double fxBOPBenchmark, double fxAVGBenchmark, double fxEOPBenchmark)", "\n{", + "\n Activity.Start();", "\n await Workspace.UpdateAsync(testData);", "\n ", "\n //Create report storage", @@ -68,6 +69,7 @@ "\n fxEOP.Should().Be(fxEOPBenchmark);", "\n ", "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -84,7 +86,17 @@ "\n new ExchangeRate{ Currency = \"USD\", Year = 2020, Month = 12, FxType = FxType.Spot, FxToGroupCurrency = 5 },", "\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Average, FxToGroupCurrency = 2 },", "\n new ExchangeRate{ Currency = \"USD\", Year = 2021, Month = 6, FxType = FxType.Spot, FxToGroupCurrency = 0.5 }};", - "\nawait CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);" + "\nvar activity = await CheckGetFx(\"EUR\", \"USD\", 2021, 6, testData, 2, 10, 60);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ReportVariablesTest.ipynb b/ifrs17-template/Test/ReportVariablesTest.ipynb index 978d2a5e..1ed77b94 100644 --- a/ifrs17-template/Test/ReportVariablesTest.ipynb +++ b/ifrs17-template/Test/ReportVariablesTest.ipynb @@ -131,8 +131,9 @@ { "cell_type": "code", "source": [ - "public async Task RunTestAsync () ", + "public async Task RunTestAsync () ", "\n{", + "\n Activity.Start();", "\n scopesData = await GetScopesDataAsync(args, reportStorage, Scopes);", "\n benchmarkData = await GetBenchmarkDataAsync(args, path, Workspace, Import);", "\n", @@ -145,6 +146,7 @@ "\n //.Excluding(o => o.Value)", "\n .Using(ctx => ctx.Subject.Should().BeApproximately(ctx.Expectation, BenchmarkPrecision))", "\n .WhenTypeIs() );", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -173,7 +175,17 @@ "cell_type": "code", "source": [ "args = ((2020, 12), \"CH\", null, CurrencyType.Contractual);", - "\nawait RunTestAsync()" + "\nvar activity = await RunTestAsync();", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -192,7 +204,17 @@ "cell_type": "code", "source": [ "args = ((2021, 3), \"CH\", null, CurrencyType.Contractual);", - "\nawait RunTestAsync()" + "\nvar activity = await RunTestAsync();", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -211,7 +233,17 @@ "cell_type": "code", "source": [ "args = ((2020, 12), \"CH\", \"MTUP10pct\", CurrencyType.Contractual);", - "\nawait RunTestAsync()" + "\nvar activity = await RunTestAsync();", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ReportVariablesTestBase.ipynb b/ifrs17-template/Test/ReportVariablesTestBase.ipynb index 36d07af7..a41671c0 100644 --- a/ifrs17-template/Test/ReportVariablesTestBase.ipynb +++ b/ifrs17-template/Test/ReportVariablesTestBase.ipynb @@ -146,7 +146,8 @@ "static async Task> GetBenchmarkDataAsync(((int Year, int Month) Period, string ReportingNode, string Scenario, CurrencyType CurrencyType) args, string path, IWorkspace workspace, IImportVariable importVariable) {", "\n var bmFileName = benchmarkFileNamePrefix + GetBenchmarkFileName(args) + \".csv\";", "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario, Year = args.Period.Year, Month = args.Period.Month });", - "\n await importVariable.FromFile(path + bmFileName).WithType(x => x.SnapshotMode()).WithTarget(workspace).ExecuteAsync();", + "\n var log = await importVariable.FromFile(path + bmFileName).WithType(x => x.SnapshotMode()).WithTarget(workspace).ExecuteAsync();", + "\n ApplicationMessage.Log(log);", "\n var ret = await workspace.Query().ToArrayAsync();", "\n workspace.Reset(x => x.ResetCurrentPartitions().ResetType());", "\n return ret;", diff --git a/ifrs17-template/Test/SequenceImportTest.ipynb b/ifrs17-template/Test/SequenceImportTest.ipynb index 1b9b3bcf..8a1b0187 100644 --- a/ifrs17-template/Test/SequenceImportTest.ipynb +++ b/ifrs17-template/Test/SequenceImportTest.ipynb @@ -156,6 +156,24 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "ifrsVars1.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrsVars2.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Test/TechnicalMarginTest.ipynb b/ifrs17-template/Test/TechnicalMarginTest.ipynb index 1407c020..8d0d4f34 100644 --- a/ifrs17-template/Test/TechnicalMarginTest.ipynb +++ b/ifrs17-template/Test/TechnicalMarginTest.ipynb @@ -90,8 +90,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckSwitchLogicAsync(IEnumerable inputDataSet, Dictionary csmLcSwitchBenchmark)", + "public async Task CheckSwitchLogicAsync(IEnumerable inputDataSet, Dictionary csmLcSwitchBenchmark)", "\n{", + "\n Activity.Start();", "\n //Save test input data", "\n await Workspace.UpdateAsync(inputDataSet);", "\n ", @@ -154,6 +155,7 @@ "\n }", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -214,7 +216,17 @@ "\n {new AocStep(\"EOP\",\"C\"),(146.5d, 0d)},", "\n };", "\n", - "\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);" + "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -240,7 +252,17 @@ "\n {new AocStep(\"EOP\",\"C\"),(29d, 0d)},", "\n };", "\n", - "\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);" + "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -279,7 +301,17 @@ "\n {new AocStep(\"EOP\",\"C\"),( 11d, 0d)},", "\n };", "\n", - "\nawait CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);" + "\nvar activity = await CheckSwitchLogicAsync(inputDataSet, csmLcSwitch_benchmark);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index a3f67136..0bf6dc5d 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -57,10 +57,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(Args args, IEnumerable testData, ", + "public async Task CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(Args args, IEnumerable testData, ", "\n (int Year, int Month, string Scenario) expectedCurrentPeriod, ", "\n (int Year, int Month, string Scenario) expectedPreviousPeriod)", "\n{", + "\n Activity.Start();", "\n await Workspace.UpdateAsync(testData);", "\n var eurCurrentAndPreviousYieldCurve = (await Workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Currency))[\"EUR\"];", "\n ", @@ -75,6 +76,7 @@ "\n eurCurrentAndPreviousYieldCurve[PreviousPeriod].Scenario.Should().Be(expectedPreviousPeriod.Scenario);", "\n ", "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -86,7 +88,17 @@ "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, null),(2020, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, null),(2020, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -98,7 +110,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new[] { new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario }, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9 } };", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario),(2020, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario),(2020, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -109,7 +131,17 @@ "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2019, 12, null), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2019, 12, null), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -121,7 +153,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -133,7 +175,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -145,7 +197,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -157,7 +219,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2019, 3, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2019, 3, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -169,7 +241,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2020, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2020, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -181,7 +263,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2019, 9, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, null), (2019, 9, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -194,7 +286,17 @@ "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = scenario},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -206,7 +308,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -218,7 +330,17 @@ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2018, Month = 9, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12, null), (2019, 12, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -231,7 +353,17 @@ "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -245,7 +377,17 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6, null), (2019, 6, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -259,7 +401,17 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3, Scenario = null}, ", "\n new YieldCurve{ Currency = \"EUR\", Year = 2015, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = null}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -274,7 +426,17 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2021, Month = 9, Scenario = null},", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = null}};", "\n", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));" + "\nvar activity = await CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -292,8 +454,9 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadDataNodeStateAsync(Args args, IEnumerable testData, bool isExpectedToBeActive)", + "public async Task CheckLoadDataNodeStateAsync(Args args, IEnumerable testData, bool isExpectedToBeActive)", "\n{", + "\n Activity.Start();", "\n await Workspace.Partition.SetAsync(args);", "\n await Workspace.UpdateAsync(testData);", "\n var isActive = (await Workspace.LoadDataNodeStateAsync(args)).Keys.Contains(gic);", @@ -301,6 +464,7 @@ "\n isActive.Should().Be(isExpectedToBeActive);", "\n ", "\n Workspace.Reset(x => x.ResetCurrentPartitions());", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -313,7 +477,17 @@ "var args = new Args(\"CH\",2020,12,Periodicity.Monthly,null);", "\nvar testData = new DataNodeState[] {new DataNodeState{ DataNode = gic, Year = 2019, Month = 12, State = State.Active },", "\n new DataNodeState{ DataNode = gic, Year = 2020, Month = 6, State = State.Inactive }};", - "\nawait CheckLoadDataNodeStateAsync(args, testData, false);" + "\nvar activity = await CheckLoadDataNodeStateAsync(args, testData, false);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -325,7 +499,17 @@ "var args = new Args(\"CH\",2020,12,Periodicity.Monthly,null);", "\nvar testData = new DataNodeState[] {new DataNodeState{ DataNode = gic, Year = 2020, Month = 3, State = State.Active },", "\n new DataNodeState{ DataNode = gic, Year = 2020, Month = 9, State = State.Inactive }};", - "\nawait CheckLoadDataNodeStateAsync(args, testData, false);" + "\nvar activity = await CheckLoadDataNodeStateAsync(args, testData, false);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -343,12 +527,13 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadYieldCurveAsync(Args args, IEnumerable testData, ", + "public async Task CheckLoadYieldCurveAsync(Args args, IEnumerable testData, ", "\n (int year , int month) dataNodeYearAndMonth, ", "\n double expectedCurrentPreviousFirstYcValue,", "\n double expectedCurrentFirstYcValue,", "\n double expectedLockedFirstYcValue)", "\n{", + "\n Activity.Start();", "\n await Workspace.Partition.SetAsync(args);", "\n await Workspace.UpdateAsync(testData);", "\n await Workspace.UpdateAsync(new ReportingNode[]{new ReportingNode{Currency=\"EUR\",SystemName=\"CH\"}});", @@ -373,6 +558,7 @@ "\n errors.Add( $\"LockedIn YieldCurve not matching:\\n Expected {expectedLockedFirstYcValue} \\n Computed {lockedYc}.\" );", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors)); ", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -388,7 +574,17 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2021, Month = 9, Values = new double[]{4.1,4.2,4.3,4.4,4.5,4.6} },", "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", - "\nawait CheckLoadYieldCurveAsync(args, testData, (2016, 6), 6.1, 0.1, 6.1);" + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, (2016, 6), 6.1, 0.1, 6.1);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -417,10 +613,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckLoadInterDataNodeParameterAsync(Args args, IEnumerable testData, ", + "public async Task CheckLoadInterDataNodeParameterAsync(Args args, IEnumerable testData, ", "\n int previousYear,", "\n int? currentYear = null)", "\n{", + "\n Activity.Start();", "\n currentYear = currentYear ?? previousYear;", "\n await Workspace.Partition.SetAsync(args);", "\n await Workspace.UpdateAsync(testData);", @@ -500,6 +697,7 @@ "\n Workspace.Reset(x => x.ResetCurrentPartitions());", "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n return Activity.Finish();", "\n}" ], "metadata": {}, @@ -517,7 +715,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)previousYear)/1000, Year = previousYear, Month = 3}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -538,7 +746,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)currentYear)/1000, Year = currentYear, Month = 9}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -556,7 +774,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)previousYear)/1000, Year = previousYear, Month = 3}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -574,7 +802,17 @@ "\n new InterDataNodeParameter{ DataNode = gric1, LinkedDataNode = xgic, ReinsuranceCoverage = ((double)currentYear)/1000, Year = currentYear, Month = 3}, ", "\n };", "\n", - "\nawait CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);" + "\nvar activity = await CheckLoadInterDataNodeParameterAsync(args, testData, previousYear, currentYear);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index e261b4a6..990dd62b 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -56,6 +56,12 @@ "\n public static Object Log (Error e, params string[] s) { log.LogError(Get(e,s)); return null; }", "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(Get(w,s)); return null; }", "\n ", + "\n public static Object Log (ActivityLog activityLog) {", + "\n foreach(var error in activityLog.Errors) log.LogError(error.ToString());", + "\n foreach(var warning in activityLog.Warnings) log.LogWarning(warning.ToString());", + "\n return null;", + "\n }", + "\n ", "\n public static bool HasErrors () => activity.HasErrors();", "\n public static bool HasWarnings () => activity.HasWarnings();", "\n}" From 9ff9ae4ce6f1710e979de97d66d64fafd88f0931 Mon Sep 17 00:00:00 2001 From: Davide Colleoni <103409906+dcolleoni@users.noreply.github.com> Date: Mon, 19 Dec 2022 09:00:27 +0100 Subject: [PATCH 09/11] Improve documentation (#134) * improvement in data structure and import scope calculation * minor --- ifrs17/DataModel/DataStructure.ipynb | 20 ++++++++++--------- ifrs17/Import/ImportScopeCalculation.ipynb | 23 +++++++++++++++++----- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 3e6144ff..d6fd7173 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -356,8 +356,7 @@ { "cell_type": "code", "source": [ - "//TODO: Should this be abstract or have a reference to the type?", - "\npublic record HierarchicalDimensionWithLevel(string SystemName, string DisplayName, string Parent, int Level) : IHierarchicalDimension;" + "public record HierarchicalDimensionWithLevel(string SystemName, string DisplayName, string Parent, int Level) : IHierarchicalDimension;" ], "metadata": {}, "execution_count": 0, @@ -1136,7 +1135,7 @@ "source": [ "", "\n## Yield Curve", - "\nThe record below holds the Yield Curves across time for each [Currency](#currency) and [Scenario](#scenario).", + "\nThe record below holds the forward rate Yield Curves across time for each [Currency](#currency) and [Scenario](#scenario).", "\nYield curves can be updated every month as part of the close preparation. In general, the last month of the reporting period should be used to import the new data for the period. ", "\n", "\nThe Yield Curve values must be entered with **yearly** granularity, i.e. every value corresponds to the rate of the whole year starting from the year entered in column Year. The last value is considered valid also for the following years (for which no value has been provided). ", @@ -1192,7 +1191,7 @@ "source": [ "", "\n## Partner Rating", - "\nThe record below holds the [Credit Risk Rating](#credit-risk-partner) for each [Partner](#partner) across time. Partner Rating can be updated every month as part of the close preparation. In general, the last month of the reporting period should be use to import the new data for the period. " + "\nThe record below holds the [Credit Risk Rating](#credit-risk-partner) for each [Partner](#partner) across time. Partner Rating can be updated every month as part of the close preparation. In general, the last month of the reporting period should be use to import the new data for the period. The Credit Default Rates for each rating is defined through the import of [Credit Default Rates](#credit-default-rate)." ], "metadata": {}, "execution_count": 0, @@ -1240,7 +1239,7 @@ "source": [ "", "\n# Partitions", - "\nThe notion of Partition is used to define small but meaningful sets of data, called partitions. Partitions are then used to optimize the extraction of data from the database, i.e. only the data for a certain partition is retrieved." + "\nThe notion of Partition is used internally to the calculation engine to define small but meaningful sets of data, called partitions. Partitions are then used to optimize the extraction of data from the database, i.e. only the data for a certain partition is retrieved. For example, a specific combination of Year and Month defines a partition." ], "metadata": {}, "execution_count": 0, @@ -1508,7 +1507,7 @@ "", "\n## Data Node State", "\n", - "\nThe Data State is used to track whether a GOC is Active or Inactive across time (year and month). ", + "\nThe Data State is used to track whether a Group of Contract is Active or Inactive across time (year and month). ", "\nIt is only possible to update the state of a Group of Contract from Active to Inactive." ], "metadata": {}, @@ -1647,8 +1646,8 @@ { "cell_type": "markdown", "source": [ - "## DataNodeData PocoType", - "\nThe DataNodeData type is not persisted (i.e. not stored in the database) and is used in order to hold Data Node data during data manipulations." + "## DataNodeData", + "\nThe DataNodeData type is not persisted (i.e. not stored in the database) and is used in order to hold Data Node data (i.e information from the dimension [data node](#data-node) and the data node [State](#data-node-state)) during data manipulations e.g import and report computations." ], "metadata": {}, "execution_count": 0, @@ -2061,7 +2060,10 @@ { "cell_type": "markdown", "source": [ - "# Args" + "# Args", + "\n", + "\nArgs are used to hold data related to the partition and additional information required to performe calculation at import and report. ", + "\nThey are not persisted, i.e. they are not saved on the database." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index 097661f1..3d155e93 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -526,7 +526,7 @@ "\nThe nominal cash flow values correspond to the cash flows provided in the cash flow input file. ", "\n
These values are stored in the database as [RawVariable](../DataModel/DataStructure#raw-variables).", "\n
Refer to the ReferenceAocStep of the AocStructure calculation to identify the correct AoC Type and Novelty to retrieve.", - "\n
Due to the Credit Default Risk of a reinsurance partner, the logic to compute the Nominal Cash flows for this Amount Type must be defined separately. " + "\n
Due to the Credit Default Risk of a reinsurance partner, the logic to compute the Nominal Cash flows for this Amount Type must be defined separately." ], "metadata": {}, "execution_count": 0, @@ -607,15 +607,28 @@ "\n$$", "\n\\text{CDC}_i(\\text{AoC step}) = \\left\\{", "\n\\begin{array}{cl}", - "\n\\text{Nominal}_i + \\text{CDC}_{i+1} \\cdot {\\text{Valid Discount}_{\\frac{i}{12}}} ~, & \\text{if AoC Type's Period Type is Beginning Of Period} \\\\", - "\n\\big( \\text{Nominal}_i + \\text{CDC}_{i+1} \\big) \\cdot {\\text{Valid Discount}_{\\frac{i}{12}}} ~, & \\text{if AoC Type's Period Type is End Of Period}", + "\n\\text{Nominal}_i + \\text{CDC}_{i+1} \\cdot {\\text{Valid Discount}_{\\frac{i}{12}}} ~, & \\text{if Amount Type's Period Type is Beginning Of Period} \\\\", + "\n\\big( \\text{Nominal}_i + \\text{CDC}_{i+1} \\big) \\cdot {\\text{Valid Discount}_{\\frac{i}{12}}} ~, & \\text{if Amount Type's Period Type is End Of Period}", "\n\\end{array}", "\n\\right.", "\n$$", "\n", "\nwhere Transaction Period depends on which Best Estimate value is being computed, in particular on what its [Amount Type](../DataModel/DataStructure#amount-type) is (each Amount Type has its own [Period Type](../Constants/Enums)); and $\\text{Valid Discount}$ stands for the fact that in case the Discount Curves are shorter than the required index, then their last element is returned. We also need to flip the sign of the discounted and cumulated values, to create a reserve view and be consistent with the usual [Cash flow Sign Convention](https://en.wikipedia.org/wiki/Cash_flow_sign_convention). ", "\n", - "\n
Also here, the Credit Default Risk contribution is calculated separately. Since it is based on Claims, the Period Type is implicitly defined." + "\n
Also here, the Credit Default Risk contribution is calculated separately. Since it is based on Claims, the Period Type is implicitly defined.", + "\nThe risk of default is included in the discounting formula as follows. First, we notice that one can explicitly write the discounting recursive relation above as:", + "\n$$", + "\n\\begin{array}{l}", + "\n\\text{CDC}_i = \\big( \\text{Nominal}_i + \\text{CDC}_{i+1} \\big) \\cdot {\\text{Valid Discount}_{\\frac{i}{12}}} ", + "\n\\Rightarrow \\text{CDC}_i = \\sum_{\\tau=i} \\big( \\text{Valid Discount}_{\\frac{i}{12}} \\big)^{\\tau-i+1} \\cdot \\text{Nominal}_\\tau ", + "\n\\end{array}", + "\n$$", + "\n", + "\nThus, the cumulated and discounted cashflow correction for default risk is assigned to the Amount Type Credit Default Risk (CDR) and it is obtained from the Amount Type Claims multiplying the right hand side of the previous formula by the corresponding risk factor", + "\n", + "\n$$", + "\n\\text{CDC}_i^{\\text{CDR}} = \\sum_{\\tau=i} \\big( \\text{Valid Discount}_{\\frac{i}{12}} \\big)^{\\tau-i+1} \\cdot \\text{Nominal}_\\tau^{\\text{Claim}} \\cdot \\big( e^{-\\gamma(\\tau-i)} -1 \\big)", + "\n$$" ], "metadata": {}, "execution_count": 0, @@ -1627,7 +1640,7 @@ "\n\\big(PV_{\\text{Novelty = I}} + PV_{\\text{Novelty = N}} \\big) - \\text{Actual}_{\\text{Novelty=C}} ~,", "\n$$", "\n", - "\nwhere the AoC Step **CF** is implicit for all formulas, $PV$ is the [present value](#present-value) with Estimate Type **BE**, and Actuals have Estimate Types **A** (see details [here](#actual-values))." + "\nwhere the AoC Step **CF** is implicit for all formulas, $PV$ is the [present value](#present-value) with Estimate Type **BE** (Best Estimate), and Actuals have Estimate Types **A** (see details [here](#actual-values)). Note that according to the applied sign convention, the sign of the CF AoC Step of Best Estimate Present Value and Actual is the same, accounting for the minus sign in the formula. " ], "metadata": {}, "execution_count": 0, From b635d6afc79c3496b6a3d08b83293ca5819d5fea Mon Sep 17 00:00:00 2001 From: Andrey Katz <118806207+andrey-katz-systemorph@users.noreply.github.com> Date: Tue, 20 Dec 2022 12:28:50 +0100 Subject: [PATCH 10/11] versions (#141) Co-authored-by: akatz --- ifrs17/DataModel/DataStructure.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index d6fd7173..92cf5634 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -59,10 +59,10 @@ "\n#r \"nuget:Systemorph.SharePoint,1.6.1\"", "\n#r \"nuget:Systemorph.OneDrive,1.6.1\"", "\n#r \"nuget:Systemorph.Scopes,1.6.1\"", - "\n#r \"nuget:Systemorph.Import,1.6.0\"", + "\n#r \"nuget:Systemorph.Import,1.6.2\"", "\n#r \"nuget:Systemorph.Test,1.6.1\"", - "\n#r \"nuget:Systemorph.Export,1.6.0\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.6.0\"", + "\n#r \"nuget:Systemorph.Export,1.6.2\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.6.2\"", "\n#r \"nuget:Systemorph.DataSource,1.6.0\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.0\"", "\n#r \"nuget:Systemorph.Reporting,1.6.1\"", From 6bb320773d6c4ff3f1a156b38e6e77b6e88ffa79 Mon Sep 17 00:00:00 2001 From: nnikolopoulos <114566025+nnikolopoulos@users.noreply.github.com> Date: Tue, 20 Dec 2022 16:05:38 +0100 Subject: [PATCH 11/11] Remove SnapshotMode from Import Parameters of Initializations NBs (#144) --- .../Initialization/InitSystemorphRefDataToMemory.ipynb | 8 ++++---- .../Initialization/InitSystemorphToDatabase.ipynb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb b/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb index b0125ccd..ad4e7b83 100644 --- a/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb +++ b/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb @@ -154,7 +154,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/YieldCurve.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/YieldCurve.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -163,7 +163,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/ExchangeRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/ExchangeRate.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -172,7 +172,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/PartnerRating.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/PartnerRating.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -181,7 +181,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/CreditDefaultRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/CreditDefaultRate.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb b/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb index bea3a013..65138c29 100644 --- a/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb +++ b/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb @@ -123,7 +123,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/YieldCurve.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/YieldCurve.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -132,7 +132,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/ExchangeRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/ExchangeRate.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -141,7 +141,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/PartnerRating.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/PartnerRating.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -150,7 +150,7 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/Parameters/CreditDefaultRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" + "await Import.FromFile(\"../Files/Parameters/CreditDefaultRate.csv\").WithType().WithTarget(DataSource).ExecuteAsync()" ], "metadata": {}, "execution_count": 0,