Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion full-ifrs17-template/Constants/Consts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{
"cell_type": "code",
"source": [
"await UploadSimpleValueAsync(\"../Files/900.TransactionalData/SimpleValue_CH_2020_12.csv\")"
"//await UploadSimpleValueAsync(\"../Files/900.TransactionalData/SimpleValue_CH_2020_12.csv\") TODO: missing benchmarks"
]
},
{
Expand Down
37 changes: 14 additions & 23 deletions full-ifrs17-template/Test/IfrsVariablesTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,11 @@
"\n var expectedNotComputed = expected.Where(x => Math.Abs(x.Value) > BenchmarkPrecision).Select(x => x.ToIdentityString()).Except(computed.Select(x => x.ToIdentityString()));",
"\n var computedNotExpected = computed.Where(x => Math.Abs(x.Value) > BenchmarkPrecision).Select(x => x.ToIdentityString()).Except(expected.Select(x => x.ToIdentityString()));",
"\n if (expectedNotComputed.Any())",
"\n {",
"\n foreach (var error in expectedNotComputed)",
"\n {",
"\n var message = error.ToIdentityString();",
"\n errors.Add(new BenchmarkTestResult(\"Extra expected variable for: \"+ message));",
"\n }",
"\n }",
"\n errors.Add(new BenchmarkTestResult(\"Extra expected variable for: \" + error));",
"\n if (computedNotExpected.Any())",
"\n {",
"\n foreach (var error in computedNotExpected)",
"\n {",
"\n var message = error.ToIdentityString();",
"\n errors.Add(new BenchmarkTestResult(\"Extra computed variable for: \"+ message));",
"\n }",
"\n }",
"\n errors.Add(new BenchmarkTestResult(\"Extra computed variable for: \" + error));",
"\n ",
"\n var misMatchedVariables = expected.Concat(computed).AggregateOver().Where(x => Math.Abs(x.Value) > BenchmarkPrecision);",
"\n if (misMatchedVariables.Any())",
Expand Down Expand Up @@ -211,13 +201,8 @@
{
"cell_type": "code",
"source": [
"var errorList = new List<BenchmarkTestResult>();"
]
},
{
"cell_type": "code",
"source": [
"foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))",
"var errorList = new List<BenchmarkTestResult>();",
"\nforeach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))",
"\n{",
"\n var reportingNode = g.Key.ReportingNode;",
"\n var year = g.Key.Year;",
Expand All @@ -244,13 +229,13 @@
"\n var mainTab = bmDataTable.Tables[Main].Rows.First();",
"\n if(!ValidateMainTab(mainTab, reportingNode, year, month))",
"\n throw new Exception(\"Metadata and main tab of the Benchmark are different.\");",
"\n ",
"\n",
"\n var bmTableName = bmDataTable.Tables.Single(x => x.TableName != Main).TableName;",
"\n var bmVariables = bmDataTable.Tables[bmTableName].Rows.Select(x => CreateVariable(x, partition));",
"\n ",
"\n",
"\n //Get the computed Data",
"\n var computedVariables = computedVariablesByEstimateType.TryGetValue(bmTableName, out var ret) ? ret : Enumerable.Empty<IfrsVariable>();",
"\n ",
"\n",
"\n if(!computedVariables.Any()) ",
"\n errorList.Add(new BenchmarkTestResult(\"No variables are computed for EstimateType: \" + bmTableName, 0, 0));",
"\n //CompareAgainstBm",
Expand All @@ -264,7 +249,13 @@
{
"cell_type": "code",
"source": [
"errorList.Count().Should().Be(0)"
"errorList.Count().Should().Be(0);"
]
},
{
"cell_type": "code",
"source": [
"errorList"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"\n// check that exporter generates only the desired columns ",
"\nvar extension = \".xlsx\";",
"\nvar stream = await Project.FileStorage.ReadAsync(filename + extension);",
"\nvar tables = await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync();",
"\nvar tables = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;",
"\nvar mainCols = new[]{nameof(PartitionByReportingNode.ReportingNode)};",
"\nvar portfolioCols = new[]{nameof(Portfolio.SystemName),nameof(Portfolio.DisplayName),nameof(Portfolio.ContractualCurrency),",
"\n nameof(Portfolio.LineOfBusiness),nameof(Portfolio.OciType),nameof(Portfolio.ValuationApproach)};",
Expand Down Expand Up @@ -236,7 +236,7 @@
"\n// check that exporter generates only the desired columns ",
"\nvar extension = \".xlsx\";",
"\nvar stream = await Project.FileStorage.ReadAsync(filename + extension);",
"\nvar tables = await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync();",
"\nvar tables = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;",
"\nvar mainCols = new[]{nameof(PartitionByReportingNodeAndPeriod.ReportingNode),",
"\n nameof(PartitionByReportingNodeAndPeriod.Year),",
"\n nameof(PartitionByReportingNodeAndPeriod.Month)};",
Expand Down Expand Up @@ -316,7 +316,7 @@
"\n// check that exporter generates only the desired columns ",
"\nvar extension = \".xlsx\";",
"\nvar stream = await Project.FileStorage.ReadAsync(filename + extension);",
"\nvar tables = await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync();",
"\nvar tables = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;",
"\nvar mainCols = new[]{nameof(PartitionByReportingNodeAndPeriod.ReportingNode),",
"\n nameof(PartitionByReportingNodeAndPeriod.Year),",
"\n nameof(PartitionByReportingNodeAndPeriod.Month),",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,8 @@
{
"cell_type": "code",
"source": [
"var identities = reportStorage.GetIdentities(period, reportingNode, null, currencyType);"
]
},
{
"cell_type": "code",
"source": [
"identities"
"var identities = reportStorage.GetIdentities(period, reportingNode, null, currencyType);",
"\nidentities"
]
},
{
Expand Down Expand Up @@ -197,8 +192,8 @@
"\n .WithQuerySource(DataSource)",
"\n .SliceRowsBy(\"VariableType\", \"EstimateType\")",
"\n .SliceColumnsBy(CurrencyGrouper(currencyType), \"LiabilityType\",\"GroupOfContract\")",
"\n .ReportGridOptions(reportHeight: 900, headerColumnWidth: 500, groupDefaultExpanded: 3)",
"\n .ToReport() with { Height = 600 }"
"\n .WithGridOptions( o => o.WithDefaultColumn( c => c.WithWidth(260) ) with {GroupDefaultExpanded = 3, Height = 900, OnGridReady = null} )",
"\n .ToReport()"
]
},
{
Expand Down
20 changes: 10 additions & 10 deletions full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@
{
"cell_type": "code",
"source": [
"var expectedInterest = yearlyYieldCurve.Select( yc => (1 + yc)^( 1.0 / 12.0) );",
"var expectedInterest = yearlyYieldCurve.Select( yc => Math.Pow(1 + yc, 1.0 / 12.0) );",
"\nexpectedInterest"
]
},
{
"cell_type": "code",
"source": [
"from yc in yearlyYieldCurve select (1 + yc)^( 1.0 / 12.0 ) "
"from yc in yearlyYieldCurve select Math.Pow(1 + yc, 1.0 / 12.0)"
]
},
{
Expand All @@ -299,7 +299,7 @@
{
"cell_type": "code",
"source": [
"var expectedDiscount = yearlyYieldCurve.Select( yc => (1 + yc)^( -1.0 / 12.0) );",
"var expectedDiscount = yearlyYieldCurve.Select( yc => Math.Pow(1 + yc, -1.0 / 12.0) );",
"\nexpectedDiscount"
]
},
Expand Down Expand Up @@ -710,7 +710,7 @@
{
"cell_type": "code",
"source": [
"var nominalClaims = nominalICO.Values + nominalNIC.Values + nominalALE.Values + nominalULE.Values;"
"var nominalClaims = Sum( Sum(nominalICO.Values, nominalNIC.Values), Sum(nominalALE.Values, nominalULE.Values) );"
]
},
{
Expand Down Expand Up @@ -1015,7 +1015,7 @@
{
"cell_type": "code",
"source": [
"var expectedPresentValueMC_PR = discountedMC_PR.Values - discountedBoP_PR.Values;"
"var expectedPresentValueMC_PR = Subtract(discountedMC_PR.Values, discountedBoP_PR.Values);"
]
},
{
Expand Down Expand Up @@ -1097,7 +1097,7 @@
{
"cell_type": "code",
"source": [
"var expectedPresentValueCF_PR = -1.0 * cfNominalReference_PR.Values;"
"var expectedPresentValueCF_PR = Multiply(-1.0, cfNominalReference_PR.Values);"
]
},
{
Expand Down Expand Up @@ -1428,7 +1428,7 @@
{
"cell_type": "code",
"source": [
"var expectedPresentValueYCU_PR = ycReferenceDiscountedEop - discountedYcParent.Values;"
"var expectedPresentValueYCU_PR = Subtract(ycReferenceDiscountedEop, discountedYcParent.Values);"
]
},
{
Expand Down Expand Up @@ -1579,7 +1579,7 @@
{
"cell_type": "code",
"source": [
"var expectedPresentValueCRU = cruExpectedDiscountedCDR - discountedCruParent.Values;"
"var expectedPresentValueCRU = Subtract(cruExpectedDiscountedCDR, discountedCruParent.Values);"
]
},
{
Expand Down Expand Up @@ -1648,8 +1648,8 @@
{
"cell_type": "code",
"source": [
"var expectedPresentValueCL_PR = Test.GetScope<DiscountedCashflow>((idCL, \"PR\", \"BE\", (int?)null)).Values -",
"\n clParents.Select(aocStep => Test.GetScope<DiscountedCashflow>((idCL with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}, \"PR\", \"BE\", (int?)null)).Values).Aggregate();"
"var expectedPresentValueCL_PR = Subtract(Test.GetScope<DiscountedCashflow>((idCL, \"PR\", \"BE\", (int?)null)).Values,",
"\n clParents.Select(aocStep => Test.GetScope<DiscountedCashflow>((idCL with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}, \"PR\", \"BE\", (int?)null)).Values).Aggregate());"
]
},
{
Expand Down
21 changes: 11 additions & 10 deletions ifrs17/DataModel/DataStructure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@
{
"cell_type": "code",
"source": [
"#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\""
"#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\""
]
},
{
Expand Down
21 changes: 11 additions & 10 deletions ifrs17/Import/ImportScopeCalculation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
"\n ",
"\n double[] Interest => YearlyYieldCurve.Select(rate => Math.Pow(1d + rate, 1d / 12d) + Perturbation).ToArray(); ",
"\n ",
"\n double[] Discount => Interest^(-1);",
"\n double[] Discount => Interest.Select(x => Math.Pow(x, -1)).ToArray();",
"\n}"
]
},
Expand Down Expand Up @@ -484,7 +484,7 @@
"\n ret[i] = Math.Exp(-nonPerformanceRiskRate) * ret.ElementAtOrDefault(i + 1) + NominalClaimsCashflow[i] - NominalClaimsCashflow.ElementAtOrDefault(i + 1);",
"\n return ret; } } ",
"\n ",
"\n double[] NominalCashflow.Values => PvCdrDecumulated - NominalClaimsCashflow;",
"\n double[] NominalCashflow.Values => Subtract(PvCdrDecumulated, NominalClaimsCashflow);",
"\n}",
"\n",
"\npublic interface AllClaimsCashflow : NominalCashflow",
Expand Down Expand Up @@ -600,7 +600,7 @@
"\n .Where(cf => cf.Count() > 0)",
"\n .Aggregate();",
"\n ",
"\n double[] Values => CurrentValues - PreviousValues;",
"\n double[] Values => Subtract(CurrentValues, PreviousValues);",
"\n}"
]
},
Expand Down Expand Up @@ -702,7 +702,7 @@
"\npublic interface IWithInterestAccretionForCreditRisk : IScope<(ImportIdentity Id, string AmountType, string EstimateType, int? AccidentYear), ImportStorage>",
"\n{",
"\n private double[] nominalClaimsCashflow => GetScope<AllClaimsCashflow>(Identity).Values;",
"\n private double[] nominalValuesCreditRisk => -1 * GetScope<CreditDefaultRiskNominalCashflow>(Identity with {Id = Identity.Id with {AocType = AocTypes.CF}}).Values;",
"\n private double[] nominalValuesCreditRisk => Multiply(-1, GetScope<CreditDefaultRiskNominalCashflow>(Identity with {Id = Identity.Id with {AocType = AocTypes.CF}}).Values);",
"\n private double[] monthlyInterestFactor => GetScope<MonthlyRate>(Identity.Id).Interest;",
"\n private double nonPerformanceRiskRate => GetStorage().GetNonPerformanceRiskRate(Identity.Id);",
"\n ",
Expand All @@ -717,7 +717,7 @@
"\n effectCreditRisk[i] = interestOnClaimsCashflow[i] - interestOnClaimsCashflowCreditRisk[i];",
"\n }",
"\n ",
"\n return effectCreditRisk - nominalValuesCreditRisk;",
"\n return Subtract(effectCreditRisk, nominalValuesCreditRisk);",
"\n }",
"\n}"
]
Expand Down Expand Up @@ -785,7 +785,7 @@
"\npublic interface CashflowAocStep : PresentValue",
"\n{",
"\n [NotVisible]",
"\n double[] PresentValue.Values => -1d * GetScope<NominalCashflow>(Identity).Values;",
"\n double[] PresentValue.Values => Multiply(-1d, GetScope<NominalCashflow>(Identity).Values);",
"\n}",
"\n",
"\npublic interface PresentValueWithInterestAccretion : PresentValue, IWithInterestAccretion",
Expand Down Expand Up @@ -1337,7 +1337,9 @@
"\n string EstimateType => EstimateTypes.BEPA;",
"\n string EconomicBasis => EconomicBases.L;",
"\n ",
"\n PresentValue[] ByAmountType => GetStorage().GetPremiums().Select(pr => GetStorage().GetPremiumAllocationFactor(Identity) * GetScope<PresentValue>((Identity, pr, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis))).ToArray(); ",
"\n PresentValue[] ByAmountType => GetStorage().GetPremiums().Select(pr => ",
"\n Multiply( GetStorage().GetPremiumAllocationFactor(Identity), ",
"\n GetScope<PresentValue>((Identity, pr, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)) ) ).ToArray(); ",
"\n}",
"\n",
"\npublic interface DefaultValueBeExperienceAdjustmentForPremium : BeExperienceAdjustmentForPremium",
Expand All @@ -1356,9 +1358,8 @@
"\n .WithApplicability<DefaultValueActualExperienceAdjustmentForPremium>(x => x.Identity.AocType != AocTypes.CF));",
"\n ",
"\n public ActualBase[] ByAmountTypeAndEstimateType => GetStorage().GetPremiums().SelectMany(pr => ",
"\n GetStorage().ExperienceAdjustEstimateTypeMapping.Keys",
"\n .Select(et => GetStorage().GetPremiumAllocationFactor(Identity) * ",
"\n GetScope<ActualBase>((Identity, pr, et, (int?)null)))).ToArray(); ",
"\n GetStorage().ExperienceAdjustEstimateTypeMapping.Keys.Select(et => ",
"\n Multiply(GetStorage().GetPremiumAllocationFactor(Identity), GetScope<ActualBase>((Identity, pr, et, (int?)null))) ) ).ToArray();",
"\n}",
"\n",
"\npublic interface DefaultValueActualExperienceAdjustmentForPremium : ActualExperienceAdjustmentForPremium",
Expand Down
Loading