From 4f178e2e8992c8de2d6d848ae16f40ee8e50084e Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Thu, 13 Oct 2022 13:01:17 +0200 Subject: [PATCH 01/23] still not working properly --- .../InitSystemorphBaseToMemory.ipynb | 2 +- .../Test/IfrsVariablesTest.ipynb | 4 +- full-ifrs17-template/Test/QueriesTest.ipynb | 113 ++++++++++++------ ifrs17/DataModel/DataStructure.ipynb | 56 ++++++--- ifrs17/Import/Importers.ipynb | 4 +- ifrs17/Utils/ApplicationMessage.ipynb | 2 +- ifrs17/Utils/Queries.ipynb | 29 +++-- 7 files changed, 142 insertions(+), 68 deletions(-) diff --git a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index 293cb431..19a4eb6e 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -29,7 +29,7 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17ce/dev/CalculationEngine\"" + "#!import \"../../../ifrs17/CalculationEngine\"" ] }, { diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index 1a40358a..a7f64ead 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -26,7 +26,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" + "#!eval-notebook \"../../full-ifrs17-template/Initialization/InitSystemorphToMemory\"" ] }, { @@ -235,7 +235,7 @@ "\n var extension = System.IO.Path.GetExtension(bmfile.FileName);", "\n var stream = await Project.FileStorage.ReadAsync(bmfile.FileName);", "\n //Read Bm csv", - "\n var bmDataTable = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync());", + "\n var bmDataTable = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;", "\n", "\n var mainTab = bmDataTable.Tables[Main].Rows.First();", "\n if(!ValidateMainTab(mainTab, reportingNode, year, month))", diff --git a/full-ifrs17-template/Test/QueriesTest.ipynb b/full-ifrs17-template/Test/QueriesTest.ipynb index ab6ca4d9..49b527f1 100644 --- a/full-ifrs17-template/Test/QueriesTest.ipynb +++ b/full-ifrs17-template/Test/QueriesTest.ipynb @@ -20,13 +20,14 @@ { "cell_type": "code", "source": [ - "#!import \"../CalculationEngine\"" + "#!import \"../../ifrs17/CalculationEngine\"" ] }, { "cell_type": "code", "source": [ - "var gic = \"DT1.1\";" + "var gic = \"DT1.1\";", + "\nvar scenario = \"SCE\";" ] }, { @@ -45,8 +46,8 @@ "cell_type": "code", "source": [ "public async Task CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(Args args, IEnumerable testData, ", - "\n (int Year, int Month) expectedCurrentPeriod, ", - "\n (int Year, int Month) expectedPreviousPeriod)", + "\n (int Year, int Month, string Scenario) expectedCurrentPeriod, ", + "\n (int Year, int Month, string Scenario) expectedPreviousPeriod)", "\n{", "\n await Workspace.UpdateAsync(testData);", "\n var eurCurrentAndPreviousYieldCurve = (await Workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Currency))[\"EUR\"];", @@ -54,10 +55,12 @@ "\n //Check Current Period", "\n eurCurrentAndPreviousYieldCurve[CurrentPeriod].Year.Should().Be(expectedCurrentPeriod.Year);", "\n eurCurrentAndPreviousYieldCurve[CurrentPeriod].Month.Should().Be(expectedCurrentPeriod.Month);", + "\n eurCurrentAndPreviousYieldCurve[CurrentPeriod].Scenario.Should().Be(expectedCurrentPeriod.Scenario);", "\n ", "\n //Check Previous Period", "\n eurCurrentAndPreviousYieldCurve[PreviousPeriod].Year.Should().Be(expectedPreviousPeriod.Year);", "\n eurCurrentAndPreviousYieldCurve[PreviousPeriod].Month.Should().Be(expectedPreviousPeriod.Month);", + "\n eurCurrentAndPreviousYieldCurve[PreviousPeriod].Scenario.Should().Be(expectedPreviousPeriod.Scenario);", "\n ", "\n await Workspace.DeleteAsync(Workspace.Query().ToArray());", "\n}" @@ -68,93 +71,131 @@ "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),(2020, 9));" + "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, null),(2020, 9, null));" + ] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", + "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario};", + "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, scenario),(2020, 9, scenario));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2019, 12), (2019, 12));" + "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null};", + "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2019, 12, null), (2019, 12, null));" + ] + }, + { + "cell_type": "code", + "source": [ + "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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6), (2020, 6));" + "\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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9), (2020, 9));" + "\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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9), (2019, 9));" + "\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));" + ] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"EUR\",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 = scenario},", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12, Scenario = null}};", + "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 9, scenario), (2019, 12, null));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 9}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12), (2019, 12));" + "\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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 12}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2018, Month = 9}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 12), (2019, 12));" + "\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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 9},", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 6}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2019, 6), (2019, 6));" + "\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));" + ] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2020,9,Periodicity.Monthly, scenario);", + "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2019, Month = 6, Scenario = scenario},", + "\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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2015, Month = 9},", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3}};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6), (2016, 3));" + "\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}, ", + "\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));" ] }, { "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,null);", - "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 3}, ", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2021, Month = 9},", - "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3}};", + "\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}, ", + "\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), (2016, 3));" + "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2016, 3, null));" ] }, { diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 98114494..def58c4f 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -43,16 +43,16 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Workspace,1.2.0\"", - "\n#r \"nuget:Systemorph.Scopes,1.2.4\"", - "\n#r \"nuget:Systemorph.Import,1.3.0\"", - "\n#r \"nuget:Systemorph.Test,1.2.4\"", - "\n#r \"nuget:Systemorph.Export,1.3.0\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.3.0\"", - "\n#r \"nuget:Systemorph.DataSource,1.2.0\"", - "\n#r \"nuget:Systemorph.DataSource.Conversions,1.2.0\"", - "\n#r \"nuget:Systemorph.Reporting,1.2.4\"", - "\n#r \"nuget:Systemorph.DomainDesigner,1.3.0\"" + "#r \"nuget:Systemorph.Workspace,1.4.1\"", + "\n#r \"nuget:Systemorph.Scopes,1.4.0\"", + "\n#r \"nuget:Systemorph.Import,1.4.0\"", + "\n#r \"nuget:Systemorph.Test,1.4.0\"", + "\n#r \"nuget:Systemorph.Export,1.4.0\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.4.0\"", + "\n#r \"nuget:Systemorph.DataSource,1.4.1\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.4.1\"", + "\n#r \"nuget:Systemorph.Reporting,1.4.0\"", + "\n#r \"nuget:Systemorph.DomainDesigner,1.4.0\"" ] }, { @@ -175,6 +175,22 @@ "\n}" ] }, + { + "cell_type": "markdown", + "source": [ + "The interface IWithYearMonthAndScenario allows to speficy to which year, month and scenario a certain piece of data applies to:", + "\n" + ] + }, + { + "cell_type": "code", + "source": [ + "public interface IWithYearMonthAndScenario : IWithYearAndMonth", + "\n{", + "\n public string Scenario { get; init; }", + "\n}" + ] + }, { "cell_type": "markdown", "source": [ @@ -891,7 +907,7 @@ { "cell_type": "code", "source": [ - "public record YieldCurve : KeyedRecord, IWithYearAndMonth", + "public record YieldCurve : KeyedRecord, IWithYearMonthAndScenario", "\n{ ", "\n [Required]", "\n [IdentityProperty]", @@ -917,6 +933,7 @@ "\n", "\n [IdentityProperty]", "\n [Display(Order = 35)]", + "\n [Dimension(typeof(Scenario))]", "\n public string Scenario { get; init; }", "\n", "\n [Conversion(typeof(PrimitiveArrayConverter))]", @@ -1214,7 +1231,7 @@ { "cell_type": "code", "source": [ - "public record DataNodeState : KeyedRecord, IPartitioned, IWithYearAndMonth", + "public record DataNodeState : KeyedRecord, IPartitioned, IWithYearMonthAndScenario", "\n{", "\n [NotVisible]", "\n [PartitionKey(typeof(PartitionByReportingNode))]", @@ -1247,6 +1264,12 @@ "\n [Display(Order = 40)]", "\n [DefaultValue(State.Active)]", "\n public State State { get; init; } = State.Active;", + "\n", + "\n [Required]", + "\n [IdentityProperty]", + "\n [Display(Order = 50)]", + "\n [Dimension(typeof(Scenario))]", + "\n public string Scenario { get; init; }", "\n}" ] }, @@ -1266,7 +1289,7 @@ { "cell_type": "code", "source": [ - "public record DataNodeParameter : KeyedRecord, IPartitioned, IWithYearAndMonth", + "public record DataNodeParameter : KeyedRecord, IPartitioned, IWithYearMonthAndScenario", "\n{", "\n [NotVisible]", "\n [PartitionKey(typeof(PartitionByReportingNode))]", @@ -1294,6 +1317,11 @@ "\n [Display(Order = 10)]", "\n [Dimension(typeof(GroupOfContract))]", "\n public string DataNode { get; init; }", + "\n", + "\n [IdentityProperty]", + "\n [Display(Order = 40)]", + "\n [Dimension(typeof(Scenario))]", + "\n public string Scenario { get; init; }", "\n}" ] }, @@ -1352,7 +1380,7 @@ "\n public State PreviousState { get; init; }", "\n ", "\n public bool IsReinsurance { get; init; }", - "\n ", + "\n public string Scenario { get; init; }", "\n public DataNodeData(){}", "\n}" ] diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 34ab4202..4b2d2a5a 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -273,7 +273,7 @@ "\n", "\n var extension = System.IO.Path.GetExtension(file);", "\n var stream = await Project.FileStorage.ReadAsync(file);", - "\n var target = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).Tables[tab];", + "\n var target = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet.Tables[tab];", "\n ", "\n", "\n var dataNodesImported = target.Rows.Select(x => x.Field(nameof(RawVariable.DataNode))).ToHashSet();", @@ -332,7 +332,7 @@ "\n{", "\n var extension = System.IO.Path.GetExtension(file);", "\n var stream = await Project.FileStorage.ReadAsync(file);", - "\n var mainTab = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).Tables[Main];", + "\n var mainTab = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet.Tables[Main];", "\n ", "\n if(mainTab == null) ApplicationMessage.Log(Error.NoMainTab);", "\n if(mainTab.Rows.Count() == 0) ApplicationMessage.Log(Error.IncompleteMainTab);", diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index 2bc8ec97..d5b26c8b 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -27,7 +27,7 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.2.3\"" + "#r \"nuget:Systemorph.Activities,1.4.0\"" ] }, { diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 02105032..4e111424 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -69,6 +69,7 @@ "\n Expression> filterExpression = null ) ", "\n where T : IWithYearAndMonth", "\n{", + "\n // this is a more change", "\n return await querySource.Query()", "\n .Where(x => x.Year == year && x.Month <= month || x.Year < year)", "\n .Where(filterExpression?? (Expression>)(x => true))", @@ -84,14 +85,16 @@ "\n Args args,", "\n Func identityExpression,", "\n Expression> filterExpression = null ) ", - "\n where T : IWithYearAndMonth", + "\n where T : IWithYearMonthAndScenario", "\n{", "\n return (await querySource.LoadParameterAsync(args.Year, args.Month, filterExpression))", - "\n .GroupBy(identityExpression)", - "\n .Select(y => y.OrderByDescending(x => x.Year)", - "\n .ThenByDescending(x => x.Month)", - "\n .FirstOrDefault())", - "\n .ToDictionary(identityExpression);", + "\n .Where(yc => yc.Scenario == args.Scenario || yc.Scenario == null)", + "\n .GroupBy(yc => identityExpression)", + "\n .Select(yc => yc.OrderByDescending(x => x.Year)", + "\n .ThenByDescending(x => x.Month)", + "\n .ThenByDescending(x => x.Scenario)", + "\n .FirstOrDefault())", + "\n .ToDictionary(identityExpression);", "\n}" ] }, @@ -103,17 +106,19 @@ "\n Args args,", "\n Func identityExpression,", "\n Expression> filterExpression = null ) ", - "\n where T : IWithYearAndMonth", + "\n where T : IWithYearMonthAndScenario", "\n{", - "\n var parameters = (await querySource.LoadParameterAsync(args.Year, args.Month, filterExpression)).GroupBy(identityExpression);", + "\n var parameters = (await querySource.LoadParameterAsync(args.Year, args.Month, filterExpression))", + "\n .Where(yc => yc.Scenario == args.Scenario || yc.Scenario == null)", + "\n .GroupBy(identityExpression);", "\n ", "\n var ret = new Dictionary>();", "\n foreach(var p in parameters)", "\n {", "\n var inner = ret.GetOrAdd(p.Key, _ => new Dictionary());", "\n", - "\n var currentCandidate = p.Where(x => x.Year == args.Year).OrderByDescending(x => x.Month).FirstOrDefault();", - "\n var previousCandidate = p.Where(x => x.Year < args.Year).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", + "\n var currentCandidate = p.Where(x => x.Year == args.Year).OrderByDescending(x => x.Month).ThenByDescending(x => x.Scenario).FirstOrDefault();", + "\n var previousCandidate = p.Where(x => x.Year < args.Year).Where(x => x.Scenario == null).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", "\n ", "\n inner.Add(CurrentPeriod, currentCandidate != null ? currentCandidate : previousCandidate);", "\n inner.Add(PreviousPeriod, previousCandidate != null ? previousCandidate : currentCandidate);", @@ -144,8 +149,8 @@ "\n var lockedInYieldCurveByGoc = new Dictionary();", "\n foreach (var dn in dataNodes.Where(x => x.ValuationApproach == ValuationApproaches.BBA))", "\n {", - "\n var argsNew = args with {Year = dn.Year, Month = dn.Month};", - "\n var loadedYc = (await querySource.LoadCurrentParameterAsync(argsNew, x => x.Currency, x => x.Currency == dn.ContractualCurrency));", + "\n var argsNew = args with {Year = dn.Year, Month = dn.Month, Scenario = dn.Scenario};", + "\n var loadedYc = (await querySource.LoadCurrentParameterAsync(argsNew, (x => x.Currency), x => x.Currency == dn.ContractualCurrency));", "\n ", "\n if(!loadedYc.TryGetValue(dn.ContractualCurrency, out var lockedYc))", "\n ApplicationMessage.Log(Error.YieldCurveNotFound, dn.ContractualCurrency, argsNew.Year.ToString(), argsNew.Month.ToString());", From 44412fa3ca671e0a25160fdcf5f43b912fd0a0ae Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Thu, 13 Oct 2022 13:43:28 +0200 Subject: [PATCH 02/23] code cleanup --- full-ifrs17-template/Test/IfrsVariablesTest.ipynb | 2 +- ifrs17/DataModel/DataStructure.ipynb | 15 ++++++++++++--- ifrs17/Utils/Queries.ipynb | 1 - 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index a7f64ead..adcea130 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -44,7 +44,7 @@ { "cell_type": "code", "source": [ - "public record BenchmarkMetadata(string FileName, string ReportingNode, int Year, int Month){} " + "public record BenchmarkMetadata(string FileName, string ReportingNode, int Year, int Month, string Scenario = null){} " ] }, { diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index def58c4f..7b8e6ed6 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -861,7 +861,7 @@ { "cell_type": "code", "source": [ - "public record CreditDefaultRate : KeyedRecord, IWithYearAndMonth", + "public record CreditDefaultRate : KeyedRecord, IWithYearMonthAndScenario", "\n{ ", "\n [Required]", "\n [IdentityProperty]", @@ -888,6 +888,11 @@ "\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}" ] }, @@ -953,7 +958,7 @@ { "cell_type": "code", "source": [ - "public record PartnerRating : KeyedRecord, IWithYearAndMonth", + "public record PartnerRating : KeyedRecord, IWithYearMonthAndScenario", "\n{ ", "\n [Required]", "\n [IdentityProperty]", @@ -981,6 +986,11 @@ "\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}" ] }, @@ -1265,7 +1275,6 @@ "\n [DefaultValue(State.Active)]", "\n public State State { get; init; } = State.Active;", "\n", - "\n [Required]", "\n [IdentityProperty]", "\n [Display(Order = 50)]", "\n [Dimension(typeof(Scenario))]", diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 4e111424..e8500833 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -69,7 +69,6 @@ "\n Expression> filterExpression = null ) ", "\n where T : IWithYearAndMonth", "\n{", - "\n // this is a more change", "\n return await querySource.Query()", "\n .Where(x => x.Year == year && x.Month <= month || x.Year < year)", "\n .Where(filterExpression?? (Expression>)(x => true))", From d98b701efe7227e8c2a92204936ff763682b0e56 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Thu, 13 Oct 2022 13:52:49 +0200 Subject: [PATCH 03/23] new file creation --- .../BM_CH_2020_12_BE_SCE.csv | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv new file mode 100644 index 00000000..8dbc1e48 --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv @@ -0,0 +1,181 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,,2020 +@@BE +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,PR,BOP,DT1.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT1.1,L,BE,N,598.7529445986629 +,PR,BOP,DT1.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT1.1,C,BE,N,598.7529445986629 +,PR,EOP,DT1.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT1.1,L,BE,C,299.67554969423594 +,PR,EOP,DT1.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT1.1,C,BE,C,299.67554969423594 +,PR,IA,DT1.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT1.1,L,BE,N,0.9226050955731167 +,PR,IA,DT1.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT1.1,C,BE,N,0.9226050955731167 +,PR,CF,DT1.1,L,BE,N,400 +,NIC,CF,DT1.1,L,BE,N,-300 +,PR,CF,DT1.1,C,BE,N,400 +,NIC,CF,DT1.1,C,BE,N,-300 +2020,NIC,BOP,DT1.2,L,BE,N,598.7529445986629 +2020,NIC,BOP,DT1.2,C,BE,N,598.7529445986629 +2020,NIC,EOP,DT1.2,L,BE,C,299.67554969423594 +2020,NIC,EOP,DT1.2,C,BE,C,299.67554969423594 +2020,NIC,IA,DT1.2,L,BE,N,0.9226050955731167 +2020,NIC,IA,DT1.2,C,BE,N,0.9226050955731167 +2020,NIC,CF,DT1.2,L,BE,N,-300 +2020,NIC,CF,DT1.2,C,BE,N,-300 +,PR,BOP,DT1.3,L,BE,N,-798.536731161375 +,NIC,BOP,DT1.3,L,BE,N,598.7529445986629 +,PR,BOP,DT1.3,C,BE,N,-798.536731161375 +,NIC,BOP,DT1.3,C,BE,N,598.7529445986629 +,PR,EOP,DT1.3,L,BE,C,-399.63392949885525 +,NIC,EOP,DT1.3,L,BE,C,299.67554969423594 +,PR,EOP,DT1.3,C,BE,C,-399.63392949885525 +,NIC,EOP,DT1.3,C,BE,C,299.67554969423594 +,PR,IA,DT1.3,L,BE,N,-1.0971983374806105 +,NIC,IA,DT1.3,L,BE,N,0.9226050955731167 +,PR,IA,DT1.3,C,BE,N,-1.0971983374806105 +,NIC,IA,DT1.3,C,BE,N,0.9226050955731167 +,PR,CF,DT1.3,L,BE,N,400 +,NIC,CF,DT1.3,L,BE,N,-300 +,PR,CF,DT1.3,C,BE,N,400 +,NIC,CF,DT1.3,C,BE,N,-300 +,PR,BOP,DT2.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT2.1,L,BE,N,598.7529445986629 +,PR,BOP,DT2.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT2.1,C,BE,N,598.7529445986629 +,PR,EOP,DT2.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT2.1,L,BE,C,299.67554969423594 +,PR,EOP,DT2.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT2.1,C,BE,C,299.67554969423594 +,PR,IA,DT2.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT2.1,L,BE,N,0.9226050955731167 +,PR,IA,DT2.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT2.1,C,BE,N,0.9226050955731167 +,PR,CF,DT2.1,L,BE,N,400 +,NIC,CF,DT2.1,L,BE,N,-300 +,PR,CF,DT2.1,C,BE,N,400 +,NIC,CF,DT2.1,C,BE,N,-300 +2020,NIC,BOP,DT2.2,L,BE,N,598.7529445986629 +2020,NIC,BOP,DT2.2,C,BE,N,598.7529445986629 +2020,NIC,EOP,DT2.2,L,BE,C,299.67554969423594 +2020,NIC,EOP,DT2.2,C,BE,C,299.67554969423594 +2020,NIC,IA,DT2.2,L,BE,N,0.9226050955731167 +2020,NIC,IA,DT2.2,C,BE,N,0.9226050955731167 +2020,NIC,CF,DT2.2,L,BE,N,-300 +2020,NIC,CF,DT2.2,C,BE,N,-300 +,PR,BOP,DTR1.1,L,BE,N,399.2683655806875 +,NIC,BOP,DTR1.1,L,BE,N,-299.37647229933145 +,CDR,BOP,DTR1.1,L,BE,N,0.4811341181992343 +,PR,BOP,DTR1.1,C,BE,N,399.2683655806875 +,NIC,BOP,DTR1.1,C,BE,N,-299.37647229933145 +,CDR,BOP,DTR1.1,C,BE,N,0.4811341181992343 +,PR,EOP,DTR1.1,L,BE,C,199.81696474942763 +,NIC,EOP,DTR1.1,L,BE,C,-149.83777484711797 +,CDR,EOP,DTR1.1,L,BE,C,0.11527160395198197 +,PR,EOP,DTR1.1,C,BE,C,199.81696474942763 +,NIC,EOP,DTR1.1,C,BE,C,-149.83777484711797 +,CDR,EOP,DTR1.1,C,BE,C,0.11527160395198197 +,PR,IA,DTR1.1,L,BE,N,0.5485991687403052 +,NIC,IA,DTR1.1,L,BE,N,-0.4613025477865583 +,CDR,IA,DTR1.1,L,BE,N,0.0011701910454977593 +,PR,IA,DTR1.1,C,BE,N,0.5485991687403052 +,NIC,IA,DTR1.1,C,BE,N,-0.4613025477865583 +,CDR,IA,DTR1.1,C,BE,N,0.0011701910454977593 +,PR,CF,DTR1.1,L,BE,N,-200 +,NIC,CF,DTR1.1,L,BE,N,150 +,CDR,CF,DTR1.1,L,BE,N,-0.36703270529272203 +,PR,CF,DTR1.1,C,BE,N,-200 +,NIC,CF,DTR1.1,C,BE,N,150 +,CDR,CF,DTR1.1,C,BE,N,-0.36703270529272203 +2020,NIC,BOP,DTR1.2,L,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR1.2,L,BE,N,0.4811341181992343 +2020,NIC,BOP,DTR1.2,C,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR1.2,C,BE,N,0.4811341181992343 +2020,NIC,EOP,DTR1.2,L,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR1.2,L,BE,C,0.11527160395198197 +2020,NIC,EOP,DTR1.2,C,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR1.2,C,BE,C,0.11527160395198197 +2020,NIC,IA,DTR1.2,L,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR1.2,L,BE,N,0.0011701910454977593 +2020,NIC,IA,DTR1.2,C,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR1.2,C,BE,N,0.0011701910454977593 +2020,NIC,CF,DTR1.2,L,BE,N,150 +2020,CDR,CF,DTR1.2,L,BE,N,-0.36703270529272203 +2020,NIC,CF,DTR1.2,C,BE,N,150 +2020,CDR,CF,DTR1.2,C,BE,N,-0.36703270529272203 +,PR,BOP,DTR2.1,L,BE,N,399.2683655806875 +,NIC,BOP,DTR2.1,L,BE,N,-299.37647229933145 +,CDR,BOP,DTR2.1,L,BE,N,0.4811341181992343 +,PR,BOP,DTR2.1,C,BE,N,399.2683655806875 +,NIC,BOP,DTR2.1,C,BE,N,-299.37647229933145 +,CDR,BOP,DTR2.1,C,BE,N,0.4811341181992343 +,PR,EOP,DTR2.1,L,BE,C,199.81696474942763 +,NIC,EOP,DTR2.1,L,BE,C,-149.83777484711797 +,CDR,EOP,DTR2.1,L,BE,C,0.11527160395198197 +,PR,EOP,DTR2.1,C,BE,C,199.81696474942763 +,NIC,EOP,DTR2.1,C,BE,C,-149.83777484711797 +,CDR,EOP,DTR2.1,C,BE,C,0.11527160395198197 +,PR,IA,DTR2.1,L,BE,N,0.5485991687403052 +,NIC,IA,DTR2.1,L,BE,N,-0.4613025477865583 +,CDR,IA,DTR2.1,L,BE,N,0.0011701910454977593 +,PR,IA,DTR2.1,C,BE,N,0.5485991687403052 +,NIC,IA,DTR2.1,C,BE,N,-0.4613025477865583 +,CDR,IA,DTR2.1,C,BE,N,0.0011701910454977593 +,PR,CF,DTR2.1,L,BE,N,-200 +,NIC,CF,DTR2.1,L,BE,N,150 +,CDR,CF,DTR2.1,L,BE,N,-0.36703270529272203 +,PR,CF,DTR2.1,C,BE,N,-200 +,NIC,CF,DTR2.1,C,BE,N,150 +,CDR,CF,DTR2.1,C,BE,N,-0.36703270529272203 +2020,NIC,BOP,DTR2.2,L,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR2.2,L,BE,N,0.4811341181992343 +2020,NIC,BOP,DTR2.2,C,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR2.2,C,BE,N,0.4811341181992343 +2020,NIC,EOP,DTR2.2,L,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR2.2,L,BE,C,0.11527160395198197 +2020,NIC,EOP,DTR2.2,C,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR2.2,C,BE,C,0.11527160395198197 +2020,NIC,IA,DTR2.2,L,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR2.2,L,BE,N,0.0011701910454977593 +2020,NIC,IA,DTR2.2,C,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR2.2,C,BE,N,0.0011701910454977593 +2020,NIC,CF,DTR2.2,L,BE,N,150 +2020,CDR,CF,DTR2.2,L,BE,N,-0.36703270529272203 +2020,NIC,CF,DTR2.2,C,BE,N,150 +2020,CDR,CF,DTR2.2,C,BE,N,-0.36703270529272203 +,PR,BOP,DT3.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT3.1,L,BE,N,598.7529445986629 +,PR,BOP,DT3.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT3.1,C,BE,N,598.7529445986629 +,PR,EOP,DT3.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT3.1,L,BE,C,299.67554969423594 +,PR,EOP,DT3.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT3.1,C,BE,C,299.67554969423594 +,PR,IA,DT3.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT3.1,L,BE,N,0.9226050955731167 +,PR,IA,DT3.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT3.1,C,BE,N,0.9226050955731167 +,PR,CF,DT3.1,L,BE,N,400 +,NIC,CF,DT3.1,L,BE,N,-300 +,PR,CF,DT3.1,C,BE,N,400 +,NIC,CF,DT3.1,C,BE,N,-300 +,PR,BOP,DT4.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT4.1,L,BE,N,598.7529445986629 +,PR,BOP,DT4.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT4.1,C,BE,N,598.7529445986629 +,PR,EOP,DT4.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT4.1,L,BE,C,299.67554969423594 +,PR,EOP,DT4.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT4.1,C,BE,C,299.67554969423594 +,PR,IA,DT4.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT4.1,L,BE,N,0.9226050955731167 +,PR,IA,DT4.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT4.1,C,BE,N,0.9226050955731167 +,PR,CF,DT4.1,L,BE,N,400 +,NIC,CF,DT4.1,L,BE,N,-300 +,PR,CF,DT4.1,C,BE,N,400 +,NIC,CF,DT4.1,C,BE,N,-300 \ No newline at end of file From c6513dac8ce2d4b7d1e8a366940da38610d405b0 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Mon, 17 Oct 2022 11:40:48 +0200 Subject: [PATCH 04/23] testing ifrsvariables --- .../Test/BM_CH_2020_12_BE_SCE.csv | 181 ++++++++++++++++++ .../Test/IfrsVariablesTest.ipynb | 2 + ifrs17/Constants/Consts.ipynb | 8 + ifrs17/Import/ImportStorage.ipynb | 17 +- ifrs17/Utils/Queries.ipynb | 56 +++++- 5 files changed, 257 insertions(+), 7 deletions(-) create mode 100644 full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv diff --git a/full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv b/full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv new file mode 100644 index 00000000..a2e38ab9 --- /dev/null +++ b/full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv @@ -0,0 +1,181 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,IR+,2020 +@@BE +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,PR,BOP,DT1.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT1.1,L,BE,N,598.7529445986629 +,PR,BOP,DT1.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT1.1,C,BE,N,598.7529445986629 +,PR,EOP,DT1.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT1.1,L,BE,C,299.67554969423594 +,PR,EOP,DT1.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT1.1,C,BE,C,299.67554969423594 +,PR,IA,DT1.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT1.1,L,BE,N,0.9226050955731167 +,PR,IA,DT1.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT1.1,C,BE,N,0.9226050955731167 +,PR,CF,DT1.1,L,BE,N,400 +,NIC,CF,DT1.1,L,BE,N,-300 +,PR,CF,DT1.1,C,BE,N,400 +,NIC,CF,DT1.1,C,BE,N,-300 +2020,NIC,BOP,DT1.2,L,BE,N,598.7529445986629 +2020,NIC,BOP,DT1.2,C,BE,N,598.7529445986629 +2020,NIC,EOP,DT1.2,L,BE,C,299.67554969423594 +2020,NIC,EOP,DT1.2,C,BE,C,299.67554969423594 +2020,NIC,IA,DT1.2,L,BE,N,0.9226050955731167 +2020,NIC,IA,DT1.2,C,BE,N,0.9226050955731167 +2020,NIC,CF,DT1.2,L,BE,N,-300 +2020,NIC,CF,DT1.2,C,BE,N,-300 +,PR,BOP,DT1.3,L,BE,N,-798.536731161375 +,NIC,BOP,DT1.3,L,BE,N,598.7529445986629 +,PR,BOP,DT1.3,C,BE,N,-798.536731161375 +,NIC,BOP,DT1.3,C,BE,N,598.7529445986629 +,PR,EOP,DT1.3,L,BE,C,-399.63392949885525 +,NIC,EOP,DT1.3,L,BE,C,299.67554969423594 +,PR,EOP,DT1.3,C,BE,C,-399.63392949885525 +,NIC,EOP,DT1.3,C,BE,C,299.67554969423594 +,PR,IA,DT1.3,L,BE,N,-1.0971983374806105 +,NIC,IA,DT1.3,L,BE,N,0.9226050955731167 +,PR,IA,DT1.3,C,BE,N,-1.0971983374806105 +,NIC,IA,DT1.3,C,BE,N,0.9226050955731167 +,PR,CF,DT1.3,L,BE,N,400 +,NIC,CF,DT1.3,L,BE,N,-300 +,PR,CF,DT1.3,C,BE,N,400 +,NIC,CF,DT1.3,C,BE,N,-300 +,PR,BOP,DT2.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT2.1,L,BE,N,598.7529445986629 +,PR,BOP,DT2.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT2.1,C,BE,N,598.7529445986629 +,PR,EOP,DT2.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT2.1,L,BE,C,299.67554969423594 +,PR,EOP,DT2.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT2.1,C,BE,C,299.67554969423594 +,PR,IA,DT2.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT2.1,L,BE,N,0.9226050955731167 +,PR,IA,DT2.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT2.1,C,BE,N,0.9226050955731167 +,PR,CF,DT2.1,L,BE,N,400 +,NIC,CF,DT2.1,L,BE,N,-300 +,PR,CF,DT2.1,C,BE,N,400 +,NIC,CF,DT2.1,C,BE,N,-300 +2020,NIC,BOP,DT2.2,L,BE,N,598.7529445986629 +2020,NIC,BOP,DT2.2,C,BE,N,598.7529445986629 +2020,NIC,EOP,DT2.2,L,BE,C,299.67554969423594 +2020,NIC,EOP,DT2.2,C,BE,C,299.67554969423594 +2020,NIC,IA,DT2.2,L,BE,N,0.9226050955731167 +2020,NIC,IA,DT2.2,C,BE,N,0.9226050955731167 +2020,NIC,CF,DT2.2,L,BE,N,-300 +2020,NIC,CF,DT2.2,C,BE,N,-300 +,PR,BOP,DTR1.1,L,BE,N,399.2683655806875 +,NIC,BOP,DTR1.1,L,BE,N,-299.37647229933145 +,CDR,BOP,DTR1.1,L,BE,N,0.4811341181992343 +,PR,BOP,DTR1.1,C,BE,N,399.2683655806875 +,NIC,BOP,DTR1.1,C,BE,N,-299.37647229933145 +,CDR,BOP,DTR1.1,C,BE,N,0.4811341181992343 +,PR,EOP,DTR1.1,L,BE,C,199.81696474942763 +,NIC,EOP,DTR1.1,L,BE,C,-149.83777484711797 +,CDR,EOP,DTR1.1,L,BE,C,0.11527160395198197 +,PR,EOP,DTR1.1,C,BE,C,199.81696474942763 +,NIC,EOP,DTR1.1,C,BE,C,-149.83777484711797 +,CDR,EOP,DTR1.1,C,BE,C,0.11527160395198197 +,PR,IA,DTR1.1,L,BE,N,0.5485991687403052 +,NIC,IA,DTR1.1,L,BE,N,-0.4613025477865583 +,CDR,IA,DTR1.1,L,BE,N,0.0011701910454977593 +,PR,IA,DTR1.1,C,BE,N,0.5485991687403052 +,NIC,IA,DTR1.1,C,BE,N,-0.4613025477865583 +,CDR,IA,DTR1.1,C,BE,N,0.0011701910454977593 +,PR,CF,DTR1.1,L,BE,N,-200 +,NIC,CF,DTR1.1,L,BE,N,150 +,CDR,CF,DTR1.1,L,BE,N,-0.36703270529272203 +,PR,CF,DTR1.1,C,BE,N,-200 +,NIC,CF,DTR1.1,C,BE,N,150 +,CDR,CF,DTR1.1,C,BE,N,-0.36703270529272203 +2020,NIC,BOP,DTR1.2,L,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR1.2,L,BE,N,0.4811341181992343 +2020,NIC,BOP,DTR1.2,C,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR1.2,C,BE,N,0.4811341181992343 +2020,NIC,EOP,DTR1.2,L,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR1.2,L,BE,C,0.11527160395198197 +2020,NIC,EOP,DTR1.2,C,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR1.2,C,BE,C,0.11527160395198197 +2020,NIC,IA,DTR1.2,L,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR1.2,L,BE,N,0.0011701910454977593 +2020,NIC,IA,DTR1.2,C,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR1.2,C,BE,N,0.0011701910454977593 +2020,NIC,CF,DTR1.2,L,BE,N,150 +2020,CDR,CF,DTR1.2,L,BE,N,-0.36703270529272203 +2020,NIC,CF,DTR1.2,C,BE,N,150 +2020,CDR,CF,DTR1.2,C,BE,N,-0.36703270529272203 +,PR,BOP,DTR2.1,L,BE,N,399.2683655806875 +,NIC,BOP,DTR2.1,L,BE,N,-299.37647229933145 +,CDR,BOP,DTR2.1,L,BE,N,0.4811341181992343 +,PR,BOP,DTR2.1,C,BE,N,399.2683655806875 +,NIC,BOP,DTR2.1,C,BE,N,-299.37647229933145 +,CDR,BOP,DTR2.1,C,BE,N,0.4811341181992343 +,PR,EOP,DTR2.1,L,BE,C,199.81696474942763 +,NIC,EOP,DTR2.1,L,BE,C,-149.83777484711797 +,CDR,EOP,DTR2.1,L,BE,C,0.11527160395198197 +,PR,EOP,DTR2.1,C,BE,C,199.81696474942763 +,NIC,EOP,DTR2.1,C,BE,C,-149.83777484711797 +,CDR,EOP,DTR2.1,C,BE,C,0.11527160395198197 +,PR,IA,DTR2.1,L,BE,N,0.5485991687403052 +,NIC,IA,DTR2.1,L,BE,N,-0.4613025477865583 +,CDR,IA,DTR2.1,L,BE,N,0.0011701910454977593 +,PR,IA,DTR2.1,C,BE,N,0.5485991687403052 +,NIC,IA,DTR2.1,C,BE,N,-0.4613025477865583 +,CDR,IA,DTR2.1,C,BE,N,0.0011701910454977593 +,PR,CF,DTR2.1,L,BE,N,-200 +,NIC,CF,DTR2.1,L,BE,N,150 +,CDR,CF,DTR2.1,L,BE,N,-0.36703270529272203 +,PR,CF,DTR2.1,C,BE,N,-200 +,NIC,CF,DTR2.1,C,BE,N,150 +,CDR,CF,DTR2.1,C,BE,N,-0.36703270529272203 +2020,NIC,BOP,DTR2.2,L,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR2.2,L,BE,N,0.4811341181992343 +2020,NIC,BOP,DTR2.2,C,BE,N,-299.37647229933145 +2020,CDR,BOP,DTR2.2,C,BE,N,0.4811341181992343 +2020,NIC,EOP,DTR2.2,L,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR2.2,L,BE,C,0.11527160395198197 +2020,NIC,EOP,DTR2.2,C,BE,C,-149.83777484711797 +2020,CDR,EOP,DTR2.2,C,BE,C,0.11527160395198197 +2020,NIC,IA,DTR2.2,L,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR2.2,L,BE,N,0.0011701910454977593 +2020,NIC,IA,DTR2.2,C,BE,N,-0.4613025477865583 +2020,CDR,IA,DTR2.2,C,BE,N,0.0011701910454977593 +2020,NIC,CF,DTR2.2,L,BE,N,150 +2020,CDR,CF,DTR2.2,L,BE,N,-0.36703270529272203 +2020,NIC,CF,DTR2.2,C,BE,N,150 +2020,CDR,CF,DTR2.2,C,BE,N,-0.36703270529272203 +,PR,BOP,DT3.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT3.1,L,BE,N,598.7529445986629 +,PR,BOP,DT3.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT3.1,C,BE,N,598.7529445986629 +,PR,EOP,DT3.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT3.1,L,BE,C,299.67554969423594 +,PR,EOP,DT3.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT3.1,C,BE,C,299.67554969423594 +,PR,IA,DT3.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT3.1,L,BE,N,0.9226050955731167 +,PR,IA,DT3.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT3.1,C,BE,N,0.9226050955731167 +,PR,CF,DT3.1,L,BE,N,400 +,NIC,CF,DT3.1,L,BE,N,-300 +,PR,CF,DT3.1,C,BE,N,400 +,NIC,CF,DT3.1,C,BE,N,-300 +,PR,BOP,DT4.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT4.1,L,BE,N,598.7529445986629 +,PR,BOP,DT4.1,C,BE,N,-798.536731161375 +,NIC,BOP,DT4.1,C,BE,N,598.7529445986629 +,PR,EOP,DT4.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT4.1,L,BE,C,299.67554969423594 +,PR,EOP,DT4.1,C,BE,C,-399.63392949885525 +,NIC,EOP,DT4.1,C,BE,C,299.67554969423594 +,PR,IA,DT4.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT4.1,L,BE,N,0.9226050955731167 +,PR,IA,DT4.1,C,BE,N,-1.0971983374806105 +,NIC,IA,DT4.1,C,BE,N,0.9226050955731167 +,PR,CF,DT4.1,L,BE,N,400 +,NIC,CF,DT4.1,L,BE,N,-300 +,PR,CF,DT4.1,C,BE,N,400 +,NIC,CF,DT4.1,C,BE,N,-300 \ No newline at end of file diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index adcea130..fa97b787 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -77,6 +77,8 @@ "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_OA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_OAPA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_RA.csv\" , \"CH\", 2021, 3),", + "\n // 2020 with Scenario", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_BE_SCE.csv\" , \"CH\", 2020, 12),", "\n};" ] }, diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 79179ff2..262523ec 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -252,6 +252,14 @@ "\n}" ] }, + { + "cell_type": "code", + "source": [ + "public static class Scenarios{", + "\n public const string IRU = nameof(IRU); // Interest Rate Up", + "\n}" + ] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 8dc36adc..0b403fc9 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -71,8 +71,8 @@ "\n public string ImportFormat => args.ImportFormat; ", "\n ", "\n //Time Periods ", - "\n public (int Year, int Month) CurrentReportingPeriod => (args.Year, args.Month);", - "\n public (int Year, int Month) PreviousReportingPeriod => (args.Year - 1, MonthInAYear); // YTD Logic", + "\n ////public (int Year, int Month) CurrentReportingPeriod => (args.Year, args.Month);", + "\n //public (int Year, int Month) PreviousReportingPeriod => (args.Year - 1, MonthInAYear); // YTD Logic", "\n", "\n //Partitions", "\n public Guid PartitionByRn;", @@ -148,6 +148,7 @@ "\n ", "\n //Get Partitions", "\n PartitionByRn = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode).ToArrayAsync()).Single().Id;", + "\n /*", "\n TargetPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", "\n p.Year == CurrentReportingPeriod.Year &&", "\n p.Month == CurrentReportingPeriod.Month &&", @@ -156,10 +157,14 @@ "\n p.Year == CurrentReportingPeriod.Year &&", "\n p.Month == CurrentReportingPeriod.Month &&", "\n p.Scenario == null).ToArrayAsync()).Single().Id;", + "\n */", "\n //Set Partitions", "\n await querySource.Partition.SetAsync(PartitionByRn);", "\n await workspace.Partition.SetAsync(PartitionByRn);", - "\n ", + "\n", + "\n (TargetPartition, DefaultPartition, PreviousPeriodPartition) = await querySource.LoadPartitionsYTDAsync(args);", + "\n", + "\n", "\n await querySource.Partition.SetAsync(TargetPartition);", "\n await workspace.Partition.SetAsync(TargetPartition);", "\n ", @@ -214,13 +219,14 @@ "\n var openingIfrsVariables = Enumerable.Empty();", "\n", "\n if(allImportScopes.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year < args.Year)) {", + "\n /*", "\n PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", "\n p.Year == PreviousReportingPeriod.Year &&", "\n p.Month == PreviousReportingPeriod.Month &&", "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n ", + "\n */", "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", - "\n ", + "\n ", "\n //Perform queries to previous Period", "\n openingRawVariables = (await querySource.Query()", "\n .Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == AocTypes.CL)", @@ -253,6 +259,7 @@ "\n .Where(rv => rv.Partition == TargetPartition)", "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", "\n .ToArrayAsync());", + "\n", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", "\n ", "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index e8500833..8ba3c880 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -117,7 +117,7 @@ "\n var inner = ret.GetOrAdd(p.Key, _ => new Dictionary());", "\n", "\n var currentCandidate = p.Where(x => x.Year == args.Year).OrderByDescending(x => x.Month).ThenByDescending(x => x.Scenario).FirstOrDefault();", - "\n var previousCandidate = p.Where(x => x.Year < args.Year).Where(x => x.Scenario == null).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", + "\n var previousCandidate = p.Where(x => x.Year < args.Year && x.Scenario == null).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", "\n ", "\n inner.Add(CurrentPeriod, currentCandidate != null ? currentCandidate : previousCandidate);", "\n inner.Add(PreviousPeriod, previousCandidate != null ? previousCandidate : currentCandidate);", @@ -314,10 +314,62 @@ "\n .ToDictionary(x => new AocStep(x.AocType, x.Novelty)); " ] }, + { + "cell_type": "markdown", + "source": [ + "# Actuarial Variables (Raw and IFRS)" + ] + }, + { + "cell_type": "code", + "source": [ + "/*public static async Task LoadOpeningVariables(", + "\n this IDataSource querySource, ", + "\n Args args,", + "\n HashSet dataNodesInScopes,", + "\n Guid targetPartition,", + "\n string aocType)", + "\n where T : BaseDataRecord", + "\n => (await querySource.Query().Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == aocType)", + "\n .Where(rv => dataNodesInScopes.Contains(rv.DataNode)).ToArrayAsync());", + "\n*/" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Partitions" + ] + }, + { + "cell_type": "code", + "source": [ + "public static async Task LoadPartitionAsync(", + "\n this IDataSource querySource, ", + "\n string reportingNode, ", + "\n int year, ", + "\n int month, ", + "\n string scenario) => (await querySource.Query()", + "\n .Where(p => p.ReportingNode == reportingNode &&", + "\n p.Year == year &&", + "\n p.Month == month &&", + "\n p.Scenario == scenario).ToArrayAsync()).Single().Id;", + "\n" + ] + }, { "cell_type": "code", "source": [ - "" + "public static async Task<(Guid, Guid, Guid)> LoadPartitionsYTDAsync(", + "\n this IDataSource querySource, ", + "\n Args args)", + "\n{", + "\n var targetPartition = await querySource.LoadPartitionAsync(args.ReportingNode, args.Year, args.Month, args.Scenario);", + "\n var defaultPartition = await querySource.LoadPartitionAsync(args.ReportingNode, args.Year, args.Month, null);", + "\n var previousPartition = await querySource.LoadPartitionAsync(args.ReportingNode, args.Year - 1, MonthInAYear, null); // YTD Logic", + "\n", + "\n return (targetPartition, defaultPartition, previousPartition);", + "\n}" ] } ] From 26970b437d6222d2fb37a26a6a5f69802833d743 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Tue, 18 Oct 2022 11:35:28 +0200 Subject: [PATCH 05/23] testing IfrsVariables calculations --- .../800.Parameters/YieldCurveScenario.csv | 20 + .../NominalCashflows_CH_2020_12_Scenario.csv | 85 +++++ .../Files/DimensionsAndPartitions.csv | 1 + .../Test/BM_CH_2020_12_BE_SCE.csv | 181 --------- .../BM_CH_2020_12_BE_SCE.csv | 360 +++++++++--------- .../Test/IfrsVariablesTest.ipynb | 6 +- full-ifrs17-template/Test/ScenarioTest.ipynb | 88 +++++ ifrs17/Import/ImportStorage.ipynb | 19 +- 8 files changed, 383 insertions(+), 377 deletions(-) create mode 100644 full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv create mode 100644 full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv delete mode 100644 full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv create mode 100644 full-ifrs17-template/Test/ScenarioTest.ipynb diff --git a/full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv b/full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv new file mode 100644 index 00000000..2cc8521d --- /dev/null +++ b/full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv @@ -0,0 +1,20 @@ +@@YieldCurve,,,,,,,,,, +Currency,Year,Month,Scenario,Values0,Values1,Values2,Values3,,, +EUR,2020,3,,0.008685495,0.008685495,0.018498471,0.019966839,,, +CHF,2020,3,,0.002,0.002,0.002,0.002,,, +CHF,2021,3,,0.1,0.1,0.1,0.1,,, +USD,2021,3,,0.005,0.005,0.005,0.005,,, +USD,2020,12,,0.002,0.002,0.002,0.002,,, +USD,2020,3,,0.002,0.002,0.002,0.002,,, +USD,2020,1,,0.002,0.002,0.002,0.002,,, +GBP,2021,3,,0.005,0.005,0.005,0.005,,, +GBP,2020,3,,0.002,0.002,0.002,0.002,,, +EUR,2020,3,IRU,0.009554045,0.009554045,0.020348318,0.021963523,,, +CHF,2020,3,IRU,0.0022,0.0022,0.0022,0.0022,,, +CHF,2021,3,IRU,0.11,0.11,0.11,0.11,,, +USD,2021,3,IRU,0.0055,0.0055,0.0055,0.0055,,, +USD,2020,12,IRU,0.0022,0.0022,0.0022,0.0022,,, +USD,2020,3,IRU,0.0022,0.0022,0.0022,0.0022,,, +USD,2020,1,IRU,0.0022,0.0022,0.0022,0.0022,,, +GBP,2021,3,IRU,0.0055,0.0055,0.0055,0.0055,,, +GBP,2020,3,IRU,0.0022,0.0022,0.0022,0.0022,,, diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv new file mode 100644 index 00000000..380f8ef1 --- /dev/null +++ b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv @@ -0,0 +1,85 @@ +@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, +CH,2020,12,IRU,,,,,,,,,,,,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, +DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 +DT1.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT1.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT1.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT1.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT1.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT1.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT1.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT1.2,NIC,BOP,N,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT1.2,CU,BOP,N,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT1.2,RA,BOP,N,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT1.2,NIC,CL,C,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT1.2,CU,CL,C,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT1.2,RA,CL,C,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT1.3,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT1.3,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT1.3,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT1.3,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT1.3,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT1.3,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT1.3,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT1.3,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT2.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT2.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT2.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT2.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT2.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT2.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT2.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT2.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT2.2,NIC,BOP,N,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT2.2,CU,BOP,N,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT2.2,RA,BOP,N,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT2.2,NIC,CL,C,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT2.2,CU,CL,C,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT2.2,RA,CL,C,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DTR1.1,PR,BOP,N,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 +DTR1.1,NIC,BOP,N,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR1.1,CU,BOP,N,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR1.1,RA,BOP,N,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR1.1,PR,CL,C,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 +DTR1.1,NIC,CL,C,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR1.1,CU,CL,C,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR1.1,RA,CL,C,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR1.2,NIC,BOP,N,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR1.2,CU,BOP,N,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR1.2,RA,BOP,N,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR1.2,NIC,CL,C,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR1.2,CU,CL,C,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR1.2,RA,CL,C,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR2.1,PR,BOP,N,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 +DTR2.1,NIC,BOP,N,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR2.1,CU,BOP,N,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR2.1,RA,BOP,N,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR2.1,PR,CL,C,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 +DTR2.1,NIC,CL,C,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR2.1,CU,CL,C,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR2.1,RA,CL,C,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR2.2,NIC,BOP,N,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR2.2,CU,BOP,N,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR2.2,RA,BOP,N,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DTR2.2,NIC,CL,C,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 +DTR2.2,CU,CL,C,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 +DTR2.2,RA,CL,C,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 +DT3.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT3.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT3.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT3.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT3.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT3.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT3.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT3.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT4.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT4.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT4.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT4.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 +DT4.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 +DT4.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 +DT4.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 +DT4.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 diff --git a/full-ifrs17-template/Files/DimensionsAndPartitions.csv b/full-ifrs17-template/Files/DimensionsAndPartitions.csv index bcfe9d1d..1e9f58cf 100644 --- a/full-ifrs17-template/Files/DimensionsAndPartitions.csv +++ b/full-ifrs17-template/Files/DimensionsAndPartitions.csv @@ -215,6 +215,7 @@ Default,Default,,,,,,,,,, @@Scenario,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, BE,Best Estimate,,,,,,,,,, +IRU,Interest Rate Up,,,,,,,,,, ,,,,,,,,,,, @@ValuationApproach,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, diff --git a/full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv b/full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv deleted file mode 100644 index a2e38ab9..00000000 --- a/full-ifrs17-template/Test/BM_CH_2020_12_BE_SCE.csv +++ /dev/null @@ -1,181 +0,0 @@ -@@Main -Month,ReportingNode,Scenario,Year -12,CH,IR+,2020 -@@BE -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,PR,BOP,DT1.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT1.1,L,BE,N,598.7529445986629 -,PR,BOP,DT1.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT1.1,C,BE,N,598.7529445986629 -,PR,EOP,DT1.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT1.1,L,BE,C,299.67554969423594 -,PR,EOP,DT1.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT1.1,C,BE,C,299.67554969423594 -,PR,IA,DT1.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT1.1,L,BE,N,0.9226050955731167 -,PR,IA,DT1.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT1.1,C,BE,N,0.9226050955731167 -,PR,CF,DT1.1,L,BE,N,400 -,NIC,CF,DT1.1,L,BE,N,-300 -,PR,CF,DT1.1,C,BE,N,400 -,NIC,CF,DT1.1,C,BE,N,-300 -2020,NIC,BOP,DT1.2,L,BE,N,598.7529445986629 -2020,NIC,BOP,DT1.2,C,BE,N,598.7529445986629 -2020,NIC,EOP,DT1.2,L,BE,C,299.67554969423594 -2020,NIC,EOP,DT1.2,C,BE,C,299.67554969423594 -2020,NIC,IA,DT1.2,L,BE,N,0.9226050955731167 -2020,NIC,IA,DT1.2,C,BE,N,0.9226050955731167 -2020,NIC,CF,DT1.2,L,BE,N,-300 -2020,NIC,CF,DT1.2,C,BE,N,-300 -,PR,BOP,DT1.3,L,BE,N,-798.536731161375 -,NIC,BOP,DT1.3,L,BE,N,598.7529445986629 -,PR,BOP,DT1.3,C,BE,N,-798.536731161375 -,NIC,BOP,DT1.3,C,BE,N,598.7529445986629 -,PR,EOP,DT1.3,L,BE,C,-399.63392949885525 -,NIC,EOP,DT1.3,L,BE,C,299.67554969423594 -,PR,EOP,DT1.3,C,BE,C,-399.63392949885525 -,NIC,EOP,DT1.3,C,BE,C,299.67554969423594 -,PR,IA,DT1.3,L,BE,N,-1.0971983374806105 -,NIC,IA,DT1.3,L,BE,N,0.9226050955731167 -,PR,IA,DT1.3,C,BE,N,-1.0971983374806105 -,NIC,IA,DT1.3,C,BE,N,0.9226050955731167 -,PR,CF,DT1.3,L,BE,N,400 -,NIC,CF,DT1.3,L,BE,N,-300 -,PR,CF,DT1.3,C,BE,N,400 -,NIC,CF,DT1.3,C,BE,N,-300 -,PR,BOP,DT2.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT2.1,L,BE,N,598.7529445986629 -,PR,BOP,DT2.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT2.1,C,BE,N,598.7529445986629 -,PR,EOP,DT2.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT2.1,L,BE,C,299.67554969423594 -,PR,EOP,DT2.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT2.1,C,BE,C,299.67554969423594 -,PR,IA,DT2.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT2.1,L,BE,N,0.9226050955731167 -,PR,IA,DT2.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT2.1,C,BE,N,0.9226050955731167 -,PR,CF,DT2.1,L,BE,N,400 -,NIC,CF,DT2.1,L,BE,N,-300 -,PR,CF,DT2.1,C,BE,N,400 -,NIC,CF,DT2.1,C,BE,N,-300 -2020,NIC,BOP,DT2.2,L,BE,N,598.7529445986629 -2020,NIC,BOP,DT2.2,C,BE,N,598.7529445986629 -2020,NIC,EOP,DT2.2,L,BE,C,299.67554969423594 -2020,NIC,EOP,DT2.2,C,BE,C,299.67554969423594 -2020,NIC,IA,DT2.2,L,BE,N,0.9226050955731167 -2020,NIC,IA,DT2.2,C,BE,N,0.9226050955731167 -2020,NIC,CF,DT2.2,L,BE,N,-300 -2020,NIC,CF,DT2.2,C,BE,N,-300 -,PR,BOP,DTR1.1,L,BE,N,399.2683655806875 -,NIC,BOP,DTR1.1,L,BE,N,-299.37647229933145 -,CDR,BOP,DTR1.1,L,BE,N,0.4811341181992343 -,PR,BOP,DTR1.1,C,BE,N,399.2683655806875 -,NIC,BOP,DTR1.1,C,BE,N,-299.37647229933145 -,CDR,BOP,DTR1.1,C,BE,N,0.4811341181992343 -,PR,EOP,DTR1.1,L,BE,C,199.81696474942763 -,NIC,EOP,DTR1.1,L,BE,C,-149.83777484711797 -,CDR,EOP,DTR1.1,L,BE,C,0.11527160395198197 -,PR,EOP,DTR1.1,C,BE,C,199.81696474942763 -,NIC,EOP,DTR1.1,C,BE,C,-149.83777484711797 -,CDR,EOP,DTR1.1,C,BE,C,0.11527160395198197 -,PR,IA,DTR1.1,L,BE,N,0.5485991687403052 -,NIC,IA,DTR1.1,L,BE,N,-0.4613025477865583 -,CDR,IA,DTR1.1,L,BE,N,0.0011701910454977593 -,PR,IA,DTR1.1,C,BE,N,0.5485991687403052 -,NIC,IA,DTR1.1,C,BE,N,-0.4613025477865583 -,CDR,IA,DTR1.1,C,BE,N,0.0011701910454977593 -,PR,CF,DTR1.1,L,BE,N,-200 -,NIC,CF,DTR1.1,L,BE,N,150 -,CDR,CF,DTR1.1,L,BE,N,-0.36703270529272203 -,PR,CF,DTR1.1,C,BE,N,-200 -,NIC,CF,DTR1.1,C,BE,N,150 -,CDR,CF,DTR1.1,C,BE,N,-0.36703270529272203 -2020,NIC,BOP,DTR1.2,L,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR1.2,L,BE,N,0.4811341181992343 -2020,NIC,BOP,DTR1.2,C,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR1.2,C,BE,N,0.4811341181992343 -2020,NIC,EOP,DTR1.2,L,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR1.2,L,BE,C,0.11527160395198197 -2020,NIC,EOP,DTR1.2,C,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR1.2,C,BE,C,0.11527160395198197 -2020,NIC,IA,DTR1.2,L,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR1.2,L,BE,N,0.0011701910454977593 -2020,NIC,IA,DTR1.2,C,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR1.2,C,BE,N,0.0011701910454977593 -2020,NIC,CF,DTR1.2,L,BE,N,150 -2020,CDR,CF,DTR1.2,L,BE,N,-0.36703270529272203 -2020,NIC,CF,DTR1.2,C,BE,N,150 -2020,CDR,CF,DTR1.2,C,BE,N,-0.36703270529272203 -,PR,BOP,DTR2.1,L,BE,N,399.2683655806875 -,NIC,BOP,DTR2.1,L,BE,N,-299.37647229933145 -,CDR,BOP,DTR2.1,L,BE,N,0.4811341181992343 -,PR,BOP,DTR2.1,C,BE,N,399.2683655806875 -,NIC,BOP,DTR2.1,C,BE,N,-299.37647229933145 -,CDR,BOP,DTR2.1,C,BE,N,0.4811341181992343 -,PR,EOP,DTR2.1,L,BE,C,199.81696474942763 -,NIC,EOP,DTR2.1,L,BE,C,-149.83777484711797 -,CDR,EOP,DTR2.1,L,BE,C,0.11527160395198197 -,PR,EOP,DTR2.1,C,BE,C,199.81696474942763 -,NIC,EOP,DTR2.1,C,BE,C,-149.83777484711797 -,CDR,EOP,DTR2.1,C,BE,C,0.11527160395198197 -,PR,IA,DTR2.1,L,BE,N,0.5485991687403052 -,NIC,IA,DTR2.1,L,BE,N,-0.4613025477865583 -,CDR,IA,DTR2.1,L,BE,N,0.0011701910454977593 -,PR,IA,DTR2.1,C,BE,N,0.5485991687403052 -,NIC,IA,DTR2.1,C,BE,N,-0.4613025477865583 -,CDR,IA,DTR2.1,C,BE,N,0.0011701910454977593 -,PR,CF,DTR2.1,L,BE,N,-200 -,NIC,CF,DTR2.1,L,BE,N,150 -,CDR,CF,DTR2.1,L,BE,N,-0.36703270529272203 -,PR,CF,DTR2.1,C,BE,N,-200 -,NIC,CF,DTR2.1,C,BE,N,150 -,CDR,CF,DTR2.1,C,BE,N,-0.36703270529272203 -2020,NIC,BOP,DTR2.2,L,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR2.2,L,BE,N,0.4811341181992343 -2020,NIC,BOP,DTR2.2,C,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR2.2,C,BE,N,0.4811341181992343 -2020,NIC,EOP,DTR2.2,L,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR2.2,L,BE,C,0.11527160395198197 -2020,NIC,EOP,DTR2.2,C,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR2.2,C,BE,C,0.11527160395198197 -2020,NIC,IA,DTR2.2,L,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR2.2,L,BE,N,0.0011701910454977593 -2020,NIC,IA,DTR2.2,C,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR2.2,C,BE,N,0.0011701910454977593 -2020,NIC,CF,DTR2.2,L,BE,N,150 -2020,CDR,CF,DTR2.2,L,BE,N,-0.36703270529272203 -2020,NIC,CF,DTR2.2,C,BE,N,150 -2020,CDR,CF,DTR2.2,C,BE,N,-0.36703270529272203 -,PR,BOP,DT3.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT3.1,L,BE,N,598.7529445986629 -,PR,BOP,DT3.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT3.1,C,BE,N,598.7529445986629 -,PR,EOP,DT3.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT3.1,L,BE,C,299.67554969423594 -,PR,EOP,DT3.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT3.1,C,BE,C,299.67554969423594 -,PR,IA,DT3.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT3.1,L,BE,N,0.9226050955731167 -,PR,IA,DT3.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT3.1,C,BE,N,0.9226050955731167 -,PR,CF,DT3.1,L,BE,N,400 -,NIC,CF,DT3.1,L,BE,N,-300 -,PR,CF,DT3.1,C,BE,N,400 -,NIC,CF,DT3.1,C,BE,N,-300 -,PR,BOP,DT4.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT4.1,L,BE,N,598.7529445986629 -,PR,BOP,DT4.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT4.1,C,BE,N,598.7529445986629 -,PR,EOP,DT4.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT4.1,L,BE,C,299.67554969423594 -,PR,EOP,DT4.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT4.1,C,BE,C,299.67554969423594 -,PR,IA,DT4.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT4.1,L,BE,N,0.9226050955731167 -,PR,IA,DT4.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT4.1,C,BE,N,0.9226050955731167 -,PR,CF,DT4.1,L,BE,N,400 -,NIC,CF,DT4.1,L,BE,N,-300 -,PR,CF,DT4.1,C,BE,N,400 -,NIC,CF,DT4.1,C,BE,N,-300 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv index 8dbc1e48..caa8a430 100644 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv @@ -1,181 +1,181 @@ -@@Main -Month,ReportingNode,Scenario,Year -12,CH,,2020 -@@BE +@@Main,,,,,,, +Month,ReportingNode,Scenario,Year,,,, +12,CH,IRU,2020,,,, +@@BE,,,,,,, AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,PR,BOP,DT1.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT1.1,L,BE,N,598.7529445986629 -,PR,BOP,DT1.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT1.1,C,BE,N,598.7529445986629 -,PR,EOP,DT1.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT1.1,L,BE,C,299.67554969423594 -,PR,EOP,DT1.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT1.1,C,BE,C,299.67554969423594 -,PR,IA,DT1.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT1.1,L,BE,N,0.9226050955731167 -,PR,IA,DT1.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT1.1,C,BE,N,0.9226050955731167 -,PR,CF,DT1.1,L,BE,N,400 -,NIC,CF,DT1.1,L,BE,N,-300 -,PR,CF,DT1.1,C,BE,N,400 -,NIC,CF,DT1.1,C,BE,N,-300 -2020,NIC,BOP,DT1.2,L,BE,N,598.7529445986629 -2020,NIC,BOP,DT1.2,C,BE,N,598.7529445986629 -2020,NIC,EOP,DT1.2,L,BE,C,299.67554969423594 -2020,NIC,EOP,DT1.2,C,BE,C,299.67554969423594 -2020,NIC,IA,DT1.2,L,BE,N,0.9226050955731167 -2020,NIC,IA,DT1.2,C,BE,N,0.9226050955731167 -2020,NIC,CF,DT1.2,L,BE,N,-300 -2020,NIC,CF,DT1.2,C,BE,N,-300 -,PR,BOP,DT1.3,L,BE,N,-798.536731161375 -,NIC,BOP,DT1.3,L,BE,N,598.7529445986629 -,PR,BOP,DT1.3,C,BE,N,-798.536731161375 -,NIC,BOP,DT1.3,C,BE,N,598.7529445986629 -,PR,EOP,DT1.3,L,BE,C,-399.63392949885525 -,NIC,EOP,DT1.3,L,BE,C,299.67554969423594 -,PR,EOP,DT1.3,C,BE,C,-399.63392949885525 -,NIC,EOP,DT1.3,C,BE,C,299.67554969423594 -,PR,IA,DT1.3,L,BE,N,-1.0971983374806105 -,NIC,IA,DT1.3,L,BE,N,0.9226050955731167 -,PR,IA,DT1.3,C,BE,N,-1.0971983374806105 -,NIC,IA,DT1.3,C,BE,N,0.9226050955731167 -,PR,CF,DT1.3,L,BE,N,400 -,NIC,CF,DT1.3,L,BE,N,-300 -,PR,CF,DT1.3,C,BE,N,400 -,NIC,CF,DT1.3,C,BE,N,-300 -,PR,BOP,DT2.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT2.1,L,BE,N,598.7529445986629 -,PR,BOP,DT2.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT2.1,C,BE,N,598.7529445986629 -,PR,EOP,DT2.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT2.1,L,BE,C,299.67554969423594 -,PR,EOP,DT2.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT2.1,C,BE,C,299.67554969423594 -,PR,IA,DT2.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT2.1,L,BE,N,0.9226050955731167 -,PR,IA,DT2.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT2.1,C,BE,N,0.9226050955731167 -,PR,CF,DT2.1,L,BE,N,400 -,NIC,CF,DT2.1,L,BE,N,-300 -,PR,CF,DT2.1,C,BE,N,400 -,NIC,CF,DT2.1,C,BE,N,-300 -2020,NIC,BOP,DT2.2,L,BE,N,598.7529445986629 -2020,NIC,BOP,DT2.2,C,BE,N,598.7529445986629 -2020,NIC,EOP,DT2.2,L,BE,C,299.67554969423594 -2020,NIC,EOP,DT2.2,C,BE,C,299.67554969423594 -2020,NIC,IA,DT2.2,L,BE,N,0.9226050955731167 -2020,NIC,IA,DT2.2,C,BE,N,0.9226050955731167 -2020,NIC,CF,DT2.2,L,BE,N,-300 -2020,NIC,CF,DT2.2,C,BE,N,-300 -,PR,BOP,DTR1.1,L,BE,N,399.2683655806875 -,NIC,BOP,DTR1.1,L,BE,N,-299.37647229933145 -,CDR,BOP,DTR1.1,L,BE,N,0.4811341181992343 -,PR,BOP,DTR1.1,C,BE,N,399.2683655806875 -,NIC,BOP,DTR1.1,C,BE,N,-299.37647229933145 -,CDR,BOP,DTR1.1,C,BE,N,0.4811341181992343 -,PR,EOP,DTR1.1,L,BE,C,199.81696474942763 -,NIC,EOP,DTR1.1,L,BE,C,-149.83777484711797 -,CDR,EOP,DTR1.1,L,BE,C,0.11527160395198197 -,PR,EOP,DTR1.1,C,BE,C,199.81696474942763 -,NIC,EOP,DTR1.1,C,BE,C,-149.83777484711797 -,CDR,EOP,DTR1.1,C,BE,C,0.11527160395198197 -,PR,IA,DTR1.1,L,BE,N,0.5485991687403052 -,NIC,IA,DTR1.1,L,BE,N,-0.4613025477865583 -,CDR,IA,DTR1.1,L,BE,N,0.0011701910454977593 -,PR,IA,DTR1.1,C,BE,N,0.5485991687403052 -,NIC,IA,DTR1.1,C,BE,N,-0.4613025477865583 -,CDR,IA,DTR1.1,C,BE,N,0.0011701910454977593 -,PR,CF,DTR1.1,L,BE,N,-200 -,NIC,CF,DTR1.1,L,BE,N,150 -,CDR,CF,DTR1.1,L,BE,N,-0.36703270529272203 -,PR,CF,DTR1.1,C,BE,N,-200 -,NIC,CF,DTR1.1,C,BE,N,150 -,CDR,CF,DTR1.1,C,BE,N,-0.36703270529272203 -2020,NIC,BOP,DTR1.2,L,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR1.2,L,BE,N,0.4811341181992343 -2020,NIC,BOP,DTR1.2,C,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR1.2,C,BE,N,0.4811341181992343 -2020,NIC,EOP,DTR1.2,L,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR1.2,L,BE,C,0.11527160395198197 -2020,NIC,EOP,DTR1.2,C,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR1.2,C,BE,C,0.11527160395198197 -2020,NIC,IA,DTR1.2,L,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR1.2,L,BE,N,0.0011701910454977593 -2020,NIC,IA,DTR1.2,C,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR1.2,C,BE,N,0.0011701910454977593 -2020,NIC,CF,DTR1.2,L,BE,N,150 -2020,CDR,CF,DTR1.2,L,BE,N,-0.36703270529272203 -2020,NIC,CF,DTR1.2,C,BE,N,150 -2020,CDR,CF,DTR1.2,C,BE,N,-0.36703270529272203 -,PR,BOP,DTR2.1,L,BE,N,399.2683655806875 -,NIC,BOP,DTR2.1,L,BE,N,-299.37647229933145 -,CDR,BOP,DTR2.1,L,BE,N,0.4811341181992343 -,PR,BOP,DTR2.1,C,BE,N,399.2683655806875 -,NIC,BOP,DTR2.1,C,BE,N,-299.37647229933145 -,CDR,BOP,DTR2.1,C,BE,N,0.4811341181992343 -,PR,EOP,DTR2.1,L,BE,C,199.81696474942763 -,NIC,EOP,DTR2.1,L,BE,C,-149.83777484711797 -,CDR,EOP,DTR2.1,L,BE,C,0.11527160395198197 -,PR,EOP,DTR2.1,C,BE,C,199.81696474942763 -,NIC,EOP,DTR2.1,C,BE,C,-149.83777484711797 -,CDR,EOP,DTR2.1,C,BE,C,0.11527160395198197 -,PR,IA,DTR2.1,L,BE,N,0.5485991687403052 -,NIC,IA,DTR2.1,L,BE,N,-0.4613025477865583 -,CDR,IA,DTR2.1,L,BE,N,0.0011701910454977593 -,PR,IA,DTR2.1,C,BE,N,0.5485991687403052 -,NIC,IA,DTR2.1,C,BE,N,-0.4613025477865583 -,CDR,IA,DTR2.1,C,BE,N,0.0011701910454977593 -,PR,CF,DTR2.1,L,BE,N,-200 -,NIC,CF,DTR2.1,L,BE,N,150 -,CDR,CF,DTR2.1,L,BE,N,-0.36703270529272203 -,PR,CF,DTR2.1,C,BE,N,-200 -,NIC,CF,DTR2.1,C,BE,N,150 -,CDR,CF,DTR2.1,C,BE,N,-0.36703270529272203 -2020,NIC,BOP,DTR2.2,L,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR2.2,L,BE,N,0.4811341181992343 -2020,NIC,BOP,DTR2.2,C,BE,N,-299.37647229933145 -2020,CDR,BOP,DTR2.2,C,BE,N,0.4811341181992343 -2020,NIC,EOP,DTR2.2,L,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR2.2,L,BE,C,0.11527160395198197 -2020,NIC,EOP,DTR2.2,C,BE,C,-149.83777484711797 -2020,CDR,EOP,DTR2.2,C,BE,C,0.11527160395198197 -2020,NIC,IA,DTR2.2,L,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR2.2,L,BE,N,0.0011701910454977593 -2020,NIC,IA,DTR2.2,C,BE,N,-0.4613025477865583 -2020,CDR,IA,DTR2.2,C,BE,N,0.0011701910454977593 -2020,NIC,CF,DTR2.2,L,BE,N,150 -2020,CDR,CF,DTR2.2,L,BE,N,-0.36703270529272203 -2020,NIC,CF,DTR2.2,C,BE,N,150 -2020,CDR,CF,DTR2.2,C,BE,N,-0.36703270529272203 -,PR,BOP,DT3.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT3.1,L,BE,N,598.7529445986629 -,PR,BOP,DT3.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT3.1,C,BE,N,598.7529445986629 -,PR,EOP,DT3.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT3.1,L,BE,C,299.67554969423594 -,PR,EOP,DT3.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT3.1,C,BE,C,299.67554969423594 -,PR,IA,DT3.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT3.1,L,BE,N,0.9226050955731167 -,PR,IA,DT3.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT3.1,C,BE,N,0.9226050955731167 -,PR,CF,DT3.1,L,BE,N,400 -,NIC,CF,DT3.1,L,BE,N,-300 -,PR,CF,DT3.1,C,BE,N,400 -,NIC,CF,DT3.1,C,BE,N,-300 -,PR,BOP,DT4.1,L,BE,N,-798.536731161375 -,NIC,BOP,DT4.1,L,BE,N,598.7529445986629 -,PR,BOP,DT4.1,C,BE,N,-798.536731161375 -,NIC,BOP,DT4.1,C,BE,N,598.7529445986629 -,PR,EOP,DT4.1,L,BE,C,-399.63392949885525 -,NIC,EOP,DT4.1,L,BE,C,299.67554969423594 -,PR,EOP,DT4.1,C,BE,C,-399.63392949885525 -,NIC,EOP,DT4.1,C,BE,C,299.67554969423594 -,PR,IA,DT4.1,L,BE,N,-1.0971983374806105 -,NIC,IA,DT4.1,L,BE,N,0.9226050955731167 -,PR,IA,DT4.1,C,BE,N,-1.0971983374806105 -,NIC,IA,DT4.1,C,BE,N,0.9226050955731167 -,PR,CF,DT4.1,L,BE,N,400 -,NIC,CF,DT4.1,L,BE,N,-300 -,PR,CF,DT4.1,C,BE,N,400 -,NIC,CF,DT4.1,C,BE,N,-300 \ No newline at end of file +,PR,BOP,DT1.1,C,BE,N,-878.3904043 +,NIC,BOP,DT1.1,L,BE,N,658.6282391 +,PR,BOP,DT1.1,L,BE,N,-878.3904043 +,NIC,BOP,DT1.1,C,BE,N,658.6282391 +,PR,EOP,DT1.1,L,BE,C,-439.5973224 +,NIC,EOP,DT1.1,L,BE,C,329.6431047 +,PR,EOP,DT1.1,C,BE,C,-439.5973224 +,NIC,EOP,DT1.1,C,BE,C,329.6431047 +,PR,IA,DT1.1,L,BE,N,-1.206918171 +,NIC,IA,DT1.1,L,BE,N,1.014865605 +,PR,IA,DT1.1,C,BE,N,-1.206918171 +,NIC,IA,DT1.1,C,BE,N,1.014865605 +,PR,CF,DT1.1,L,BE,N,440 +,NIC,CF,DT1.1,L,BE,N,-330 +,PR,CF,DT1.1,C,BE,N,440 +,NIC,CF,DT1.1,C,BE,N,-330 +2020,NIC,BOP,DT1.2,L,BE,N,658.6282391 +2020,NIC,BOP,DT1.2,C,BE,N,658.6282391 +2020,NIC,EOP,DT1.2,L,BE,C,329.6431047 +2020,NIC,EOP,DT1.2,C,BE,C,329.6431047 +2020,NIC,IA,DT1.2,L,BE,N,1.014865605 +2020,NIC,IA,DT1.2,C,BE,N,1.014865605 +2020,NIC,CF,DT1.2,L,BE,N,-330 +2020,NIC,CF,DT1.2,C,BE,N,-330 +,PR,BOP,DT1.3,L,BE,N,-878.3904043 +,NIC,BOP,DT1.3,L,BE,N,658.6282391 +,PR,BOP,DT1.3,C,BE,N,-878.3904043 +,NIC,BOP,DT1.3,C,BE,N,658.6282391 +,PR,EOP,DT1.3,L,BE,C,-439.5973224 +,NIC,EOP,DT1.3,L,BE,C,329.6431047 +,PR,EOP,DT1.3,C,BE,C,-439.5973224 +,NIC,EOP,DT1.3,C,BE,C,329.6431047 +,PR,IA,DT1.3,L,BE,N,-1.206918171 +,NIC,IA,DT1.3,L,BE,N,1.014865605 +,PR,IA,DT1.3,C,BE,N,-1.206918171 +,NIC,IA,DT1.3,C,BE,N,1.014865605 +,PR,CF,DT1.3,L,BE,N,440 +,NIC,CF,DT1.3,L,BE,N,-330 +,PR,CF,DT1.3,C,BE,N,440 +,NIC,CF,DT1.3,C,BE,N,-330 +,PR,BOP,DT2.1,L,BE,N,-878.3904043 +,NIC,BOP,DT2.1,L,BE,N,658.6282391 +,PR,BOP,DT2.1,C,BE,N,-878.3904043 +,NIC,BOP,DT2.1,C,BE,N,658.6282391 +,PR,EOP,DT2.1,L,BE,C,-439.5973224 +,NIC,EOP,DT2.1,L,BE,C,329.6431047 +,PR,EOP,DT2.1,C,BE,C,-439.5973224 +,NIC,EOP,DT2.1,C,BE,C,329.6431047 +,PR,IA,DT2.1,L,BE,N,-1.206918171 +,NIC,IA,DT2.1,L,BE,N,1.014865605 +,PR,IA,DT2.1,C,BE,N,-1.206918171 +,NIC,IA,DT2.1,C,BE,N,1.014865605 +,PR,CF,DT2.1,L,BE,N,440 +,NIC,CF,DT2.1,L,BE,N,-330 +,PR,CF,DT2.1,C,BE,N,440 +,NIC,CF,DT2.1,C,BE,N,-330 +2020,NIC,BOP,DT2.2,L,BE,N,658.6282391 +2020,NIC,BOP,DT2.2,C,BE,N,658.6282391 +2020,NIC,EOP,DT2.2,L,BE,C,329.6431047 +2020,NIC,EOP,DT2.2,C,BE,C,329.6431047 +2020,NIC,IA,DT2.2,L,BE,N,1.014865605 +2020,NIC,IA,DT2.2,C,BE,N,1.014865605 +2020,NIC,CF,DT2.2,L,BE,N,-330 +2020,NIC,CF,DT2.2,C,BE,N,-330 +,PR,BOP,DTR1.1,L,BE,N,439.1952021 +,NIC,BOP,DTR1.1,L,BE,N,-329.3141195 +,CDR,BOP,DTR1.1,L,BE,N,0.52924753 +,PR,BOP,DTR1.1,C,BE,N,439.1952021 +,NIC,BOP,DTR1.1,C,BE,N,-329.3141195 +,CDR,BOP,DTR1.1,C,BE,N,0.52924753 +,PR,EOP,DTR1.1,L,BE,C,219.7986612 +,NIC,EOP,DTR1.1,L,BE,C,-164.8215523 +,CDR,EOP,DTR1.1,L,BE,C,0.126798764 +,PR,EOP,DTR1.1,C,BE,C,219.7986612 +,NIC,EOP,DTR1.1,C,BE,C,-164.8215523 +,CDR,EOP,DTR1.1,C,BE,C,0.126798764 +,PR,IA,DTR1.1,L,BE,N,0.603459086 +,NIC,IA,DTR1.1,L,BE,N,-0.507432803 +,CDR,IA,DTR1.1,L,BE,N,0.00128721 +,PR,IA,DTR1.1,C,BE,N,0.603459086 +,NIC,IA,DTR1.1,C,BE,N,-0.507432803 +,CDR,IA,DTR1.1,C,BE,N,0.00128721 +,PR,CF,DTR1.1,L,BE,N,-220 +,NIC,CF,DTR1.1,L,BE,N,165 +,CDR,CF,DTR1.1,L,BE,N,-0.403735976 +,PR,CF,DTR1.1,C,BE,N,-220 +,NIC,CF,DTR1.1,C,BE,N,165 +,CDR,CF,DTR1.1,C,BE,N,-0.403735976 +2020,NIC,BOP,DTR1.2,L,BE,N,-329.3141195 +2020,CDR,BOP,DTR1.2,L,BE,N,0.52924753 +2020,NIC,BOP,DTR1.2,C,BE,N,-329.3141195 +2020,CDR,BOP,DTR1.2,C,BE,N,0.52924753 +2020,NIC,EOP,DTR1.2,L,BE,C,-164.8215523 +2020,CDR,EOP,DTR1.2,L,BE,C,0.126798764 +2020,NIC,EOP,DTR1.2,C,BE,C,-164.8215523 +2020,CDR,EOP,DTR1.2,C,BE,C,0.126798764 +2020,NIC,IA,DTR1.2,L,BE,N,-0.507432803 +2020,CDR,IA,DTR1.2,L,BE,N,0.00128721 +2020,NIC,IA,DTR1.2,C,BE,N,-0.507432803 +2020,CDR,IA,DTR1.2,C,BE,N,0.00128721 +2020,NIC,CF,DTR1.2,L,BE,N,165 +2020,CDR,CF,DTR1.2,L,BE,N,-0.403735976 +2020,NIC,CF,DTR1.2,C,BE,N,165 +2020,CDR,CF,DTR1.2,C,BE,N,-0.403735976 +,PR,BOP,DTR2.1,L,BE,N,439.1952021 +,NIC,BOP,DTR2.1,L,BE,N,-329.3141195 +,CDR,BOP,DTR2.1,L,BE,N,0.52924753 +,PR,BOP,DTR2.1,C,BE,N,439.1952021 +,NIC,BOP,DTR2.1,C,BE,N,-329.3141195 +,CDR,BOP,DTR2.1,C,BE,N,0.52924753 +,PR,EOP,DTR2.1,L,BE,C,219.7986612 +,NIC,EOP,DTR2.1,L,BE,C,-164.8215523 +,CDR,EOP,DTR2.1,L,BE,C,0.126798764 +,PR,EOP,DTR2.1,C,BE,C,219.7986612 +,NIC,EOP,DTR2.1,C,BE,C,-164.8215523 +,CDR,EOP,DTR2.1,C,BE,C,0.126798764 +,PR,IA,DTR2.1,L,BE,N,0.603459086 +,NIC,IA,DTR2.1,L,BE,N,-0.507432803 +,CDR,IA,DTR2.1,L,BE,N,0.00128721 +,PR,IA,DTR2.1,C,BE,N,0.603459086 +,NIC,IA,DTR2.1,C,BE,N,-0.507432803 +,CDR,IA,DTR2.1,C,BE,N,0.00128721 +,PR,CF,DTR2.1,L,BE,N,-220 +,NIC,CF,DTR2.1,L,BE,N,165 +,CDR,CF,DTR2.1,L,BE,N,-0.403735976 +,PR,CF,DTR2.1,C,BE,N,-220 +,NIC,CF,DTR2.1,C,BE,N,165 +,CDR,CF,DTR2.1,C,BE,N,-0.403735976 +2020,NIC,BOP,DTR2.2,L,BE,N,-329.3141195 +2020,CDR,BOP,DTR2.2,L,BE,N,0.52924753 +2020,NIC,BOP,DTR2.2,C,BE,N,-329.3141195 +2020,CDR,BOP,DTR2.2,C,BE,N,0.52924753 +2020,NIC,EOP,DTR2.2,L,BE,C,-164.8215523 +2020,CDR,EOP,DTR2.2,L,BE,C,0.126798764 +2020,NIC,EOP,DTR2.2,C,BE,C,-164.8215523 +2020,CDR,EOP,DTR2.2,C,BE,C,0.126798764 +2020,NIC,IA,DTR2.2,L,BE,N,-0.507432803 +2020,CDR,IA,DTR2.2,L,BE,N,0.00128721 +2020,NIC,IA,DTR2.2,C,BE,N,-0.507432803 +2020,CDR,IA,DTR2.2,C,BE,N,0.00128721 +2020,NIC,CF,DTR2.2,L,BE,N,165 +2020,CDR,CF,DTR2.2,L,BE,N,-0.403735976 +2020,NIC,CF,DTR2.2,C,BE,N,165 +2020,CDR,CF,DTR2.2,C,BE,N,-0.403735976 +,PR,BOP,DT3.1,L,BE,N,-878.3904043 +,NIC,BOP,DT3.1,L,BE,N,658.6282391 +,PR,BOP,DT3.1,C,BE,N,-878.3904043 +,NIC,BOP,DT3.1,C,BE,N,658.6282391 +,PR,EOP,DT3.1,L,BE,C,-439.5973224 +,NIC,EOP,DT3.1,L,BE,C,329.6431047 +,PR,EOP,DT3.1,C,BE,C,-439.5973224 +,NIC,EOP,DT3.1,C,BE,C,329.6431047 +,PR,IA,DT3.1,L,BE,N,-1.206918171 +,NIC,IA,DT3.1,L,BE,N,1.014865605 +,PR,IA,DT3.1,C,BE,N,-1.206918171 +,NIC,IA,DT3.1,C,BE,N,1.014865605 +,PR,CF,DT3.1,L,BE,N,440 +,NIC,CF,DT3.1,L,BE,N,-330 +,PR,CF,DT3.1,C,BE,N,440 +,NIC,CF,DT3.1,C,BE,N,-330 +,PR,BOP,DT4.1,L,BE,N,-878.3904043 +,NIC,BOP,DT4.1,L,BE,N,658.6282391 +,PR,BOP,DT4.1,C,BE,N,-878.3904043 +,NIC,BOP,DT4.1,C,BE,N,658.6282391 +,PR,EOP,DT4.1,L,BE,C,-439.5973224 +,NIC,EOP,DT4.1,L,BE,C,329.6431047 +,PR,EOP,DT4.1,C,BE,C,-439.5973224 +,NIC,EOP,DT4.1,C,BE,C,329.6431047 +,PR,IA,DT4.1,L,BE,N,-1.206918171 +,NIC,IA,DT4.1,L,BE,N,1.014865605 +,PR,IA,DT4.1,C,BE,N,-1.206918171 +,NIC,IA,DT4.1,C,BE,N,1.014865605 +,PR,CF,DT4.1,L,BE,N,440 +,NIC,CF,DT4.1,L,BE,N,-330 +,PR,CF,DT4.1,C,BE,N,440 +,NIC,CF,DT4.1,C,BE,N,-330 diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index 9cec0651..05cf7586 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -78,7 +78,7 @@ "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_OAPA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_RA.csv\" , \"CH\", 2021, 3),", "\n // 2020 with Scenario", - "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_BE_SCE.csv\" , \"CH\", 2020, 12),", + "\n //new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_BE_SCE.csv\" , \"CH\", 2020, 12, \"IRU\"),", "\n};" ] }, @@ -219,12 +219,12 @@ { "cell_type": "code", "source": [ - "foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))", + "foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month, Scenario : x.Scenario)))", "\n{", "\n var reportingNode = g.Key.ReportingNode;", "\n var year = g.Key.Year;", "\n var month = g.Key.Month;", - "\n string scenario = null;", + "\n string scenario = g.Key.Scenario;", "\n ", "\n //Set up Args and storage", "\n await DataSource.Partition.SetAsync(new {ReportingNode = reportingNode, ", diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb new file mode 100644 index 00000000..f31cefd7 --- /dev/null +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -0,0 +1,88 @@ +{ + "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": [ + "var scenario = \"IRU\";" + ] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" + ] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" + ] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Initialize(x => x.FromSource(DataSource));" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Scenario Data" + ] + }, + { + "cell_type": "code", + "source": [ + "await UploadDimensionsAsync(\"../Files/800.Parameters/YieldCurveScenario.csv\")" + ] + }, + { + "cell_type": "code", + "source": [ + "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\")" + ] + }, + { + "cell_type": "code", + "source": [ + "//Define partition", + "\nvar args = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);", + "\nvar partition = DataSource.Query().FirstOrDefault(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && ", + "\n x.Month == args.Month && x.Scenario == args.Scenario);", + "\nif(partition == null) ApplicationMessage.Log(Error.PartitionNotFound);", + "\n", + "\nvar previousPeriodPartition = Workspace.Query().FirstOrDefault(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year - 1 && ", + "\n x.Month == MonthInAYear && x.Scenario == args.Scenario);", + "\nif(previousPeriodPartition == null) ApplicationMessage.Log(Error.PartitionNotFound);", + "\nDataSource.Query()" + ] + }, + { + "cell_type": "code", + "source": [ + "partition" + ] + }, + { + "cell_type": "markdown", + "source": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 0b403fc9..472af983 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -71,8 +71,8 @@ "\n public string ImportFormat => args.ImportFormat; ", "\n ", "\n //Time Periods ", - "\n ////public (int Year, int Month) CurrentReportingPeriod => (args.Year, args.Month);", - "\n //public (int Year, int Month) PreviousReportingPeriod => (args.Year - 1, MonthInAYear); // YTD Logic", + "\n public (int Year, int Month) CurrentReportingPeriod => (args.Year, args.Month);", + "\n public (int Year, int Month) PreviousReportingPeriod => (args.Year - 1, MonthInAYear); // YTD Logic", "\n", "\n //Partitions", "\n public Guid PartitionByRn;", @@ -148,7 +148,6 @@ "\n ", "\n //Get Partitions", "\n PartitionByRn = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode).ToArrayAsync()).Single().Id;", - "\n /*", "\n TargetPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", "\n p.Year == CurrentReportingPeriod.Year &&", "\n p.Month == CurrentReportingPeriod.Month &&", @@ -157,14 +156,10 @@ "\n p.Year == CurrentReportingPeriod.Year &&", "\n p.Month == CurrentReportingPeriod.Month &&", "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n */", "\n //Set Partitions", "\n await querySource.Partition.SetAsync(PartitionByRn);", "\n await workspace.Partition.SetAsync(PartitionByRn);", - "\n", - "\n (TargetPartition, DefaultPartition, PreviousPeriodPartition) = await querySource.LoadPartitionsYTDAsync(args);", - "\n", - "\n", + "\n ", "\n await querySource.Partition.SetAsync(TargetPartition);", "\n await workspace.Partition.SetAsync(TargetPartition);", "\n ", @@ -219,14 +214,13 @@ "\n var openingIfrsVariables = Enumerable.Empty();", "\n", "\n if(allImportScopes.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year < args.Year)) {", - "\n /*", "\n PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", "\n p.Year == PreviousReportingPeriod.Year &&", "\n p.Month == PreviousReportingPeriod.Month &&", - "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n */", - "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", + "\n p.Scenario == null).ToArrayAsync()).Single().Id; // This can send an exception", "\n ", + "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", + "\n ", "\n //Perform queries to previous Period", "\n openingRawVariables = (await querySource.Query()", "\n .Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == AocTypes.CL)", @@ -259,7 +253,6 @@ "\n .Where(rv => rv.Partition == TargetPartition)", "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", "\n .ToArrayAsync());", - "\n", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", "\n ", "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", From d304e3d31c0830ce1dd349f79e474c6442e87e3a Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Tue, 18 Oct 2022 12:30:04 +0200 Subject: [PATCH 06/23] new partition added --- full-ifrs17-template/Files/DimensionsAndPartitions.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/full-ifrs17-template/Files/DimensionsAndPartitions.csv b/full-ifrs17-template/Files/DimensionsAndPartitions.csv index 1e9f58cf..ebf955f8 100644 --- a/full-ifrs17-template/Files/DimensionsAndPartitions.csv +++ b/full-ifrs17-template/Files/DimensionsAndPartitions.csv @@ -226,8 +226,9 @@ ReportingNode,Id,,,,,,,,,, CH,00000000-0000-0000-0000-000000000001,,,,,,,,,, ,,,,,,,,,,, @@PartitionByReportingNodeAndPeriod,,,,,,,,,,, -ReportingNode,Year,Month,Id,,,,,,,, +ReportingNode,Year,Month,Id,Scenario,,,,,,, CH,2020,12,10000000-0000-0000-0000-000000000000,,,,,,,, +CH,2020,12,10000000-0000-0000-0000-000000000000,IRU,,,,,,, CH,2021,3,20000000-0000-0000-0000-000000000000,,,,,,,, CH,2021,9,30000000-0000-0000-0000-000000000000,,,,,,,, CH,2021,12,35000000-0000-0000-0000-000000000000,,,,,,,, From ad47b3ed1364bd81b7072ecde0d11a8264ea9db5 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Tue, 18 Oct 2022 19:44:30 +0200 Subject: [PATCH 07/23] implementing new test --- .../Files/DimensionsAndPartitions.csv | 2 +- .../InitSystemorphBaseToMemory.ipynb | 2 +- full-ifrs17-template/Test/ScenarioTest.ipynb | 48 +++++++++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/full-ifrs17-template/Files/DimensionsAndPartitions.csv b/full-ifrs17-template/Files/DimensionsAndPartitions.csv index ebf955f8..75ffa34b 100644 --- a/full-ifrs17-template/Files/DimensionsAndPartitions.csv +++ b/full-ifrs17-template/Files/DimensionsAndPartitions.csv @@ -228,7 +228,7 @@ CH,00000000-0000-0000-0000-000000000001,,,,,,,,,, @@PartitionByReportingNodeAndPeriod,,,,,,,,,,, ReportingNode,Year,Month,Id,Scenario,,,,,,, CH,2020,12,10000000-0000-0000-0000-000000000000,,,,,,,, -CH,2020,12,10000000-0000-0000-0000-000000000000,IRU,,,,,,, +CH,2020,12,15000000-0000-0000-0000-000000000000,IRU,,,,,,, CH,2021,3,20000000-0000-0000-0000-000000000000,,,,,,,, CH,2021,9,30000000-0000-0000-0000-000000000000,,,,,,,, CH,2021,12,35000000-0000-0000-0000-000000000000,,,,,,,, diff --git a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index 582fe3b6..cf90dac4 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -29,7 +29,7 @@ { "cell_type": "code", "source": [ - "#!import \"../../../ifrs17/CalculationEngine\"" + "#!import \"../Constants/Consts\"", "\n#!eval calculationEngine" ] }, diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index f31cefd7..8c577792 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -18,7 +18,10 @@ { "cell_type": "code", "source": [ - "var scenario = \"IRU\";" + "var scenario = \"IRU\";", + "\nvar year = 2020;", + "\nvar month = 12;", + "\nvar reportingNode = \"CH\";" ] }, { @@ -27,6 +30,21 @@ "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" ] }, + { + "cell_type": "code", + "source": [ + "var targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == reportingNode &&", + "\n p.Year == year &&", + "\n p.Month == month &&", + "\n p.Scenario == scenario).ToArrayAsync()).Single().Id;", + "\nvar defaultPartition = (await DataSource.Query().Where(p => p.ReportingNode == reportingNode &&", + "\n p.Year == year &&", + "\n p.Month == month &&", + "\n p.Scenario == null).ToArrayAsync()).Single().Id;", + "\n/*await DataSource.Partition.SetAsync(defaultPartition);", + "\nawait DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync()*/" + ] + }, { "cell_type": "code", "source": [ @@ -36,7 +54,7 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource));" + "(await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync())" ] }, { @@ -48,34 +66,34 @@ { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/YieldCurveScenario.csv\")" + "Workspace.Initialize(x => x.FromSource(DataSource));", + "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\");", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nvar test1 = (await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync());", + "\ntest1" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\")" + "Workspace.Initialize(x => x.FromSource(DataSource));", + "\n//await UploadDimensionsAsync(\"../Files/800.Parameters/YieldCurveScenario.csv\");", + "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\");", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" ] }, { "cell_type": "code", "source": [ - "//Define partition", - "\nvar args = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar partition = DataSource.Query().FirstOrDefault(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && ", - "\n x.Month == args.Month && x.Scenario == args.Scenario);", - "\nif(partition == null) ApplicationMessage.Log(Error.PartitionNotFound);", - "\n", - "\nvar previousPeriodPartition = Workspace.Query().FirstOrDefault(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year - 1 && ", - "\n x.Month == MonthInAYear && x.Scenario == args.Scenario);", - "\nif(previousPeriodPartition == null) ApplicationMessage.Log(Error.PartitionNotFound);", - "\nDataSource.Query()" + "var computedVariablesByEstimateTypeWithScenario = (await DataSource.Query().Where(x => x.Partition == targetPartition).ToArrayAsync());", + "\nawait DataSource.Partition.SetAsync(defaultPartition);", + "\nvar computedVariablesByEstimateType = (await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync());" ] }, { "cell_type": "code", "source": [ - "partition" + "computedVariablesByEstimateTypeWithScenario" ] }, { From 254a97e2470696ccd675c53cc5fd5edca8dc7bb7 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Tue, 18 Oct 2022 20:40:08 +0200 Subject: [PATCH 08/23] test cleaned --- full-ifrs17-template/Test/ScenarioTest.ipynb | 45 ++++---------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index 8c577792..cddc21bc 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -41,20 +41,7 @@ "\n p.Year == year &&", "\n p.Month == month &&", "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n/*await DataSource.Partition.SetAsync(defaultPartition);", - "\nawait DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync()*/" - ] - }, - { - "cell_type": "code", - "source": [ - "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" - ] - }, - { - "cell_type": "code", - "source": [ - "(await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync())" + "\n" ] }, { @@ -66,38 +53,24 @@ { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource));", - "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\");", - "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\nvar test1 = (await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync());", - "\ntest1" + "//Workspace.Initialize(x => x.FromSource(DataSource));", + "\n//await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\");", + "\nawait DataSource.Partition.SetAsync(defaultPartition);", + "\nvar computedVariablesByEstimateTypeBestEstimeate = (await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync());", + "\ncomputedVariablesByEstimateTypeBestEstimeate.Count()" ] }, { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource));", - "\n//await UploadDimensionsAsync(\"../Files/800.Parameters/YieldCurveScenario.csv\");", + "//await DataSource.Partition.SetAsync(targetPartition);", "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\");", - "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" + "\nvar computedVariablesByEstimateTypeWithScenario = (await DataSource.Query().Where(x => x.Partition == targetPartition).ToArrayAsync());", + "\ncomputedVariablesByEstimateTypeWithScenario.Count()" ] }, { "cell_type": "code", - "source": [ - "var computedVariablesByEstimateTypeWithScenario = (await DataSource.Query().Where(x => x.Partition == targetPartition).ToArrayAsync());", - "\nawait DataSource.Partition.SetAsync(defaultPartition);", - "\nvar computedVariablesByEstimateType = (await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync());" - ] - }, - { - "cell_type": "code", - "source": [ - "computedVariablesByEstimateTypeWithScenario" - ] - }, - { - "cell_type": "markdown", "source": [ "" ] From c26697d7121f92a3e4a03edc513a32e9ff474aa4 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Mon, 24 Oct 2022 09:48:54 +0200 Subject: [PATCH 09/23] testing queries --- full-ifrs17-template/Database/Configure.ipynb | 2 +- .../InitSystemorphBaseToMemory.ipynb | 3 +- full-ifrs17-template/Test/ScenarioTest.ipynb | 421 +++++++++++++++++- ifrs17/Import/ImportStorage.ipynb | 27 +- 4 files changed, 440 insertions(+), 13 deletions(-) diff --git a/full-ifrs17-template/Database/Configure.ipynb b/full-ifrs17-template/Database/Configure.ipynb index b332a43c..1a2fc211 100644 --- a/full-ifrs17-template/Database/Configure.ipynb +++ b/full-ifrs17-template/Database/Configure.ipynb @@ -27,7 +27,7 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17ce/dev/CalculationEngine\"" + "#!import \"../../ifrs17/CalculationEngine\"" ] }, { diff --git a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index cf90dac4..f2d16a7d 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -30,7 +30,8 @@ "cell_type": "code", "source": [ "#!import \"../Constants/Consts\"", - "\n#!eval calculationEngine" + "\n//#!eval calculationEngine", + "\n#!import \"../../ifrs17/CalculationEngine\"" ] }, { diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index cddc21bc..54493262 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -21,7 +21,8 @@ "var scenario = \"IRU\";", "\nvar year = 2020;", "\nvar month = 12;", - "\nvar reportingNode = \"CH\";" + "\nvar reportingNode = \"CH\";", + "\nvar dataNode = \"DT1.1\";" ] }, { @@ -30,6 +31,12 @@ "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" ] }, + { + "cell_type": "code", + "source": [ + "Workspace.Initialize(x => x.FromSource(DataSource));" + ] + }, { "cell_type": "code", "source": [ @@ -53,20 +60,414 @@ { "cell_type": "code", "source": [ - "//Workspace.Initialize(x => x.FromSource(DataSource));", - "\n//await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\");", - "\nawait DataSource.Partition.SetAsync(defaultPartition);", - "\nvar computedVariablesByEstimateTypeBestEstimeate = (await DataSource.Query().Where(x => x.Partition == defaultPartition).ToArrayAsync());", - "\ncomputedVariablesByEstimateTypeBestEstimeate.Count()" + "#!import \"../../ifrs17/Utils/ImportCalculationMethods\"", + "\n#!import \"../../ifrs17/Utils/Queries\"" + ] + }, + { + "cell_type": "code", + "source": [ + "public class ImportStorage", + "\n{ ", + "\n private readonly IDataSource querySource; ", + "\n private readonly IWorkspace workspace;", + "\n private readonly Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchyCache;", + "\n private readonly ImportArgs args;", + "\n ", + "\n // Constants", + "\n private static int periodicityInMonths => 3; // Revisit", + "\n ", + "\n //Format", + "\n public string ImportFormat => args.ImportFormat; ", + "\n ", + "\n //Time Periods ", + "\n public (int Year, int Month) CurrentReportingPeriod => (args.Year, args.Month);", + "\n public (int Year, int Month) PreviousReportingPeriod => (args.Year - 1, MonthInAYear); // YTD Logic", + "\n", + "\n //Partitions", + "\n public Guid PartitionByRn;", + "\n public Guid TargetPartition;", + "\n public Guid DefaultPartition;", + "\n public Guid PreviousPeriodPartition; ", + "\n", + "\n //Projections", + "\n private ProjectionConfiguration[] ProjectionConfiguration;", + "\n ", + "\n //DataNodes", + "\n public IDictionary DataNodeDataBySystemName { get; private set; }", + "\n public IDictionary> DataNodesByImportScope { get; private set; }", + "\n public IDictionary> AccidentYearsByDataNode { get; private set; }", + "\n //Variables", + "\n public IDictionary> RawVariablesByImportIdentity { get; private set; }", + "\n public IDictionary> IfrsVariablesByImportIdentity { get; private set; }", + "\n public RawVariable[] DefaultRawVariables { get; private set; }", + "\n public HashSet PrimaryScopeFromLinkedReinsurance { get; private set; }", + "\n ", + "\n //Parameters", + "\n public Dictionary LockedInYieldCurve { get; private set; }", + "\n public Dictionary> CurrentYieldCurve { get; private set; }", + "\n public Dictionary> PartnerRating { get; private set; }", + "\n public Dictionary> CreditDefaultRates { get; private set; }", + "\n public Dictionary> SingleDataNodeParametersByGoc { get; private set; }", + "\n public Dictionary>> InterDataNodeParametersByGoc { get; private set; }", + "\n public Dictionary AocConfigurationByAocStep { get; private set; }", + "\n ", + "\n private Dictionary> aocStepByInputSource;", + "\n ", + "\n //Dimensions", + "\n public Dictionary AmountTypeDimension { get; private set; }", + "\n public Dictionary NoveltyDimension { get; private set; }", + "\n public Dictionary EstimateTypeDimension { get; private set; }", + "\n public Dictionary> EstimateTypesByImportFormat { get; private set; }", + "\n public Dictionary ExperienceAdjustEstimateTypeMapping { get; private set; } ", + "\n ", + "\n //Constructor", + "\n public ImportStorage(ImportArgs args, IDataSource querySource, IWorkspace workspace)", + "\n {", + "\n this.querySource = querySource;", + "\n this.workspace = workspace;", + "\n hierarchyCache = workspace.ToHierarchicalDimensionCache();", + "\n this.args = args;", + "\n }", + "\n ", + "\n //Initialize", + "\n public async Task InitializeAsync()", + "\n { ", + "\n //Dimensions", + "\n var estimateTypes = (await workspace.Query().ToArrayAsync());", + "\n ", + "\n EstimateTypeDimension = estimateTypes.ToDictionary(x => x.SystemName);", + "\n AmountTypeDimension = (await workspace.Query().ToArrayAsync()).ToDictionary(x => x.SystemName);", + "\n NoveltyDimension = (await workspace.Query().ToArrayAsync()).ToDictionary(x => x.SystemName);", + "\n ", + "\n ExperienceAdjustEstimateTypeMapping = new Dictionary{{EstimateTypes.A, EstimateTypes.APA}, {EstimateTypes.AA, EstimateTypes.AAPA}, {EstimateTypes.OA, EstimateTypes.OAPA}}; //TODO move this logic", + "\n ", + "\n //Hierarchy Cache", + "\n hierarchyCache.Initialize();", + "\n ", + "\n //EstimateType to load and to update", + "\n EstimateTypesByImportFormat = new InputSource[] { InputSource.Opening, InputSource.Actual, InputSource.Cashflow,}", + "\n .ToDictionary(x => x.ToString(), ", + "\n x => estimateTypes", + "\n .Where(et => et.InputSource.Contains(x))", + "\n .Select(et => et.SystemName)", + "\n .ToHashSet());", + "\n ", + "\n //ProjectionConfiguration : Current Period + projection for every Quarter End for current Year and next Years as in projectionConfiguration.csv", + "\n ProjectionConfiguration = (await workspace.Query()", + "\n .Where(x => x.Shift > 0 || x.TimeStep == args.Month || (x.TimeStep > args.Month && x.TimeStep % periodicityInMonths == 0))", + "\n .OrderBy(x => x.Shift).ThenBy(x => x.TimeStep).ToArrayAsync());", + "\n ", + "\n //Get Partitions", + "\n PartitionByRn = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode).ToArrayAsync()).Single().Id;", + "\n TargetPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == CurrentReportingPeriod.Year &&", + "\n p.Month == CurrentReportingPeriod.Month &&", + "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", + "\n DefaultPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == CurrentReportingPeriod.Year &&", + "\n p.Month == CurrentReportingPeriod.Month &&", + "\n p.Scenario == null).ToArrayAsync()).Single().Id;", + "\n //Set Partitions", + "\n await querySource.Partition.SetAsync(PartitionByRn);", + "\n await workspace.Partition.SetAsync(PartitionByRn);", + "\n ", + "\n await querySource.Partition.SetAsync(TargetPartition);", + "\n await workspace.Partition.SetAsync(TargetPartition);", + "\n ", + "\n //Get data from Workspace (result of parsing)", + "\n var parsedRawVariables = await workspace.Query().ToArrayAsync();", + "\n var parsedIfrsVariables = await workspace.Query().ToArrayAsync();", + "\n ", + "\n //DataNodes", + "\n DataNodeDataBySystemName = await workspace.LoadDataNodesAsync(args);", + "\n ", + "\n //Accident Years", + "\n AccidentYearsByDataNode = (IDictionary>)", + "\n (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => new {x.DataNode, x.AccidentYear}) : parsedIfrsVariables.Select(x => new {x.DataNode, x.AccidentYear}))", + "\n .ToDictionaryGrouped(x => x.DataNode, x => (ICollection)x.Select(y => y.AccidentYear).ToHashSet());", + "\n ", + "\n // Import Scopes and Data Node relationship parameters", + "\n InterDataNodeParametersByGoc = await workspace.LoadInterDataNodeParametersAsync(args);", + "\n ", + "\n var primaryScopeFromParsedVariables = (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => x.DataNode) : parsedIfrsVariables.Select(x => x.DataNode)).ToHashSet();", + "\n PrimaryScopeFromLinkedReinsurance = primaryScopeFromParsedVariables", + "\n .Where(goc => !DataNodeDataBySystemName[goc].IsReinsurance && DataNodeDataBySystemName[goc].LiabilityType == LiabilityTypes.LRC)", + "\n .SelectMany(goc => InterDataNodeParametersByGoc.TryGetValue(goc, out var interDataNodeParamByPeriod)", + "\n ? interDataNodeParamByPeriod[CurrentPeriod].Select(param => param.DataNode == goc ? param.LinkedDataNode : param.DataNode).Where(goc => !primaryScopeFromParsedVariables.Contains(goc))", + "\n : Enumerable.Empty())", + "\n .ToHashSet();", + "\n ", + "\n var primaryScope = primaryScopeFromParsedVariables.Concat(PrimaryScopeFromLinkedReinsurance).ToHashSet();", + "\n var secondaryScope = InterDataNodeParametersByGoc", + "\n .Where(kvp => primaryScope.Contains(kvp.Key))", + "\n .SelectMany(kvp => { var linkedGocs = kvp.Value[CurrentPeriod].Select(param => param.DataNode == kvp.Key ? param.LinkedDataNode : param.DataNode);", + "\n return linkedGocs.Where(goc => !primaryScope.Contains(goc));}).ToHashSet();", + "\n var allImportScopes = new HashSet(primaryScope.Concat(secondaryScope));", + "\n ", + "\n DataNodesByImportScope = new Dictionary> { { ImportScope.Primary, primaryScope }, { ImportScope.Secondary, secondaryScope } };", + "\n ", + "\n // Parameters", + "\n PartnerRating = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Partner);", + "\n CreditDefaultRates = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.CreditRiskRating);", + "\n SingleDataNodeParametersByGoc = await workspace.LoadSingleDataNodeParametersAsync(args);", + "\n LockedInYieldCurve = await workspace.LoadLockedInYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn]));", + "\n CurrentYieldCurve = await workspace.LoadCurrentYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn])); //TODO Rename this variable", + "\n ", + "\n AocConfigurationByAocStep = await querySource.LoadAocStepConfigurationAsDictionaryAsync(args.Year, args.Month); ", + "\n aocStepByInputSource = ((InputSource[])Enum.GetValues(typeof(InputSource))).ToDictionary(x => x,", + "\n x => AocConfigurationByAocStep", + "\n .Where(kvp => kvp.Value.InputSource.Contains(x))", + "\n .Select(kvp => kvp.Key)", + "\n .ToHashSet());", + "\n ", + "\n //Previous Period", + "\n var openingRawVariables = Enumerable.Empty();", + "\n var openingIfrsVariables = Enumerable.Empty();", + "\n", + "\n if(allImportScopes.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year < args.Year)) {", + "\n PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == PreviousReportingPeriod.Year &&", + "\n p.Month == PreviousReportingPeriod.Month &&", + "\n p.Scenario == null).ToArrayAsync()).Single().Id; // This can send an exception", + "\n ", + "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", + "\n ", + "\n //Perform queries to previous Period", + "\n openingRawVariables = (await querySource.Query()", + "\n .Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == AocTypes.CL)", + "\n .Where(v => primaryScope.Contains(v.DataNode))", + "\n .ToArrayAsync())", + "\n .Select(rv => rv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Values = rv.Values.Skip(MonthInAYear).ToArray(), Partition = TargetPartition});", + "\n ", + "\n openingIfrsVariables = (await querySource.Query()", + "\n .Where(iv => iv.Partition == PreviousPeriodPartition && iv.AocType == AocTypes.EOP)", + "\n .Where(v => allImportScopes.Contains(v.DataNode))", + "\n .ToArrayAsync())", + "\n .Select(iv => iv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Partition = TargetPartition});", + "\n ", + "\n // TODO: print error if ", + "\n //openingRawVariables.Select(x => x.DataNode).ToHashSet() != dataNodesWithPreviousPeriod", + "\n }", + "\n ", + "\n //SetPartition to current Period", + "\n await querySource.Partition.SetAsync(TargetPartition);", + "\n ", + "\n if(primaryScope.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year == args.Year) && ImportFormat != ImportFormats.Opening)", + "\n openingIfrsVariables = openingIfrsVariables.Concat(await querySource.Query()", + "\n .Where(iv => iv.Partition == TargetPartition && iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)", + "\n .Where(iv => primaryScope.Contains(iv.DataNode) && EstimateTypesByImportFormat[InputSource.Opening.ToString()].Contains(iv.EstimateType) || secondaryScope.Contains(iv.DataNode))", + "\n .ToArrayAsync());", + "\n ", + "\n //Variables", + "\n var rawVariables = parsedRawVariables.Concat(openingRawVariables)", + "\n .Concat(await querySource.Query()", + "\n .Where(rv => rv.Partition == TargetPartition)", + "\n .Where(rv => PrimaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", + "\n .ToArrayAsync());", + "\n", + "\n if(DefaultPartition != TargetPartition){", + "\n var orderedPartition = new List {TargetPartition, DefaultPartition};", + "\n await querySource.Partition.SetAsync(DefaultPartition);", + "\n var defaultRawVariables = await querySource.Query()", + "\n .Where(rv => rv.Partition == DefaultPartition)", + "\n .Where(rv => primaryScopeFromParsedVariables.Contains(rv.DataNode)).ToArrayAsync();", + "\n rawVariables = rawVariables.Concat(defaultRawVariables)", + "\n .GroupBy(rv => ", + "\n new {rv.DataNode, rv.AocType, rv.Novelty, rv.EstimateType, rv.AccidentYear, rv.Partition})", + "\n .OrderBy(grv => orderedPartition.IndexOf(grv.Key.Partition))", + "\n .Select(grv => grv.FirstOrDefault());", + "\n DefaultRawVariables = defaultRawVariables; ", + "\n }", + "\n else {", + "\n DefaultRawVariables = Enumerable.Empty().ToArray();", + "\n }", + "\n ", + "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", + "\n ", + "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", + "\n .Concat(await querySource.Query()", + "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)) //Actuals or Gross", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || PrimaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", + "\n || secondaryScope.Contains(iv.DataNode))", + "\n .ToArrayAsync());", + "\n IfrsVariablesByImportIdentity = (IDictionary>)ifrsVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", + "\n }", + "\n ", + "\n //Getters", + "\n ", + "\n //Periods", + "\n public ValuationPeriod GetValuationPeriod(ImportIdentity id) => AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].ValuationPeriod;", + "\n public PeriodType GetYieldCurvePeriod(ImportIdentity id) => AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].YcPeriod;", + "\n public PeriodType GetCreditDefaultRiskPeriod(ImportIdentity id) => AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].CdrPeriod;", + "\n ", + "\n public IEnumerable GetAllAocSteps(InputSource source) => aocStepByInputSource[source];", + "\n public IEnumerable GetCalculatedTelescopicAocSteps() => AocConfigurationByAocStep.Where(kvp => kvp.Value.DataType == DataType.CalculatedTelescopic).Select(kvp => kvp.Key);", + "\n ", + "\n //YieldCurve", + "\n public double[] GetYearlyYieldCurve(ImportIdentity id, string economicBasis) {", + "\n var yc = GetYieldCurve(id, economicBasis);", + "\n return yc.Values.Skip(args.Year - yc.Year).ToArray(); //Check if the returned array is empty? Log Warning?", + "\n }", + "\n ", + "\n public YieldCurve GetYieldCurve(ImportIdentity id, string economicBasis) => (economicBasis, GetYieldCurvePeriod(id)) switch {", + "\n (EconomicBases.C, PeriodType.BeginningOfPeriod) => CurrentYieldCurve[DataNodeDataBySystemName[id.DataNode].ContractualCurrency][PreviousPeriod],", + "\n (EconomicBases.C, PeriodType.EndOfPeriod) => CurrentYieldCurve[DataNodeDataBySystemName[id.DataNode].ContractualCurrency][CurrentPeriod],", + "\n (EconomicBases.L, _ ) => LockedInYieldCurve[id.DataNode],", + "\n (_, PeriodType.NotApplicable) => (YieldCurve)ApplicationMessage.Log(Error.YieldCurvePeriodNotApplicable, id.AocType, id.Novelty),", + "\n (_, _) => (YieldCurve)ApplicationMessage.Log(Error.EconomicBasisNotFound, id.DataNode)", + "\n };", + "\n ", + "\n //int Identity.ProjectionPeriod ", + "\n public int GetProjectionCount() => ProjectionConfiguration.Count();", + "\n public int GetShift(int projectionPeriod) => ProjectionConfiguration[projectionPeriod].Shift;", + "\n public int GetTimeStep(int projectionPeriod) => ProjectionConfiguration[projectionPeriod].TimeStep;", + "\n ", + "\n public PeriodType GetPeriodType(string amountType, string estimateType) => ", + "\n amountType != null && AmountTypeDimension.TryGetValue(amountType, out var at) ", + "\n ? at.PeriodType", + "\n : estimateType != null && EstimateTypeDimension.TryGetValue(estimateType, out var ct) ", + "\n ? ct.PeriodType : PeriodType.EndOfPeriod;", + "\n", + "\n //Variables and Cashflows", + "\n ", + "\n public IDictionary> TestRawVars() => RawVariablesByImportIdentity;", + "\n public IDictionary> TestIfrsVars() => IfrsVariablesByImportIdentity;", + "\n public IEnumerable GetRawVariables(string dataNode) => RawVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", + "\n public IEnumerable GetIfrsVariables(string dataNode) => IfrsVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", + "\n ", + "\n public double[] GetValues(ImportIdentity id, Func whereClause) => GetRawVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Values ?? Enumerable.Empty().ToArray();", + "\n public double GetValue(ImportIdentity id, Func whereClause) => GetIfrsVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Value ?? 0;", + "\n ", + "\n public double[] GetValues(ImportIdentity id, string amountType, string estimateType, int? accidentYear) => GetValues(id, v => v.AccidentYear == accidentYear && v.AmountType == amountType && v.EstimateType == estimateType);", + "\n public double GetValue(ImportIdentity id, string amountType, string estimateType, int? accidentYear) => GetValue(id, v => v.AccidentYear == accidentYear && v.AmountType == amountType && v.EstimateType == estimateType);", + "\n public double GetValue(ImportIdentity id, string amountType, string estimateType, string economicBasis, int? accidentYear) => GetValue(id, v => v.AccidentYear == accidentYear && v.AmountType == amountType && v.EstimateType == estimateType && v.EconomicBasis == economicBasis);", + "\n ", + "\n //Novelty", + "\n private IEnumerable GetNoveltiesForAocType(string aocType, IEnumerable aocConfiguration) => aocConfiguration.Where(aocStep => aocStep.AocType == aocType).Select(aocStep => aocStep.Novelty);", + "\n public IEnumerable GetNovelties() => NoveltyDimension.Keys;", + "\n public IEnumerable GetNovelties(string aocType) => GetNoveltiesForAocType(aocType, AocConfigurationByAocStep.Keys);", + "\n public IEnumerable GetNovelties(string aocType, InputSource inputSource) => GetNoveltiesForAocType(aocType, aocStepByInputSource[inputSource]);", + "\n ", + "\n //Accident years", + "\n public IEnumerable GetAccidentYears(string dataNode) => AccidentYearsByDataNode.TryGetValue(dataNode, out var accidentYear) ? accidentYear : new int?[] { null };", + "\n ", + "\n // Parameters", + "\n public double GetNonPerformanceRiskRate (ImportIdentity identity) {", + "\n var period = GetCreditDefaultRiskPeriod(identity) == PeriodType.BeginningOfPeriod ? PreviousPeriod : CurrentPeriod;", + "\n ", + "\n if(!DataNodeDataBySystemName.TryGetValue(identity.DataNode, out var dataNodeData)) ApplicationMessage.Log(Error.DataNodeNotFound, identity.DataNode);", + "\n if(dataNodeData.Partner == null) ApplicationMessage.Log(Error.PartnerNotFound, identity.DataNode);", + "\n // if Partner == Internal then return 0;", + "\n if(!PartnerRating.TryGetValue(dataNodeData.Partner, out var rating)) ApplicationMessage.Log(Error.RatingNotFound, dataNodeData.Partner);", + "\n if(!CreditDefaultRates.TryGetValue(rating[period].CreditRiskRating, out var rate)) ApplicationMessage.Log(Error.CreditDefaultRateNotFound, rating[period].CreditRiskRating);", + "\n return rate[period].Values[0];", + "\n }", + "\n ", + "\n public double GetPremiumAllocationFactor(ImportIdentity id) => SingleDataNodeParametersByGoc.TryGetValue(id.DataNode, out var singleDataNodeParameter) ", + "\n ? singleDataNodeParameter[CurrentPeriod].PremiumAllocation : DefaultPremiumExperienceAdjustmentFactor;", + "\n ", + "\n // Data Node relationships", + "\n public IEnumerable GetUnderlyingGic(ImportIdentity id) => !InterDataNodeParametersByGoc.TryGetValue(id.DataNode, out var interDataNodeParameters)", + "\n ? Enumerable.Empty()", + "\n : interDataNodeParameters[CurrentPeriod].Select(x => x.DataNode != id.DataNode ? x.DataNode : x.LinkedDataNode).Where(goc => !DataNodeDataBySystemName[goc].IsReinsurance);", + "\n ", + "\n public double GetReinsuranceCoverage (ImportIdentity id, string gic) ", + "\n {", + "\n var targetPeriod = AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].RcPeriod == PeriodType.EndOfPeriod ? CurrentPeriod : PreviousPeriod;", + "\n return InterDataNodeParametersByGoc.TryGetValue(id.DataNode, out var interDataNodeParameters)", + "\n ? interDataNodeParameters[targetPeriod].FirstOrDefault(x => x.DataNode == gic || x.LinkedDataNode == gic).ReinsuranceCoverage", + "\n : (double)ApplicationMessage.Log(Error.ReinsuranceCoverage, id.DataNode);", + "\n }", + "\n ", + "\n // Import Scope", + "\n public bool IsPrimaryScope (string dataNode) => DataNodesByImportScope[ImportScope.Primary].Contains(dataNode);", + "\n public bool IsSecondaryScope (string dataNode) => DataNodesByImportScope[ImportScope.Secondary].Contains(dataNode);", + "\n ", + "\n // Other", + "\n public IEnumerable GetNonAttributableAmountType() => new string[]{AmountTypes.NE};", + "\n public IEnumerable GetAttributableExpenseAndCommissionAmountType() => new string[] {AmountTypes.ACA, AmountTypes.AEA}; //U+ specific", + "\n public IEnumerable GetInvestmentClaims() => hierarchyCache.Get(AmountTypes.ICO).Descendants(includeSelf : true).Select(x => x.SystemName);", + "\n public IEnumerable GetPremiums() => hierarchyCache.Get(AmountTypes.PR).Descendants(includeSelf : true).Select(x => x.SystemName);", + "\n public IEnumerable GetClaims() => hierarchyCache.Get(AmountTypes.CL).Descendants().Select(x => x.SystemName);", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "var fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\";", + "\nActivity.Start();", + "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", + "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", + "\nif(Activity.HasErrors()) return Activity.Finish();", + "\n ", + "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", + "\nif(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", + "\n ", + "\nvar storage = new ImportStorage(args, DataSource, Workspace);", + "\nawait storage.InitializeAsync();", + "\nvar test = storage.TestRawVars();", + "\n", + "\nawait DataSource.Partition.SetAsync(targetPartition);", + "\nvar defaultRawVariables = await DataSource.Query()", + "\n .Where(rv => rv.Partition == targetPartition)", + "\n .ToArrayAsync();", + "\ntest[dataNode].GroupBy(x => x.Partition).Select(x => x)", + "\n/*", + "\n.ToDictionaryGrouped( x => x.Partition, x=> x).Keys;", + "\nrawDictScenario", + "\n /*.GroupBy(rv => ImportIdentity)", + "\n .Select(rv => rv.OrderByDescending(x => x.Scenario)", + "\n .FirstOrDefault()).ToArray();", + "\nif(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", + "\nvar idGroups = rawDictScenario[dataNode].ToDictionaryGrouped( x => x.Partition, x=> x);", + "\nvar universe = Scopes.ForStorage(storage).ToScope();", + "\nvar identities = universe.GetScopes(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);", + "\nvar ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", + "\nif(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", + "\nvar test = ivs.ToDictionaryGrouped( x => x.Partition, x=> x);", + "\ntest", + "\nawait Workspace.UpdateAsync(ivs);", + "\nawait CommitToDatabase(storage.TargetPartition, ", + "\n snapshot : true, ", + "\n filter : x => storage.EstimateTypesByImportFormat[ImportFormats.Cashflow].Contains(x.EstimateType) && ", + "\n storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode)); ", + "\nawait CommitToDatabase(storage.TargetPartition, ", + "\n snapshot : true,", + "\n filter : x => storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode));", + "\n", + "\n", + "\nvar idGroups = ifrsDict[dataNode].ToDictionaryGrouped( x => x.Id, x=> x);", + "\nidGroups.Keys", + "\nvar test = ifrsDict[dataNode].ToList().Select(x => new { x.Id == defif(x.Id == targetPartition || x.Id == defaultPartition) new x : null});*/" + ] + }, + { + "cell_type": "code", + "source": [ + "" ] }, { "cell_type": "code", "source": [ - "//await DataSource.Partition.SetAsync(targetPartition);", - "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\");", - "\nvar computedVariablesByEstimateTypeWithScenario = (await DataSource.Query().Where(x => x.Partition == targetPartition).ToArrayAsync());", - "\ncomputedVariablesByEstimateTypeWithScenario.Count()" + "var fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\";", + "\nActivity.Start();", + "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", + "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", + "\nif(Activity.HasErrors()) return Activity.Finish();", + "\n ", + "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", + "\nif(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", + "\n ", + "\nvar storage = new ImportStorage(args, DataSource, Workspace);", + "\nawait storage.InitializeAsync();", + "\nvar rawDictBE = storage.TestRawVars();", + "\nif(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", + "\nvar idGroups = rawDictBE[dataNode].ToDictionaryGrouped( x => x.Partition, x=> x);", + "\nidGroups.Keys" ] }, { diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 472af983..6c6ca277 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -90,6 +90,7 @@ "\n //Variables", "\n public IDictionary> RawVariablesByImportIdentity { get; private set; }", "\n public IDictionary> IfrsVariablesByImportIdentity { get; private set; }", + "\n public RawVariable[] DefaultRawVariables { get; private set; }", "\n ", "\n //Parameters", "\n public Dictionary LockedInYieldCurve { get; private set; }", @@ -253,11 +254,24 @@ "\n .Where(rv => rv.Partition == TargetPartition)", "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", "\n .ToArrayAsync());", + "\n", + "\n if(DefaultPartition != TargetPartition){", + "\n await querySource.Partition.SetAsync(DefaultPartition);", + "\n var defaultRawVariables = await querySource.Query()", + "\n .Where(rv => rv.Partition == DefaultPartition)", + "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode)).ToArrayAsync();", + "\n rawVariables = rawVariables.Concat(defaultRawVariables);", + "\n DefaultRawVariables = defaultRawVariables; ", + "\n }", + "\n else {", + "\n DefaultRawVariables = Enumerable.Empty().ToArray();", + "\n }", + "\n ", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", "\n ", "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", "\n .Concat(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", + "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)) //Actuals or Gross", "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", "\n || secondaryScope.Contains(iv.DataNode))", @@ -301,8 +315,19 @@ "\n ? ct.PeriodType : PeriodType.EndOfPeriod;", "\n", "\n //Variables and Cashflows", + "\n ", + "\n public IDictionary> TestRawVars() => RawVariablesByImportIdentity;", + "\n //public IEnumerable EnumRawVars() => DefaultRawVariables;", + "\n public IDictionary> TestIfrsVars() => IfrsVariablesByImportIdentity;", "\n public IEnumerable GetRawVariables(string dataNode) => RawVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", "\n public IEnumerable GetIfrsVariables(string dataNode) => IfrsVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", + "\n /*? variableCollection.Select(", + "\n x => x.Scenario switch {", + "\n args.Scenario => new IfrsVariable(x),", + "\n null => new IfrsVariable(x),", + "\n _ => null", + "\n }", + "\n ) : Enumerable.Empty();*/", "\n ", "\n public double[] GetValues(ImportIdentity id, Func whereClause) => GetRawVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Values ?? Enumerable.Empty().ToArray();", "\n public double GetValue(ImportIdentity id, Func whereClause) => GetIfrsVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Value ?? 0;", From 193c06669ea251d33f3a2d1300a41b4362fab26b Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Thu, 27 Oct 2022 09:04:44 +0200 Subject: [PATCH 10/23] checking multiple import of the same scenario --- .../NominalCashflows_CH_2020_12_Scenario.csv | 76 ---- ...ominalCashflows_CH_2020_12_Scenario_BE.csv | 9 + .../Initialization/testEqualityComparer.ipynb | 77 ++++ full-ifrs17-template/Test/ScenarioTest.ipynb | 414 +----------------- ifrs17/Constants/Validations.ipynb | 4 +- ifrs17/DataModel/DataStructure.ipynb | 35 ++ ifrs17/Import/ImportStorage.ipynb | 18 +- ifrs17/Import/Importers.ipynb | 32 ++ 8 files changed, 169 insertions(+), 496 deletions(-) create mode 100644 full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv create mode 100644 full-ifrs17-template/Initialization/testEqualityComparer.ipynb diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv index 380f8ef1..8bd8e6e2 100644 --- a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv +++ b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv @@ -3,83 +3,7 @@ ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, CH,2020,12,IRU,,,,,,,,,,,,,,,,,,,,,,,,, @@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 -DT1.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT1.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT1.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT1.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 DT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 DT1.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 DT1.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 DT1.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT1.2,NIC,BOP,N,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT1.2,CU,BOP,N,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT1.2,RA,BOP,N,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT1.2,NIC,CL,C,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT1.2,CU,CL,C,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT1.2,RA,CL,C,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT1.3,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT1.3,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT1.3,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT1.3,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT1.3,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT1.3,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT1.3,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT1.3,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT2.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT2.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT2.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT2.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT2.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT2.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT2.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT2.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT2.2,NIC,BOP,N,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT2.2,CU,BOP,N,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT2.2,RA,BOP,N,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT2.2,NIC,CL,C,2020,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT2.2,CU,CL,C,2020,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT2.2,RA,CL,C,2020,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DTR1.1,PR,BOP,N,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 -DTR1.1,NIC,BOP,N,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR1.1,CU,BOP,N,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR1.1,RA,BOP,N,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR1.1,PR,CL,C,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 -DTR1.1,NIC,CL,C,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR1.1,CU,CL,C,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR1.1,RA,CL,C,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR1.2,NIC,BOP,N,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR1.2,CU,BOP,N,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR1.2,RA,BOP,N,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR1.2,NIC,CL,C,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR1.2,CU,CL,C,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR1.2,RA,CL,C,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR2.1,PR,BOP,N,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 -DTR2.1,NIC,BOP,N,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR2.1,CU,BOP,N,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR2.1,RA,BOP,N,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR2.1,PR,CL,C,,55,0,0,55,0,0,55,0,0,55,0,0,0,55,0,0,55,0,0,55,0,0,55,0 -DTR2.1,NIC,CL,C,,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR2.1,CU,CL,C,,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR2.1,RA,CL,C,,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR2.2,NIC,BOP,N,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR2.2,CU,BOP,N,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR2.2,RA,BOP,N,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DTR2.2,NIC,CL,C,2020,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75,-13.75 -DTR2.2,CU,CL,C,2020,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,1.65 -DTR2.2,RA,CL,C,2020,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375,-1.375 -DT3.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT3.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT3.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT3.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT3.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT3.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT3.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT3.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT4.1,PR,BOP,N,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT4.1,NIC,BOP,N,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT4.1,CU,BOP,N,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT4.1,RA,BOP,N,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 -DT4.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT4.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT4.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT4.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv new file mode 100644 index 00000000..b2b4ed32 --- /dev/null +++ b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv @@ -0,0 +1,9 @@ +@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, +CH,2020,12,IRU,,,,,,,,,,,,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, +DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 +DT1.1,PR,BOP,N,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0 +DT1.1,NIC,BOP,N,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25 +DT1.1,CU,BOP,N,,10,10,10,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,5,5,5,5,5,3 +DT1.1,RA,BOP,N,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5 diff --git a/full-ifrs17-template/Initialization/testEqualityComparer.ipynb b/full-ifrs17-template/Initialization/testEqualityComparer.ipynb new file mode 100644 index 00000000..7482c101 --- /dev/null +++ b/full-ifrs17-template/Initialization/testEqualityComparer.ipynb @@ -0,0 +1,77 @@ +{ + "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": [ + "#!eval-notebook \"InitSystemorphBaseToMemory\"" + ] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" + ] + }, + { + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);" + ] + }, + { + "cell_type": "code", + "source": [ + "await UploadOpeningAsync(\"../Files/900.TransactionalData/Openings_CH_2020_12.csv\")" + ] + }, + { + "cell_type": "code", + "source": [ + "var fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\";", + "\nActivity.Start();", + "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", + "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", + "\nif(Activity.HasErrors()) return Activity.Finish();", + "\n ", + "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", + "\n", + "\nvar targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == args.Year &&", + "\n p.Month == args.Month &&", + "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", + "\nawait Workspace.Partition.SetAsync(targetPartition); ", + "\nawait DataSource.Partition.SetAsync(targetPartition);", + "\nvar parsedVariables = await Workspace.Query().ToArrayAsync();", + "\nvar savedVariables = await DataSource.Query().ToArrayAsync();", + "\nvar updatedVariables = savedVariables?.Union(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", + "\nvar newVariables = updatedVariables?.Except(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", + "\nif(newVariables.Count() == 0) {", + "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", + "\n return Activity.Finish().Merge(parsingLog);", + "\n }", + "\nreturn Activity.Finish().Merge(parsingLog);" + ] + }, + { + "cell_type": "code", + "source": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index 54493262..3e4e3fb3 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -18,17 +18,18 @@ { "cell_type": "code", "source": [ - "var scenario = \"IRU\";", - "\nvar year = 2020;", - "\nvar month = 12;", - "\nvar reportingNode = \"CH\";", - "\nvar dataNode = \"DT1.1\";" + "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" ] }, { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" + "var scenario = \"IRU\";", + "\nvar year = 2020;", + "\nvar month = 12;", + "\nvar reportingNode = \"CH\";", + "\nvar dataNode = \"DT1.1\";", + "\nvar format = ImportFormats.Cashflow;" ] }, { @@ -60,414 +61,19 @@ { "cell_type": "code", "source": [ - "#!import \"../../ifrs17/Utils/ImportCalculationMethods\"", - "\n#!import \"../../ifrs17/Utils/Queries\"" - ] - }, - { - "cell_type": "code", - "source": [ - "public class ImportStorage", - "\n{ ", - "\n private readonly IDataSource querySource; ", - "\n private readonly IWorkspace workspace;", - "\n private readonly Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchyCache;", - "\n private readonly ImportArgs args;", - "\n ", - "\n // Constants", - "\n private static int periodicityInMonths => 3; // Revisit", - "\n ", - "\n //Format", - "\n public string ImportFormat => args.ImportFormat; ", - "\n ", - "\n //Time Periods ", - "\n public (int Year, int Month) CurrentReportingPeriod => (args.Year, args.Month);", - "\n public (int Year, int Month) PreviousReportingPeriod => (args.Year - 1, MonthInAYear); // YTD Logic", - "\n", - "\n //Partitions", - "\n public Guid PartitionByRn;", - "\n public Guid TargetPartition;", - "\n public Guid DefaultPartition;", - "\n public Guid PreviousPeriodPartition; ", - "\n", - "\n //Projections", - "\n private ProjectionConfiguration[] ProjectionConfiguration;", - "\n ", - "\n //DataNodes", - "\n public IDictionary DataNodeDataBySystemName { get; private set; }", - "\n public IDictionary> DataNodesByImportScope { get; private set; }", - "\n public IDictionary> AccidentYearsByDataNode { get; private set; }", - "\n //Variables", - "\n public IDictionary> RawVariablesByImportIdentity { get; private set; }", - "\n public IDictionary> IfrsVariablesByImportIdentity { get; private set; }", - "\n public RawVariable[] DefaultRawVariables { get; private set; }", - "\n public HashSet PrimaryScopeFromLinkedReinsurance { get; private set; }", - "\n ", - "\n //Parameters", - "\n public Dictionary LockedInYieldCurve { get; private set; }", - "\n public Dictionary> CurrentYieldCurve { get; private set; }", - "\n public Dictionary> PartnerRating { get; private set; }", - "\n public Dictionary> CreditDefaultRates { get; private set; }", - "\n public Dictionary> SingleDataNodeParametersByGoc { get; private set; }", - "\n public Dictionary>> InterDataNodeParametersByGoc { get; private set; }", - "\n public Dictionary AocConfigurationByAocStep { get; private set; }", - "\n ", - "\n private Dictionary> aocStepByInputSource;", - "\n ", - "\n //Dimensions", - "\n public Dictionary AmountTypeDimension { get; private set; }", - "\n public Dictionary NoveltyDimension { get; private set; }", - "\n public Dictionary EstimateTypeDimension { get; private set; }", - "\n public Dictionary> EstimateTypesByImportFormat { get; private set; }", - "\n public Dictionary ExperienceAdjustEstimateTypeMapping { get; private set; } ", - "\n ", - "\n //Constructor", - "\n public ImportStorage(ImportArgs args, IDataSource querySource, IWorkspace workspace)", - "\n {", - "\n this.querySource = querySource;", - "\n this.workspace = workspace;", - "\n hierarchyCache = workspace.ToHierarchicalDimensionCache();", - "\n this.args = args;", - "\n }", - "\n ", - "\n //Initialize", - "\n public async Task InitializeAsync()", - "\n { ", - "\n //Dimensions", - "\n var estimateTypes = (await workspace.Query().ToArrayAsync());", - "\n ", - "\n EstimateTypeDimension = estimateTypes.ToDictionary(x => x.SystemName);", - "\n AmountTypeDimension = (await workspace.Query().ToArrayAsync()).ToDictionary(x => x.SystemName);", - "\n NoveltyDimension = (await workspace.Query().ToArrayAsync()).ToDictionary(x => x.SystemName);", - "\n ", - "\n ExperienceAdjustEstimateTypeMapping = new Dictionary{{EstimateTypes.A, EstimateTypes.APA}, {EstimateTypes.AA, EstimateTypes.AAPA}, {EstimateTypes.OA, EstimateTypes.OAPA}}; //TODO move this logic", - "\n ", - "\n //Hierarchy Cache", - "\n hierarchyCache.Initialize();", - "\n ", - "\n //EstimateType to load and to update", - "\n EstimateTypesByImportFormat = new InputSource[] { InputSource.Opening, InputSource.Actual, InputSource.Cashflow,}", - "\n .ToDictionary(x => x.ToString(), ", - "\n x => estimateTypes", - "\n .Where(et => et.InputSource.Contains(x))", - "\n .Select(et => et.SystemName)", - "\n .ToHashSet());", - "\n ", - "\n //ProjectionConfiguration : Current Period + projection for every Quarter End for current Year and next Years as in projectionConfiguration.csv", - "\n ProjectionConfiguration = (await workspace.Query()", - "\n .Where(x => x.Shift > 0 || x.TimeStep == args.Month || (x.TimeStep > args.Month && x.TimeStep % periodicityInMonths == 0))", - "\n .OrderBy(x => x.Shift).ThenBy(x => x.TimeStep).ToArrayAsync());", - "\n ", - "\n //Get Partitions", - "\n PartitionByRn = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode).ToArrayAsync()).Single().Id;", - "\n TargetPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == CurrentReportingPeriod.Year &&", - "\n p.Month == CurrentReportingPeriod.Month &&", - "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", - "\n DefaultPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == CurrentReportingPeriod.Year &&", - "\n p.Month == CurrentReportingPeriod.Month &&", - "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n //Set Partitions", - "\n await querySource.Partition.SetAsync(PartitionByRn);", - "\n await workspace.Partition.SetAsync(PartitionByRn);", - "\n ", - "\n await querySource.Partition.SetAsync(TargetPartition);", - "\n await workspace.Partition.SetAsync(TargetPartition);", - "\n ", - "\n //Get data from Workspace (result of parsing)", - "\n var parsedRawVariables = await workspace.Query().ToArrayAsync();", - "\n var parsedIfrsVariables = await workspace.Query().ToArrayAsync();", - "\n ", - "\n //DataNodes", - "\n DataNodeDataBySystemName = await workspace.LoadDataNodesAsync(args);", - "\n ", - "\n //Accident Years", - "\n AccidentYearsByDataNode = (IDictionary>)", - "\n (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => new {x.DataNode, x.AccidentYear}) : parsedIfrsVariables.Select(x => new {x.DataNode, x.AccidentYear}))", - "\n .ToDictionaryGrouped(x => x.DataNode, x => (ICollection)x.Select(y => y.AccidentYear).ToHashSet());", - "\n ", - "\n // Import Scopes and Data Node relationship parameters", - "\n InterDataNodeParametersByGoc = await workspace.LoadInterDataNodeParametersAsync(args);", - "\n ", - "\n var primaryScopeFromParsedVariables = (ImportFormat == ImportFormats.Cashflow ? parsedRawVariables.Select(x => x.DataNode) : parsedIfrsVariables.Select(x => x.DataNode)).ToHashSet();", - "\n PrimaryScopeFromLinkedReinsurance = primaryScopeFromParsedVariables", - "\n .Where(goc => !DataNodeDataBySystemName[goc].IsReinsurance && DataNodeDataBySystemName[goc].LiabilityType == LiabilityTypes.LRC)", - "\n .SelectMany(goc => InterDataNodeParametersByGoc.TryGetValue(goc, out var interDataNodeParamByPeriod)", - "\n ? interDataNodeParamByPeriod[CurrentPeriod].Select(param => param.DataNode == goc ? param.LinkedDataNode : param.DataNode).Where(goc => !primaryScopeFromParsedVariables.Contains(goc))", - "\n : Enumerable.Empty())", - "\n .ToHashSet();", - "\n ", - "\n var primaryScope = primaryScopeFromParsedVariables.Concat(PrimaryScopeFromLinkedReinsurance).ToHashSet();", - "\n var secondaryScope = InterDataNodeParametersByGoc", - "\n .Where(kvp => primaryScope.Contains(kvp.Key))", - "\n .SelectMany(kvp => { var linkedGocs = kvp.Value[CurrentPeriod].Select(param => param.DataNode == kvp.Key ? param.LinkedDataNode : param.DataNode);", - "\n return linkedGocs.Where(goc => !primaryScope.Contains(goc));}).ToHashSet();", - "\n var allImportScopes = new HashSet(primaryScope.Concat(secondaryScope));", - "\n ", - "\n DataNodesByImportScope = new Dictionary> { { ImportScope.Primary, primaryScope }, { ImportScope.Secondary, secondaryScope } };", - "\n ", - "\n // Parameters", - "\n PartnerRating = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.Partner);", - "\n CreditDefaultRates = await workspace.LoadCurrentAndPreviousParameterAsync(args, x => x.CreditRiskRating);", - "\n SingleDataNodeParametersByGoc = await workspace.LoadSingleDataNodeParametersAsync(args);", - "\n LockedInYieldCurve = await workspace.LoadLockedInYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn]));", - "\n CurrentYieldCurve = await workspace.LoadCurrentYieldCurveAsync(args, allImportScopes.Select(dn => DataNodeDataBySystemName[dn])); //TODO Rename this variable", - "\n ", - "\n AocConfigurationByAocStep = await querySource.LoadAocStepConfigurationAsDictionaryAsync(args.Year, args.Month); ", - "\n aocStepByInputSource = ((InputSource[])Enum.GetValues(typeof(InputSource))).ToDictionary(x => x,", - "\n x => AocConfigurationByAocStep", - "\n .Where(kvp => kvp.Value.InputSource.Contains(x))", - "\n .Select(kvp => kvp.Key)", - "\n .ToHashSet());", - "\n ", - "\n //Previous Period", - "\n var openingRawVariables = Enumerable.Empty();", - "\n var openingIfrsVariables = Enumerable.Empty();", - "\n", - "\n if(allImportScopes.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year < args.Year)) {", - "\n PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == PreviousReportingPeriod.Year &&", - "\n p.Month == PreviousReportingPeriod.Month &&", - "\n p.Scenario == null).ToArrayAsync()).Single().Id; // This can send an exception", - "\n ", - "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", - "\n ", - "\n //Perform queries to previous Period", - "\n openingRawVariables = (await querySource.Query()", - "\n .Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == AocTypes.CL)", - "\n .Where(v => primaryScope.Contains(v.DataNode))", - "\n .ToArrayAsync())", - "\n .Select(rv => rv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Values = rv.Values.Skip(MonthInAYear).ToArray(), Partition = TargetPartition});", - "\n ", - "\n openingIfrsVariables = (await querySource.Query()", - "\n .Where(iv => iv.Partition == PreviousPeriodPartition && iv.AocType == AocTypes.EOP)", - "\n .Where(v => allImportScopes.Contains(v.DataNode))", - "\n .ToArrayAsync())", - "\n .Select(iv => iv with {AocType = AocTypes.BOP, Novelty = Novelties.I, Partition = TargetPartition});", - "\n ", - "\n // TODO: print error if ", - "\n //openingRawVariables.Select(x => x.DataNode).ToHashSet() != dataNodesWithPreviousPeriod", - "\n }", - "\n ", - "\n //SetPartition to current Period", - "\n await querySource.Partition.SetAsync(TargetPartition);", - "\n ", - "\n if(primaryScope.Select(dn => DataNodeDataBySystemName[dn]).Any(dnd => dnd.Year == args.Year) && ImportFormat != ImportFormats.Opening)", - "\n openingIfrsVariables = openingIfrsVariables.Concat(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)", - "\n .Where(iv => primaryScope.Contains(iv.DataNode) && EstimateTypesByImportFormat[InputSource.Opening.ToString()].Contains(iv.EstimateType) || secondaryScope.Contains(iv.DataNode))", - "\n .ToArrayAsync());", - "\n ", - "\n //Variables", - "\n var rawVariables = parsedRawVariables.Concat(openingRawVariables)", - "\n .Concat(await querySource.Query()", - "\n .Where(rv => rv.Partition == TargetPartition)", - "\n .Where(rv => PrimaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", - "\n .ToArrayAsync());", - "\n", - "\n if(DefaultPartition != TargetPartition){", - "\n var orderedPartition = new List {TargetPartition, DefaultPartition};", - "\n await querySource.Partition.SetAsync(DefaultPartition);", - "\n var defaultRawVariables = await querySource.Query()", - "\n .Where(rv => rv.Partition == DefaultPartition)", - "\n .Where(rv => primaryScopeFromParsedVariables.Contains(rv.DataNode)).ToArrayAsync();", - "\n rawVariables = rawVariables.Concat(defaultRawVariables)", - "\n .GroupBy(rv => ", - "\n new {rv.DataNode, rv.AocType, rv.Novelty, rv.EstimateType, rv.AccidentYear, rv.Partition})", - "\n .OrderBy(grv => orderedPartition.IndexOf(grv.Key.Partition))", - "\n .Select(grv => grv.FirstOrDefault());", - "\n DefaultRawVariables = defaultRawVariables; ", - "\n }", - "\n else {", - "\n DefaultRawVariables = Enumerable.Empty().ToArray();", - "\n }", - "\n ", - "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", - "\n ", - "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", - "\n .Concat(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)) //Actuals or Gross", - "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", - "\n || PrimaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", - "\n || secondaryScope.Contains(iv.DataNode))", - "\n .ToArrayAsync());", - "\n IfrsVariablesByImportIdentity = (IDictionary>)ifrsVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", - "\n }", - "\n ", - "\n //Getters", - "\n ", - "\n //Periods", - "\n public ValuationPeriod GetValuationPeriod(ImportIdentity id) => AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].ValuationPeriod;", - "\n public PeriodType GetYieldCurvePeriod(ImportIdentity id) => AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].YcPeriod;", - "\n public PeriodType GetCreditDefaultRiskPeriod(ImportIdentity id) => AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].CdrPeriod;", - "\n ", - "\n public IEnumerable GetAllAocSteps(InputSource source) => aocStepByInputSource[source];", - "\n public IEnumerable GetCalculatedTelescopicAocSteps() => AocConfigurationByAocStep.Where(kvp => kvp.Value.DataType == DataType.CalculatedTelescopic).Select(kvp => kvp.Key);", - "\n ", - "\n //YieldCurve", - "\n public double[] GetYearlyYieldCurve(ImportIdentity id, string economicBasis) {", - "\n var yc = GetYieldCurve(id, economicBasis);", - "\n return yc.Values.Skip(args.Year - yc.Year).ToArray(); //Check if the returned array is empty? Log Warning?", - "\n }", - "\n ", - "\n public YieldCurve GetYieldCurve(ImportIdentity id, string economicBasis) => (economicBasis, GetYieldCurvePeriod(id)) switch {", - "\n (EconomicBases.C, PeriodType.BeginningOfPeriod) => CurrentYieldCurve[DataNodeDataBySystemName[id.DataNode].ContractualCurrency][PreviousPeriod],", - "\n (EconomicBases.C, PeriodType.EndOfPeriod) => CurrentYieldCurve[DataNodeDataBySystemName[id.DataNode].ContractualCurrency][CurrentPeriod],", - "\n (EconomicBases.L, _ ) => LockedInYieldCurve[id.DataNode],", - "\n (_, PeriodType.NotApplicable) => (YieldCurve)ApplicationMessage.Log(Error.YieldCurvePeriodNotApplicable, id.AocType, id.Novelty),", - "\n (_, _) => (YieldCurve)ApplicationMessage.Log(Error.EconomicBasisNotFound, id.DataNode)", - "\n };", - "\n ", - "\n //int Identity.ProjectionPeriod ", - "\n public int GetProjectionCount() => ProjectionConfiguration.Count();", - "\n public int GetShift(int projectionPeriod) => ProjectionConfiguration[projectionPeriod].Shift;", - "\n public int GetTimeStep(int projectionPeriod) => ProjectionConfiguration[projectionPeriod].TimeStep;", - "\n ", - "\n public PeriodType GetPeriodType(string amountType, string estimateType) => ", - "\n amountType != null && AmountTypeDimension.TryGetValue(amountType, out var at) ", - "\n ? at.PeriodType", - "\n : estimateType != null && EstimateTypeDimension.TryGetValue(estimateType, out var ct) ", - "\n ? ct.PeriodType : PeriodType.EndOfPeriod;", - "\n", - "\n //Variables and Cashflows", - "\n ", - "\n public IDictionary> TestRawVars() => RawVariablesByImportIdentity;", - "\n public IDictionary> TestIfrsVars() => IfrsVariablesByImportIdentity;", - "\n public IEnumerable GetRawVariables(string dataNode) => RawVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", - "\n public IEnumerable GetIfrsVariables(string dataNode) => IfrsVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", - "\n ", - "\n public double[] GetValues(ImportIdentity id, Func whereClause) => GetRawVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Values ?? Enumerable.Empty().ToArray();", - "\n public double GetValue(ImportIdentity id, Func whereClause) => GetIfrsVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Value ?? 0;", - "\n ", - "\n public double[] GetValues(ImportIdentity id, string amountType, string estimateType, int? accidentYear) => GetValues(id, v => v.AccidentYear == accidentYear && v.AmountType == amountType && v.EstimateType == estimateType);", - "\n public double GetValue(ImportIdentity id, string amountType, string estimateType, int? accidentYear) => GetValue(id, v => v.AccidentYear == accidentYear && v.AmountType == amountType && v.EstimateType == estimateType);", - "\n public double GetValue(ImportIdentity id, string amountType, string estimateType, string economicBasis, int? accidentYear) => GetValue(id, v => v.AccidentYear == accidentYear && v.AmountType == amountType && v.EstimateType == estimateType && v.EconomicBasis == economicBasis);", - "\n ", - "\n //Novelty", - "\n private IEnumerable GetNoveltiesForAocType(string aocType, IEnumerable aocConfiguration) => aocConfiguration.Where(aocStep => aocStep.AocType == aocType).Select(aocStep => aocStep.Novelty);", - "\n public IEnumerable GetNovelties() => NoveltyDimension.Keys;", - "\n public IEnumerable GetNovelties(string aocType) => GetNoveltiesForAocType(aocType, AocConfigurationByAocStep.Keys);", - "\n public IEnumerable GetNovelties(string aocType, InputSource inputSource) => GetNoveltiesForAocType(aocType, aocStepByInputSource[inputSource]);", - "\n ", - "\n //Accident years", - "\n public IEnumerable GetAccidentYears(string dataNode) => AccidentYearsByDataNode.TryGetValue(dataNode, out var accidentYear) ? accidentYear : new int?[] { null };", - "\n ", - "\n // Parameters", - "\n public double GetNonPerformanceRiskRate (ImportIdentity identity) {", - "\n var period = GetCreditDefaultRiskPeriod(identity) == PeriodType.BeginningOfPeriod ? PreviousPeriod : CurrentPeriod;", - "\n ", - "\n if(!DataNodeDataBySystemName.TryGetValue(identity.DataNode, out var dataNodeData)) ApplicationMessage.Log(Error.DataNodeNotFound, identity.DataNode);", - "\n if(dataNodeData.Partner == null) ApplicationMessage.Log(Error.PartnerNotFound, identity.DataNode);", - "\n // if Partner == Internal then return 0;", - "\n if(!PartnerRating.TryGetValue(dataNodeData.Partner, out var rating)) ApplicationMessage.Log(Error.RatingNotFound, dataNodeData.Partner);", - "\n if(!CreditDefaultRates.TryGetValue(rating[period].CreditRiskRating, out var rate)) ApplicationMessage.Log(Error.CreditDefaultRateNotFound, rating[period].CreditRiskRating);", - "\n return rate[period].Values[0];", - "\n }", - "\n ", - "\n public double GetPremiumAllocationFactor(ImportIdentity id) => SingleDataNodeParametersByGoc.TryGetValue(id.DataNode, out var singleDataNodeParameter) ", - "\n ? singleDataNodeParameter[CurrentPeriod].PremiumAllocation : DefaultPremiumExperienceAdjustmentFactor;", - "\n ", - "\n // Data Node relationships", - "\n public IEnumerable GetUnderlyingGic(ImportIdentity id) => !InterDataNodeParametersByGoc.TryGetValue(id.DataNode, out var interDataNodeParameters)", - "\n ? Enumerable.Empty()", - "\n : interDataNodeParameters[CurrentPeriod].Select(x => x.DataNode != id.DataNode ? x.DataNode : x.LinkedDataNode).Where(goc => !DataNodeDataBySystemName[goc].IsReinsurance);", - "\n ", - "\n public double GetReinsuranceCoverage (ImportIdentity id, string gic) ", - "\n {", - "\n var targetPeriod = AocConfigurationByAocStep[new AocStep(id.AocType, id.Novelty)].RcPeriod == PeriodType.EndOfPeriod ? CurrentPeriod : PreviousPeriod;", - "\n return InterDataNodeParametersByGoc.TryGetValue(id.DataNode, out var interDataNodeParameters)", - "\n ? interDataNodeParameters[targetPeriod].FirstOrDefault(x => x.DataNode == gic || x.LinkedDataNode == gic).ReinsuranceCoverage", - "\n : (double)ApplicationMessage.Log(Error.ReinsuranceCoverage, id.DataNode);", - "\n }", - "\n ", - "\n // Import Scope", - "\n public bool IsPrimaryScope (string dataNode) => DataNodesByImportScope[ImportScope.Primary].Contains(dataNode);", - "\n public bool IsSecondaryScope (string dataNode) => DataNodesByImportScope[ImportScope.Secondary].Contains(dataNode);", - "\n ", - "\n // Other", - "\n public IEnumerable GetNonAttributableAmountType() => new string[]{AmountTypes.NE};", - "\n public IEnumerable GetAttributableExpenseAndCommissionAmountType() => new string[] {AmountTypes.ACA, AmountTypes.AEA}; //U+ specific", - "\n public IEnumerable GetInvestmentClaims() => hierarchyCache.Get(AmountTypes.ICO).Descendants(includeSelf : true).Select(x => x.SystemName);", - "\n public IEnumerable GetPremiums() => hierarchyCache.Get(AmountTypes.PR).Descendants(includeSelf : true).Select(x => x.SystemName);", - "\n public IEnumerable GetClaims() => hierarchyCache.Get(AmountTypes.CL).Descendants().Select(x => x.SystemName);", - "\n}" + "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\")" ] }, { "cell_type": "code", "source": [ - "var fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\";", - "\nActivity.Start();", - "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", - "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", - "\nif(Activity.HasErrors()) return Activity.Finish();", - "\n ", - "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", - "\nif(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", - "\n ", - "\nvar storage = new ImportStorage(args, DataSource, Workspace);", - "\nawait storage.InitializeAsync();", - "\nvar test = storage.TestRawVars();", - "\n", - "\nawait DataSource.Partition.SetAsync(targetPartition);", - "\nvar defaultRawVariables = await DataSource.Query()", - "\n .Where(rv => rv.Partition == targetPartition)", - "\n .ToArrayAsync();", - "\ntest[dataNode].GroupBy(x => x.Partition).Select(x => x)", - "\n/*", - "\n.ToDictionaryGrouped( x => x.Partition, x=> x).Keys;", - "\nrawDictScenario", - "\n /*.GroupBy(rv => ImportIdentity)", - "\n .Select(rv => rv.OrderByDescending(x => x.Scenario)", - "\n .FirstOrDefault()).ToArray();", - "\nif(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", - "\nvar idGroups = rawDictScenario[dataNode].ToDictionaryGrouped( x => x.Partition, x=> x);", - "\nvar universe = Scopes.ForStorage(storage).ToScope();", - "\nvar identities = universe.GetScopes(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);", - "\nvar ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", - "\nif(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", - "\nvar test = ivs.ToDictionaryGrouped( x => x.Partition, x=> x);", - "\ntest", - "\nawait Workspace.UpdateAsync(ivs);", - "\nawait CommitToDatabase(storage.TargetPartition, ", - "\n snapshot : true, ", - "\n filter : x => storage.EstimateTypesByImportFormat[ImportFormats.Cashflow].Contains(x.EstimateType) && ", - "\n storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode)); ", - "\nawait CommitToDatabase(storage.TargetPartition, ", - "\n snapshot : true,", - "\n filter : x => storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode));", - "\n", - "\n", - "\nvar idGroups = ifrsDict[dataNode].ToDictionaryGrouped( x => x.Id, x=> x);", - "\nidGroups.Keys", - "\nvar test = ifrsDict[dataNode].ToList().Select(x => new { x.Id == defif(x.Id == targetPartition || x.Id == defaultPartition) new x : null});*/" - ] - }, - { - "cell_type": "code", - "source": [ - "" + "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv\")" ] }, { "cell_type": "code", "source": [ - "var fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\";", - "\nActivity.Start();", - "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", - "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", - "\nif(Activity.HasErrors()) return Activity.Finish();", - "\n ", - "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", - "\nif(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", - "\n ", - "\nvar storage = new ImportStorage(args, DataSource, Workspace);", - "\nawait storage.InitializeAsync();", - "\nvar rawDictBE = storage.TestRawVars();", - "\nif(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", - "\nvar idGroups = rawDictBE[dataNode].ToDictionaryGrouped( x => x.Partition, x=> x);", - "\nidGroups.Keys" + "Workspace.InitializeFrom(DataSource);" ] }, { diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index afd2e82e..3f177dfa 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -42,7 +42,7 @@ "source": [ "public enum Warning {", "\n // Import", - "\n ActiveDataNodeWithCashflowBOPI,", + "\n ActiveDataNodeWithCashflowBOPI, VariablesAlreadyImported, VariablesAlreadyCalculated,", "\n // Default", "\n Generic", "\n}; " @@ -157,6 +157,8 @@ "public static string Get (Warning w, params string[] s) => (w, s.Length) switch {", "\n // Import", "\n (Warning.ActiveDataNodeWithCashflowBOPI , _) => $\"Cashflows for active DataNode has been parsed with AocType {AocTypes.BOP} and Novelty {Novelties.I} \",", + "\n (Warning.VariablesAlreadyImported , _) => $\"The imported file contains only informations already imported. No calculation will be performed\",", + "\n (Warning.VariablesAlreadyCalculated , _) => $\"The imported file produced informations already calculated. No data will be saved\",", "\n // Default", "\n (Warning.Generic , _) => $\"{s[0]}\",", "\n (_ , _) => $\"Warning not found.\"", diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 7b8e6ed6..afa14947 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1508,6 +1508,41 @@ "\n}" ] }, + { + "cell_type": "code", + "source": [ + "public class DataRecordComparer : IEqualityComparer where T : BaseDataRecord", + "\n{", + "\n public DataRecordComparer(){}", + "\n", + "\n public virtual bool Equals(T x, T y) {", + "\n if (x == null || y == null) return false;", + "\n if( x.AccidentYear != y.AccidentYear || x.AmountType != y.AmountType || ", + "\n x.DataNode != y.DataNode || x.AocType != y.AocType || ", + "\n x.Novelty != y.Novelty || x.Partition != y.Partition) return false;", + "\n dynamic dx = x;", + "\n dynamic dy = y;", + "\n return typeof(T).Name switch {", + "\n nameof(RawVariable) => dx.EstimateType == dy.EstimateType && dx.Values.SequenceEqual(dy.Values),", + "\n nameof(IfrsVariable) => dx.EstimateType == dy.EstimateType && dx.Value == dy.Value,", + "\n _ => throw new ArgumentOutOfRangeException(\"\", \"Not expected variable value\") ", + "\n };", + "\n }", + "\n", + "\n public virtual int GetHashCode(T v){", + "\n var baseHashCode = HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty);", + "\n dynamic dv = v;", + "\n return typeof(T).Name switch {", + "\n nameof(RawVariable) => HashCode.Combine(baseHashCode, dv.EstimateType, dv.Values),", + "\n nameof(IfrsVariable) => HashCode.Combine(baseHashCode, dv.EstimateType, dv.Value),", + "\n _ => throw new ArgumentOutOfRangeException(\"\", \"Not expected variable value\")", + "\n };", + "\n }", + "\n ", + "\n public static readonly DataRecordComparer Instance = new DataRecordComparer();", + "\n}" + ] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 6c6ca277..bb1b63d9 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -255,16 +255,12 @@ "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", "\n .ToArrayAsync());", "\n", - "\n if(DefaultPartition != TargetPartition){", + "\n if(DefaultPartition != TargetPartition){", "\n await querySource.Partition.SetAsync(DefaultPartition);", "\n var defaultRawVariables = await querySource.Query()", "\n .Where(rv => rv.Partition == DefaultPartition)", - "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode)).ToArrayAsync();", - "\n rawVariables = rawVariables.Concat(defaultRawVariables);", - "\n DefaultRawVariables = defaultRawVariables; ", - "\n }", - "\n else {", - "\n DefaultRawVariables = Enumerable.Empty().ToArray();", + "\n .Where(rv => primaryScopeFromParsedVariables.Contains(rv.DataNode)).ToArrayAsync(); // TODO: what about the linked reinsurance?", + "\n rawVariables = rawVariables.Union(defaultRawVariables, DataRecordComparer.Instance);", "\n }", "\n ", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", @@ -317,17 +313,9 @@ "\n //Variables and Cashflows", "\n ", "\n public IDictionary> TestRawVars() => RawVariablesByImportIdentity;", - "\n //public IEnumerable EnumRawVars() => DefaultRawVariables;", "\n public IDictionary> TestIfrsVars() => IfrsVariablesByImportIdentity;", "\n public IEnumerable GetRawVariables(string dataNode) => RawVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", "\n public IEnumerable GetIfrsVariables(string dataNode) => IfrsVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", - "\n /*? variableCollection.Select(", - "\n x => x.Scenario switch {", - "\n args.Scenario => new IfrsVariable(x),", - "\n null => new IfrsVariable(x),", - "\n _ => null", - "\n }", - "\n ) : Enumerable.Empty();*/", "\n ", "\n public double[] GetValues(ImportIdentity id, Func whereClause) => GetRawVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Values ?? Enumerable.Empty().ToArray();", "\n public double GetValue(ImportIdentity id, Func whereClause) => GetIfrsVariables(id.DataNode).Where(v => (v.AocType, v.Novelty) == id.AocStep && whereClause(v)).Aggregate()?.Value ?? 0;", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index cd3fe8a0..50492fe0 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -878,6 +878,29 @@ "\n}" ] }, + { + "cell_type": "code", + "source": [ + "public async Task CompareParsedWithDataBaseAsync(ImportArgs args) where T : BaseDataRecord", + "\n{", + "\n //Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\n //Workspace.Initialize(x => x.FromSource(DataSource));", + "\n", + "\n var targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == args.Year &&", + "\n p.Month == args.Month &&", + "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", + "\n await Workspace.Partition.SetAsync(targetPartition); ", + "\n await DataSource.Partition.SetAsync(targetPartition);", + "\n var parsedVariables = await Workspace.Query().ToArrayAsync();", + "\n var savedVariables = await DataSource.Query().ToArrayAsync();", + "\n if (!savedVariables.Any()) return parsedVariables.Any();", + "\n var updatedVariables = savedVariables?.Union(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", + "\n var newVariables = updatedVariables?.Except(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", + "\n return !newVariables.Any();", + "\n}" + ] + }, { "cell_type": "code", "source": [ @@ -889,6 +912,10 @@ "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", + "\n if(await CompareParsedWithDataBaseAsync(args)) {", + "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", + "\n return Activity.Finish().Merge(parsingLog);", + "\n }", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n var storage = new ImportStorage(args, DataSource, Workspace);", @@ -898,9 +925,14 @@ "\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 /*if (await CompareCalculatedWithDataBaseAsync(args)){", + "\n ApplicationMessage.Log(Warning.VariablesAlreadyCalculated, \"\");", + "\n return Activity.Finish().Merge(parsingLog);", + "\n }*/", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n await Workspace.UpdateAsync(ivs);", + "\n //scrematura = union minus per ifrs", "\n await CommitToDatabase(storage.TargetPartition, ", "\n snapshot : true, ", "\n filter : x => storage.EstimateTypesByImportFormat[ImportFormats.Cashflow].Contains(x.EstimateType) && ", From 4ca1bd3e88d103cadc754550d21417dff09babac Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Thu, 27 Oct 2022 14:16:11 +0200 Subject: [PATCH 11/23] dynamic problems solved --- full-ifrs17-template/Test/ScenarioTest.ipynb | 19 +++++++++++- ifrs17/DataModel/DataStructure.ipynb | 31 ++++++++++++++++---- ifrs17/Import/ImportStorage.ipynb | 4 +-- ifrs17/Import/Importers.ipynb | 23 ++++++++++----- 4 files changed, 61 insertions(+), 16 deletions(-) diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index 3e4e3fb3..a7e239e5 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -61,7 +61,24 @@ { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\")" + "//await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\")", + "\nvar fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\";", + "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", + "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", + "\n ", + "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", + "\nvar targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", + "\n p.Year == args.Year &&", + "\n p.Month == args.Month &&", + "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", + "\nawait Workspace.Partition.SetAsync(targetPartition); ", + "\nawait DataSource.Partition.SetAsync(targetPartition);", + "\nvar parsedVariables = await Workspace.Query().ToArrayAsync();", + "\nvar savedVariables = await DataSource.Query().ToArrayAsync();", + "\nif (!parsedVariables.Any()) return true;", + "\nvar updatedVariables = savedVariables?.Union(parsedVariables, RawVariableComparer.Instance) ?? parsedVariables;", + "\nvar newVariables = updatedVariables?.Except(parsedVariables, RawVariableComparer.Instance) ?? Enumerable.Empty();", + "\nupdatedVariables" ] }, { diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index afa14947..3a9fc280 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -44,14 +44,14 @@ "cell_type": "code", "source": [ "#r \"nuget:Systemorph.Workspace,1.4.1\"", - "\n#r \"nuget:Systemorph.Scopes,1.4.0\"", + "\n#r \"nuget:Systemorph.Scopes,1.5.4\"", "\n#r \"nuget:Systemorph.Import,1.4.0\"", - "\n#r \"nuget:Systemorph.Test,1.4.0\"", + "\n#r \"nuget:Systemorph.Test,1.5.4\"", "\n#r \"nuget:Systemorph.Export,1.4.0\"", "\n#r \"nuget:Systemorph.DataSetReader,1.4.0\"", "\n#r \"nuget:Systemorph.DataSource,1.4.1\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.4.1\"", - "\n#r \"nuget:Systemorph.Reporting,1.4.0\"", + "\n#r \"nuget:Systemorph.Reporting,1.5.4\"", "\n#r \"nuget:Systemorph.DomainDesigner,1.4.0\"" ] }, @@ -1471,6 +1471,27 @@ "\n}" ] }, + { + "cell_type": "code", + "source": [ + "class RawVariableComparer : IEqualityComparer", + "\n{", + "\n private RawVariableComparer(){}", + "\n", + "\n public bool Equals(RawVariable x, RawVariable y) =>", + "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && ", + "\n x.DataNode == y.DataNode && x.AocType == y.AocType && ", + "\n x.Novelty == y.Novelty && x.Partition == y.Partition &&", + "\n x.EstimateType == y.EstimateType && x.Values.SequenceEqual(y.Values); ", + "\n", + "\n public int GetHashCode(RawVariable v) => HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, ", + "\n v.AocType, v.Novelty, v.Partition, v.Partition, v.Values);", + "\n", + "\n public static readonly RawVariableComparer Instance = new RawVariableComparer();", + "\n", + "\n}" + ] + }, { "cell_type": "markdown", "source": [ @@ -1511,7 +1532,7 @@ { "cell_type": "code", "source": [ - "public class DataRecordComparer : IEqualityComparer where T : BaseDataRecord", + "/*public class DataRecordComparer : IEqualityComparer where T : BaseDataRecord", "\n{", "\n public DataRecordComparer(){}", "\n", @@ -1540,7 +1561,7 @@ "\n }", "\n ", "\n public static readonly DataRecordComparer Instance = new DataRecordComparer();", - "\n}" + "\n}*/" ] }, { diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index bb1b63d9..f88157b7 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -253,14 +253,14 @@ "\n .Concat(await querySource.Query()", "\n .Where(rv => rv.Partition == TargetPartition)", "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", - "\n .ToArrayAsync());", + "\n .ToArrayAsync()); // TODO: what if DatSource has some rawvars identical to the parsed ones", "\n", "\n if(DefaultPartition != TargetPartition){", "\n await querySource.Partition.SetAsync(DefaultPartition);", "\n var defaultRawVariables = await querySource.Query()", "\n .Where(rv => rv.Partition == DefaultPartition)", "\n .Where(rv => primaryScopeFromParsedVariables.Contains(rv.DataNode)).ToArrayAsync(); // TODO: what about the linked reinsurance?", - "\n rawVariables = rawVariables.Union(defaultRawVariables, DataRecordComparer.Instance);", + "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance);", "\n }", "\n ", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 50492fe0..8496cf71 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -881,7 +881,7 @@ { "cell_type": "code", "source": [ - "public async Task CompareParsedWithDataBaseAsync(ImportArgs args) where T : BaseDataRecord", + "public async Task CompareParsedToDBAsync(ImportArgs args)", "\n{", "\n //Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n //Workspace.Initialize(x => x.FromSource(DataSource));", @@ -892,15 +892,21 @@ "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", "\n await Workspace.Partition.SetAsync(targetPartition); ", "\n await DataSource.Partition.SetAsync(targetPartition);", - "\n var parsedVariables = await Workspace.Query().ToArrayAsync();", - "\n var savedVariables = await DataSource.Query().ToArrayAsync();", - "\n if (!savedVariables.Any()) return parsedVariables.Any();", - "\n var updatedVariables = savedVariables?.Union(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", - "\n var newVariables = updatedVariables?.Except(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", + "\n var parsedVariables = await Workspace.Query().ToArrayAsync();", + "\n var savedVariables = await DataSource.Query().ToArrayAsync();", + "\n if (!parsedVariables.Any()) return true;", + "\n var updatedVariables = savedVariables?.Union(parsedVariables, RawVariableComparer.Instance) ?? return true;", + "\n var newVariables = updatedVariables?.Except(parsedVariables, RawVariableComparer.Instance) ?? Enumerable.Empty();", "\n return !newVariables.Any();", "\n}" ] }, + { + "cell_type": "code", + "source": [ + "" + ] + }, { "cell_type": "code", "source": [ @@ -912,11 +918,12 @@ "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", - "\n if(await CompareParsedWithDataBaseAsync(args)) {", + "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", + "\n ", + "\n if(await CompareParsedToDBAsync(args)) {", "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", "\n return Activity.Finish().Merge(parsingLog);", "\n }", - "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n var storage = new ImportStorage(args, DataSource, Workspace);", "\n await storage.InitializeAsync();", From dfbc6b9b0c7deb8dcc68db71cfdc9ecfa641a4d3 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Mon, 31 Oct 2022 09:42:02 +0100 Subject: [PATCH 12/23] fixing aoctype for scenario --- .../NominalCashflows_CH_2020_12_Scenario_BE.csv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv index b2b4ed32..a1c2201a 100644 --- a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv +++ b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv @@ -3,7 +3,7 @@ ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, CH,2020,12,IRU,,,,,,,,,,,,,,,,,,,,,,,,, @@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 -DT1.1,PR,BOP,N,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0 -DT1.1,NIC,BOP,N,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25 -DT1.1,CU,BOP,N,,10,10,10,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,5,5,5,5,5,3 -DT1.1,RA,BOP,N,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5 +DT1.1,PR,CL,C,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0 +DT1.1,NIC,CL,C,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25 +DT1.1,CU,CL,C,,10,10,10,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,5,5,5,5,5,3 +DT1.1,RA,CL,C,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5 From b78b36a0086c157146f43f497506a81b38f7f071 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Wed, 2 Nov 2022 11:44:36 +0100 Subject: [PATCH 13/23] test for actualsr --- .../Actuals_CH_2020_12_Scenario.csv | 7 ++ .../Actuals_CH_2020_12_Scenario_BE.csv | 7 ++ .../Test/IfrsVariablesTest.ipynb | 3 +- full-ifrs17-template/Test/ScenarioTest.ipynb | 92 +++++++++++++------ ifrs17/DataModel/DataStructure.ipynb | 68 +++++++------- ifrs17/Import/ImportStorage.ipynb | 17 ++-- ifrs17/Import/Importers.ipynb | 30 +++--- 7 files changed, 130 insertions(+), 94 deletions(-) create mode 100644 full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv create mode 100644 full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv diff --git a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv new file mode 100644 index 00000000..1cbbd12f --- /dev/null +++ b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv @@ -0,0 +1,7 @@ +@@Main,,,, +ReportingNode,Year,Month,, +CH,2020,12,, +@@Actual,,,, +DataNode,AocType,ValueType,AccidentYear,Value +DT1.1,CF,NIC,,308 + diff --git a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv new file mode 100644 index 00000000..19484c76 --- /dev/null +++ b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv @@ -0,0 +1,7 @@ +@@Main,,,, +ReportingNode,Year,Month,, +CH,2020,12,, +@@Actual,,,, +DataNode,AocType,ValueType,AccidentYear,Value +DT1.1,CF,NIC,,280 + diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index 736bc434..d66baf41 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -204,8 +204,7 @@ "cell_type": "code", "source": [ "var errorList = new List();", - "\nforeach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))", - "foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month, Scenario : x.Scenario)))", + "\nforeach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month, Scenario : x.Scenario)))", "\n{", "\n var reportingNode = g.Key.ReportingNode;", "\n var year = g.Key.Year;", diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index a7e239e5..e2defaf5 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -18,24 +18,33 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" + "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Set Contest" ] }, { "cell_type": "code", "source": [ - "var scenario = \"IRU\";", - "\nvar year = 2020;", - "\nvar month = 12;", - "\nvar reportingNode = \"CH\";", - "\nvar dataNode = \"DT1.1\";", - "\nvar format = ImportFormats.Cashflow;" + "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.Initialize(x => x.FromSource(DataSource));", + "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\");" ] }, { "cell_type": "code", "source": [ - "Workspace.Initialize(x => x.FromSource(DataSource));" + "var scenario = \"IRU\";", + "\nvar year = 2020;", + "\nvar month = 12;", + "\nvar reportingNode = \"CH\";", + "\nvar dataNode = \"DT1.1\";", + "\nvar format = ImportFormats.Cashflow;", + "\nFunc filter = x => x.AmountType == \"NIC\" && x.DataNode == dataNode;" ] }, { @@ -55,42 +64,67 @@ { "cell_type": "markdown", "source": [ - "# Import Scenario Data" + "# Import Best Estimate and Scenario Cashflows" + ] + }, + { + "cell_type": "code", + "source": [ + "await Workspace.Partition.SetAsync(defaultPartition); ", + "\nawait DataSource.Partition.SetAsync(defaultPartition);", + "\nvar defaultVar = Workspace.Query().Where(filter).ToArray();", + "\ndefaultVar" + ] + }, + { + "cell_type": "markdown", + "source": [ + "" + ] + }, + { + "cell_type": "code", + "source": [ + "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\");", + "\nvar scenarioVar = Workspace.Query().Where(filter).ToArray();", + "\n(scenarioVar.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().NotBe(0)" + ] + }, + { + "cell_type": "code", + "source": [ + "var log = await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv\");", + "\nvar mirrorBE = Workspace.Query().Where(filter);", + "\n(mirrorBE.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().Be(0)" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Best Estimate and Scenario Actuals" ] }, { "cell_type": "code", "source": [ - "//await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\")", - "\nvar fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\";", - "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", - "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", - "\n ", - "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", - "\nvar targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == args.Year &&", - "\n p.Month == args.Month &&", - "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", - "\nawait Workspace.Partition.SetAsync(targetPartition); ", - "\nawait DataSource.Partition.SetAsync(targetPartition);", - "\nvar parsedVariables = await Workspace.Query().ToArrayAsync();", - "\nvar savedVariables = await DataSource.Query().ToArrayAsync();", - "\nif (!parsedVariables.Any()) return true;", - "\nvar updatedVariables = savedVariables?.Union(parsedVariables, RawVariableComparer.Instance) ?? parsedVariables;", - "\nvar newVariables = updatedVariables?.Except(parsedVariables, RawVariableComparer.Instance) ?? Enumerable.Empty();", - "\nupdatedVariables" + "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\");", + "\nvar defaultVar = Workspace.Query().Where(filter).ToArray();" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv\")" + "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv\")", + "\nvar scenarioVar = Workspace.Query().Where(filter).ToArray();", + "\n(scenarioVar.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().NotBe(0)" ] }, { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);" + "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv\")", + "\nvar mirrorBE = Workspace.Query().Where(filter);", + "\n(mirrorBE.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().Be(0)" ] }, { diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 44470663..4d93c490 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1475,21 +1475,26 @@ { "cell_type": "code", "source": [ - "class RawVariableComparer : IEqualityComparer", + "class RawVariableComparer: IEqualityComparer", "\n{", - "\n private RawVariableComparer(){}", + "\n private bool IgnoreValues;", + "\n private RawVariableComparer(bool ignoreValues)", + "\n {", + "\n IgnoreValues = ignoreValues;", + "\n }", "\n", "\n public bool Equals(RawVariable x, RawVariable y) =>", - "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && ", - "\n x.DataNode == y.DataNode && x.AocType == y.AocType && ", - "\n x.Novelty == y.Novelty && x.Partition == y.Partition &&", - "\n x.EstimateType == y.EstimateType && x.Values.SequenceEqual(y.Values); ", - "\n", - "\n public int GetHashCode(RawVariable v) => HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, ", - "\n v.AocType, v.Novelty, v.Partition, v.Partition, v.Values);", + "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", + "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValues ? true : x.Values.SequenceEqual(y.Values)); ", "\n", - "\n public static readonly RawVariableComparer Instance = new RawVariableComparer();", + "\n public int GetHashCode(RawVariable v) => IgnoreValues ", + "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", + "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Values);", "\n", + "\n public static RawVariableComparer Instance(bool ignoreValues = false)", + "\n { ", + "\n return new RawVariableComparer(ignoreValues);", + "\n }", "\n}" ] }, @@ -1533,36 +1538,27 @@ { "cell_type": "code", "source": [ - "/*public class DataRecordComparer : IEqualityComparer where T : BaseDataRecord", + "class IfrsVariableComparer: IEqualityComparer", "\n{", - "\n public DataRecordComparer(){}", - "\n", - "\n public virtual bool Equals(T x, T y) {", - "\n if (x == null || y == null) return false;", - "\n if( x.AccidentYear != y.AccidentYear || x.AmountType != y.AmountType || ", - "\n x.DataNode != y.DataNode || x.AocType != y.AocType || ", - "\n x.Novelty != y.Novelty || x.Partition != y.Partition) return false;", - "\n dynamic dx = x;", - "\n dynamic dy = y;", - "\n return typeof(T).Name switch {", - "\n nameof(RawVariable) => dx.EstimateType == dy.EstimateType && dx.Values.SequenceEqual(dy.Values),", - "\n nameof(IfrsVariable) => dx.EstimateType == dy.EstimateType && dx.Value == dy.Value,", - "\n _ => throw new ArgumentOutOfRangeException(\"\", \"Not expected variable value\") ", - "\n };", + "\n private bool IgnoreValue;", + "\n private IfrsVariableComparer(bool ignoreValue)", + "\n {", + "\n IgnoreValue = ignoreValue;", "\n }", "\n", - "\n public virtual int GetHashCode(T v){", - "\n var baseHashCode = HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty);", - "\n dynamic dv = v;", - "\n return typeof(T).Name switch {", - "\n nameof(RawVariable) => HashCode.Combine(baseHashCode, dv.EstimateType, dv.Values),", - "\n nameof(IfrsVariable) => HashCode.Combine(baseHashCode, dv.EstimateType, dv.Value),", - "\n _ => throw new ArgumentOutOfRangeException(\"\", \"Not expected variable value\")", - "\n };", + "\n public bool Equals(IfrsVariable x, IfrsVariable y) =>", + "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", + "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValue ? true : x.Value == y.Value); ", + "\n", + "\n public int GetHashCode(IfrsVariable v) => IgnoreValue ", + "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", + "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Value);", + "\n", + "\n public static IfrsVariableComparer Instance(bool ignoreValue = false)", + "\n { ", + "\n return new IfrsVariableComparer(ignoreValue);", "\n }", - "\n ", - "\n public static readonly DataRecordComparer Instance = new DataRecordComparer();", - "\n}*/" + "\n}" ] }, { diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index f88157b7..065aa67d 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -253,25 +253,26 @@ "\n .Concat(await querySource.Query()", "\n .Where(rv => rv.Partition == TargetPartition)", "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", - "\n .ToArrayAsync()); // TODO: what if DatSource has some rawvars identical to the parsed ones", - "\n", - "\n if(DefaultPartition != TargetPartition){", + "\n .ToArrayAsync()); // TODO: we perform Union() instead of Concat() to check if DataSource has some rawvars identical to the parsed ones", + "\n if (!rawVariables.Any()) ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", + "\n ", + "\n if(DefaultPartition != TargetPartition){", "\n await querySource.Partition.SetAsync(DefaultPartition);", "\n var defaultRawVariables = await querySource.Query()", "\n .Where(rv => rv.Partition == DefaultPartition)", - "\n .Where(rv => primaryScopeFromParsedVariables.Contains(rv.DataNode)).ToArrayAsync(); // TODO: what about the linked reinsurance?", - "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance);", + "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", + "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance(true));", "\n }", "\n ", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", "\n ", - "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", - "\n .Concat(await querySource.Query()", + "\n var ifrsVariables = parsedIfrsVariables.Union(openingIfrsVariables, IfrsVariableComparer.Instance())", + "\n .Union(await querySource.Query()", "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)) //Actuals or Gross", "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", "\n || secondaryScope.Contains(iv.DataNode))", - "\n .ToArrayAsync());", + "\n .ToArrayAsync(), IfrsVariableComparer.Instance());", "\n IfrsVariablesByImportIdentity = (IDictionary>)ifrsVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", "\n }", "\n ", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 05e33a80..3a4e21fb 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -881,32 +881,24 @@ { "cell_type": "code", "source": [ - "public async Task CompareParsedToDBAsync(ImportArgs args)", + "public async Task CompareCalculatedToDBAsync(ImportArgs args, IEnumerable calculatedVariables)", "\n{", - "\n //Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n //Workspace.Initialize(x => x.FromSource(DataSource));", - "\n", "\n var targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", "\n p.Year == args.Year &&", "\n p.Month == args.Month &&", "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", "\n await Workspace.Partition.SetAsync(targetPartition); ", "\n await DataSource.Partition.SetAsync(targetPartition);", - "\n var parsedVariables = await Workspace.Query().ToArrayAsync();", - "\n var savedVariables = await DataSource.Query().ToArrayAsync();", - "\n if (!parsedVariables.Any()) return true;", - "\n var updatedVariables = savedVariables?.Union(parsedVariables, RawVariableComparer.Instance) ?? return true;", - "\n var newVariables = updatedVariables?.Except(parsedVariables, RawVariableComparer.Instance) ?? Enumerable.Empty();", + "\n var parsedVariables = await Workspace.Query().ToArrayAsync();", + "\n var savedVariables = await DataSource.Query().ToArrayAsync();", + "\n if (!parsedVariables.Any() || !savedVariables.Any()) return false;", + "\n var updatedVariables = parsedVariables.Union(calculatedVariables, IfrsVariableComparer.Instance());", + "\n var newVariables = updatedVariables?.Union(savedVariables, IfrsVariableComparer.Instance()) ?? Enumerable.Empty();", + "\n await Workspace.UpdateAsync(updatedVariables);", "\n return !newVariables.Any();", "\n}" ] }, - { - "cell_type": "code", - "source": [ - "" - ] - }, { "cell_type": "code", "source": [ @@ -920,10 +912,10 @@ "\n var parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n ", - "\n if(await CompareParsedToDBAsync(args)) {", + "\n /*if(await CompareParsedToDBAsync(args)) { // TODO: implement in storage so as not to repeat queries", "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", "\n return Activity.Finish().Merge(parsingLog);", - "\n }", + "\n }*/", "\n ", "\n var storage = new ImportStorage(args, DataSource, Workspace);", "\n await storage.InitializeAsync();", @@ -932,10 +924,10 @@ "\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 /*if (await CompareCalculatedWithDataBaseAsync(args)){", + "\n if (await CompareCalculatedToDBAsync(args, ivs)){", "\n ApplicationMessage.Log(Warning.VariablesAlreadyCalculated, \"\");", "\n return Activity.Finish().Merge(parsingLog);", - "\n }*/", + "\n }", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n await Workspace.UpdateAsync(ivs);", From e614d1a694e96939b5ce770d69aa7092c1ffbd36 Mon Sep 17 00:00:00 2001 From: Danilo Calderini Date: Wed, 2 Nov 2022 13:11:36 +0100 Subject: [PATCH 14/23] code cleanup --- full-ifrs17-template/Database/Configure.ipynb | 2 +- .../InitSystemorphBaseToMemory.ipynb | 3 +- .../Initialization/testEqualityComparer.ipynb | 77 ------------------- .../Test/IfrsVariablesTest.ipynb | 2 +- 4 files changed, 3 insertions(+), 81 deletions(-) delete mode 100644 full-ifrs17-template/Initialization/testEqualityComparer.ipynb diff --git a/full-ifrs17-template/Database/Configure.ipynb b/full-ifrs17-template/Database/Configure.ipynb index 1a2fc211..b332a43c 100644 --- a/full-ifrs17-template/Database/Configure.ipynb +++ b/full-ifrs17-template/Database/Configure.ipynb @@ -27,7 +27,7 @@ { "cell_type": "code", "source": [ - "#!import \"../../ifrs17/CalculationEngine\"" + "#!import \"//ifrs17ce/dev/CalculationEngine\"" ] }, { diff --git a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index 65b1a50d..1dc82a4e 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -30,8 +30,7 @@ "cell_type": "code", "source": [ "#!import \"../Constants/Consts\"", - "\n//#!eval calculationEngine", - "\n#!import \"../../ifrs17/CalculationEngine\"" + "\n#!eval calculationEngine" ] }, { diff --git a/full-ifrs17-template/Initialization/testEqualityComparer.ipynb b/full-ifrs17-template/Initialization/testEqualityComparer.ipynb deleted file mode 100644 index 7482c101..00000000 --- a/full-ifrs17-template/Initialization/testEqualityComparer.ipynb +++ /dev/null @@ -1,77 +0,0 @@ -{ - "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": [ - "#!eval-notebook \"InitSystemorphBaseToMemory\"" - ] - }, - { - "cell_type": "code", - "source": [ - "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" - ] - }, - { - "cell_type": "code", - "source": [ - "Workspace.InitializeFrom(DataSource);" - ] - }, - { - "cell_type": "code", - "source": [ - "await UploadOpeningAsync(\"../Files/900.TransactionalData/Openings_CH_2020_12.csv\")" - ] - }, - { - "cell_type": "code", - "source": [ - "var fileName = \"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\";", - "\nActivity.Start();", - "\nvar args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", - "\nawait DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", - "\nif(Activity.HasErrors()) return Activity.Finish();", - "\n ", - "\nvar parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", - "\n", - "\nvar targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == args.Year &&", - "\n p.Month == args.Month &&", - "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", - "\nawait Workspace.Partition.SetAsync(targetPartition); ", - "\nawait DataSource.Partition.SetAsync(targetPartition);", - "\nvar parsedVariables = await Workspace.Query().ToArrayAsync();", - "\nvar savedVariables = await DataSource.Query().ToArrayAsync();", - "\nvar updatedVariables = savedVariables?.Union(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", - "\nvar newVariables = updatedVariables?.Except(parsedVariables, DataRecordComparer.Instance) ?? Enumerable.Empty();", - "\nif(newVariables.Count() == 0) {", - "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", - "\n return Activity.Finish().Merge(parsingLog);", - "\n }", - "\nreturn Activity.Finish().Merge(parsingLog);" - ] - }, - { - "cell_type": "code", - "source": [ - "" - ] - } - ] -} \ No newline at end of file diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index d66baf41..16e77887 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -204,7 +204,7 @@ "cell_type": "code", "source": [ "var errorList = new List();", - "\nforeach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month, Scenario : x.Scenario)))", + "\nforeach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month, Scenario : x.Scenario)))", "\n{", "\n var reportingNode = g.Key.ReportingNode;", "\n var year = g.Key.Year;", From 0c0821c7d58fecc8355f5d0a5a56398790558780 Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Thu, 3 Nov 2022 17:58:45 +0100 Subject: [PATCH 15/23] forward --- .../Actuals_CH_2020_12_Scenario.csv | 5 ++- .../Actuals_CH_2020_12_Scenario_BE.csv | 5 ++- .../NominalCashflows_CH_2020_12_Scenario.csv | 2 +- ...ominalCashflows_CH_2020_12_Scenario_BE.csv | 2 +- .../Files/DimensionsAndPartitions.csv | 12 ++++--- .../BM_CH_2020_12_BE_SCE.csv | 2 +- .../Test/IfrsVariablesTest.ipynb | 2 +- ifrs17/Constants/Consts.ipynb | 27 +++++++-------- ifrs17/DataModel/DataStructure.ipynb | 33 ++++++++++++------- ifrs17/Utils/ApplicationMessage.ipynb | 9 ++--- 10 files changed, 52 insertions(+), 47 deletions(-) diff --git a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv index 1cbbd12f..b1ae4572 100644 --- a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv +++ b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv @@ -1,7 +1,6 @@ @@Main,,,, -ReportingNode,Year,Month,, -CH,2020,12,, +ReportingNode,Year,Month,Scenario, +CH,2020,12,MUP, @@Actual,,,, DataNode,AocType,ValueType,AccidentYear,Value DT1.1,CF,NIC,,308 - diff --git a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv index 19484c76..c12a4dd9 100644 --- a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv +++ b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv @@ -1,7 +1,6 @@ @@Main,,,, -ReportingNode,Year,Month,, -CH,2020,12,, +ReportingNode,Year,Month,Scenario, +CH,2020,12,MUP, @@Actual,,,, DataNode,AocType,ValueType,AccidentYear,Value DT1.1,CF,NIC,,280 - diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv index 8bd8e6e2..83d87c11 100644 --- a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv +++ b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv @@ -1,6 +1,6 @@ @@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, -CH,2020,12,IRU,,,,,,,,,,,,,,,,,,,,,,,,, +CH,2020,12,MUP,,,,,,,,,,,,,,,,,,,,,,,,, @@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 DT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv index a1c2201a..ae346156 100644 --- a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv +++ b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv @@ -1,6 +1,6 @@ @@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, -CH,2020,12,IRU,,,,,,,,,,,,,,,,,,,,,,,,, +CH,2020,12,MUP,,,,,,,,,,,,,,,,,,,,,,,,, @@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 DT1.1,PR,CL,C,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0 diff --git a/full-ifrs17-template/Files/DimensionsAndPartitions.csv b/full-ifrs17-template/Files/DimensionsAndPartitions.csv index 0e0679ec..666d19c2 100644 --- a/full-ifrs17-template/Files/DimensionsAndPartitions.csv +++ b/full-ifrs17-template/Files/DimensionsAndPartitions.csv @@ -215,7 +215,8 @@ Default,Default,,,,,,,,,, @@Scenario,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, BE,Best Estimate,,,,,,,,,, -IRU,Interest Rate Up,,,,,,,,,, +YCUP,Yield Curve Up,,,,,,,,,, +MUP,Mortality Up,,,,,,,,,, ,,,,,,,,,,, @@ValuationApproach,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, @@ -226,10 +227,11 @@ ReportingNode,Id,,,,,,,,,, CH,00000000-0000-0000-0000-000000000001,,,,,,,,,, ,,,,,,,,,,, @@PartitionByReportingNodeAndPeriod,,,,,,,,,,, -ReportingNode,Year,Month,Id,Scenario,,,,,,, -CH,2020,12,10000000-0000-0000-0000-000000000000,,,,,,,, -CH,2020,12,15000000-0000-0000-0000-000000000000,IRU,,,,,,, -CH,2021,3,20000000-0000-0000-0000-000000000000,,,,,,,, +ReportingNode,Year,Month,Scenario,Id,,,,,,, +CH,2020,12,,10000000-0000-0000-0000-000000000000,,,,,,, +CH,2020,12,YCUP,15000000-0000-0000-0000-000000000000,,,,,,, +CH,2020,12,MUP,16000000-0000-0000-0000-000000000000,,,,,,, +CH,2021,3,,20000000-0000-0000-0000-000000000000,,,,,,, ,,,,,,,,,,, @@ProjectionConfiguration,,,,,,,,,,, SystemName,DisplayName,Shift,TimeStep,,,,,,,, diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv index caa8a430..5dd14c6e 100644 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv @@ -1,6 +1,6 @@ @@Main,,,,,,, Month,ReportingNode,Scenario,Year,,,, -12,CH,IRU,2020,,,, +12,CH,MUP,2020,,,, @@BE,,,,,,, AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value ,PR,BOP,DT1.1,C,BE,N,-878.3904043 diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index 16e77887..b17096a5 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -26,7 +26,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../../full-ifrs17-template/Initialization/InitSystemorphToMemory\"" + "#!eval-notebook \"../Initialization/InitSystemorphToMemory\"" ] }, { diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 7f29fbaa..4a7bf306 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -241,18 +241,18 @@ "cell_type": "code", "source": [ "public static class AmountTypes{", - "\n public const string ACA = nameof(ACA); //Attributable Commissions Acquisition", - "\n public const string AEA = nameof(AEA); //Attributable Expenses Acquisition", - "\n public const string CDR = nameof(CDR); //Credit Default Risk", - "\n public const string CL = nameof(CL); //Claims", - "\n public const string PR = nameof(PR); //Premiums", - "\n public const string NIC = nameof(NIC); //Claims Non-Investment component", - "\n public const string ICO = nameof(ICO); //Claims Investment component", - "\n public const string NE = nameof(NE); //Non Attributable Expenses", - "\n public const string ACM = nameof(ACM); //Attributable Commissions Maintenance", - "\n public const string AEM = nameof(AEM); //Attributable Expenses Maintenance", - "\n public const string AC = nameof(AC); //Attributable Commissions", - "\n public const string AE = nameof(AE); //Attributable Expenses", + "\n public const string ACA = nameof(ACA); // Attributable Commissions Acquisition", + "\n public const string AEA = nameof(AEA); // Attributable Expenses Acquisition", + "\n public const string CDR = nameof(CDR); // Credit Default Risk", + "\n public const string CL = nameof(CL); // Claims", + "\n public const string PR = nameof(PR); // Premiums", + "\n public const string NIC = nameof(NIC); // Claims Non-Investment component", + "\n public const string ICO = nameof(ICO); // Claims Investment component", + "\n public const string NE = nameof(NE); // Non Attributable Expenses", + "\n public const string ACM = nameof(ACM); // Attributable Commissions Maintenance", + "\n public const string AEM = nameof(AEM); // Attributable Expenses Maintenance", + "\n public const string AC = nameof(AC); // Attributable Commissions", + "\n public const string AE = nameof(AE); // Attributable Expenses", "\n}" ] }, @@ -260,7 +260,8 @@ "cell_type": "code", "source": [ "public static class Scenarios{", - "\n public const string IRU = nameof(IRU); // Interest Rate Up", + "\n public const string YCUP = nameof(YCUP); // Yield Curve Up", + "\n public const string MUP = nameof(MUP); // Mortality Up", "\n}" ] }, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index a5724006..1261d55d 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -43,17 +43,21 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Arithmetics,1.5.4\"", - "\n#r \"nuget:Systemorph.Workspace,1.5.0\"", - "\n#r \"nuget:Systemorph.Scopes,1.5.2\"", - "\n#r \"nuget:Systemorph.Import,1.5.0\"", - "\n#r \"nuget:Systemorph.Test,1.5.2\"", - "\n#r \"nuget:Systemorph.Export,1.5.0\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.5.0\"", - "\n#r \"nuget:Systemorph.DataSource,1.5.0\"", - "\n#r \"nuget:Systemorph.DataSource.Conversions,1.5.0\"", - "\n#r \"nuget:Systemorph.Reporting,1.5.2\"", - "\n#r \"nuget:Systemorph.DomainDesigner,1.5.0\"" + "#r \"nuget:Systemorph.Activities,1.5.5\"", + "\n#r \"nuget:Systemorph.Arithmetics,1.5.5\"", + "\n#r \"nuget:Systemorph.Workspace,1.5.3\"", + "\n#r \"nuget:Systemorph.InteractiveObjects,1.5.5\"", + "\n#r \"nuget:Systemorph.SharePoint,1.5.6\"", + "\n#r \"nuget:Systemorph.OneDrive,1.5.6\"", + "\n#r \"nuget:Systemorph.Scopes,1.5.5\"", + "\n#r \"nuget:Systemorph.Import,1.5.1\"", + "\n#r \"nuget:Systemorph.Test,1.5.5\"", + "\n#r \"nuget:Systemorph.Export,1.5.1\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.5.1\"", + "\n#r \"nuget:Systemorph.DataSource,1.5.3\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.5.3\"", + "\n#r \"nuget:Systemorph.Reporting,1.5.5\"", + "\n#r \"nuget:Systemorph.DomainDesigner,1.5.1\"" ] }, { @@ -813,7 +817,7 @@ { "cell_type": "code", "source": [ - "public record ExchangeRate : KeyedRecord", + "public record ExchangeRate : KeyedRecord, IWithYearMonthAndScenario", "\n{ ", "\n [Required]", "\n [IdentityProperty]", @@ -844,6 +848,11 @@ "\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}" ] }, diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index f2253bd6..031b3280 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -27,13 +27,8 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.5.1\"" - ] - }, - { - "cell_type": "code", - "source": [ - "#!import \"../Constants/Validations\"" + "#!import \"../Constants/Validations\"", + "\n#!import \"../DataModel/DataStructure\"" ] }, { From dcac721087c1ce99e5a51fbe20f458849c291f1d Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Fri, 4 Nov 2022 09:06:45 +0100 Subject: [PATCH 16/23] cleanups --- .../800.Parameters/YieldCurveScenario.csv | 20 ------- .../Actuals_CH_2020_12_Scenario.csv | 6 --- .../Actuals_CH_2020_12_Scenario_BE.csv | 6 --- .../NominalCashflows_CH_2020_12_Scenario.csv | 9 ---- ...ominalCashflows_CH_2020_12_Scenario_BE.csv | 9 ---- full-ifrs17-template/Test/ScenarioTest.ipynb | 54 +++++++++++++++++++ 6 files changed, 54 insertions(+), 50 deletions(-) delete mode 100644 full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv delete mode 100644 full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv delete mode 100644 full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv delete mode 100644 full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv delete mode 100644 full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv diff --git a/full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv b/full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv deleted file mode 100644 index 2cc8521d..00000000 --- a/full-ifrs17-template/Files/800.Parameters/YieldCurveScenario.csv +++ /dev/null @@ -1,20 +0,0 @@ -@@YieldCurve,,,,,,,,,, -Currency,Year,Month,Scenario,Values0,Values1,Values2,Values3,,, -EUR,2020,3,,0.008685495,0.008685495,0.018498471,0.019966839,,, -CHF,2020,3,,0.002,0.002,0.002,0.002,,, -CHF,2021,3,,0.1,0.1,0.1,0.1,,, -USD,2021,3,,0.005,0.005,0.005,0.005,,, -USD,2020,12,,0.002,0.002,0.002,0.002,,, -USD,2020,3,,0.002,0.002,0.002,0.002,,, -USD,2020,1,,0.002,0.002,0.002,0.002,,, -GBP,2021,3,,0.005,0.005,0.005,0.005,,, -GBP,2020,3,,0.002,0.002,0.002,0.002,,, -EUR,2020,3,IRU,0.009554045,0.009554045,0.020348318,0.021963523,,, -CHF,2020,3,IRU,0.0022,0.0022,0.0022,0.0022,,, -CHF,2021,3,IRU,0.11,0.11,0.11,0.11,,, -USD,2021,3,IRU,0.0055,0.0055,0.0055,0.0055,,, -USD,2020,12,IRU,0.0022,0.0022,0.0022,0.0022,,, -USD,2020,3,IRU,0.0022,0.0022,0.0022,0.0022,,, -USD,2020,1,IRU,0.0022,0.0022,0.0022,0.0022,,, -GBP,2021,3,IRU,0.0055,0.0055,0.0055,0.0055,,, -GBP,2020,3,IRU,0.0022,0.0022,0.0022,0.0022,,, diff --git a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv deleted file mode 100644 index b1ae4572..00000000 --- a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv +++ /dev/null @@ -1,6 +0,0 @@ -@@Main,,,, -ReportingNode,Year,Month,Scenario, -CH,2020,12,MUP, -@@Actual,,,, -DataNode,AocType,ValueType,AccidentYear,Value -DT1.1,CF,NIC,,308 diff --git a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv deleted file mode 100644 index c12a4dd9..00000000 --- a/full-ifrs17-template/Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv +++ /dev/null @@ -1,6 +0,0 @@ -@@Main,,,, -ReportingNode,Year,Month,Scenario, -CH,2020,12,MUP, -@@Actual,,,, -DataNode,AocType,ValueType,AccidentYear,Value -DT1.1,CF,NIC,,280 diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv deleted file mode 100644 index 83d87c11..00000000 --- a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv +++ /dev/null @@ -1,9 +0,0 @@ -@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, -ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, -CH,2020,12,MUP,,,,,,,,,,,,,,,,,,,,,,,,, -@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, -DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 -DT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0 -DT1.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5 -DT1.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3 -DT1.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75 diff --git a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv b/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv deleted file mode 100644 index ae346156..00000000 --- a/full-ifrs17-template/Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv +++ /dev/null @@ -1,9 +0,0 @@ -@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, -ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, -CH,2020,12,MUP,,,,,,,,,,,,,,,,,,,,,,,,, -@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, -DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 -DT1.1,PR,CL,C,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0 -DT1.1,NIC,CL,C,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25 -DT1.1,CU,CL,C,,10,10,10,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,5,5,5,5,5,3 -DT1.1,RA,CL,C,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5 diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index e2defaf5..730caf62 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -67,6 +67,36 @@ "# Import Best Estimate and Scenario Cashflows" ] }, + { + "cell_type": "code", + "source": [ + "var cashflows_MUP = $\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,MUP", + "\n@@Cashflow", + "\nDataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0", + "\nDT1.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5", + "\nDT1.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3", + "\nDT1.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75\";" + ] + }, + { + "cell_type": "code", + "source": [ + "var cashflowsMUP_BE = $\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,MUP", + "\n@@Cashflow", + "\nDataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,CL,C,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0", + "\nDT1.1,NIC,CL,C,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25", + "\nDT1.1,CU,CL,C,,10,10,10,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,5,5,5,5,5,3", + "\nDT1.1,RA,CL,C,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5\";" + ] + }, { "cell_type": "code", "source": [ @@ -104,6 +134,30 @@ "# Import Best Estimate and Scenario Actuals" ] }, + { + "cell_type": "code", + "source": [ + "var actualsMUP = $\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario,", + "\nCH,2020,12,MUP,", + "\n@@Actual", + "\nDataNode,AocType,ValueType,AccidentYear,Value", + "\nDT1.1,CF,NIC,,308\";" + ] + }, + { + "cell_type": "code", + "source": [ + "var actualsMUP_BE = $\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario,", + "\nCH,2020,12,MUP,", + "\n@@Actual", + "\nDataNode,AocType,ValueType,AccidentYear,Value", + "\nDT1.1,CF,NIC,,280\";" + ] + }, { "cell_type": "code", "source": [ From 372dcb6c78ec93b64531d00a9d3ba56a2ee492f2 Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Sat, 5 Nov 2022 11:48:26 +0100 Subject: [PATCH 17/23] much better --- .../Files/DimensionsAndPartitions.csv | 10 +- .../BM_CH_2020_12_BE_SCE.csv | 181 ------------------ .../BM_CH_2020_12_MTUP10pct.csv | 181 ++++++++++++++++++ .../Test/IfrsVariablesTest.ipynb | 4 +- full-ifrs17-template/Test/ScenarioTest.ipynb | 152 ++++++++++----- .../Test/SequenceImportTest.ipynb | 115 +++++++++++ ifrs17/CalculationEngine.ipynb | 3 +- ifrs17/Constants/Consts.ipynb | 5 +- ifrs17/DataModel/DataStructure.ipynb | 56 +----- ifrs17/Import/ImportStorage.ipynb | 46 +++-- ifrs17/Test/QueriesTest.ipynb | 4 +- ifrs17/Utils/EqualityComparers.ipynb | 134 +++++++++++++ 12 files changed, 575 insertions(+), 316 deletions(-) delete mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv create mode 100644 full-ifrs17-template/Test/SequenceImportTest.ipynb create mode 100644 ifrs17/Utils/EqualityComparers.ipynb diff --git a/full-ifrs17-template/Files/DimensionsAndPartitions.csv b/full-ifrs17-template/Files/DimensionsAndPartitions.csv index 666d19c2..e72d39c9 100644 --- a/full-ifrs17-template/Files/DimensionsAndPartitions.csv +++ b/full-ifrs17-template/Files/DimensionsAndPartitions.csv @@ -214,9 +214,9 @@ Default,Default,,,,,,,,,, ,,,,,,,,,,, @@Scenario,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, -BE,Best Estimate,,,,,,,,,, -YCUP,Yield Curve Up,,,,,,,,,, -MUP,Mortality Up,,,,,,,,,, +YCUP0.5pct,Yield Curve Up 0.5pct,,,,,,,,,, +YCUP1.0pct,Yield Curve Up 1.0pct,,,,,,,,,, +MTUP10pct,Mortality Up 10pct,,,,,,,,,, ,,,,,,,,,,, @@ValuationApproach,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, @@ -229,8 +229,8 @@ CH,00000000-0000-0000-0000-000000000001,,,,,,,,,, @@PartitionByReportingNodeAndPeriod,,,,,,,,,,, ReportingNode,Year,Month,Scenario,Id,,,,,,, CH,2020,12,,10000000-0000-0000-0000-000000000000,,,,,,, -CH,2020,12,YCUP,15000000-0000-0000-0000-000000000000,,,,,,, -CH,2020,12,MUP,16000000-0000-0000-0000-000000000000,,,,,,, +CH,2020,12,YCUP1.0pct,15000000-0000-0000-0000-000000000000,,,,,,, +CH,2020,12,MTUP10pct,16000000-0000-0000-0000-000000000000,,,,,,, CH,2021,3,,20000000-0000-0000-0000-000000000000,,,,,,, ,,,,,,,,,,, @@ProjectionConfiguration,,,,,,,,,,, diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv deleted file mode 100644 index 5dd14c6e..00000000 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE_SCE.csv +++ /dev/null @@ -1,181 +0,0 @@ -@@Main,,,,,,, -Month,ReportingNode,Scenario,Year,,,, -12,CH,MUP,2020,,,, -@@BE,,,,,,, -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,PR,BOP,DT1.1,C,BE,N,-878.3904043 -,NIC,BOP,DT1.1,L,BE,N,658.6282391 -,PR,BOP,DT1.1,L,BE,N,-878.3904043 -,NIC,BOP,DT1.1,C,BE,N,658.6282391 -,PR,EOP,DT1.1,L,BE,C,-439.5973224 -,NIC,EOP,DT1.1,L,BE,C,329.6431047 -,PR,EOP,DT1.1,C,BE,C,-439.5973224 -,NIC,EOP,DT1.1,C,BE,C,329.6431047 -,PR,IA,DT1.1,L,BE,N,-1.206918171 -,NIC,IA,DT1.1,L,BE,N,1.014865605 -,PR,IA,DT1.1,C,BE,N,-1.206918171 -,NIC,IA,DT1.1,C,BE,N,1.014865605 -,PR,CF,DT1.1,L,BE,N,440 -,NIC,CF,DT1.1,L,BE,N,-330 -,PR,CF,DT1.1,C,BE,N,440 -,NIC,CF,DT1.1,C,BE,N,-330 -2020,NIC,BOP,DT1.2,L,BE,N,658.6282391 -2020,NIC,BOP,DT1.2,C,BE,N,658.6282391 -2020,NIC,EOP,DT1.2,L,BE,C,329.6431047 -2020,NIC,EOP,DT1.2,C,BE,C,329.6431047 -2020,NIC,IA,DT1.2,L,BE,N,1.014865605 -2020,NIC,IA,DT1.2,C,BE,N,1.014865605 -2020,NIC,CF,DT1.2,L,BE,N,-330 -2020,NIC,CF,DT1.2,C,BE,N,-330 -,PR,BOP,DT1.3,L,BE,N,-878.3904043 -,NIC,BOP,DT1.3,L,BE,N,658.6282391 -,PR,BOP,DT1.3,C,BE,N,-878.3904043 -,NIC,BOP,DT1.3,C,BE,N,658.6282391 -,PR,EOP,DT1.3,L,BE,C,-439.5973224 -,NIC,EOP,DT1.3,L,BE,C,329.6431047 -,PR,EOP,DT1.3,C,BE,C,-439.5973224 -,NIC,EOP,DT1.3,C,BE,C,329.6431047 -,PR,IA,DT1.3,L,BE,N,-1.206918171 -,NIC,IA,DT1.3,L,BE,N,1.014865605 -,PR,IA,DT1.3,C,BE,N,-1.206918171 -,NIC,IA,DT1.3,C,BE,N,1.014865605 -,PR,CF,DT1.3,L,BE,N,440 -,NIC,CF,DT1.3,L,BE,N,-330 -,PR,CF,DT1.3,C,BE,N,440 -,NIC,CF,DT1.3,C,BE,N,-330 -,PR,BOP,DT2.1,L,BE,N,-878.3904043 -,NIC,BOP,DT2.1,L,BE,N,658.6282391 -,PR,BOP,DT2.1,C,BE,N,-878.3904043 -,NIC,BOP,DT2.1,C,BE,N,658.6282391 -,PR,EOP,DT2.1,L,BE,C,-439.5973224 -,NIC,EOP,DT2.1,L,BE,C,329.6431047 -,PR,EOP,DT2.1,C,BE,C,-439.5973224 -,NIC,EOP,DT2.1,C,BE,C,329.6431047 -,PR,IA,DT2.1,L,BE,N,-1.206918171 -,NIC,IA,DT2.1,L,BE,N,1.014865605 -,PR,IA,DT2.1,C,BE,N,-1.206918171 -,NIC,IA,DT2.1,C,BE,N,1.014865605 -,PR,CF,DT2.1,L,BE,N,440 -,NIC,CF,DT2.1,L,BE,N,-330 -,PR,CF,DT2.1,C,BE,N,440 -,NIC,CF,DT2.1,C,BE,N,-330 -2020,NIC,BOP,DT2.2,L,BE,N,658.6282391 -2020,NIC,BOP,DT2.2,C,BE,N,658.6282391 -2020,NIC,EOP,DT2.2,L,BE,C,329.6431047 -2020,NIC,EOP,DT2.2,C,BE,C,329.6431047 -2020,NIC,IA,DT2.2,L,BE,N,1.014865605 -2020,NIC,IA,DT2.2,C,BE,N,1.014865605 -2020,NIC,CF,DT2.2,L,BE,N,-330 -2020,NIC,CF,DT2.2,C,BE,N,-330 -,PR,BOP,DTR1.1,L,BE,N,439.1952021 -,NIC,BOP,DTR1.1,L,BE,N,-329.3141195 -,CDR,BOP,DTR1.1,L,BE,N,0.52924753 -,PR,BOP,DTR1.1,C,BE,N,439.1952021 -,NIC,BOP,DTR1.1,C,BE,N,-329.3141195 -,CDR,BOP,DTR1.1,C,BE,N,0.52924753 -,PR,EOP,DTR1.1,L,BE,C,219.7986612 -,NIC,EOP,DTR1.1,L,BE,C,-164.8215523 -,CDR,EOP,DTR1.1,L,BE,C,0.126798764 -,PR,EOP,DTR1.1,C,BE,C,219.7986612 -,NIC,EOP,DTR1.1,C,BE,C,-164.8215523 -,CDR,EOP,DTR1.1,C,BE,C,0.126798764 -,PR,IA,DTR1.1,L,BE,N,0.603459086 -,NIC,IA,DTR1.1,L,BE,N,-0.507432803 -,CDR,IA,DTR1.1,L,BE,N,0.00128721 -,PR,IA,DTR1.1,C,BE,N,0.603459086 -,NIC,IA,DTR1.1,C,BE,N,-0.507432803 -,CDR,IA,DTR1.1,C,BE,N,0.00128721 -,PR,CF,DTR1.1,L,BE,N,-220 -,NIC,CF,DTR1.1,L,BE,N,165 -,CDR,CF,DTR1.1,L,BE,N,-0.403735976 -,PR,CF,DTR1.1,C,BE,N,-220 -,NIC,CF,DTR1.1,C,BE,N,165 -,CDR,CF,DTR1.1,C,BE,N,-0.403735976 -2020,NIC,BOP,DTR1.2,L,BE,N,-329.3141195 -2020,CDR,BOP,DTR1.2,L,BE,N,0.52924753 -2020,NIC,BOP,DTR1.2,C,BE,N,-329.3141195 -2020,CDR,BOP,DTR1.2,C,BE,N,0.52924753 -2020,NIC,EOP,DTR1.2,L,BE,C,-164.8215523 -2020,CDR,EOP,DTR1.2,L,BE,C,0.126798764 -2020,NIC,EOP,DTR1.2,C,BE,C,-164.8215523 -2020,CDR,EOP,DTR1.2,C,BE,C,0.126798764 -2020,NIC,IA,DTR1.2,L,BE,N,-0.507432803 -2020,CDR,IA,DTR1.2,L,BE,N,0.00128721 -2020,NIC,IA,DTR1.2,C,BE,N,-0.507432803 -2020,CDR,IA,DTR1.2,C,BE,N,0.00128721 -2020,NIC,CF,DTR1.2,L,BE,N,165 -2020,CDR,CF,DTR1.2,L,BE,N,-0.403735976 -2020,NIC,CF,DTR1.2,C,BE,N,165 -2020,CDR,CF,DTR1.2,C,BE,N,-0.403735976 -,PR,BOP,DTR2.1,L,BE,N,439.1952021 -,NIC,BOP,DTR2.1,L,BE,N,-329.3141195 -,CDR,BOP,DTR2.1,L,BE,N,0.52924753 -,PR,BOP,DTR2.1,C,BE,N,439.1952021 -,NIC,BOP,DTR2.1,C,BE,N,-329.3141195 -,CDR,BOP,DTR2.1,C,BE,N,0.52924753 -,PR,EOP,DTR2.1,L,BE,C,219.7986612 -,NIC,EOP,DTR2.1,L,BE,C,-164.8215523 -,CDR,EOP,DTR2.1,L,BE,C,0.126798764 -,PR,EOP,DTR2.1,C,BE,C,219.7986612 -,NIC,EOP,DTR2.1,C,BE,C,-164.8215523 -,CDR,EOP,DTR2.1,C,BE,C,0.126798764 -,PR,IA,DTR2.1,L,BE,N,0.603459086 -,NIC,IA,DTR2.1,L,BE,N,-0.507432803 -,CDR,IA,DTR2.1,L,BE,N,0.00128721 -,PR,IA,DTR2.1,C,BE,N,0.603459086 -,NIC,IA,DTR2.1,C,BE,N,-0.507432803 -,CDR,IA,DTR2.1,C,BE,N,0.00128721 -,PR,CF,DTR2.1,L,BE,N,-220 -,NIC,CF,DTR2.1,L,BE,N,165 -,CDR,CF,DTR2.1,L,BE,N,-0.403735976 -,PR,CF,DTR2.1,C,BE,N,-220 -,NIC,CF,DTR2.1,C,BE,N,165 -,CDR,CF,DTR2.1,C,BE,N,-0.403735976 -2020,NIC,BOP,DTR2.2,L,BE,N,-329.3141195 -2020,CDR,BOP,DTR2.2,L,BE,N,0.52924753 -2020,NIC,BOP,DTR2.2,C,BE,N,-329.3141195 -2020,CDR,BOP,DTR2.2,C,BE,N,0.52924753 -2020,NIC,EOP,DTR2.2,L,BE,C,-164.8215523 -2020,CDR,EOP,DTR2.2,L,BE,C,0.126798764 -2020,NIC,EOP,DTR2.2,C,BE,C,-164.8215523 -2020,CDR,EOP,DTR2.2,C,BE,C,0.126798764 -2020,NIC,IA,DTR2.2,L,BE,N,-0.507432803 -2020,CDR,IA,DTR2.2,L,BE,N,0.00128721 -2020,NIC,IA,DTR2.2,C,BE,N,-0.507432803 -2020,CDR,IA,DTR2.2,C,BE,N,0.00128721 -2020,NIC,CF,DTR2.2,L,BE,N,165 -2020,CDR,CF,DTR2.2,L,BE,N,-0.403735976 -2020,NIC,CF,DTR2.2,C,BE,N,165 -2020,CDR,CF,DTR2.2,C,BE,N,-0.403735976 -,PR,BOP,DT3.1,L,BE,N,-878.3904043 -,NIC,BOP,DT3.1,L,BE,N,658.6282391 -,PR,BOP,DT3.1,C,BE,N,-878.3904043 -,NIC,BOP,DT3.1,C,BE,N,658.6282391 -,PR,EOP,DT3.1,L,BE,C,-439.5973224 -,NIC,EOP,DT3.1,L,BE,C,329.6431047 -,PR,EOP,DT3.1,C,BE,C,-439.5973224 -,NIC,EOP,DT3.1,C,BE,C,329.6431047 -,PR,IA,DT3.1,L,BE,N,-1.206918171 -,NIC,IA,DT3.1,L,BE,N,1.014865605 -,PR,IA,DT3.1,C,BE,N,-1.206918171 -,NIC,IA,DT3.1,C,BE,N,1.014865605 -,PR,CF,DT3.1,L,BE,N,440 -,NIC,CF,DT3.1,L,BE,N,-330 -,PR,CF,DT3.1,C,BE,N,440 -,NIC,CF,DT3.1,C,BE,N,-330 -,PR,BOP,DT4.1,L,BE,N,-878.3904043 -,NIC,BOP,DT4.1,L,BE,N,658.6282391 -,PR,BOP,DT4.1,C,BE,N,-878.3904043 -,NIC,BOP,DT4.1,C,BE,N,658.6282391 -,PR,EOP,DT4.1,L,BE,C,-439.5973224 -,NIC,EOP,DT4.1,L,BE,C,329.6431047 -,PR,EOP,DT4.1,C,BE,C,-439.5973224 -,NIC,EOP,DT4.1,C,BE,C,329.6431047 -,PR,IA,DT4.1,L,BE,N,-1.206918171 -,NIC,IA,DT4.1,L,BE,N,1.014865605 -,PR,IA,DT4.1,C,BE,N,-1.206918171 -,NIC,IA,DT4.1,C,BE,N,1.014865605 -,PR,CF,DT4.1,L,BE,N,440 -,NIC,CF,DT4.1,L,BE,N,-330 -,PR,CF,DT4.1,C,BE,N,440 -,NIC,CF,DT4.1,C,BE,N,-330 diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv new file mode 100644 index 00000000..64bf4ea9 --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv @@ -0,0 +1,181 @@ +@@Main,,,,,,, +Month,ReportingNode,Scenario,Year,,,, +12,CH,MTUP10pct,2020,,,, +@@BE,,,,,,, +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,PR,BOP,DT1.1,C,BE,N,878.3904043 +,NIC,BOP,DT1.1,L,BE,N,-658.6282391 +,PR,BOP,DT1.1,L,BE,N,878.3904043 +,NIC,BOP,DT1.1,C,BE,N,-658.6282391 +,PR,EOP,DT1.1,L,BE,C,439.5973224 +,NIC,EOP,DT1.1,L,BE,C,-329.6431047 +,PR,EOP,DT1.1,C,BE,C,439.5973224 +,NIC,EOP,DT1.1,C,BE,C,-329.6431047 +,PR,IA,DT1.1,L,BE,N,1.206918171 +,NIC,IA,DT1.1,L,BE,N,-1.014865605 +,PR,IA,DT1.1,C,BE,N,1.206918171 +,NIC,IA,DT1.1,C,BE,N,-1.014865605 +,PR,CF,DT1.1,L,BE,N,-440 +,NIC,CF,DT1.1,L,BE,N,330 +,PR,CF,DT1.1,C,BE,N,-440 +,NIC,CF,DT1.1,C,BE,N,330 +2020,NIC,BOP,DT1.2,L,BE,N,-658.6282391 +2020,NIC,BOP,DT1.2,C,BE,N,-658.6282391 +2020,NIC,EOP,DT1.2,L,BE,C,-329.6431047 +2020,NIC,EOP,DT1.2,C,BE,C,-329.6431047 +2020,NIC,IA,DT1.2,L,BE,N,-1.014865605 +2020,NIC,IA,DT1.2,C,BE,N,-1.014865605 +2020,NIC,CF,DT1.2,L,BE,N,330 +2020,NIC,CF,DT1.2,C,BE,N,330 +,PR,BOP,DT1.3,L,BE,N,878.3904043 +,NIC,BOP,DT1.3,L,BE,N,-658.6282391 +,PR,BOP,DT1.3,C,BE,N,878.3904043 +,NIC,BOP,DT1.3,C,BE,N,-658.6282391 +,PR,EOP,DT1.3,L,BE,C,439.5973224 +,NIC,EOP,DT1.3,L,BE,C,-329.6431047 +,PR,EOP,DT1.3,C,BE,C,439.5973224 +,NIC,EOP,DT1.3,C,BE,C,-329.6431047 +,PR,IA,DT1.3,L,BE,N,1.206918171 +,NIC,IA,DT1.3,L,BE,N,-1.014865605 +,PR,IA,DT1.3,C,BE,N,1.206918171 +,NIC,IA,DT1.3,C,BE,N,-1.014865605 +,PR,CF,DT1.3,L,BE,N,-440 +,NIC,CF,DT1.3,L,BE,N,330 +,PR,CF,DT1.3,C,BE,N,-440 +,NIC,CF,DT1.3,C,BE,N,330 +,PR,BOP,DT2.1,L,BE,N,878.3904043 +,NIC,BOP,DT2.1,L,BE,N,-658.6282391 +,PR,BOP,DT2.1,C,BE,N,878.3904043 +,NIC,BOP,DT2.1,C,BE,N,-658.6282391 +,PR,EOP,DT2.1,L,BE,C,439.5973224 +,NIC,EOP,DT2.1,L,BE,C,-329.6431047 +,PR,EOP,DT2.1,C,BE,C,439.5973224 +,NIC,EOP,DT2.1,C,BE,C,-329.6431047 +,PR,IA,DT2.1,L,BE,N,1.206918171 +,NIC,IA,DT2.1,L,BE,N,-1.014865605 +,PR,IA,DT2.1,C,BE,N,1.206918171 +,NIC,IA,DT2.1,C,BE,N,-1.014865605 +,PR,CF,DT2.1,L,BE,N,-440 +,NIC,CF,DT2.1,L,BE,N,330 +,PR,CF,DT2.1,C,BE,N,-440 +,NIC,CF,DT2.1,C,BE,N,330 +2020,NIC,BOP,DT2.2,L,BE,N,-658.6282391 +2020,NIC,BOP,DT2.2,C,BE,N,-658.6282391 +2020,NIC,EOP,DT2.2,L,BE,C,-329.6431047 +2020,NIC,EOP,DT2.2,C,BE,C,-329.6431047 +2020,NIC,IA,DT2.2,L,BE,N,-1.014865605 +2020,NIC,IA,DT2.2,C,BE,N,-1.014865605 +2020,NIC,CF,DT2.2,L,BE,N,330 +2020,NIC,CF,DT2.2,C,BE,N,330 +,PR,BOP,DTR1.1,L,BE,N,-439.1952021 +,NIC,BOP,DTR1.1,L,BE,N,329.3141195 +,CDR,BOP,DTR1.1,L,BE,N,-0.52924753 +,PR,BOP,DTR1.1,C,BE,N,-439.1952021 +,NIC,BOP,DTR1.1,C,BE,N,329.3141195 +,CDR,BOP,DTR1.1,C,BE,N,-0.52924753 +,PR,EOP,DTR1.1,L,BE,C,-219.7986612 +,NIC,EOP,DTR1.1,L,BE,C,164.8215523 +,CDR,EOP,DTR1.1,L,BE,C,-0.126798764 +,PR,EOP,DTR1.1,C,BE,C,-219.7986612 +,NIC,EOP,DTR1.1,C,BE,C,164.8215523 +,CDR,EOP,DTR1.1,C,BE,C,-0.126798764 +,PR,IA,DTR1.1,L,BE,N,-0.603459086 +,NIC,IA,DTR1.1,L,BE,N,0.507432803 +,CDR,IA,DTR1.1,L,BE,N,-0.00128721 +,PR,IA,DTR1.1,C,BE,N,-0.603459086 +,NIC,IA,DTR1.1,C,BE,N,0.507432803 +,CDR,IA,DTR1.1,C,BE,N,-0.00128721 +,PR,CF,DTR1.1,L,BE,N,220 +,NIC,CF,DTR1.1,L,BE,N,-165 +,CDR,CF,DTR1.1,L,BE,N,0.403735976 +,PR,CF,DTR1.1,C,BE,N,220 +,NIC,CF,DTR1.1,C,BE,N,-165 +,CDR,CF,DTR1.1,C,BE,N,0.403735976 +2020,NIC,BOP,DTR1.2,L,BE,N,329.3141195 +2020,CDR,BOP,DTR1.2,L,BE,N,-0.52924753 +2020,NIC,BOP,DTR1.2,C,BE,N,329.3141195 +2020,CDR,BOP,DTR1.2,C,BE,N,-0.52924753 +2020,NIC,EOP,DTR1.2,L,BE,C,164.8215523 +2020,CDR,EOP,DTR1.2,L,BE,C,-0.126798764 +2020,NIC,EOP,DTR1.2,C,BE,C,164.8215523 +2020,CDR,EOP,DTR1.2,C,BE,C,-0.126798764 +2020,NIC,IA,DTR1.2,L,BE,N,0.507432803 +2020,CDR,IA,DTR1.2,L,BE,N,-0.00128721 +2020,NIC,IA,DTR1.2,C,BE,N,0.507432803 +2020,CDR,IA,DTR1.2,C,BE,N,-0.00128721 +2020,NIC,CF,DTR1.2,L,BE,N,-165 +2020,CDR,CF,DTR1.2,L,BE,N,0.403735976 +2020,NIC,CF,DTR1.2,C,BE,N,-165 +2020,CDR,CF,DTR1.2,C,BE,N,0.403735976 +,PR,BOP,DTR2.1,L,BE,N,-439.1952021 +,NIC,BOP,DTR2.1,L,BE,N,329.3141195 +,CDR,BOP,DTR2.1,L,BE,N,-0.52924753 +,PR,BOP,DTR2.1,C,BE,N,-439.1952021 +,NIC,BOP,DTR2.1,C,BE,N,329.3141195 +,CDR,BOP,DTR2.1,C,BE,N,-0.52924753 +,PR,EOP,DTR2.1,L,BE,C,-219.7986612 +,NIC,EOP,DTR2.1,L,BE,C,164.8215523 +,CDR,EOP,DTR2.1,L,BE,C,-0.126798764 +,PR,EOP,DTR2.1,C,BE,C,-219.7986612 +,NIC,EOP,DTR2.1,C,BE,C,164.8215523 +,CDR,EOP,DTR2.1,C,BE,C,-0.126798764 +,PR,IA,DTR2.1,L,BE,N,-0.603459086 +,NIC,IA,DTR2.1,L,BE,N,0.507432803 +,CDR,IA,DTR2.1,L,BE,N,-0.00128721 +,PR,IA,DTR2.1,C,BE,N,-0.603459086 +,NIC,IA,DTR2.1,C,BE,N,0.507432803 +,CDR,IA,DTR2.1,C,BE,N,-0.00128721 +,PR,CF,DTR2.1,L,BE,N,220 +,NIC,CF,DTR2.1,L,BE,N,-165 +,CDR,CF,DTR2.1,L,BE,N,0.403735976 +,PR,CF,DTR2.1,C,BE,N,220 +,NIC,CF,DTR2.1,C,BE,N,-165 +,CDR,CF,DTR2.1,C,BE,N,0.403735976 +2020,NIC,BOP,DTR2.2,L,BE,N,329.3141195 +2020,CDR,BOP,DTR2.2,L,BE,N,-0.52924753 +2020,NIC,BOP,DTR2.2,C,BE,N,329.3141195 +2020,CDR,BOP,DTR2.2,C,BE,N,-0.52924753 +2020,NIC,EOP,DTR2.2,L,BE,C,164.8215523 +2020,CDR,EOP,DTR2.2,L,BE,C,-0.126798764 +2020,NIC,EOP,DTR2.2,C,BE,C,164.8215523 +2020,CDR,EOP,DTR2.2,C,BE,C,-0.126798764 +2020,NIC,IA,DTR2.2,L,BE,N,0.507432803 +2020,CDR,IA,DTR2.2,L,BE,N,-0.00128721 +2020,NIC,IA,DTR2.2,C,BE,N,0.507432803 +2020,CDR,IA,DTR2.2,C,BE,N,-0.00128721 +2020,NIC,CF,DTR2.2,L,BE,N,-165 +2020,CDR,CF,DTR2.2,L,BE,N,0.403735976 +2020,NIC,CF,DTR2.2,C,BE,N,-165 +2020,CDR,CF,DTR2.2,C,BE,N,0.403735976 +,PR,BOP,DT3.1,L,BE,N,878.3904043 +,NIC,BOP,DT3.1,L,BE,N,-658.6282391 +,PR,BOP,DT3.1,C,BE,N,878.3904043 +,NIC,BOP,DT3.1,C,BE,N,-658.6282391 +,PR,EOP,DT3.1,L,BE,C,439.5973224 +,NIC,EOP,DT3.1,L,BE,C,-329.6431047 +,PR,EOP,DT3.1,C,BE,C,439.5973224 +,NIC,EOP,DT3.1,C,BE,C,-329.6431047 +,PR,IA,DT3.1,L,BE,N,1.206918171 +,NIC,IA,DT3.1,L,BE,N,-1.014865605 +,PR,IA,DT3.1,C,BE,N,1.206918171 +,NIC,IA,DT3.1,C,BE,N,-1.014865605 +,PR,CF,DT3.1,L,BE,N,-440 +,NIC,CF,DT3.1,L,BE,N,330 +,PR,CF,DT3.1,C,BE,N,-440 +,NIC,CF,DT3.1,C,BE,N,330 +,PR,BOP,DT4.1,L,BE,N,878.3904043 +,NIC,BOP,DT4.1,L,BE,N,-658.6282391 +,PR,BOP,DT4.1,C,BE,N,878.3904043 +,NIC,BOP,DT4.1,C,BE,N,-658.6282391 +,PR,EOP,DT4.1,L,BE,C,439.5973224 +,NIC,EOP,DT4.1,L,BE,C,-329.6431047 +,PR,EOP,DT4.1,C,BE,C,439.5973224 +,NIC,EOP,DT4.1,C,BE,C,-329.6431047 +,PR,IA,DT4.1,L,BE,N,1.206918171 +,NIC,IA,DT4.1,L,BE,N,-1.014865605 +,PR,IA,DT4.1,C,BE,N,1.206918171 +,NIC,IA,DT4.1,C,BE,N,-1.014865605 +,PR,CF,DT4.1,L,BE,N,-440 +,NIC,CF,DT4.1,L,BE,N,330 +,PR,CF,DT4.1,C,BE,N,-440 +,NIC,CF,DT4.1,C,BE,N,330 diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index b17096a5..71e7d93f 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -78,7 +78,7 @@ "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_OAPA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_RA.csv\" , \"CH\", 2021, 3),", "\n // 2020 with Scenario", - "\n //new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_BE_SCE.csv\" , \"CH\", 2020, 12, \"IRU\"),", + "\n //new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", "\n};" ] }, @@ -213,7 +213,7 @@ "\n ", "\n //Set up Args and storage", "\n await DataSource.Partition.SetAsync(new {ReportingNode = reportingNode, ", - "\n Year= year, ", + "\n Year = year, ", "\n Month = month, ", "\n Scenario = scenario});", "\n var partition = (await DataSource.Query().ToArrayAsync())", diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index 730caf62..45281af0 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -24,56 +24,46 @@ { "cell_type": "markdown", "source": [ - "# Set Contest" + "# Context" ] }, { "cell_type": "code", "source": [ - "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "var log = await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", - "\nawait UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\");" + "\nlog" ] }, { "cell_type": "code", "source": [ - "var scenario = \"IRU\";", - "\nvar year = 2020;", - "\nvar month = 12;", - "\nvar reportingNode = \"CH\";", - "\nvar dataNode = \"DT1.1\";", - "\nvar format = ImportFormats.Cashflow;", - "\nFunc filter = x => x.AmountType == \"NIC\" && x.DataNode == dataNode;" + "var log = await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.Initialize(x => x.FromSource(DataSource));", + "\nlog" ] }, { "cell_type": "code", "source": [ - "var targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == reportingNode &&", - "\n p.Year == year &&", - "\n p.Month == month &&", - "\n p.Scenario == scenario).ToArrayAsync()).Single().Id;", - "\nvar defaultPartition = (await DataSource.Query().Where(p => p.ReportingNode == reportingNode &&", - "\n p.Year == year &&", - "\n p.Month == month &&", - "\n p.Scenario == null).ToArrayAsync()).Single().Id;", - "\n" + "var defaultVarsBE = Workspace.Query().ToArray();" ] }, { "cell_type": "markdown", "source": [ - "# Import Best Estimate and Scenario Cashflows" + "# Scenario Cashflows" ] }, { "cell_type": "code", "source": [ - "var cashflows_MUP = $\"", + "var cashflows_MTUP10pct = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", - "\nCH,2020,12,MUP", + "\nCH,2020,12,MTUP10pct", "\n@@Cashflow", "\nDataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", "\nDT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0", @@ -85,10 +75,10 @@ { "cell_type": "code", "source": [ - "var cashflowsMUP_BE = $\"", + "var cashflows_MTUP10pct_BE = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", - "\nCH,2020,12,MUP", + "\nCH,2020,12,MTUP10pct", "\n@@Cashflow", "\nDataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", "\nDT1.1,PR,CL,C,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0", @@ -100,47 +90,85 @@ { "cell_type": "code", "source": [ - "await Workspace.Partition.SetAsync(defaultPartition); ", - "\nawait DataSource.Partition.SetAsync(defaultPartition);", - "\nvar defaultVar = Workspace.Query().Where(filter).ToArray();", - "\ndefaultVar" + "var log = await Import.FromString(cashflows_MTUP10pct).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.Initialize(x => x.FromSource(DataSource));", + "\nlog" ] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "" + "class IfrsVariableComparer: IEqualityComparer", + "\n{", + "\n private bool IgnoreValue;", + "\n private IfrsVariableComparer(bool ignoreValue)", + "\n {", + "\n IgnoreValue = ignoreValue;", + "\n }", + "\n", + "\n public bool Equals(IfrsVariable x, IfrsVariable y) =>", + "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", + "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValue ? true : Math.Abs(x.Value - y.Value) < Precision); ", + "\n", + "\n public int GetHashCode(IfrsVariable v) => IgnoreValue ", + "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", + "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Value.ToString(\"F5\"));", + "\n", + "\n public static IfrsVariableComparer Instance(bool ignoreValue = false)", + "\n { ", + "\n return new IfrsVariableComparer(ignoreValue);", + "\n }", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "await Workspace.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", + "\nawait DataSource.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", + "\nvar diffs = Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance());", + "\ndiffs.Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().Be(0);", + "\ndiffs.Where(x => !(new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().NotBe(0);" + ] + }, + { + "cell_type": "code", + "source": [ + "var a = Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance()).Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray(); a" + ] + }, + { + "cell_type": "code", + "source": [ + "var b = Workspace.Query().Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType) && x.DataNode == \"DT1.1\").ToArray(); b" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario.csv\");", - "\nvar scenarioVar = Workspace.Query().Where(filter).ToArray();", - "\n(scenarioVar.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().NotBe(0)" + "var c = defaultVarsBE.Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType) && x.DataNode == \"DT1.1\").ToArray(); c" ] }, { "cell_type": "code", "source": [ - "var log = await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12_Scenario_BE.csv\");", - "\nvar mirrorBE = Workspace.Query().Where(filter);", - "\n(mirrorBE.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().Be(0)" + "// DISCUSS: some Actuals are missing..." ] }, { "cell_type": "markdown", "source": [ - "# Import Best Estimate and Scenario Actuals" + "# Scenario Actuals" ] }, { "cell_type": "code", "source": [ - "var actualsMUP = $\"", + "var actuals_MTUP10pct = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario,", - "\nCH,2020,12,MUP,", + "\nCH,2020,12,MTUP10pct,", "\n@@Actual", "\nDataNode,AocType,ValueType,AccidentYear,Value", "\nDT1.1,CF,NIC,,308\";" @@ -149,10 +177,10 @@ { "cell_type": "code", "source": [ - "var actualsMUP_BE = $\"", + "var actuals_MTUP10pct_BE = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario,", - "\nCH,2020,12,MUP,", + "\nCH,2020,12,MTUP10pct,", "\n@@Actual", "\nDataNode,AocType,ValueType,AccidentYear,Value", "\nDT1.1,CF,NIC,,280\";" @@ -161,24 +189,50 @@ { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\");", - "\nvar defaultVar = Workspace.Query().Where(filter).ToArray();" + "var log = await Import.FromString(actuals_MTUP10pct).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.Initialize(x => x.FromSource(DataSource));", + "\nlog" ] }, { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12_Scenario.csv\")", - "\nvar scenarioVar = Workspace.Query().Where(filter).ToArray();", - "\n(scenarioVar.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().NotBe(0)" + "await Workspace.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", + "\nawait DataSource.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", + "\nvar diffs = Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance());", + "\ndiffs.Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().NotBe(0);", + "\ndiffs.Where(x => x.EstimateType == \"CU\").ToArray().Length.Should().Be(0);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Robustness: back to Best Estimate" + ] + }, + { + "cell_type": "code", + "source": [ + "var log = await Import.FromString(actuals_MTUP10pct_BE).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.Initialize(x => x.FromSource(DataSource));", + "\nlog" + ] + }, + { + "cell_type": "code", + "source": [ + "var log = await Import.FromString(cashflows_MTUP10pct_BE).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", + "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.Initialize(x => x.FromSource(DataSource));", + "\nlog" ] }, { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12_Scenario_BE.csv\")", - "\nvar mirrorBE = Workspace.Query().Where(filter);", - "\n(mirrorBE.Except(defaultVar, IfrsVariableComparer.Instance()).ToArray()).Length.Should().Be(0)" + "Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance()).ToArray().Length.Should().Be(0);" ] }, { diff --git a/full-ifrs17-template/Test/SequenceImportTest.ipynb b/full-ifrs17-template/Test/SequenceImportTest.ipynb new file mode 100644 index 00000000..d080e549 --- /dev/null +++ b/full-ifrs17-template/Test/SequenceImportTest.ipynb @@ -0,0 +1,115 @@ +{ + "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": [ + "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Cashflow -> Actuals" + ] + }, + { + "cell_type": "code", + "source": [ + "var ws1 = Workspace.CreateNew();", + "\nws1.InitializeFrom(DataSource);" + ] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(ws1).ExecuteAsync()" + ] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(ws1).ExecuteAsync()" + ] + }, + { + "cell_type": "code", + "source": [ + "ws1.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nws1.Initialize(x => x.FromSource(DataSource));" + ] + }, + { + "cell_type": "code", + "source": [ + "var ifrsVars1 = await ws1.Query().ToArrayAsync();", + "\nifrsVars1.Count()" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Actuals -> Cashflow" + ] + }, + { + "cell_type": "code", + "source": [ + "var ws2 = Workspace.CreateNew();", + "\nws2.InitializeFrom(DataSource);" + ] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync()" + ] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(ws2).ExecuteAsync()" + ] + }, + { + "cell_type": "code", + "source": [ + "ws2.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nws2.Initialize(x => x.FromSource(DataSource));" + ] + }, + { + "cell_type": "code", + "source": [ + "var ifrsVars2 = await ws2.Query().ToArrayAsync();", + "\nifrsVars2.Count()" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" + ] + }, + { + "cell_type": "code", + "source": [ + "ifrsVars1.Except(ifrsVars2, IfrsVariableComparer.Instance())" + ] + } + ] +} \ No newline at end of file diff --git a/ifrs17/CalculationEngine.ipynb b/ifrs17/CalculationEngine.ipynb index 0936fa66..13b87df7 100644 --- a/ifrs17/CalculationEngine.ipynb +++ b/ifrs17/CalculationEngine.ipynb @@ -22,8 +22,7 @@ "\n#!import \"Report/ReportMutableScopes\"", "\n#!import \"Import/Importers\"", "\n#!import \"Export/ExportConfiguration\"", - "\n#!import \"Utils/TestHelper\"", - "\n#!import \"Utils/ImportCalculationMethods\"" + "\n#!import \"Utils/TestHelper\"" ] }, { diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index ca151081..70293fb3 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -262,8 +262,9 @@ "cell_type": "code", "source": [ "public static class Scenarios{", - "\n public const string YCUP = nameof(YCUP); // Yield Curve Up", - "\n public const string MUP = nameof(MUP); // Mortality Up", + "\n public const string YCUP05pct = nameof(YCUP05pct); // Yield Curve Up 0.5pct", + "\n public const string YCUP10pct = nameof(YCUP10pct); // Yield Curve Up 1.0pct", + "\n public const string MTUP10pct = nameof(MTUP10pct); // Mortality Up 10pct", "\n}" ] }, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index b5e38ab7..f5bcd82a 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -183,7 +183,7 @@ { "cell_type": "markdown", "source": [ - "The interface IWithYearMonthAndScenario allows to speficy to which year, month and scenario a certain piece of data applies to:", + "The interface IWithYearMonthAndScenario allows to identify the year, month and scenario associated to the data:", "\n" ] }, @@ -1472,32 +1472,6 @@ "\n}" ] }, - { - "cell_type": "code", - "source": [ - "class RawVariableComparer: IEqualityComparer", - "\n{", - "\n private bool IgnoreValues;", - "\n private RawVariableComparer(bool ignoreValues)", - "\n {", - "\n IgnoreValues = ignoreValues;", - "\n }", - "\n", - "\n public bool Equals(RawVariable x, RawVariable y) =>", - "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", - "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValues ? true : x.Values.SequenceEqual(y.Values)); ", - "\n", - "\n public int GetHashCode(RawVariable v) => IgnoreValues ", - "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", - "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Values);", - "\n", - "\n public static RawVariableComparer Instance(bool ignoreValues = false)", - "\n { ", - "\n return new RawVariableComparer(ignoreValues);", - "\n }", - "\n}" - ] - }, { "cell_type": "markdown", "source": [ @@ -1535,32 +1509,6 @@ "\n}" ] }, - { - "cell_type": "code", - "source": [ - "class IfrsVariableComparer: IEqualityComparer", - "\n{", - "\n private bool IgnoreValue;", - "\n private IfrsVariableComparer(bool ignoreValue)", - "\n {", - "\n IgnoreValue = ignoreValue;", - "\n }", - "\n", - "\n public bool Equals(IfrsVariable x, IfrsVariable y) =>", - "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", - "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValue ? true : x.Value == y.Value); ", - "\n", - "\n public int GetHashCode(IfrsVariable v) => IgnoreValue ", - "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", - "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Value);", - "\n", - "\n public static IfrsVariableComparer Instance(bool ignoreValue = false)", - "\n { ", - "\n return new IfrsVariableComparer(ignoreValue);", - "\n }", - "\n}" - ] - }, { "cell_type": "markdown", "source": [ @@ -1827,4 +1775,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 065aa67d..ba71ca3f 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -44,7 +44,8 @@ { "cell_type": "code", "source": [ - "#!import \"../Utils/ImportCalculationMethods\"", + "#!import \"../Utils/EqualityComparers\"", + "\n#!import \"../Utils/ImportCalculationMethods\"", "\n#!import \"../Utils/Queries\"" ] }, @@ -90,7 +91,6 @@ "\n //Variables", "\n public IDictionary> RawVariablesByImportIdentity { get; private set; }", "\n public IDictionary> IfrsVariablesByImportIdentity { get; private set; }", - "\n public RawVariable[] DefaultRawVariables { get; private set; }", "\n ", "\n //Parameters", "\n public Dictionary LockedInYieldCurve { get; private set; }", @@ -249,30 +249,40 @@ "\n .ToArrayAsync());", "\n ", "\n //Variables", + "\n // DISCUSS: wouldn't it be better to use Union() instead of Concat() to check if DataSource has some rawvars identical to the parsed ones", "\n var rawVariables = parsedRawVariables.Concat(openingRawVariables)", "\n .Concat(await querySource.Query()", "\n .Where(rv => rv.Partition == TargetPartition)", "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", - "\n .ToArrayAsync()); // TODO: we perform Union() instead of Concat() to check if DataSource has some rawvars identical to the parsed ones", - "\n if (!rawVariables.Any()) ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", + "\n .ToArrayAsync()); ", + "\n //if (!rawVariables.Any()) ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\"); // DISCUSS: goes with the above one", "\n ", - "\n if(DefaultPartition != TargetPartition){", + "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", + "\n .Concat(await querySource.Query()", + "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", + "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", + "\n || secondaryScope.Contains(iv.DataNode))", + "\n .ToArrayAsync());", + "\n", + "\n if(DefaultPartition != TargetPartition) {", "\n await querySource.Partition.SetAsync(DefaultPartition);", "\n var defaultRawVariables = await querySource.Query()", - "\n .Where(rv => rv.Partition == DefaultPartition)", - "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", - "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance(true));", + "\n .Where(rv => rv.Partition == DefaultPartition)", + "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", + "\n var defaultIfrsVariables = await querySource.Query()", + "\n .Where(iv => iv.Partition == DefaultPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", + "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", + "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync();", + "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance(ignoreValues : true));", + "\n ifrsVariables = ifrsVariables.Union(defaultIfrsVariables, IfrsVariableComparer.Instance(ignoreValue : true));", + "\n await querySource.Partition.SetAsync(TargetPartition);", "\n }", - "\n ", + "\n", "\n RawVariablesByImportIdentity = (IDictionary>)rawVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", - "\n ", - "\n var ifrsVariables = parsedIfrsVariables.Union(openingIfrsVariables, IfrsVariableComparer.Instance())", - "\n .Union(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I)) //Actuals or Gross", - "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", - "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", - "\n || secondaryScope.Contains(iv.DataNode))", - "\n .ToArrayAsync(), IfrsVariableComparer.Instance());", "\n IfrsVariablesByImportIdentity = (IDictionary>)ifrsVariables.ToDictionaryGrouped(v => v.DataNode, v => (ICollection)v.ToArray());", "\n }", "\n ", @@ -313,8 +323,6 @@ "\n", "\n //Variables and Cashflows", "\n ", - "\n public IDictionary> TestRawVars() => RawVariablesByImportIdentity;", - "\n public IDictionary> TestIfrsVars() => IfrsVariablesByImportIdentity;", "\n public IEnumerable GetRawVariables(string dataNode) => RawVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", "\n public IEnumerable GetIfrsVariables(string dataNode) => IfrsVariablesByImportIdentity.TryGetValue(dataNode, out var variableCollection) ? variableCollection : Enumerable.Empty();", "\n ", diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index cded950d..52633379 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -20,14 +20,14 @@ { "cell_type": "code", "source": [ - "#!import \"../../ifrs17/CalculationEngine\"" + "#!import \"../CalculationEngine\"" ] }, { "cell_type": "code", "source": [ "var gic = \"DT1.1\";", - "\nvar scenario = \"SCE\";" + "\nvar scenario = \"MUP\";" ] }, { diff --git a/ifrs17/Utils/EqualityComparers.ipynb b/ifrs17/Utils/EqualityComparers.ipynb new file mode 100644 index 00000000..127ab9ee --- /dev/null +++ b/ifrs17/Utils/EqualityComparers.ipynb @@ -0,0 +1,134 @@ +{ + "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 \"../DataModel/DataStructure\"" + ] + }, + { + "cell_type": "code", + "source": [ + "using System ;", + "\nusing System.Diagnostics ; ", + "\nusing System.Threading ;" + ] + }, + { + "cell_type": "code", + "source": [ + "using static Systemorph.Vertex.Equality.IdentityPropertyExtensions;", + "\n", + "\npublic class MyClass{", + "\n [IdentityProperty]", + "\n public string Prop1 {get; set;}", + "\n [IdentityProperty]", + "\n public string Prop2 {get; set;}", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "var a = new MyClass[] { new MyClass{Prop1=\"blabla\", Prop2=\"blublu\"}, new MyClass{Prop1=\"bloblo\", Prop2=\"blublu\"}, new MyClass{Prop1=\"blibli\", Prop2=\"blublu\"}, new MyClass{Prop1=\"blibli\", Prop2=\"blublu\"} };" + ] + }, + { + "cell_type": "code", + "source": [ + "Stopwatch sw = new Stopwatch();", + "\nsw.Start();", + "\nvar r = new List();", + "\nfor(int i = 0; i < 10000000; i++) {", + "\n for(int j = 0; j < a.Length; j++) {", + "\n r.Add((string)typeof(MyClass).GetIdentityProperties().First().GetValue(a[j]));", + "\n }", + "\n}", + "\nsw.Stop();", + "\nsw.Elapsed" + ] + }, + { + "cell_type": "code", + "source": [ + "Stopwatch sw = new Stopwatch();", + "\nsw.Start();", + "\nvar r = new List();", + "\nfor(int i = 0; i < 10000000; i++) {", + "\n for(int j = 0; j < a.Length; j++) {", + "\n r.Add(a[j].Prop1);", + "\n }", + "\n}", + "\nsw.Stop();", + "\nsw.Elapsed" + ] + }, + { + "cell_type": "code", + "source": [ + "class RawVariableComparer: IEqualityComparer", + "\n{", + "\n private bool IgnoreValues;", + "\n private RawVariableComparer(bool ignoreValues)", + "\n {", + "\n IgnoreValues = ignoreValues;", + "\n }", + "\n", + "\n public bool Equals(RawVariable x, RawVariable y) =>", + "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", + "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValues ? true : x.Values.SequenceEqual(y.Values)); // TODO: enable Precision", + "\n", + "\n public int GetHashCode(RawVariable v) => IgnoreValues ", + "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", + "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Values);", + "\n", + "\n public static RawVariableComparer Instance(bool ignoreValues = false)", + "\n { ", + "\n return new RawVariableComparer(ignoreValues);", + "\n }", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "class IfrsVariableComparer: IEqualityComparer", + "\n{", + "\n private bool IgnoreValue;", + "\n private IfrsVariableComparer(bool ignoreValue)", + "\n {", + "\n IgnoreValue = ignoreValue;", + "\n }", + "\n", + "\n public bool Equals(IfrsVariable x, IfrsVariable y) =>", + "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", + "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValue ? true : Math.Abs(x.Value - y.Value) < Precision); ", + "\n", + "\n public int GetHashCode(IfrsVariable v) => IgnoreValue ", + "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", + "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Value.ToString(\"F5\"));", + "\n", + "\n public static IfrsVariableComparer Instance(bool ignoreValue = false)", + "\n { ", + "\n return new IfrsVariableComparer(ignoreValue);", + "\n }", + "\n}" + ] + } + ] +} \ No newline at end of file From 8bddd27789520a9f87f256882c79af6e6bb33be2 Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Mon, 7 Nov 2022 16:11:08 +0100 Subject: [PATCH 18/23] cleanups --- ifrs17/Import/Importers.ipynb | 31 +-------------- ifrs17/Test/QueriesTest.ipynb | 2 +- ifrs17/Utils/EqualityComparers.ipynb | 57 ++-------------------------- 3 files changed, 6 insertions(+), 84 deletions(-) diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 6f7f5cc9..f36cf6fb 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -903,27 +903,6 @@ "\n}" ] }, - { - "cell_type": "code", - "source": [ - "public async Task CompareCalculatedToDBAsync(ImportArgs args, IEnumerable calculatedVariables)", - "\n{", - "\n var targetPartition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", - "\n p.Year == args.Year &&", - "\n p.Month == args.Month &&", - "\n p.Scenario == args.Scenario).ToArrayAsync()).Single().Id;", - "\n await Workspace.Partition.SetAsync(targetPartition); ", - "\n await DataSource.Partition.SetAsync(targetPartition);", - "\n var parsedVariables = await Workspace.Query().ToArrayAsync();", - "\n var savedVariables = await DataSource.Query().ToArrayAsync();", - "\n if (!parsedVariables.Any() || !savedVariables.Any()) return false;", - "\n var updatedVariables = parsedVariables.Union(calculatedVariables, IfrsVariableComparer.Instance());", - "\n var newVariables = updatedVariables?.Union(savedVariables, IfrsVariableComparer.Instance()) ?? Enumerable.Empty();", - "\n await Workspace.UpdateAsync(updatedVariables);", - "\n return !newVariables.Any();", - "\n}" - ] - }, { "cell_type": "code", "source": [ @@ -935,12 +914,7 @@ "\n ", "\n var parsingLog = await ParseCashflowsToWorkspaceAsync(dataSet, args);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", - "\n ", - "\n /*if(await CompareParsedToDBAsync(args)) { // TODO: implement in storage so as not to repeat queries", - "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\");", - "\n return Activity.Finish().Merge(parsingLog);", - "\n }*/", - "\n ", + "\n ", "\n var storage = new ImportStorage(args, DataSource, Workspace);", "\n await storage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", @@ -955,7 +929,6 @@ "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n await Workspace.UpdateAsync(ivs);", - "\n //scrematura = union minus per ifrs", "\n await CommitToDatabase(storage.TargetPartition, ", "\n snapshot : true, ", "\n filter : x => storage.EstimateTypesByImportFormat[ImportFormats.Cashflow].Contains(x.EstimateType) && ", @@ -1222,4 +1195,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index 52633379..c72041a9 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -27,7 +27,7 @@ "cell_type": "code", "source": [ "var gic = \"DT1.1\";", - "\nvar scenario = \"MUP\";" + "\nvar scenario = \"MTUP\";" ] }, { diff --git a/ifrs17/Utils/EqualityComparers.ipynb b/ifrs17/Utils/EqualityComparers.ipynb index 127ab9ee..f2394b0a 100644 --- a/ifrs17/Utils/EqualityComparers.ipynb +++ b/ifrs17/Utils/EqualityComparers.ipynb @@ -16,66 +16,15 @@ "nbformat_minor": 5, "cells": [ { - "cell_type": "code", - "source": [ - "#!import \"../DataModel/DataStructure\"" - ] - }, - { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "using System ;", - "\nusing System.Diagnostics ; ", - "\nusing System.Threading ;" - ] - }, - { - "cell_type": "code", - "source": [ - "using static Systemorph.Vertex.Equality.IdentityPropertyExtensions;", - "\n", - "\npublic class MyClass{", - "\n [IdentityProperty]", - "\n public string Prop1 {get; set;}", - "\n [IdentityProperty]", - "\n public string Prop2 {get; set;}", - "\n}" + "

Equality Comparers

" ] }, { "cell_type": "code", "source": [ - "var a = new MyClass[] { new MyClass{Prop1=\"blabla\", Prop2=\"blublu\"}, new MyClass{Prop1=\"bloblo\", Prop2=\"blublu\"}, new MyClass{Prop1=\"blibli\", Prop2=\"blublu\"}, new MyClass{Prop1=\"blibli\", Prop2=\"blublu\"} };" - ] - }, - { - "cell_type": "code", - "source": [ - "Stopwatch sw = new Stopwatch();", - "\nsw.Start();", - "\nvar r = new List();", - "\nfor(int i = 0; i < 10000000; i++) {", - "\n for(int j = 0; j < a.Length; j++) {", - "\n r.Add((string)typeof(MyClass).GetIdentityProperties().First().GetValue(a[j]));", - "\n }", - "\n}", - "\nsw.Stop();", - "\nsw.Elapsed" - ] - }, - { - "cell_type": "code", - "source": [ - "Stopwatch sw = new Stopwatch();", - "\nsw.Start();", - "\nvar r = new List();", - "\nfor(int i = 0; i < 10000000; i++) {", - "\n for(int j = 0; j < a.Length; j++) {", - "\n r.Add(a[j].Prop1);", - "\n }", - "\n}", - "\nsw.Stop();", - "\nsw.Elapsed" + "#!import \"../DataModel/DataStructure\"" ] }, { From 3cb6ee89a2115fb19992fb3524e4c70c97ab9d1b Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Mon, 7 Nov 2022 16:59:36 +0100 Subject: [PATCH 19/23] cleanups x2 --- ifrs17/Utils/Queries.ipynb | 60 +------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 0e080704..d3d331a9 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -155,7 +155,7 @@ "\n foreach (var dn in dataNodes.Where(x => x.ValuationApproach == ValuationApproaches.BBA))", "\n {", "\n var argsNew = args with {Year = dn.Year, Month = dn.Month, Scenario = dn.Scenario};", - "\n var loadedYc = (await querySource.LoadCurrentParameterAsync(argsNew, (x => x.Currency), x => x.Currency == dn.ContractualCurrency));", + "\n var loadedYc = (await querySource.LoadCurrentParameterAsync(argsNew, x => x.Currency, x => x.Currency == dn.ContractualCurrency));", "\n ", "\n if(!loadedYc.TryGetValue(dn.ContractualCurrency, out var lockedYc))", "\n ApplicationMessage.Log(Error.YieldCurveNotFound, dn.ContractualCurrency, argsNew.Year.ToString(), argsNew.Month.ToString());", @@ -319,64 +319,6 @@ "\n => (await querySource.LoadAocStepConfigurationAsync(year, month))", "\n .ToDictionary(x => new AocStep(x.AocType, x.Novelty)); " ] - }, - { - "cell_type": "markdown", - "source": [ - "# Actuarial Variables (Raw and IFRS)" - ] - }, - { - "cell_type": "code", - "source": [ - "/*public static async Task LoadOpeningVariables(", - "\n this IDataSource querySource, ", - "\n Args args,", - "\n HashSet dataNodesInScopes,", - "\n Guid targetPartition,", - "\n string aocType)", - "\n where T : BaseDataRecord", - "\n => (await querySource.Query().Where(rv => rv.Partition == PreviousPeriodPartition && rv.AocType == aocType)", - "\n .Where(rv => dataNodesInScopes.Contains(rv.DataNode)).ToArrayAsync());", - "\n*/" - ] - }, - { - "cell_type": "markdown", - "source": [ - "# Partitions" - ] - }, - { - "cell_type": "code", - "source": [ - "public static async Task LoadPartitionAsync(", - "\n this IDataSource querySource, ", - "\n string reportingNode, ", - "\n int year, ", - "\n int month, ", - "\n string scenario) => (await querySource.Query()", - "\n .Where(p => p.ReportingNode == reportingNode &&", - "\n p.Year == year &&", - "\n p.Month == month &&", - "\n p.Scenario == scenario).ToArrayAsync()).Single().Id;", - "\n" - ] - }, - { - "cell_type": "code", - "source": [ - "public static async Task<(Guid, Guid, Guid)> LoadPartitionsYTDAsync(", - "\n this IDataSource querySource, ", - "\n Args args)", - "\n{", - "\n var targetPartition = await querySource.LoadPartitionAsync(args.ReportingNode, args.Year, args.Month, args.Scenario);", - "\n var defaultPartition = await querySource.LoadPartitionAsync(args.ReportingNode, args.Year, args.Month, null);", - "\n var previousPartition = await querySource.LoadPartitionAsync(args.ReportingNode, args.Year - 1, MonthInAYear, null); // YTD Logic", - "\n", - "\n return (targetPartition, defaultPartition, previousPartition);", - "\n}" - ] } ] } \ No newline at end of file From bf0c9c78c8421cac63e5569b13ba014947a2b7c3 Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Tue, 8 Nov 2022 16:44:11 +0100 Subject: [PATCH 20/23] fixes needed after merge --- .../Actuals_CH_2020_12_MTUP10pct.csv | 12 ++ .../NominalCashflows_CH_2020_12_MTUP10pct.csv | 13 ++ .../InitSystemorphToMemory.ipynb | 12 ++ .../BM_CH_2020_12_MTUP10pct.csv | 181 ------------------ .../Test/ExportIfrsVariable.ipynb | 49 ++++- full-ifrs17-template/Test/ScenarioTest.ipynb | 70 +++---- full-ifrs17-template/Test/Tests.ipynb | 12 ++ ifrs17/DataModel/DataStructure.ipynb | 3 +- ifrs17/Import/Importers.ipynb | 16 -- 9 files changed, 119 insertions(+), 249 deletions(-) create mode 100644 full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv create mode 100644 full-ifrs17-template/Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv delete mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv diff --git a/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv b/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv new file mode 100644 index 00000000..f0453d45 --- /dev/null +++ b/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv @@ -0,0 +1,12 @@ +@@Main,,,, +ReportingNode,Year,Month,Scenario , +CH,2020,12,MTUP10pct, +@@Actual,,,, +DataNode,AocType,ValueType,AccidentYear,Value +DT1.1,CF,NIC,,-310 +DT1.2,CF,NIC,2020,-310 +DT2.1,CF,NIC,,-310 +DT1.3,CF,NIC,,-310 +DT2.2,CF,NIC,2020,-310 +DTR1.1,CF,NIC,,170 +DTR1.2,CF,NIC,2020,170 diff --git a/full-ifrs17-template/Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv b/full-ifrs17-template/Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv new file mode 100644 index 00000000..3e08a787 --- /dev/null +++ b/full-ifrs17-template/Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv @@ -0,0 +1,13 @@ +@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,,,,,,,,,,,,, +CH,2020,12,MTUP10pct,,,,,,,,,,,,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,,, +DataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23 +DT1.1,NIC,BOP,N,,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5 +DT1.1,NIC,CL,C,,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5 +DT1.2,NIC,BOP,N,2020,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5 +DT1.2,NIC,CL,C,2020,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5 +DTR1.1,NIC,BOP,N,,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75 +DTR1.1,NIC,CL,C,,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75 +DTR1.2,NIC,BOP,N,2020,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75 +DTR1.2,NIC,CL,C,2020,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75,13.75 diff --git a/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb index a96f6a66..37489f3f 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb @@ -85,6 +85,18 @@ "await Import.FromFile(\"../Files/TransactionalData/SimpleValue_CH_2020_12.csv\").WithFormat(ImportFormats.SimpleValue ).WithTarget(DataSource).ExecuteAsync()" ] }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" + ] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" + ] + }, { "cell_type": "markdown", "source": [ diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv deleted file mode 100644 index 64bf4ea9..00000000 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct.csv +++ /dev/null @@ -1,181 +0,0 @@ -@@Main,,,,,,, -Month,ReportingNode,Scenario,Year,,,, -12,CH,MTUP10pct,2020,,,, -@@BE,,,,,,, -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,PR,BOP,DT1.1,C,BE,N,878.3904043 -,NIC,BOP,DT1.1,L,BE,N,-658.6282391 -,PR,BOP,DT1.1,L,BE,N,878.3904043 -,NIC,BOP,DT1.1,C,BE,N,-658.6282391 -,PR,EOP,DT1.1,L,BE,C,439.5973224 -,NIC,EOP,DT1.1,L,BE,C,-329.6431047 -,PR,EOP,DT1.1,C,BE,C,439.5973224 -,NIC,EOP,DT1.1,C,BE,C,-329.6431047 -,PR,IA,DT1.1,L,BE,N,1.206918171 -,NIC,IA,DT1.1,L,BE,N,-1.014865605 -,PR,IA,DT1.1,C,BE,N,1.206918171 -,NIC,IA,DT1.1,C,BE,N,-1.014865605 -,PR,CF,DT1.1,L,BE,N,-440 -,NIC,CF,DT1.1,L,BE,N,330 -,PR,CF,DT1.1,C,BE,N,-440 -,NIC,CF,DT1.1,C,BE,N,330 -2020,NIC,BOP,DT1.2,L,BE,N,-658.6282391 -2020,NIC,BOP,DT1.2,C,BE,N,-658.6282391 -2020,NIC,EOP,DT1.2,L,BE,C,-329.6431047 -2020,NIC,EOP,DT1.2,C,BE,C,-329.6431047 -2020,NIC,IA,DT1.2,L,BE,N,-1.014865605 -2020,NIC,IA,DT1.2,C,BE,N,-1.014865605 -2020,NIC,CF,DT1.2,L,BE,N,330 -2020,NIC,CF,DT1.2,C,BE,N,330 -,PR,BOP,DT1.3,L,BE,N,878.3904043 -,NIC,BOP,DT1.3,L,BE,N,-658.6282391 -,PR,BOP,DT1.3,C,BE,N,878.3904043 -,NIC,BOP,DT1.3,C,BE,N,-658.6282391 -,PR,EOP,DT1.3,L,BE,C,439.5973224 -,NIC,EOP,DT1.3,L,BE,C,-329.6431047 -,PR,EOP,DT1.3,C,BE,C,439.5973224 -,NIC,EOP,DT1.3,C,BE,C,-329.6431047 -,PR,IA,DT1.3,L,BE,N,1.206918171 -,NIC,IA,DT1.3,L,BE,N,-1.014865605 -,PR,IA,DT1.3,C,BE,N,1.206918171 -,NIC,IA,DT1.3,C,BE,N,-1.014865605 -,PR,CF,DT1.3,L,BE,N,-440 -,NIC,CF,DT1.3,L,BE,N,330 -,PR,CF,DT1.3,C,BE,N,-440 -,NIC,CF,DT1.3,C,BE,N,330 -,PR,BOP,DT2.1,L,BE,N,878.3904043 -,NIC,BOP,DT2.1,L,BE,N,-658.6282391 -,PR,BOP,DT2.1,C,BE,N,878.3904043 -,NIC,BOP,DT2.1,C,BE,N,-658.6282391 -,PR,EOP,DT2.1,L,BE,C,439.5973224 -,NIC,EOP,DT2.1,L,BE,C,-329.6431047 -,PR,EOP,DT2.1,C,BE,C,439.5973224 -,NIC,EOP,DT2.1,C,BE,C,-329.6431047 -,PR,IA,DT2.1,L,BE,N,1.206918171 -,NIC,IA,DT2.1,L,BE,N,-1.014865605 -,PR,IA,DT2.1,C,BE,N,1.206918171 -,NIC,IA,DT2.1,C,BE,N,-1.014865605 -,PR,CF,DT2.1,L,BE,N,-440 -,NIC,CF,DT2.1,L,BE,N,330 -,PR,CF,DT2.1,C,BE,N,-440 -,NIC,CF,DT2.1,C,BE,N,330 -2020,NIC,BOP,DT2.2,L,BE,N,-658.6282391 -2020,NIC,BOP,DT2.2,C,BE,N,-658.6282391 -2020,NIC,EOP,DT2.2,L,BE,C,-329.6431047 -2020,NIC,EOP,DT2.2,C,BE,C,-329.6431047 -2020,NIC,IA,DT2.2,L,BE,N,-1.014865605 -2020,NIC,IA,DT2.2,C,BE,N,-1.014865605 -2020,NIC,CF,DT2.2,L,BE,N,330 -2020,NIC,CF,DT2.2,C,BE,N,330 -,PR,BOP,DTR1.1,L,BE,N,-439.1952021 -,NIC,BOP,DTR1.1,L,BE,N,329.3141195 -,CDR,BOP,DTR1.1,L,BE,N,-0.52924753 -,PR,BOP,DTR1.1,C,BE,N,-439.1952021 -,NIC,BOP,DTR1.1,C,BE,N,329.3141195 -,CDR,BOP,DTR1.1,C,BE,N,-0.52924753 -,PR,EOP,DTR1.1,L,BE,C,-219.7986612 -,NIC,EOP,DTR1.1,L,BE,C,164.8215523 -,CDR,EOP,DTR1.1,L,BE,C,-0.126798764 -,PR,EOP,DTR1.1,C,BE,C,-219.7986612 -,NIC,EOP,DTR1.1,C,BE,C,164.8215523 -,CDR,EOP,DTR1.1,C,BE,C,-0.126798764 -,PR,IA,DTR1.1,L,BE,N,-0.603459086 -,NIC,IA,DTR1.1,L,BE,N,0.507432803 -,CDR,IA,DTR1.1,L,BE,N,-0.00128721 -,PR,IA,DTR1.1,C,BE,N,-0.603459086 -,NIC,IA,DTR1.1,C,BE,N,0.507432803 -,CDR,IA,DTR1.1,C,BE,N,-0.00128721 -,PR,CF,DTR1.1,L,BE,N,220 -,NIC,CF,DTR1.1,L,BE,N,-165 -,CDR,CF,DTR1.1,L,BE,N,0.403735976 -,PR,CF,DTR1.1,C,BE,N,220 -,NIC,CF,DTR1.1,C,BE,N,-165 -,CDR,CF,DTR1.1,C,BE,N,0.403735976 -2020,NIC,BOP,DTR1.2,L,BE,N,329.3141195 -2020,CDR,BOP,DTR1.2,L,BE,N,-0.52924753 -2020,NIC,BOP,DTR1.2,C,BE,N,329.3141195 -2020,CDR,BOP,DTR1.2,C,BE,N,-0.52924753 -2020,NIC,EOP,DTR1.2,L,BE,C,164.8215523 -2020,CDR,EOP,DTR1.2,L,BE,C,-0.126798764 -2020,NIC,EOP,DTR1.2,C,BE,C,164.8215523 -2020,CDR,EOP,DTR1.2,C,BE,C,-0.126798764 -2020,NIC,IA,DTR1.2,L,BE,N,0.507432803 -2020,CDR,IA,DTR1.2,L,BE,N,-0.00128721 -2020,NIC,IA,DTR1.2,C,BE,N,0.507432803 -2020,CDR,IA,DTR1.2,C,BE,N,-0.00128721 -2020,NIC,CF,DTR1.2,L,BE,N,-165 -2020,CDR,CF,DTR1.2,L,BE,N,0.403735976 -2020,NIC,CF,DTR1.2,C,BE,N,-165 -2020,CDR,CF,DTR1.2,C,BE,N,0.403735976 -,PR,BOP,DTR2.1,L,BE,N,-439.1952021 -,NIC,BOP,DTR2.1,L,BE,N,329.3141195 -,CDR,BOP,DTR2.1,L,BE,N,-0.52924753 -,PR,BOP,DTR2.1,C,BE,N,-439.1952021 -,NIC,BOP,DTR2.1,C,BE,N,329.3141195 -,CDR,BOP,DTR2.1,C,BE,N,-0.52924753 -,PR,EOP,DTR2.1,L,BE,C,-219.7986612 -,NIC,EOP,DTR2.1,L,BE,C,164.8215523 -,CDR,EOP,DTR2.1,L,BE,C,-0.126798764 -,PR,EOP,DTR2.1,C,BE,C,-219.7986612 -,NIC,EOP,DTR2.1,C,BE,C,164.8215523 -,CDR,EOP,DTR2.1,C,BE,C,-0.126798764 -,PR,IA,DTR2.1,L,BE,N,-0.603459086 -,NIC,IA,DTR2.1,L,BE,N,0.507432803 -,CDR,IA,DTR2.1,L,BE,N,-0.00128721 -,PR,IA,DTR2.1,C,BE,N,-0.603459086 -,NIC,IA,DTR2.1,C,BE,N,0.507432803 -,CDR,IA,DTR2.1,C,BE,N,-0.00128721 -,PR,CF,DTR2.1,L,BE,N,220 -,NIC,CF,DTR2.1,L,BE,N,-165 -,CDR,CF,DTR2.1,L,BE,N,0.403735976 -,PR,CF,DTR2.1,C,BE,N,220 -,NIC,CF,DTR2.1,C,BE,N,-165 -,CDR,CF,DTR2.1,C,BE,N,0.403735976 -2020,NIC,BOP,DTR2.2,L,BE,N,329.3141195 -2020,CDR,BOP,DTR2.2,L,BE,N,-0.52924753 -2020,NIC,BOP,DTR2.2,C,BE,N,329.3141195 -2020,CDR,BOP,DTR2.2,C,BE,N,-0.52924753 -2020,NIC,EOP,DTR2.2,L,BE,C,164.8215523 -2020,CDR,EOP,DTR2.2,L,BE,C,-0.126798764 -2020,NIC,EOP,DTR2.2,C,BE,C,164.8215523 -2020,CDR,EOP,DTR2.2,C,BE,C,-0.126798764 -2020,NIC,IA,DTR2.2,L,BE,N,0.507432803 -2020,CDR,IA,DTR2.2,L,BE,N,-0.00128721 -2020,NIC,IA,DTR2.2,C,BE,N,0.507432803 -2020,CDR,IA,DTR2.2,C,BE,N,-0.00128721 -2020,NIC,CF,DTR2.2,L,BE,N,-165 -2020,CDR,CF,DTR2.2,L,BE,N,0.403735976 -2020,NIC,CF,DTR2.2,C,BE,N,-165 -2020,CDR,CF,DTR2.2,C,BE,N,0.403735976 -,PR,BOP,DT3.1,L,BE,N,878.3904043 -,NIC,BOP,DT3.1,L,BE,N,-658.6282391 -,PR,BOP,DT3.1,C,BE,N,878.3904043 -,NIC,BOP,DT3.1,C,BE,N,-658.6282391 -,PR,EOP,DT3.1,L,BE,C,439.5973224 -,NIC,EOP,DT3.1,L,BE,C,-329.6431047 -,PR,EOP,DT3.1,C,BE,C,439.5973224 -,NIC,EOP,DT3.1,C,BE,C,-329.6431047 -,PR,IA,DT3.1,L,BE,N,1.206918171 -,NIC,IA,DT3.1,L,BE,N,-1.014865605 -,PR,IA,DT3.1,C,BE,N,1.206918171 -,NIC,IA,DT3.1,C,BE,N,-1.014865605 -,PR,CF,DT3.1,L,BE,N,-440 -,NIC,CF,DT3.1,L,BE,N,330 -,PR,CF,DT3.1,C,BE,N,-440 -,NIC,CF,DT3.1,C,BE,N,330 -,PR,BOP,DT4.1,L,BE,N,878.3904043 -,NIC,BOP,DT4.1,L,BE,N,-658.6282391 -,PR,BOP,DT4.1,C,BE,N,878.3904043 -,NIC,BOP,DT4.1,C,BE,N,-658.6282391 -,PR,EOP,DT4.1,L,BE,C,439.5973224 -,NIC,EOP,DT4.1,L,BE,C,-329.6431047 -,PR,EOP,DT4.1,C,BE,C,439.5973224 -,NIC,EOP,DT4.1,C,BE,C,-329.6431047 -,PR,IA,DT4.1,L,BE,N,1.206918171 -,NIC,IA,DT4.1,L,BE,N,-1.014865605 -,PR,IA,DT4.1,C,BE,N,1.206918171 -,NIC,IA,DT4.1,C,BE,N,-1.014865605 -,PR,CF,DT4.1,L,BE,N,-440 -,NIC,CF,DT4.1,L,BE,N,330 -,PR,CF,DT4.1,C,BE,N,-440 -,NIC,CF,DT4.1,C,BE,N,330 diff --git a/full-ifrs17-template/Test/ExportIfrsVariable.ipynb b/full-ifrs17-template/Test/ExportIfrsVariable.ipynb index 9d21556c..25f352ba 100644 --- a/full-ifrs17-template/Test/ExportIfrsVariable.ipynb +++ b/full-ifrs17-template/Test/ExportIfrsVariable.ipynb @@ -60,7 +60,8 @@ "\n", "\n foreach (var estimateType in computedVariables.Keys)", "\n {", - "\n await Export.ToCsv(pathToBm+\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", + "\n //await Export.ToCsv(pathToBm+\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", + "\n await Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", "\n .WithTable(tableConfig => tableConfig", "\n .AtBeginning()", "\n .WithName(Main)", @@ -74,6 +75,7 @@ "\n .WithColumn(x => x.Partition, x => x.Delete())", "\n .WithColumn(x => x.Id, x => x.Delete())", "\n )", + "\n .WithSource(DataSource)", "\n .ExecuteAsync();", "\n }", "\n}" @@ -82,10 +84,53 @@ { "cell_type": "code", "source": [ - "foreach (var args in argsArray)", + "// TODO: This doesn't seem to work", + "\nforeach (var args in argsArray)", "\n await ExportBenchmarks(args);" ] }, + { + "cell_type": "code", + "source": [ + "var scenario = \"MTUP10pct\";" + ] + }, + { + "cell_type": "code", + "source": [ + "var args = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, scenario, null);", + "\nawait DataSource.Partition.SetAsync(new {ReportingNode = args.ReportingNode, Year= args.Year, Month = args.Month, Scenario = args.Scenario});", + "\nvar computedVariables = (await DataSource.Query().ToArrayAsync()).ToDictionaryGrouped(x => x.EstimateType, x => x.ToArray());" + ] + }, + { + "cell_type": "code", + "source": [ + "(0, computedVariables.Keys, \"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType )" + ] + }, + { + "cell_type": "code", + "source": [ + "var estimateType = \"BEPA\";", + "\nawait Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", + "\n .WithTable(tableConfig => tableConfig", + "\n .AtBeginning()", + "\n .WithName(Main)", + "\n .WithSource(source => args.RepeatOnce().AsQueryable())", + "\n .WithColumn(x => x.Periodicity, x => x.Delete())", + "\n .WithColumn(x => x.ImportFormat, x => x.Delete())", + "\n )", + "\n .WithTable(tableConfig => tableConfig", + "\n .WithSource(source => computedVariables[estimateType].AsQueryable())", + "\n .WithName(estimateType)", + "\n .WithColumn(x => x.Partition, x => x.Delete())", + "\n .WithColumn(x => x.Id, x => x.Delete())", + "\n )", + "\n .WithSource(DataSource)", + "\n .ExecuteAsync()" + ] + }, { "cell_type": "code", "source": [ diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index 45281af0..defadcba 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -30,7 +30,7 @@ { "cell_type": "code", "source": [ - "var log = await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", + "var log = await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", "\nlog" @@ -39,7 +39,7 @@ { "cell_type": "code", "source": [ - "var log = await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", + "var log = await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", "\nlog" @@ -63,13 +63,13 @@ "var cashflows_MTUP10pct = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", - "\nCH,2020,12,MTUP10pct", + "\nCH,2020,12,Test", "\n@@Cashflow", "\nDataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", - "\nDT1.1,PR,CL,C,,-110,0,0,-110,0,0,-110,0,0,-110,0,0,0,-110,0,0,-110,0,0,-110,0,0,-110,0", - "\nDT1.1,NIC,CL,C,,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5,27.5", - "\nDT1.1,CU,CL,C,,11,11,11,11,11,11,11,11,11,11,11,11,11,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,3.3", - "\nDT1.1,RA,CL,C,,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75\";" + "\nDT1.1,PR,CL,C,,110,0,0,110,0,0,110,0,0,110,0,0,0,110,0,0,110,0,0,110,0,0,110,0", + "\nDT1.1,NIC,CL,C,,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5,-27.5", + "\nDT1.1,CU,CL,C,,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-5.5,-5.5,-5.5,-5.5,-5.5,-5.5,-5.5,-5.5,-5.5,-5.5,-3.3", + "\nDT1.1,RA,CL,C,,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75,-2.75\";" ] }, { @@ -78,13 +78,13 @@ "var cashflows_MTUP10pct_BE = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", - "\nCH,2020,12,MTUP10pct", + "\nCH,2020,12,Test", "\n@@Cashflow", "\nDataNode,AmountType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", - "\nDT1.1,PR,CL,C,,-100,0,0,-100,0,0,-100,0,0,-100,0,0,0,-100,0,0,-100,0,0,-100,0,0,-100,0", - "\nDT1.1,NIC,CL,C,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25", - "\nDT1.1,CU,CL,C,,10,10,10,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,5,5,5,5,5,3", - "\nDT1.1,RA,CL,C,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5\";" + "\nDT1.1,PR,CL,C,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0", + "\nDT1.1,NIC,CL,C,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25", + "\nDT1.1,CU,CL,C,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3", + "\nDT1.1,RA,CL,C,,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5\";" ] }, { @@ -99,34 +99,8 @@ { "cell_type": "code", "source": [ - "class IfrsVariableComparer: IEqualityComparer", - "\n{", - "\n private bool IgnoreValue;", - "\n private IfrsVariableComparer(bool ignoreValue)", - "\n {", - "\n IgnoreValue = ignoreValue;", - "\n }", - "\n", - "\n public bool Equals(IfrsVariable x, IfrsVariable y) =>", - "\n x.AccidentYear == y.AccidentYear && x.AmountType == y.AmountType && x.DataNode == y.DataNode && x.AocType == y.AocType && ", - "\n x.Novelty == y.Novelty && x.EstimateType == y.EstimateType && (IgnoreValue ? true : Math.Abs(x.Value - y.Value) < Precision); ", - "\n", - "\n public int GetHashCode(IfrsVariable v) => IgnoreValue ", - "\n ? HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty) ", - "\n : HashCode.Combine(v.AccidentYear, v.AmountType, v.DataNode, v.AocType, v.Novelty, v.Value.ToString(\"F5\"));", - "\n", - "\n public static IfrsVariableComparer Instance(bool ignoreValue = false)", - "\n { ", - "\n return new IfrsVariableComparer(ignoreValue);", - "\n }", - "\n}" - ] - }, - { - "cell_type": "code", - "source": [ - "await Workspace.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", - "\nawait DataSource.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", + "await Workspace.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"Test\", Year = 2020, Month = 12});", + "\nawait DataSource.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"Test\", Year = 2020, Month = 12});", "\nvar diffs = Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance());", "\ndiffs.Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().Be(0);", "\ndiffs.Where(x => !(new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().NotBe(0);" @@ -167,11 +141,11 @@ "source": [ "var actuals_MTUP10pct = @\"", "\n@@Main", - "\nReportingNode,Year,Month,Scenario,", - "\nCH,2020,12,MTUP10pct,", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,Test", "\n@@Actual", "\nDataNode,AocType,ValueType,AccidentYear,Value", - "\nDT1.1,CF,NIC,,308\";" + "\nDT1.1,CF,NIC,,-308\";" ] }, { @@ -179,11 +153,11 @@ "source": [ "var actuals_MTUP10pct_BE = @\"", "\n@@Main", - "\nReportingNode,Year,Month,Scenario,", - "\nCH,2020,12,MTUP10pct,", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,Test", "\n@@Actual", "\nDataNode,AocType,ValueType,AccidentYear,Value", - "\nDT1.1,CF,NIC,,280\";" + "\nDT1.1,CF,NIC,,-280\";" ] }, { @@ -198,8 +172,8 @@ { "cell_type": "code", "source": [ - "await Workspace.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", - "\nawait DataSource.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"MTUP10pct\", Year = 2020, Month = 12});", + "await Workspace.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"Test\", Year = 2020, Month = 12});", + "\nawait DataSource.Partition.SetAsync(new{ReportingNode = \"CH\", Scenario = \"Test\", Year = 2020, Month = 12});", "\nvar diffs = Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance());", "\ndiffs.Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().NotBe(0);", "\ndiffs.Where(x => x.EstimateType == \"CU\").ToArray().Length.Should().Be(0);" diff --git a/full-ifrs17-template/Test/Tests.ipynb b/full-ifrs17-template/Test/Tests.ipynb index 06b5b7d7..2b7fefcb 100644 --- a/full-ifrs17-template/Test/Tests.ipynb +++ b/full-ifrs17-template/Test/Tests.ipynb @@ -53,6 +53,18 @@ "#!eval-notebook \"TechnicalMarginTest\"" ] }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"SequenceImportTest\"" + ] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"ScenarioTest\"" + ] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index e7c17ad9..0755159b 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -56,8 +56,7 @@ "\n#r \"nuget:Systemorph.DataSetReader,1.5.1\"", "\n#r \"nuget:Systemorph.DataSource,1.5.3\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.5.3\"", - "\n#r \"nuget:Systemorph.Reporting,1.5.5\"", - "\n#r \"nuget:Systemorph.DomainDesigner,1.5.1\"" + "\n#r \"nuget:Systemorph.Reporting,1.5.5\"" ] }, { diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index f36cf6fb..d115059d 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -331,18 +331,6 @@ "\nThe new Aoc Configurations are created with the same order of the Aoc Types. " ] }, - { - "cell_type": "code", - "source": [ - "" - ] - }, - { - "cell_type": "code", - "source": [ - "" - ] - }, { "cell_type": "code", "source": [ @@ -922,10 +910,6 @@ "\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 if (await CompareCalculatedToDBAsync(args, ivs)){", - "\n ApplicationMessage.Log(Warning.VariablesAlreadyCalculated, \"\");", - "\n return Activity.Finish().Merge(parsingLog);", - "\n }", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n await Workspace.UpdateAsync(ivs);", From fd7cfbfef7e66709921e1dad746a80fed0a55d11 Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Tue, 8 Nov 2022 17:38:03 +0100 Subject: [PATCH 21/23] all tests are green --- .../Actuals_CH_2020_12_MTUP10pct.csv | 2 +- .../BM_CH_2020_12_MTUP10pct_A.csv | 12 ++++ .../BM_CH_2020_12_MTUP10pct_BE.csv | 69 +++++++++++++++++++ .../BM_CH_2020_12_MTUP10pct_BEPA.csv | 6 ++ .../BM_CH_2020_12_MTUP10pct_C.csv | 22 ++++++ .../BM_CH_2020_12_MTUP10pct_F.csv | 9 +++ .../BM_CH_2020_12_MTUP10pct_L.csv | 14 ++++ .../BM_CH_2020_12_MTUP10pct_RA.csv | 37 ++++++++++ .../Test/ExportIfrsVariable.ipynb | 6 +- .../Test/IfrsVariablesTest.ipynb | 21 +++--- ifrs17/Import/ImportStorage.ipynb | 27 +++----- 11 files changed, 197 insertions(+), 28 deletions(-) create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv create mode 100644 full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv diff --git a/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv b/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv index f0453d45..eb8fb4c5 100644 --- a/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv +++ b/full-ifrs17-template/Files/TransactionalData/Actuals_CH_2020_12_MTUP10pct.csv @@ -1,5 +1,5 @@ @@Main,,,, -ReportingNode,Year,Month,Scenario , +ReportingNode,Year,Month,Scenario, CH,2020,12,MTUP10pct, @@Actual,,,, DataNode,AocType,ValueType,AccidentYear,Value diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv new file mode 100644 index 00000000..8d10f69c --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv @@ -0,0 +1,12 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@A +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,NIC,CF,DT2.1,,A,C,-310 +2020,NIC,CF,DT1.2,,A,C,-310 +,NIC,CF,DT1.1,,A,C,-310 +,NIC,CF,DT1.3,,A,C,-310 +2020,NIC,CF,DT2.2,,A,C,-310 +,NIC,CF,DTR1.1,,A,C,170 +2020,NIC,CF,DTR1.2,,A,C,170 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv new file mode 100644 index 00000000..9d548fcb --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv @@ -0,0 +1,69 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@BE +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,NIC,BOP,DT1.1,L,BE,N,658.6282390585294 +,PR,BOP,DT1.1,L,BE,N,-798.536731161375 +,NIC,BOP,DT1.1,C,BE,N,658.6282390585294 +,PR,BOP,DT1.1,C,BE,N,-798.536731161375 +,NIC,EOP,DT1.1,L,BE,C,329.6431046636596 +,PR,EOP,DT1.1,L,BE,C,-399.63392949885525 +,NIC,EOP,DT1.1,C,BE,C,329.6431046636596 +,PR,EOP,DT1.1,C,BE,C,-399.63392949885525 +,NIC,IA,DT1.1,L,BE,N,1.0148656051304286 +,PR,IA,DT1.1,L,BE,N,-1.0971983374806105 +,NIC,IA,DT1.1,C,BE,N,1.0148656051304286 +,PR,IA,DT1.1,C,BE,N,-1.0971983374806105 +,NIC,CF,DT1.1,L,BE,N,-330 +,PR,CF,DT1.1,L,BE,N,400 +,NIC,CF,DT1.1,C,BE,N,-330 +,PR,CF,DT1.1,C,BE,N,400 +2020,NIC,BOP,DT1.2,L,BE,N,658.6282390585294 +2020,NIC,BOP,DT1.2,C,BE,N,658.6282390585294 +2020,NIC,EOP,DT1.2,L,BE,C,329.6431046636596 +2020,NIC,EOP,DT1.2,C,BE,C,329.6431046636596 +2020,NIC,IA,DT1.2,L,BE,N,1.0148656051304286 +2020,NIC,IA,DT1.2,C,BE,N,1.0148656051304286 +2020,NIC,CF,DT1.2,L,BE,N,-330 +2020,NIC,CF,DT1.2,C,BE,N,-330 +,NIC,BOP,DTR1.1,L,BE,N,-329.3141195292647 +,PR,BOP,DTR1.1,L,BE,N,399.2683655806875 +,CDR,BOP,DTR1.1,L,BE,N,0.5292475300191577 +,NIC,BOP,DTR1.1,C,BE,N,-329.3141195292647 +,PR,BOP,DTR1.1,C,BE,N,399.2683655806875 +,CDR,BOP,DTR1.1,C,BE,N,0.5292475300191577 +,NIC,EOP,DTR1.1,L,BE,C,-164.8215523318298 +,PR,EOP,DTR1.1,L,BE,C,199.81696474942763 +,CDR,EOP,DTR1.1,L,BE,C,0.12679876434718015 +,NIC,EOP,DTR1.1,C,BE,C,-164.8215523318298 +,PR,EOP,DTR1.1,C,BE,C,199.81696474942763 +,CDR,EOP,DTR1.1,C,BE,C,0.12679876434718015 +,NIC,IA,DTR1.1,L,BE,N,-0.5074328025652143 +,PR,IA,DTR1.1,L,BE,N,0.5485991687403052 +,CDR,IA,DTR1.1,L,BE,N,0.001287210150087148 +,NIC,IA,DTR1.1,C,BE,N,-0.5074328025652143 +,PR,IA,DTR1.1,C,BE,N,0.5485991687403052 +,CDR,IA,DTR1.1,C,BE,N,0.001287210150087148 +,NIC,CF,DTR1.1,L,BE,N,165 +,PR,CF,DTR1.1,L,BE,N,-200 +,CDR,CF,DTR1.1,L,BE,N,-0.40373597582193455 +,NIC,CF,DTR1.1,C,BE,N,165 +,PR,CF,DTR1.1,C,BE,N,-200 +,CDR,CF,DTR1.1,C,BE,N,-0.40373597582193455 +2020,NIC,BOP,DTR1.2,L,BE,N,-329.3141195292647 +2020,CDR,BOP,DTR1.2,L,BE,N,0.5292475300191577 +2020,NIC,BOP,DTR1.2,C,BE,N,-329.3141195292647 +2020,CDR,BOP,DTR1.2,C,BE,N,0.5292475300191577 +2020,NIC,EOP,DTR1.2,L,BE,C,-164.8215523318298 +2020,CDR,EOP,DTR1.2,L,BE,C,0.12679876434718015 +2020,NIC,EOP,DTR1.2,C,BE,C,-164.8215523318298 +2020,CDR,EOP,DTR1.2,C,BE,C,0.12679876434718015 +2020,NIC,IA,DTR1.2,L,BE,N,-0.5074328025652143 +2020,CDR,IA,DTR1.2,L,BE,N,0.001287210150087148 +2020,NIC,IA,DTR1.2,C,BE,N,-0.5074328025652143 +2020,CDR,IA,DTR1.2,C,BE,N,0.001287210150087148 +2020,NIC,CF,DTR1.2,L,BE,N,165 +2020,CDR,CF,DTR1.2,L,BE,N,-0.40373597582193455 +2020,NIC,CF,DTR1.2,C,BE,N,165 +2020,CDR,CF,DTR1.2,C,BE,N,-0.40373597582193455 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv new file mode 100644 index 00000000..4674e6db --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv @@ -0,0 +1,6 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@BEPA +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,PR,CF,DT1.1,L,BEPA,N,320 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv new file mode 100644 index 00000000..d18a01c9 --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv @@ -0,0 +1,22 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@C +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,,EA,DT2.1,,C,C,-199.95837980461957 +,,EA,DT1.1,,C,C,-139.99082483519575 +,,BOP,DT1.1,,C,N,139.90849210284557 +,,IA,DT1.1,,C,N,0.0823327323501819 +,,BOP,DT2.1,,C,N,199.78378656271207 +,,IA,DT2.1,,C,N,0.1745932419074938 +,,EA,DT1.3,,C,C,-199.95837980461957 +,,BOP,DT1.3,,C,N,199.78378656271207 +,,IA,DT1.3,,C,N,0.1745932419074938 +,,AM,DTR1.1,,C,C,46.281232281883625 +,,EOP,DTR1.1,,C,C,-24.244714875883496 +,,BOP,DTR1.1,,C,N,-70.48349358144195 +,,IA,DTR1.1,,C,N,-0.0424535763251781 +,,AM,DTR2.1,,C,C,65.92583207126779 +,,EOP,DTR2.1,,C,C,-34.53566214028672 +,,BOP,DTR2.1,,C,N,-100.37302739955527 +,,IA,DTR2.1,,C,N,-0.08846681199924467 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv new file mode 100644 index 00000000..a3a224c1 --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv @@ -0,0 +1,9 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@F +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,,AM,DT1.1,L,F,C,0.6562298579039588 +,,AM,DT1.2,L,F,C,1 +,,AM,DTR1.1,L,F,C,0.6562298579039588 +,,AM,DTR1.2,L,F,C,1 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv new file mode 100644 index 00000000..d68249f2 --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv @@ -0,0 +1,14 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@L +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,,AM,DT2.1,,L,C,-78.77489536337549 +,,EA,DT2.1,,L,C,120.04162019538043 +,,EA,DT1.1,,L,C,180.00917516480425 +,,AM,DT1.1,,L,C,-118.12739543980832 +,,EOP,DT1.1,,L,C,61.88177972499592 +,,EOP,DT2.1,,L,C,41.26672483200494 +,,EA,DT1.3,,L,C,200.04162019538043 +,,AM,DT1.3,,L,C,-131.2732839956922 +,,EOP,DT1.3,,L,C,68.76833619968824 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv new file mode 100644 index 00000000..fdff21b6 --- /dev/null +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv @@ -0,0 +1,37 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@RA +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value +,,BOP,DT1.1,C,RA,N,59.8752944598663 +,,BOP,DT1.1,L,RA,N,59.8752944598663 +,,EOP,DT1.1,C,RA,C,29.967554969423595 +,,EOP,DT1.1,L,RA,C,29.967554969423595 +,,IA,DT1.1,C,RA,N,0.09226050955731169 +,,IA,DT1.1,L,RA,N,0.09226050955731169 +,,CF,DT1.1,C,RA,N,-30 +,,CF,DT1.1,L,RA,N,-30 +2020,,BOP,DT1.2,C,RA,N,59.8752944598663 +2020,,BOP,DT1.2,L,RA,N,59.8752944598663 +2020,,EOP,DT1.2,C,RA,C,29.967554969423595 +2020,,EOP,DT1.2,L,RA,C,29.967554969423595 +2020,,IA,DT1.2,C,RA,N,0.09226050955731169 +2020,,IA,DT1.2,L,RA,N,0.09226050955731169 +2020,,CF,DT1.2,C,RA,N,-30 +2020,,CF,DT1.2,L,RA,N,-30 +,,BOP,DTR1.1,C,RA,N,-29.93764722993315 +,,BOP,DTR1.1,L,RA,N,-29.93764722993315 +,,EOP,DTR1.1,C,RA,C,-14.983777484711798 +,,EOP,DTR1.1,L,RA,C,-14.983777484711798 +,,IA,DTR1.1,C,RA,N,-0.046130254778655844 +,,IA,DTR1.1,L,RA,N,-0.046130254778655844 +,,CF,DTR1.1,C,RA,N,15 +,,CF,DTR1.1,L,RA,N,15 +2020,,BOP,DTR1.2,C,RA,N,-29.93764722993315 +2020,,BOP,DTR1.2,L,RA,N,-29.93764722993315 +2020,,EOP,DTR1.2,C,RA,C,-14.983777484711798 +2020,,EOP,DTR1.2,L,RA,C,-14.983777484711798 +2020,,IA,DTR1.2,C,RA,N,-0.046130254778655844 +2020,,IA,DTR1.2,L,RA,N,-0.046130254778655844 +2020,,CF,DTR1.2,C,RA,N,15 +2020,,CF,DTR1.2,L,RA,N,15 \ No newline at end of file diff --git a/full-ifrs17-template/Test/ExportIfrsVariable.ipynb b/full-ifrs17-template/Test/ExportIfrsVariable.ipynb index 25f352ba..e0976bd1 100644 --- a/full-ifrs17-template/Test/ExportIfrsVariable.ipynb +++ b/full-ifrs17-template/Test/ExportIfrsVariable.ipynb @@ -106,14 +106,14 @@ { "cell_type": "code", "source": [ - "(0, computedVariables.Keys, \"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType )" + "(0, computedVariables.Keys)" ] }, { "cell_type": "code", "source": [ - "var estimateType = \"BEPA\";", - "\nawait Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", + "var estimateType = \"BE\";", + "\nawait Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_MTUP10pct\"+\"_\"+estimateType)", "\n .WithTable(tableConfig => tableConfig", "\n .AtBeginning()", "\n .WithName(Main)", diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index 952b19d7..78347e9c 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -51,7 +51,7 @@ "cell_type": "code", "source": [ "var bmFiles = new BenchmarkMetadata[]{", - "\n //2020 Q4", + "\n // 2020 Q4", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_A.csv\" , \"CH\", 2020, 12),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_AA.csv\" , \"CH\", 2020, 12),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_APA.csv\" , \"CH\", 2020, 12),", @@ -62,7 +62,7 @@ "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_F.csv\" , \"CH\", 2020, 12),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_OA.csv\" , \"CH\", 2020, 12),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_RA.csv\" , \"CH\", 2020, 12),", - "\n //2021 Q1", + "\n // 2021 Q1", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_A.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_AA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_AAPA.csv\" , \"CH\", 2021, 3),", @@ -77,8 +77,14 @@ "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_OA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_OAPA.csv\" , \"CH\", 2021, 3),", "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2021_3_RA.csv\" , \"CH\", 2021, 3),", - "\n // 2020 with Scenario", - "\n //new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n // 2020 Q4", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_BE.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_BEPA.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_A.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_C.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_F.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_L.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", + "\n new BenchmarkMetadata(pathToBm+\"BM_CH_2020_12_MTUP10pct_RA.csv\" , \"CH\", 2020, 12, \"MTUP10pct\"),", "\n};" ] }, @@ -247,14 +253,13 @@ "\n //Get the computed Data", "\n var computedVariables = computedVariablesByEstimateType.TryGetValue(bmTableName, out var ret) ? ret : Enumerable.Empty();", "\n", - "\n if(!computedVariables.Any()) ", + "\n if(!computedVariables.Any())", "\n errorList.Add(new BenchmarkTestResult(\"No variables are computed for EstimateType: \" + bmTableName, 0, 0));", "\n //CompareAgainstBm", "\n if (bmVariables.Any() && computedVariables.Any()) //TODO we are adding duplicates here", - "\n errorList = errorList.Concat(CompareAgainstBm(errorList, bmVariables, computedVariables)).ToList();", + "\n errorList = errorList.Concat(CompareAgainstBm(errorList, bmVariables, computedVariables)).Distinct().ToList();", "\n }", - "\n}", - "\nerrorList = errorList.Distinct().ToList();" + "\n}" ] }, { diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index ba71ca3f..2e5e21f8 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -249,22 +249,18 @@ "\n .ToArrayAsync());", "\n ", "\n //Variables", - "\n // DISCUSS: wouldn't it be better to use Union() instead of Concat() to check if DataSource has some rawvars identical to the parsed ones", "\n var rawVariables = parsedRawVariables.Concat(openingRawVariables)", "\n .Concat(await querySource.Query()", - "\n .Where(rv => rv.Partition == TargetPartition)", - "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode))", - "\n .ToArrayAsync()); ", - "\n //if (!rawVariables.Any()) ApplicationMessage.Log(Warning.VariablesAlreadyImported, \"\"); // DISCUSS: goes with the above one", + "\n .Where(rv => rv.Partition == TargetPartition)", + "\n .Where(rv => primaryScopeFromLinkedReinsurance.Contains(rv.DataNode)).ToArrayAsync()); ", "\n ", "\n var ifrsVariables = parsedIfrsVariables.Concat(openingIfrsVariables)", "\n .Concat(await querySource.Query()", - "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", - "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", - "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", - "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", - "\n || secondaryScope.Contains(iv.DataNode))", - "\n .ToArrayAsync());", + "\n .Where(iv => iv.Partition == TargetPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", + "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", + "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync());", "\n", "\n if(DefaultPartition != TargetPartition) {", "\n await querySource.Partition.SetAsync(DefaultPartition);", @@ -272,11 +268,10 @@ "\n .Where(rv => rv.Partition == DefaultPartition)", "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", "\n var defaultIfrsVariables = await querySource.Query()", - "\n .Where(iv => iv.Partition == DefaultPartition && !(iv.AocType == AocTypes.BOP && iv.Novelty == Novelties.I))", - "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode) ", - "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", - "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", - "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync();", + "\n .Where(iv => iv.Partition == DefaultPartition)", + "\n .Where(iv => primaryScope.Contains(iv.DataNode)", + "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync();", "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance(ignoreValues : true));", "\n ifrsVariables = ifrsVariables.Union(defaultIfrsVariables, IfrsVariableComparer.Instance(ignoreValue : true));", "\n await querySource.Partition.SetAsync(TargetPartition);", From fa369592a6f786000ffbcdd9963f1c1cbc0ad34d Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Tue, 8 Nov 2022 17:55:08 +0100 Subject: [PATCH 22/23] implement feedback --- ifrs17/Import/ImportStorage.ipynb | 2 +- ifrs17/Utils/Queries.ipynb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 2e5e21f8..1c8c889e 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -218,7 +218,7 @@ "\n PreviousPeriodPartition = (await querySource.Query().Where(p => p.ReportingNode == args.ReportingNode &&", "\n p.Year == PreviousReportingPeriod.Year &&", "\n p.Month == PreviousReportingPeriod.Month &&", - "\n p.Scenario == null).ToArrayAsync()).Single().Id; // This can send an exception", + "\n p.Scenario == null).ToArrayAsync()).Single().Id;", "\n ", "\n await querySource.Partition.SetAsync(PreviousPeriodPartition);", "\n ", diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index d3d331a9..399d68f5 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -93,13 +93,13 @@ "\n where T : IWithYearMonthAndScenario", "\n{", "\n return (await querySource.LoadParameterAsync(args.Year, args.Month, filterExpression))", - "\n .Where(yc => yc.Scenario == args.Scenario || yc.Scenario == null)", - "\n .GroupBy(yc => identityExpression)", - "\n .Select(yc => yc.OrderByDescending(x => x.Year)", - "\n .ThenByDescending(x => x.Month)", - "\n .ThenByDescending(x => x.Scenario)", - "\n .FirstOrDefault())", - "\n .ToDictionary(identityExpression);", + "\n .Where(x => x.Scenario == args.Scenario || x.Scenario == null)", + "\n .GroupBy(x => identityExpression)", + "\n .Select(x => x.OrderByDescending(y => y.Year)", + "\n .ThenByDescending(y => y.Month)", + "\n .ThenByDescending(y => y.Scenario)", + "\n .FirstOrDefault())", + "\n .ToDictionary(identityExpression);", "\n}" ] }, From ace44c8be888ccc64fcc9bc8f49ca30ef04c4e8b Mon Sep 17 00:00:00 2001 From: Andrea Muolo Date: Wed, 9 Nov 2022 22:18:24 +0100 Subject: [PATCH 23/23] implement all feedbacks --- full-ifrs17-template/Files/Dimensions.csv | 15 ++++- .../Import/CloseImportTemplate.ipynb | 4 +- .../BM_CH_2020_12_MTUP10pct_A.csv | 4 +- .../BM_CH_2020_12_MTUP10pct_C.csv | 34 +++++------ .../BM_CH_2020_12_MTUP10pct_L.csv | 18 +++--- .../Test/ExportIfrsVariable.ipynb | 43 +------------- full-ifrs17-template/Test/ScenarioTest.ipynb | 40 +++---------- .../Test/SequenceImportTest.ipynb | 16 ++++-- ifrs17/Constants/Consts.ipynb | 21 +++++-- ifrs17/Import/ImportStorage.ipynb | 7 ++- .../Report/ReportConfigurationAndUtils.ipynb | 26 +++++++-- ifrs17/Report/ReportStorage.ipynb | 4 +- ifrs17/Test/QueriesTest.ipynb | 23 +++++++- ifrs17/Utils/EqualityComparers.ipynb | 56 +++++++++++++++++++ ifrs17/Utils/Queries.ipynb | 4 +- 15 files changed, 192 insertions(+), 123 deletions(-) diff --git a/full-ifrs17-template/Files/Dimensions.csv b/full-ifrs17-template/Files/Dimensions.csv index c07bb9a1..d0a29c98 100644 --- a/full-ifrs17-template/Files/Dimensions.csv +++ b/full-ifrs17-template/Files/Dimensions.csv @@ -214,9 +214,22 @@ Default,Default,,,,,,,,,, ,,,,,,,,,,, @@Scenario,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, -YCUP0.5pct,Yield Curve Up 0.5pct,,,,,,,,,, YCUP1.0pct,Yield Curve Up 1.0pct,,,,,,,,,, +YCDW1.0pct,Yield Curve Down 1.0pct,,,,,,,,,, +SRUP1.0pct,Spread Rate Up 1.0pct,,,,,,,,,, +SRDW1.0pct,Spread Rate Down 1.0pct,,,,,,,,,, +EUP1.0pct,Equity Up 1.0pct,,,,,,,,,, +EDW1.0pct,Equity Down 1.0pct,,,,,,,,,, +FXUP1.0pct,Exchange Rate Up 1.0pct,,,,,,,,,, +FXDW1.0pct,Exchange Rate Down 1.0pct,,,,,,,,,, MTUP10pct,Mortality Up 10pct,,,,,,,,,, +MTDW10pct,Mortality Down 10pct,,,,,,,,,, +LUP10pct,Longevity Up 10pct,,,,,,,,,, +LDW10pct,Longevity Down 10pct,,,,,,,,,, +DUP10pct,Disability Up 10pct,,,,,,,,,, +DDW10pct,Disability Down 10pct,,,,,,,,,, +LICUP10pct,Lic Up 10pct,,,,,,,,,, +LICDW10pct,Lic Down 10pct,,,,,,,,,, ,,,,,,,,,,, @@ValuationApproach,,,,,,,,,,, SystemName,DisplayName,,,,,,,,,, diff --git a/full-ifrs17-template/Import/CloseImportTemplate.ipynb b/full-ifrs17-template/Import/CloseImportTemplate.ipynb index eae574bf..bfdfe090 100644 --- a/full-ifrs17-template/Import/CloseImportTemplate.ipynb +++ b/full-ifrs17-template/Import/CloseImportTemplate.ipynb @@ -118,7 +118,9 @@ { "cell_type": "code", "source": [ - "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" + "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nawait DataSource.Partition.SetAsync(null);", + "\nawait DataSource.Partition.SetAsync(null);" ] } ] diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv index 8d10f69c..6a49b39f 100644 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv @@ -9,4 +9,6 @@ AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Valu ,NIC,CF,DT1.3,,A,C,-310 2020,NIC,CF,DT2.2,,A,C,-310 ,NIC,CF,DTR1.1,,A,C,170 -2020,NIC,CF,DTR1.2,,A,C,170 \ No newline at end of file +2020,NIC,CF,DTR1.2,,A,C,170 +,PR,CF,DTR2.1,,A,C,-200 +,NIC,CF,DTR2.1,,A,C,140 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv index d18a01c9..5b4b8afc 100644 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv @@ -3,20 +3,20 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@C AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,,EA,DT2.1,,C,C,-199.95837980461957 -,,EA,DT1.1,,C,C,-139.99082483519575 -,,BOP,DT1.1,,C,N,139.90849210284557 -,,IA,DT1.1,,C,N,0.0823327323501819 -,,BOP,DT2.1,,C,N,199.78378656271207 -,,IA,DT2.1,,C,N,0.1745932419074938 -,,EA,DT1.3,,C,C,-199.95837980461957 -,,BOP,DT1.3,,C,N,199.78378656271207 -,,IA,DT1.3,,C,N,0.1745932419074938 -,,AM,DTR1.1,,C,C,46.281232281883625 -,,EOP,DTR1.1,,C,C,-24.244714875883496 -,,BOP,DTR1.1,,C,N,-70.48349358144195 -,,IA,DTR1.1,,C,N,-0.0424535763251781 -,,AM,DTR2.1,,C,C,65.92583207126779 -,,EOP,DTR2.1,,C,C,-34.53566214028672 -,,BOP,DTR2.1,,C,N,-100.37302739955527 -,,IA,DTR2.1,,C,N,-0.08846681199924467 \ No newline at end of file +,,EA,DT2.1,,C,C,-139.99082483519595 +,,EA,DT1.1,,C,C,-80.02326986577215 +,,BOP,DT1.1,,C,N,80.03319764297927 +,,IA,DT1.1,,C,N,-0.009927777207129784 +,,BOP,DT2.1,,C,N,139.90849210284577 +,,IA,DT2.1,,C,N,0.08233273235018213 +,,EA,DT1.3,,C,C,-139.99082483519595 +,,BOP,DT1.3,,C,N,139.90849210284577 +,,IA,DT1.3,,C,N,0.08233273235018213 +,,AM,DTR1.1,,C,C,26.60498224366728 +,,EOP,DTR1.1,,C,C,-13.93718742938804 +,,BOP,DTR1.1,,C,N,-40.5458463515088 +,,IA,DTR1.1,,C,N,0.003676678453477744 +,,AM,DTR2.1,,C,C,46.24958203305145 +,,EOP,DTR2.1,,C,C,-24.22813469379126 +,,BOP,DTR2.1,,C,N,-70.43538016962212 +,,IA,DTR2.1,,C,N,-0.04233655722058882 \ No newline at end of file diff --git a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv index d68249f2..4f72f891 100644 --- a/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv +++ b/full-ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_L.csv @@ -3,12 +3,12 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@L AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,,AM,DT2.1,,L,C,-78.77489536337549 -,,EA,DT2.1,,L,C,120.04162019538043 -,,EA,DT1.1,,L,C,180.00917516480425 -,,AM,DT1.1,,L,C,-118.12739543980832 -,,EOP,DT1.1,,L,C,61.88177972499592 -,,EOP,DT2.1,,L,C,41.26672483200494 -,,EA,DT1.3,,L,C,200.04162019538043 -,,AM,DT1.3,,L,C,-131.2732839956922 -,,EOP,DT1.3,,L,C,68.76833619968824 \ No newline at end of file +,,AM,DT2.1,,L,C,-118.1273954398082 +,,EA,DT2.1,,L,C,180.00917516480405 +,,EA,DT1.1,,L,C,239.97673013422786 +,,AM,DT1.1,,L,C,-157.47989551624102 +,,EOP,DT1.1,,L,C,82.49683461798685 +,,EOP,DT2.1,,L,C,61.88177972499585 +,,EA,DT1.3,,L,C,260.00917516480405 +,,AM,DT1.3,,L,C,-170.6257840721249 +,,EOP,DT1.3,,L,C,89.38339109267915 \ No newline at end of file diff --git a/full-ifrs17-template/Test/ExportIfrsVariable.ipynb b/full-ifrs17-template/Test/ExportIfrsVariable.ipynb index e0976bd1..f844924b 100644 --- a/full-ifrs17-template/Test/ExportIfrsVariable.ipynb +++ b/full-ifrs17-template/Test/ExportIfrsVariable.ipynb @@ -50,45 +50,6 @@ "\n };" ] }, - { - "cell_type": "code", - "source": [ - "public async Task ExportBenchmarks(ImportArgs args)", - "\n{", - "\n await DataSource.Partition.SetAsync(new {ReportingNode = args.ReportingNode, Year= args.Year, Month = args.Month, Scenario = args.Scenario});", - "\n var computedVariables = (await DataSource.Query().ToArrayAsync()).ToDictionaryGrouped(x => x.EstimateType, x => x.ToArray());", - "\n", - "\n foreach (var estimateType in computedVariables.Keys)", - "\n {", - "\n //await Export.ToCsv(pathToBm+\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", - "\n await Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+estimateType)", - "\n .WithTable(tableConfig => tableConfig", - "\n .AtBeginning()", - "\n .WithName(Main)", - "\n .WithSource(source => args.RepeatOnce().AsQueryable())", - "\n .WithColumn(x => x.Periodicity, x => x.Delete())", - "\n .WithColumn(x => x.ImportFormat, x => x.Delete())", - "\n )", - "\n .WithTable(tableConfig => tableConfig", - "\n .WithSource(source => computedVariables[estimateType].AsQueryable())", - "\n .WithName(estimateType)", - "\n .WithColumn(x => x.Partition, x => x.Delete())", - "\n .WithColumn(x => x.Id, x => x.Delete())", - "\n )", - "\n .WithSource(DataSource)", - "\n .ExecuteAsync();", - "\n }", - "\n}" - ] - }, - { - "cell_type": "code", - "source": [ - "// TODO: This doesn't seem to work", - "\nforeach (var args in argsArray)", - "\n await ExportBenchmarks(args);" - ] - }, { "cell_type": "code", "source": [ @@ -112,8 +73,8 @@ { "cell_type": "code", "source": [ - "var estimateType = \"BE\";", - "\nawait Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_MTUP10pct\"+\"_\"+estimateType)", + "var estimateType = \"BEPA\";", + "\nawait Export.ToCsv(\"BM_\"+args.ReportingNode+\"_\"+args.Year.ToString()+\"_\"+args.Month.ToString()+\"_\"+scenario+\"_\"+estimateType)", "\n .WithTable(tableConfig => tableConfig", "\n .AtBeginning()", "\n .WithName(Main)", diff --git a/full-ifrs17-template/Test/ScenarioTest.ipynb b/full-ifrs17-template/Test/ScenarioTest.ipynb index defadcba..c86a432b 100644 --- a/full-ifrs17-template/Test/ScenarioTest.ipynb +++ b/full-ifrs17-template/Test/ScenarioTest.ipynb @@ -60,7 +60,7 @@ { "cell_type": "code", "source": [ - "var cashflows_MTUP10pct = @\"", + "var cashflows_scenarioTest = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", "\nCH,2020,12,Test", @@ -75,7 +75,7 @@ { "cell_type": "code", "source": [ - "var cashflows_MTUP10pct_BE = @\"", + "var cashflows_scenarioTest_equalTo_BestEstimate = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", "\nCH,2020,12,Test", @@ -90,7 +90,7 @@ { "cell_type": "code", "source": [ - "var log = await Import.FromString(cashflows_MTUP10pct).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", + "var log = await Import.FromString(cashflows_scenarioTest).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", "\nlog" @@ -106,30 +106,6 @@ "\ndiffs.Where(x => !(new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray().Length.Should().NotBe(0);" ] }, - { - "cell_type": "code", - "source": [ - "var a = Workspace.Query().Except(defaultVarsBE, IfrsVariableComparer.Instance()).Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType)).ToArray(); a" - ] - }, - { - "cell_type": "code", - "source": [ - "var b = Workspace.Query().Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType) && x.DataNode == \"DT1.1\").ToArray(); b" - ] - }, - { - "cell_type": "code", - "source": [ - "var c = defaultVarsBE.Where(x => (new[]{\"A\",\"AA\",\"OA\",\"DA\"}).Contains(x.EstimateType) && x.DataNode == \"DT1.1\").ToArray(); c" - ] - }, - { - "cell_type": "code", - "source": [ - "// DISCUSS: some Actuals are missing..." - ] - }, { "cell_type": "markdown", "source": [ @@ -139,7 +115,7 @@ { "cell_type": "code", "source": [ - "var actuals_MTUP10pct = @\"", + "var actuals_scenarioTest = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", "\nCH,2020,12,Test", @@ -151,7 +127,7 @@ { "cell_type": "code", "source": [ - "var actuals_MTUP10pct_BE = @\"", + "var actuals_scenarioTest_equalTo_BestEstimate = @\"", "\n@@Main", "\nReportingNode,Year,Month,Scenario", "\nCH,2020,12,Test", @@ -163,7 +139,7 @@ { "cell_type": "code", "source": [ - "var log = await Import.FromString(actuals_MTUP10pct).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", + "var log = await Import.FromString(actuals_scenarioTest).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", "\nlog" @@ -188,7 +164,7 @@ { "cell_type": "code", "source": [ - "var log = await Import.FromString(actuals_MTUP10pct_BE).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", + "var log = await Import.FromString(actuals_scenarioTest_equalTo_BestEstimate).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync();", "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", "\nlog" @@ -197,7 +173,7 @@ { "cell_type": "code", "source": [ - "var log = await Import.FromString(cashflows_MTUP10pct_BE).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", + "var log = await Import.FromString(cashflows_scenarioTest_equalTo_BestEstimate).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync();", "\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\nWorkspace.Initialize(x => x.FromSource(DataSource));", "\nlog" diff --git a/full-ifrs17-template/Test/SequenceImportTest.ipynb b/full-ifrs17-template/Test/SequenceImportTest.ipynb index d080e549..cfbc24c3 100644 --- a/full-ifrs17-template/Test/SequenceImportTest.ipynb +++ b/full-ifrs17-template/Test/SequenceImportTest.ipynb @@ -37,13 +37,13 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(ws1).ExecuteAsync()" + "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(ws1).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(ws1).ExecuteAsync()" + "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(ws1).ExecuteAsync()" ] }, { @@ -76,13 +76,13 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync()" + "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(ws2).ExecuteAsync()" + "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(ws2).ExecuteAsync()" ] }, { @@ -108,7 +108,13 @@ { "cell_type": "code", "source": [ - "ifrsVars1.Except(ifrsVars2, IfrsVariableComparer.Instance())" + "ifrsVars1.Except(ifrsVars2, IfrsVariableComparer.Instance()).Count().Should().Be(0);" + ] + }, + { + "cell_type": "code", + "source": [ + "" ] } ] diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 9839c951..9d54b276 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -264,9 +264,22 @@ "cell_type": "code", "source": [ "public static class Scenarios{", - "\n public const string YCUP05pct = nameof(YCUP05pct); // Yield Curve Up 0.5pct", - "\n public const string YCUP10pct = nameof(YCUP10pct); // Yield Curve Up 1.0pct", - "\n public const string MTUP10pct = nameof(MTUP10pct); // Mortality Up 10pct", + "\n public const string YCUP1pct = nameof(YCUP1pct); // Yield Curve Up 1.0pct", + "\n public const string YCDW1pct = nameof(YCDW1pct); // Yield Curve Down 1.0pct", + "\n public const string SRUP1pct = nameof(SRUP1pct); // Spread Rate Up 1.0pct", + "\n public const string SRDW1pct = nameof(SRDW1pct); // Spread Rate Down 1.0pct", + "\n public const string EUP1pct = nameof(EUP1pct); // Equity Up 1.0pct", + "\n public const string EDW1pct = nameof(EDW1pct); // Equity Down 1.0pct", + "\n public const string FXUP1pct = nameof(FXUP1pct); // Exchange Rate Up 1.0pct", + "\n public const string FXDW1pct = nameof(FXDW1pct); // Exchange Rate Down 1.0pct", + "\n public const string MTUP10pct = nameof(MTUP10pct); // Mortality Up 10pct", + "\n public const string MTDW10pct = nameof(MTDW10pct); // Mortality Down 10pct", + "\n public const string LUP10pct = nameof(LUP10pct); // Longevity Up 10pct", + "\n public const string LDW10pct = nameof(LDW10pct); // Longevity Down 10pct", + "\n public const string DUP10pct = nameof(DUP10pct); // Disability Up 10pct", + "\n public const string DDW10pct = nameof(DDW10pct); // Disability Down 10pct", + "\n public const string LICUP10pct = nameof(LICUP10pct); // Lic Up 10pct", + "\n public const string LICDW10pct = nameof(LICDW10pct); // Lic Down 10pct", "\n}" ] }, @@ -286,4 +299,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 1c8c889e..00ccbba0 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -269,11 +269,12 @@ "\n .Where(rv => primaryScope.Contains(rv.DataNode)).ToArrayAsync();", "\n var defaultIfrsVariables = await querySource.Query()", "\n .Where(iv => iv.Partition == DefaultPartition)", - "\n .Where(iv => primaryScope.Contains(iv.DataNode)", + "\n .Where(iv => primaryScopeFromParsedVariables.Contains(iv.DataNode)", "\n && !EstimateTypesByImportFormat[ImportFormat].Contains(iv.EstimateType) ", + "\n || primaryScopeFromLinkedReinsurance.Contains(iv.DataNode) ", "\n || secondaryScope.Contains(iv.DataNode)).ToArrayAsync();", - "\n rawVariables = rawVariables.Union(defaultRawVariables, RawVariableComparer.Instance(ignoreValues : true));", - "\n ifrsVariables = ifrsVariables.Union(defaultIfrsVariables, IfrsVariableComparer.Instance(ignoreValue : true));", + "\n rawVariables = rawVariables.Union(defaultRawVariables, EqualityComparer.Instance);", + "\n ifrsVariables = ifrsVariables.Union(defaultIfrsVariables, EqualityComparer.Instance);", "\n await querySource.Partition.SetAsync(TargetPartition);", "\n }", "\n", diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 6b2cbab2..28b0acd6 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -26,7 +26,8 @@ { "cell_type": "code", "source": [ - "#!import \"../Utils/Queries\"" + "#!import \"../Utils/EqualityComparers\"", + "\n#!import \"../Utils/Queries\"" ] }, { @@ -91,11 +92,12 @@ { "cell_type": "code", "source": [ - "public static async Task> QueryReportVariablesAsync(this IWorkspace workspace, (int Year, int Month, string ReportingNode, string Scenario) args ) {", - "\n ", + "public static async Task QueryReportVariablesSingleScenarioAsync(this IWorkspace workspace, (int Year, int Month, string ReportingNode, string Scenario) args ) {", + "\n", + "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = (string)null}); // TODO: Scenario from args + relaxed query ", "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario, Year = args.Year, Month = args.Month });", "\n ", - "\n return await workspace.Query()", + "\n var reportVariables = await workspace.Query()", "\n .Join(workspace.Query(),", "\n dn => dn.SystemName,", "\n iv => iv.DataNode,", @@ -134,6 +136,22 @@ "\n ", "\n Value = iv.Value })", "\n .ToArrayAsync();", + "\n", + "\n await workspace.Partition.SetAsync(null);", + "\n await workspace.Partition.SetAsync(null);", + "\n return reportVariables;", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "public static async Task> QueryReportVariablesAsync(this IWorkspace workspace, (int Year, int Month, string ReportingNode, string Scenario) args ) {", + "\n ReportVariable[] reportVariables = new ReportVariable[0];", + "\n if(args.Scenario != null) ", + "\n reportVariables = (await workspace.QueryReportVariablesSingleScenarioAsync((args.Year, args.Month, args.ReportingNode, null)));", + "\n return (await workspace.QueryReportVariablesSingleScenarioAsync((args.Year, args.Month, args.ReportingNode, args.Scenario)))", + "\n .Union(reportVariables.Select(x => x with {Scenario = args.Scenario}), EqualityComparer.Instance).ToArray();", "\n}" ] }, diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index 0c61fe1a..13525d14 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -141,7 +141,7 @@ "\n }", "\n ", "\n // Variables", - "\n foreach(var rn in GetLeaves(reportingNode)) { ", + "\n foreach(var rn in GetLeaves(reportingNode)) {", "\n if(!variablesDictionary.TryGetValue((period, rn, scenario), out var variablesByIdentity)) {", "\n variablesByIdentity = (await workspace.QueryReportVariablesAsync((period.year, period.month, rn, scenario)))", "\n .ToDictionaryGrouped(x => new ReportIdentity {", @@ -159,7 +159,7 @@ "\n x => x.ToDictionaryGrouped(y => y.EstimateType,", "\n y => y.ToArray().ToDataCube()));", "\n ", - "\n variablesDictionary.Add((period, rn, scenario), variablesByIdentity);", + "\n variablesDictionary.Add((period, rn, scenario), variablesByIdentity);", "\n }", "\n }", "\n }", diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index c72041a9..6b91461e 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -78,8 +78,9 @@ "cell_type": "code", "source": [ "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,scenario);", - "\nvar testData = new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 9, Scenario = scenario};", - "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData.RepeatOnce(), (2020, 9, scenario),(2020, 9, 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));" ] }, { @@ -108,6 +109,24 @@ "\nawait CheckLoadCurrentAndPreviousParameterForYieldCurveAsync(args, testData, (2020, 6, null), (2020, 6, null));" ] }, + { + "cell_type": "code", + "source": [ + "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));" + ] + }, + { + "cell_type": "code", + "source": [ + "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));" + ] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Utils/EqualityComparers.ipynb b/ifrs17/Utils/EqualityComparers.ipynb index f2394b0a..bd3021eb 100644 --- a/ifrs17/Utils/EqualityComparers.ipynb +++ b/ifrs17/Utils/EqualityComparers.ipynb @@ -78,6 +78,62 @@ "\n }", "\n}" ] + }, + { + "cell_type": "code", + "source": [ + "using System;", + "\nusing System.Collections.Generic;", + "\nusing System.Diagnostics; ", + "\nusing System.Linq;", + "\nusing System.Linq.Expressions;", + "\nusing System.Reflection;", + "\nusing System.Threading;", + "\n//using Systemorph.Domain;", + "\n//using Systemorph.Utils.Reflection;", + "\nusing static Systemorph.Vertex.Equality.IdentityPropertyExtensions;" + ] + }, + { + "cell_type": "code", + "source": [ + "class EqualityComparer : IEqualityComparer", + "\n{", + "\n private static readonly System.Reflection.PropertyInfo[] IdentityProperties = typeof(T).GetIdentityProperties().ToArray();", + "\n private static Func compiledEqualityFunction;", + "\n", + "\n private EqualityComparer() {", + "\n compiledEqualityFunction = GetEqualityFunction();", + "\n }", + "\n", + "\n public static readonly EqualityComparer Instance = new EqualityComparer();", + "\n", + "\n public bool Equals(T x, T y) => compiledEqualityFunction(x, y);", + "\n public int GetHashCode(T obj) => 0;", + "\n", + "\n private static Func GetEqualityFunction()", + "\n {", + "\n var prm1 = Expression.Parameter(typeof(T));", + "\n var prm2 = Expression.Parameter(typeof(T));", + "\n", + "\n // r1 == null && r2 == null", + "\n var nullConditionExpression = Expression.AndAlso(Expression.Equal(prm1, Expression.Constant(null, typeof(T))), Expression.Equal(prm2, Expression.Constant(null, typeof(T))));", + "\n // r1 != null && r2 != null", + "\n var nonNullConditionExpression = Expression.AndAlso(Expression.NotEqual(prm1, Expression.Constant(null, typeof(T))), Expression.NotEqual(prm2, Expression.Constant(null, typeof(T))));", + "\n // r1.prop1 == r2.prop1 && r1.prop2 == r2.prop2...... ", + "\n var allPropertiesEqualExpression = IdentityProperties.Select(propertyInfo => Expression.Equal(Expression.Property(prm1, propertyInfo), Expression.Property(prm2, propertyInfo))).Aggregate(Expression.AndAlso);", + "\n", + "\n var equalityExpr = Expression.OrElse(nullConditionExpression, Expression.AndAlso(nonNullConditionExpression, allPropertiesEqualExpression));", + "\n return Expression.Lambda>(equalityExpr, prm1, prm2).Compile();", + "\n }", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "" + ] } ] } \ No newline at end of file diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 399d68f5..83b6c1ef 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -124,9 +124,11 @@ "\n", "\n var currentCandidate = p.Where(x => x.Year == args.Year).OrderByDescending(x => x.Month).ThenByDescending(x => x.Scenario).FirstOrDefault();", "\n var previousCandidate = p.Where(x => x.Year < args.Year && x.Scenario == null).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", + "\n var currentCandidateBE = p.Where(x => x.Year <= args.Year && x.Scenario == null).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", "\n ", "\n inner.Add(CurrentPeriod, currentCandidate != null ? currentCandidate : previousCandidate);", - "\n inner.Add(PreviousPeriod, previousCandidate != null ? previousCandidate : currentCandidate);", + "\n inner.Add(PreviousPeriod, previousCandidate != null ? previousCandidate : (currentCandidateBE != null ? currentCandidateBE : currentCandidate));", + "\n // TODO: log error if currentCandidate is null", "\n }", "\n return ret;", "\n}"