From 0c894dc4650c4a2a9c082554546841b995fe9d76 Mon Sep 17 00:00:00 2001 From: Andrey Katz Date: Mon, 7 Aug 2023 16:04:37 +0200 Subject: [PATCH 1/4] method that queries yield curves for VFA --- ifrs17/Utils/Queries.ipynb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 593b57bc..086abc37 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -213,6 +213,35 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Data Nodes with VFA valuation" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static async Task> LoadVFAYieldCurveAsync(this IQuerySource querySource, Args args, IEnumerable dataNodes)", + "\n{", + "\n var YiieldCurveByGoc = new Dictionary();", + "\n foreach(var dn in dataNodes.Where(x => x.ValuationApproach == ValuationApproaches.VFA)){", + "\n var monthUpperLimit = args.Year == dn.Year ? args.Month : MonthInAYear;", + "\n var argsNew = args with {Year = dn.Year, Month = monthUpperLimit, Scenario = args.Scenario};", + "\n var loadedYc = await querySource.LoadCurrentParameterAsync(argsNew, x => x.Currency, x => x.Currency == dn. ContractualCurrency && x.Name == dn.YieldCurveName);", + "\n if (loadedYc.TryGetValue(dn.ContractualCurrency, out var vfaYc)) YiieldCurveByGoc[dn.DataNode] = vfaYc;", + "\n // Should we load an error or a warning if the did not succeed to get value? - A.K. ", + "\n }", + "\n return YiieldCurveByGoc;", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ From 8160fa05a21c4670ca7f298927d4777e83783c0a Mon Sep 17 00:00:00 2001 From: Andrey Katz Date: Mon, 7 Aug 2023 17:10:17 +0200 Subject: [PATCH 2/4] Update GetYieldCurveReportParameters. Not tested yet --- ifrs17/Report/ParameterReportsQueries.ipynb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ifrs17/Report/ParameterReportsQueries.ipynb b/ifrs17/Report/ParameterReportsQueries.ipynb index 81f6690a..52fc8ad4 100644 --- a/ifrs17/Report/ParameterReportsQueries.ipynb +++ b/ifrs17/Report/ParameterReportsQueries.ipynb @@ -277,6 +277,19 @@ "\n Name = x.Value.Name }", "\n )", "\n .ToArray();", + "\n ", + "\n var vfaYieldCurves = (await workspace.LoadVFAYieldCurveAsync(args, dataNodeData))", + "\n .Select(x => new YieldCurveReportParameter{", + "\n GroupOfContract = x.Key, ", + "\n YieldCurveType = \"VFA\", ", + "\n Year = x.Value.Year, ", + "\n Month = x.Value.Month, ", + "\n Currency = x.Value.Currency, ", + "\n Name = x.Value.Name", + "\n })", + "\n .ToArray();", + "\n", + "\n var vfaAndLockedYc = vfaYieldCurves.Concat(lockedYieldCurves);", "\n", "\n var currentYieldCurves = (await workspace.LoadCurrentYieldCurveAsync(args, dataNodeData))", "\n .Values", @@ -290,7 +303,7 @@ "\n Name = y.Value.Name}", "\n ));", "\n", - "\n var allYieldCurves = lockedYieldCurves.Concat(lockedYieldCurves.SelectMany(loc => currentYieldCurves.Select(cuc => new YieldCurveReportParameter {", + "\n var allYieldCurves = vfaAndLockedYc.Concat(vfaAndLockedYc.SelectMany(loc => currentYieldCurves.Select(cuc => new YieldCurveReportParameter {", "\n GroupOfContract = loc.GroupOfContract,", "\n Period = cuc.Period,", "\n YieldCurveType = cuc.YieldCurveType,", From 732306013ac9a9ccc0a243676684d233676eeff6 Mon Sep 17 00:00:00 2001 From: Andrey Katz Date: Wed, 9 Aug 2023 20:36:30 +0200 Subject: [PATCH 3/4] saving the progress --- .../Constants/CalculationEngine.ipynb | 2 +- .../Test/MapTemplateAndImportTest.ipynb | 2 +- .../Test/ScenarioParametersImportTest.ipynb | 2 +- .../Test/ScenarioYieldCurveImportTest.ipynb | 2 +- ifrs17/Constants/Validations.ipynb | 368 +++++++++++------- ifrs17/Import/Importers.ipynb | 19 +- ifrs17/Report/ParameterReportsQueries.ipynb | 40 +- ifrs17/Test/DataNodeParameterTest.ipynb | 26 +- ifrs17/Test/QueriesTest.ipynb | 4 +- ifrs17/Utils/ApplicationMessage.ipynb | 4 +- ifrs17/Utils/Queries.ipynb | 29 -- 11 files changed, 283 insertions(+), 215 deletions(-) diff --git a/ifrs17-template/Constants/CalculationEngine.ipynb b/ifrs17-template/Constants/CalculationEngine.ipynb index 7d011d96..b8a11471 100644 --- a/ifrs17-template/Constants/CalculationEngine.ipynb +++ b/ifrs17-template/Constants/CalculationEngine.ipynb @@ -22,7 +22,7 @@ "var projectName = \"ifrs17\";", "\nvar environmentName = \"v1.3.1\";", "\nvar notebookName = \"CalculationEngine\";", - "\nvar calculationEngine = $\"#!import \\\"../../{projectName}/{notebookName}\\\"\";" + "\nvar calculationEngine = $\"#!import \\\"../../{projectName}/{environmentName}/{notebookName}\\\"\";" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index d87aad73..11d9254c 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -508,7 +508,7 @@ "\nawait Workspace.ValidateDataNodeStatesAsync(persistentDataNodeDataByDataNode);", "\nActivity.HasErrors().Should().Be(true);", "\nvar log = Activity.Finish().Errors.First().ToString().Substring(40);", - "\n(log.Substring(0,log.Length-2) == Get(Error.ChangeDataNodeState, \"GIC1\")).Should().Be(true);" + "\n(log.Substring(0,log.Length-2) == Error.ChangeDataNodeState.GetMessage(\"GIC1\")).Should().Be(true);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ScenarioParametersImportTest.ipynb b/ifrs17-template/Test/ScenarioParametersImportTest.ipynb index ff8fd02e..0abc120e 100644 --- a/ifrs17-template/Test/ScenarioParametersImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioParametersImportTest.ipynb @@ -260,7 +260,7 @@ { "cell_type": "code", "source": [ - "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Get(Warning.VariablesAlreadyImported)).Should().Be(true);" + "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Warning.VariablesAlreadyImported.GetMessage()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb index 243164fd..cc65f604 100644 --- a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb @@ -290,7 +290,7 @@ { "cell_type": "code", "source": [ - "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Get(Warning.VariablesAlreadyImported)).Should().Be(true);" + "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Warning.VariablesAlreadyImported.GetMessage()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index 49ecd6c5..290e12d1 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -47,12 +47,15 @@ { "cell_type": "code", "source": [ - "public enum Warning {", - "\n // Import", - "\n ActiveDataNodeWithCashflowBOPI, VariablesAlreadyImported, VariablesAlreadyCalculated, ScenarioReCalculations, MandatoryAocStepMissing,", - "\n // Default", - "\n Generic", - "\n}; " + "public abstract class ValidationBase{", + "\n public string MessageCode {get; protected set;}", + "\n", + "\n protected ValidationBase(string messageCode){", + "\n this.MessageCode = messageCode;", + "\n }", + "\n", + "\n public abstract string GetMessage(params string[] s);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -61,45 +64,30 @@ { "cell_type": "code", "source": [ - "public enum Error { ", - "\n // Import", - "\n NoMainTab, IncompleteMainTab, ParsingInvalidOrScientificValue, ValueTypeNotFound, ValueTypeNotValid, ", - "\n ReportingNodeInMainNotFound, YearInMainNotFound, MonthInMainNotFound, ScenarioInMainNotAvailable,", - "\n AocTypeNotValid, AocTypeCompulsoryNotFound, AocTypePositionNotSupported, AocConfigurationOrderNotUnique,", - "\n AccidentYearTypeNotValid,", - "\n // Partition", - "\n PartitionNotFound, ParsedPartitionNotFound, PartititionNameNotFound, PartitionTypeNotFound,", - "\n // Dimensions", - "\n AmountTypeNotFound, EstimateTypeNotFound, ReportingNodeNotFound, AocTypeMapNotFound, AocTypeNotFound, PortfolioGicNotFound, PortfolioGricNotFound, ", - "\n InvalidAmountTypeEstimateType, MultipleTechnicalMarginOpening, DimensionNotFound, NoScenarioOpening,", - "\n // Exchange Rate", - "\n ExchangeRateNotFound, ExchangeRateCurrency,", - "\n // Data Note State", - "\n ChangeDataNodeState, InactiveDataNodeState,", - "\n // Parameters", - "\n ReinsuranceCoverageDataNode, DuplicateInterDataNode, DuplicateSingleDataNode, MissingSingleDataNodeParameter, InvalidDataNode, InvalidDataNodeForOpening, InvalidCashFlowPeriodicity, MissingInterpolationMethod, InvalidInterpolationMethod, InvalidEconomicBasisDriver, InvalidReleasePattern,", - "\n // Storage", - "\n DataNodeNotFound, PartnerNotFound, PeriodNotFound, RatingNotFound, CreditDefaultRateNotFound, MissingPremiumAllocation, ReinsuranceCoverage, ", - "\n YieldCurveNotFound, YieldCurvePeriodNotApplicable, EconomicBasisNotFound, AccountingVariableTypeNotFound, InvalidGric, InvalidGic, ReleasePatternNotFound,", - "\n MissingPreviousPeriodData,", - "\n // Scopes", - "\n NotSupportedAocStepReference, MultipleEoP,", - "\n // Data completeness", - "\n MissingDataAtPosting, MissingCombinedLiability, MissingCoverageUnit, ", - "\n // Index", - "\n NegativeIndex,", - "\n // Default", - "\n Generic", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Messages" + "public class Warning : ValidationBase{", + "\n", + "\n protected const string DefaultMessage = \"Warning not found.\";", + "\n", + "\n protected Warning(string messageCode) : base(messageCode) {}", + "\n", + "\n public static readonly Warning ActiveDataNodeWithCashflowBOPI = new Warning(nameof(ActiveDataNodeWithCashflowBOPI));", + "\n public static readonly Warning VariablesAlreadyImported = new Warning(nameof(VariablesAlreadyImported));", + "\n public static readonly Warning VariablesAlreadyCalculated = new Warning(nameof(VariablesAlreadyCalculated));", + "\n public static readonly Warning ScenarioReCalculations = new Warning(nameof(ScenarioReCalculations));", + "\n public static readonly Warning MandatoryAocStepMissing = new Warning(nameof(MandatoryAocStepMissing));", + "\n public static readonly Warning Generic = new Warning(nameof(Generic));", + "\n", + "\n public override string GetMessage(params string[] s) => (MessageCode, s.Length) switch{", + "\n (nameof(ActiveDataNodeWithCashflowBOPI), 1) => $\"Cash flow with AoC Type: {AocTypes.BOP} and Novelty: {Novelties.I} for Group of Contract {s[0]} is not allowed because previous period data are available.\",", + "\n (nameof(VariablesAlreadyImported), 0) => $\"The import of the current file does not contain any new data. Hence, no data will be saved or calculations will be performed.\",", + "\n (nameof(MandatoryAocStepMissing), 3) => $\"The AoC step ({s[0]}, {s[1]}) is not imported for ({s[2]}).\",", + "\n (nameof(ScenarioReCalculations), 1) => $\"The present Best Estimate import makes the result of dependent Scenarios out of date. Hence, the following Scenarios are re-calculated: {s[0]}.\", ", + "\n // Default", + "\n (nameof(Generic), _) => $\"{s[0]}\",", + "\n _ => DefaultMessage", + "\n };", + "\n ", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -108,110 +96,196 @@ { "cell_type": "code", "source": [ - "public static string Get (Error e, params string[] s) => (e, s.Length) switch ", - "\n{", - "\n // Import", - "\n (Error.NoMainTab , _) => $\"No Main tab in the parsed file.\",", - "\n (Error.IncompleteMainTab , _) => $\"Incomplete Main tab in the parsed file.\",", - "\n (Error.ParsingInvalidOrScientificValue, 1) => $\"While parsing found invalid value or real number in scientific notation: {s[0]}.\",", - "\n (Error.ValueTypeNotFound , _) => $\"Value Type not found.\",", - "\n (Error.ValueTypeNotValid , 1) => $\"The Value Type {s[0]} is invalid.\",", - "\n (Error.ReportingNodeInMainNotFound , _) => $\"Reporting Node missing from the Main tab.\",", - "\n (Error.YearInMainNotFound , _) => $\"Year missing from the Main tab.\",", - "\n (Error.MonthInMainNotFound , _) => $\"Month missing from the Main tab.\",", - "\n (Error.ScenarioInMainNotAvailable , 1) => $\"Scenario {s[0]} has not been defined.\",", - "\n (Error.AocTypeNotValid , 1) => $\"The parsed AoC Type {s[0]} is invalid.\",", - "\n (Error.AocTypeCompulsoryNotFound , _) => $\"Not all compulsory AoC Types have been imported.\",", - "\n (Error.AocTypePositionNotSupported , 1) => $\"The position of the AoC Type {s[0]} is not supported.\",", - "\n (Error.AocConfigurationOrderNotUnique , _) => $\"Two or more AoC Configurations have the same Order.\",", - "\n (Error.AccidentYearTypeNotValid , 1) => $\"The parsed AccidentYear {s[0]} is invalid. Expected Accident Year input of type int.\",", - "\n // Partition", - "\n (Error.PartitionNotFound , _) => $\"Partition do not found.\",", - "\n (Error.ParsedPartitionNotFound , 1) => $\"Parsed partition not available: ReportingNode {s[0]}.\",", - "\n (Error.ParsedPartitionNotFound , 4) => $\"Parsed partition not available: ReportingNode {s[0]}, Year {s[1]}, Month {s[2]}, Scenario {s[3]}.\",", - "\n (Error.PartitionTypeNotFound , 1) => $\"Partition type not found: {s[0]}.\",", - "\n // Dimensions", - "\n (Error.AmountTypeNotFound , 1) => $\"AmountType {s[0]} not found.\",", - "\n (Error.EstimateTypeNotFound , 1) => $\"EstimateType {s[0]} not found.\",", - "\n (Error.ReportingNodeNotFound , 1) => $\"Reporting Node {s[0]} not found.\",", - "\n (Error.AocTypeNotFound , 1) => $\"AoC Type {s[0]} not found.\",", - "\n (Error.AocTypeMapNotFound , 2) => $\"AoC Type {s[0]} and Novelty {s[1]} combination not defined in the mapping.\",", - "\n (Error.PortfolioGicNotFound , 2) => $\"Portfolio {s[0]} assigned to Group of Insurance Contract {s[1]} does not exist.\",", - "\n (Error.PortfolioGricNotFound , 2) => $\"Portfolio {s[0]} assigned to Group of Reinsurance Contract {s[1]} does not exist.\",", - "\n (Error.InvalidAmountTypeEstimateType , 2) => $\"Invalid combination of EstimateType {s[0]} and AmountType {s[1]}.\",", - "\n (Error.MultipleTechnicalMarginOpening , 1) => $\"Multiple opening for techincal margin are not allowed for DataNode {s[0]}.\",", - "\n (Error.DimensionNotFound , 2) => $\"Column {0} has unknown value {1}.\",", - "\n (Error.NoScenarioOpening , 0) => \"Only Best Estimate is valid Scenario for Openings\",", + "public class Error : ValidationBase{", + "\n", + "\n protected const string DefaultMessage = \"Error not found.\";", "\n ", - "\n // Exchange Rate", - "\n (Error.ExchangeRateNotFound , 2) => $\"Exchange Rate for {s[0]} {s[1]} is not present.\",", - "\n (Error.ExchangeRateCurrency , 1) => $\"{s[0]} does not have any Exchange Rate defined.\", ", - "\n // Data Node State", - "\n (Error.ChangeDataNodeState , 0) => $\"Data Node State can not change from Inactive state into Active state.\",", - "\n (Error.ChangeDataNodeState , 1) => $\"Data Node State for {s[0]} can not change from Inactive state into Active state.\",", - "\n (Error.ChangeDataNodeState , 3) => $\"Data Node State for {s[0]} can not change from {s[1]} state into {s[2]} state.\",", - "\n (Error.InactiveDataNodeState , 1) => $\"Data imported for inactive Data Node {s[0]}.\",", - "\n //Parameters", - "\n (Error.ReinsuranceCoverageDataNode , 2) => $\"Invalid Reinsurance Coverage parameter does not link a GroupOfReinsuranceContract to a GroupOfInsuranceContract. Provided GroupOfContracts are: {s[0]}, {s[1]}.\",", - "\n (Error.DuplicateInterDataNode , 2) => $\"Duplicated Inter-DataNode parameter for {s[0]}-{s[1]} is found.\",", - "\n (Error.DuplicateSingleDataNode , 1) => $\"Duplicated Single-DataNode parameter for {s[0]} is found.\",", - "\n (Error.MissingSingleDataNodeParameter , 1) => $\"Single DataNode Parameter for Data Node {s[0]} is not found.\",", - "\n (Error.InvalidDataNode , 1) => $\"Data imported for invalid Data Node {s[0]}.\",", - "\n (Error.InvalidDataNodeForOpening , 1) => $\"Data imported for invalid Data Node or for a Data Node after its inception year {s[0]}.\",", - "\n (Error.InvalidCashFlowPeriodicity , 1) => $\"Invalid CashFlowPeriodicity parameter for Data Node {s[0]}.\",", - "\n (Error.MissingInterpolationMethod , 1) => $\"Missing InterpolationMethod parameter for Data Node {s[0]}.\",", - "\n (Error.InvalidInterpolationMethod , 1) => $\"Invalid InterpolationMethod parameter for Data Node {s[0]}.\",", - "\n (Error.InvalidEconomicBasisDriver , 1) => $\"Invalid EconomicBasisDriver parameter for Data Node {s[0]}.\",", - "\n (Error.InvalidReleasePattern , 1) => $\"Invalid ReleasePattern parameters for Data Node {s[0]}.\",", + "\n protected Error(string messageCode) : base(messageCode) {}", + "\n", + "\n // Import Errors", + "\n public static readonly Error NoMainTab = new Error(nameof(NoMainTab));", + "\n public static readonly Error IncompleteMainTab = new Error(nameof(IncompleteMainTab));", + "\n public static readonly Error ParsingInvalidOrScientificValue = new Error(nameof(ParsingInvalidOrScientificValue));", + "\n public static readonly Error ValueTypeNotFound = new Error(nameof(ValueTypeNotFound));", + "\n public static readonly Error ValueTypeNotValid = new Error(nameof(ValueTypeNotValid));", + "\n public static readonly Error ReportingNodeInMainNotFound = new Error(nameof(ReportingNodeInMainNotFound));", + "\n public static readonly Error YearInMainNotFound = new Error(nameof(YearInMainNotFound));", + "\n public static readonly Error MonthInMainNotFound = new Error(nameof(MonthInMainNotFound));", + "\n public static readonly Error ScenarioInMainNotAvailable = new Error(nameof(ScenarioInMainNotAvailable));", + "\n public static readonly Error AocTypeNotValid = new Error(nameof(AocTypeNotValid));", + "\n public static readonly Error AocTypeCompulsoryNotFound = new Error(nameof(AocTypeCompulsoryNotFound));", + "\n public static readonly Error AocTypePositionNotSupported = new Error(nameof(AocTypePositionNotSupported));", + "\n public static readonly Error AocConfigurationOrderNotUnique = new Error(nameof(AocConfigurationOrderNotUnique));", + "\n public static readonly Error AccidentYearTypeNotValid = new Error(nameof(AccidentYearTypeNotValid));", + "\n public static readonly Error TableNotFound = new Error(nameof(TableNotFound));", + "\n", + "\n // Partition Errors", + "\n public static readonly Error PartitionNotFound = new Error(nameof(PartitionNotFound));", + "\n public static readonly Error ParsedPartitionNotFound = new Error(nameof(ParsedPartitionNotFound));", + "\n public static readonly Error PartititionNameNotFound = new Error(nameof(PartititionNameNotFound));", + "\n public static readonly Error PartitionTypeNotFound = new Error(nameof(PartitionTypeNotFound));", + "\n", + "\n // Dimensions Errors", + "\n public static readonly Error AmountTypeNotFound = new Error(nameof(AmountTypeNotFound));", + "\n public static readonly Error EstimateTypeNotFound = new Error(nameof(EstimateTypeNotFound)); ", + "\n public static readonly Error ReportingNodeNotFound = new Error(nameof(ReportingNodeNotFound));", + "\n public static readonly Error AocTypeMapNotFound = new Error(nameof(AocTypeMapNotFound));", + "\n public static readonly Error AocTypeNotFound = new Error(nameof(AocTypeNotFound));", + "\n public static readonly Error PortfolioGicNotFound = new Error(nameof(PortfolioGicNotFound));", + "\n public static readonly Error PortfolioGricNotFound = new Error(nameof(PortfolioGricNotFound));", + "\n public static readonly Error InvalidAmountTypeEstimateType = new Error(nameof(InvalidAmountTypeEstimateType));", + "\n public static readonly Error MultipleTechnicalMarginOpening = new Error(nameof(MultipleTechnicalMarginOpening));", + "\n public static readonly Error DimensionNotFound = new Error(nameof(DimensionNotFound));", + "\n public static readonly Error NoScenarioOpening = new Error(nameof(NoScenarioOpening));", + "\n", + "\n // Exchange Rate Errors", + "\n public static readonly Error ExchangeRateNotFound = new Error(nameof(ExchangeRateNotFound));", + "\n public static readonly Error ExchangeRateCurrency = new Error(nameof(ExchangeRateCurrency));", + "\n", + "\n // Data Node State Errors", + "\n public static readonly Error ChangeDataNodeState = new Error(nameof(ChangeDataNodeState));", + "\n public static readonly Error InactiveDataNodeState = new Error(nameof(InactiveDataNodeState));", + "\n", + "\n // Parameters Errors", + "\n public static readonly Error ReinsuranceCoverageDataNode = new Error(nameof(ReinsuranceCoverageDataNode));", + "\n public static readonly Error DuplicateInterDataNode = new Error(nameof(DuplicateInterDataNode));", + "\n public static readonly Error DuplicateSingleDataNode = new Error(nameof(DuplicateSingleDataNode));", + "\n public static readonly Error MissingSingleDataNodeParameter = new Error(nameof(MissingSingleDataNodeParameter));", + "\n public static readonly Error InvalidDataNode = new Error(nameof(InvalidDataNode));", + "\n public static readonly Error InvalidDataNodeForOpening = new Error(nameof(InvalidDataNodeForOpening));", + "\n public static readonly Error InvalidCashFlowPeriodicity = new Error(nameof(InvalidCashFlowPeriodicity));", + "\n public static readonly Error MissingInterpolationMethod = new Error(nameof(MissingInterpolationMethod));", + "\n public static readonly Error InvalidInterpolationMethod = new Error(nameof(InvalidInterpolationMethod));", + "\n public static readonly Error InvalidEconomicBasisDriver = new Error(nameof(InvalidEconomicBasisDriver));", + "\n public static readonly Error InvalidReleasePattern = new Error(nameof(InvalidReleasePattern));", + "\n", + "\n // Storage Errors", + "\n public static readonly Error DataNodeNotFound = new Error(nameof(DataNodeNotFound));", + "\n public static readonly Error PartnerNotFound = new Error(nameof(PartnerNotFound));", + "\n public static readonly Error PeriodNotFound = new Error(nameof(PeriodNotFound));", + "\n public static readonly Error RatingNotFound = new Error(nameof(RatingNotFound));", + "\n public static readonly Error CreditDefaultRateNotFound = new Error(nameof(CreditDefaultRateNotFound));", + "\n public static readonly Error MissingPremiumAllocation = new Error(nameof(MissingPremiumAllocation));", + "\n public static readonly Error ReinsuranceCoverage = new Error(nameof(ReinsuranceCoverage));", + "\n public static readonly Error YieldCurveNotFound = new Error(nameof(YieldCurveNotFound));", + "\n public static readonly Error YieldCurvePeriodNotApplicable = new Error(nameof(YieldCurvePeriodNotApplicable));", + "\n public static readonly Error EconomicBasisNotFound = new Error(nameof(EconomicBasisNotFound));", + "\n public static readonly Error AccountingVariableTypeNotFound = new Error(nameof(AccountingVariableTypeNotFound));", + "\n public static readonly Error InvalidGric = new Error(nameof(InvalidGric));", + "\n public static readonly Error InvalidGic = new Error(nameof(InvalidGic));", + "\n public static readonly Error ReleasePatternNotFound = new Error(nameof(ReleasePatternNotFound));", + "\n public static readonly Error MissingPreviousPeriodData = new Error(nameof(MissingPreviousPeriodData));", + "\n", + "\n // Scopes Errors; Range 110 -119", + "\n public static readonly Error NotSupportedAocStepReference = new Error(nameof(NotSupportedAocStepReference));", + "\n public static readonly Error MultipleEoP = new Error(nameof(MultipleEoP));", + "\n", + "\n // Data Completeness Errors; Range 120 - 129", + "\n public static readonly Error MissingDataAtPosting = new Error(nameof(MissingDataAtPosting));", + "\n public static readonly Error MissingCombinedLiability = new Error(nameof(MissingCombinedLiability));", + "\n public static readonly Error MissingCoverageUnit = new Error(nameof(MissingCoverageUnit));", + "\n", + "\n // Index Error ", + "\n public static readonly Error NegativeIndex = new Error(nameof(NegativeIndex));", + "\n", + "\n // Generic Errors", + "\n public static readonly Error Generic = new Error(nameof(Generic)); ", + "\n", + "\n public override string GetMessage (params string[] s) => (MessageCode, s.Length) switch{", + "\n // Import", + "\n (nameof(NoMainTab), 0) => $\"No Main tab in the parsed file.\", ", + "\n (nameof(IncompleteMainTab), _) => $\"Incomplete Main tab in the parsed file.\",", + "\n (nameof(ParsingInvalidOrScientificValue), 1) => $\"While parsing found invalid value or real number in scientific notation: {s[0]}.\",", + "\n (nameof(ValueTypeNotFound), _) => $\"Value Type not found.\",", + "\n (nameof(ValueTypeNotValid), 1) => $\"The Value Type {s[0]} is invalid.\",", + "\n (nameof(ReportingNodeInMainNotFound), _) => $\"Reporting Node missing from the Main tab.\",", + "\n (nameof(YearInMainNotFound), _) => $\"Year missing from the Main tab.\",", + "\n (nameof(MonthInMainNotFound), _) => $\"Month missing from the Main tab.\",", + "\n (nameof(ScenarioInMainNotAvailable), 1) => $\"Scenario {s[0]} has not been defined.\",", + "\n (nameof(AocTypeNotValid), 1) => $\"The parsed AoC Type {s[0]} is invalid.\",", + "\n (nameof(AocTypeCompulsoryNotFound), _) => $\"Not all compulsory AoC Types have been imported.\",", + "\n (nameof(AocTypePositionNotSupported), 1) => $\"The position of the AoC Type {s[0]} is not supported.\",", + "\n (nameof(AocConfigurationOrderNotUnique), _) => $\"Two or more AoC Configurations have the same Order.\",", + "\n (nameof(AccidentYearTypeNotValid), 1) => $\"The parsed AccidentYear {s[0]} is invalid. Expected Accident Year input of type int.\",", + "\n (nameof(TableNotFound), 1) => $\"The import file does not contain table {s[0]}\",", + "\n (nameof(TableNotFound), 2) => $\"The import file contains table {s[0]} nor {s[1]}\",", + "\n", + "\n // Partition", + "\n (nameof(PartitionNotFound), _) => $\"Partition do not found.\",", + "\n (nameof(ParsedPartitionNotFound), 1) => $\"Parsed partition not available: ReportingNode {s[0]}.\",", + "\n (nameof(ParsedPartitionNotFound), 4) => $\"Parsed partition not available: ReportingNode {s[0]}, Year {s[1]}, Month {s[2]}, Scenario {s[3]}.\",", + "\n (nameof(PartitionTypeNotFound), 1) => $\"Partition type not found: {s[0]}.\",", + "\n", + "\n // Dimensions", + "\n (nameof(AmountTypeNotFound), 1) => $\"AmountType {s[0]} not found.\",", + "\n (nameof(EstimateTypeNotFound), 1) => $\"EstimateType {s[0]} not found.\",", + "\n (nameof(ReportingNodeNotFound), 1) => $\"Reporting Node {s[0]} not found.\",", + "\n (nameof(AocTypeNotFound), 1) => $\"AoC Type {s[0]} not found.\",", + "\n (nameof(AocTypeMapNotFound), 2) => $\"AoC Type {s[0]} and Novelty {s[1]} combination not defined in the mapping.\",", + "\n (nameof(PortfolioGicNotFound), 2) => $\"Portfolio {s[0]} assigned to Group of Insurance Contract {s[1]} does not exist.\",", + "\n (nameof(PortfolioGricNotFound), 2) => $\"Portfolio {s[0]} assigned to Group of Reinsurance Contract {s[1]} does not exist.\",", + "\n (nameof(InvalidAmountTypeEstimateType), 2) => $\"Invalid combination of EstimateType {s[0]} and AmountType {s[1]}.\",", + "\n (nameof(MultipleTechnicalMarginOpening), 1) => $\"Multiple opening for techincal margin are not allowed for DataNode {s[0]}.\",", + "\n (nameof(DimensionNotFound), 2) => $\"Column {0} has unknown value {1}.\",", + "\n (nameof(NoScenarioOpening), 0) => \"Only Best Estimate is valid Scenario for Openings\",", "\n ", - "\n // Storage", - "\n (Error.DataNodeNotFound , 1) => $\"DataNode {s[0]} not found.\",", - "\n (Error.PartnerNotFound , 1) => $\"Partner not found for DataNode {s[0]}.\",", - "\n (Error.PeriodNotFound , 1) => $\"Invalid Period {s[0]} used during calculation. Allowed values are Current Period (0) and Previous Period (-1).\",", - "\n (Error.RatingNotFound , 1) => $\"Rating not found for Partner {s[0]}.\",", - "\n (Error.CreditDefaultRateNotFound , 1) => $\"Credit Default Rate not found for rating {s[0]}.\",", - "\n (Error.MissingPremiumAllocation , 1) => $\"Premium Allocation Rate not found for Group of Contract {s[0]}.\", // TODO: this is now a warning to be produced by a validation in the importers (default is 1)", - "\n (Error.ReinsuranceCoverage , 1) => $\"Reinsurance Allocation Rate not found for Group of Insurance Contract {s[0]}.\",", - "\n (Error.YieldCurveNotFound , 6) => $\"Yield Curve not found for DataNode {s[0]}, Currency {s[1]}, Year {s[2]}, Month {s[3]}, Scenario {(s[4] == null ? \"Best Estimate\" : s[4])} and Name {s[5]}.\",", - "\n (Error.YieldCurvePeriodNotApplicable , 2) => $\"YieldCurve period NotApplicable not valid for AoC Step with AoC Type {s[0]} and Novelty {s[1]}.\",", - "\n (Error.EconomicBasisNotFound , 1) => $\"EconomicBasis not valid for DataNode {s[0]}.\",", - "\n (Error.AccountingVariableTypeNotFound , 1) => $\"AccountingVariableType {s[0]} not found.\",", - "\n (Error.InvalidGric , 1) => $\"Invalid Group of Reinsurance Contract {s[0]} has been requested during calculation.\",", - "\n (Error.InvalidGic , 1) => $\"Invalid Group of Insurance Contract {s[0]} has been requested during calculation.\",", - "\n (Error.ReleasePatternNotFound , 2) => $\"Release pattern for Group of Contract {s[0]} and AmountType {s[1]} is not found.\",", - "\n (Error.MissingPreviousPeriodData , 3) => $\"Data for previous period (Year: {s[0]}, Month: {s[1]}) is missing for Group of contracts: {s[2]}.\",", - "\n // Scopes", - "\n (Error.NotSupportedAocStepReference , 1) => $\"Unsupported reference AoC Step for AoC Type {s[0]}.\",", - "\n (Error.MultipleEoP , 0) => $\"Closing Balance for both Csm and Lc are computed.\",", - "\n // Data Completeness", - "\n (Error.MissingDataAtPosting , 1) => $\"Missing imported data for {s[0]} DataNode.\",", - "\n (Error.MissingCombinedLiability , 2) => $\"Missing Combined Liability AoC Type for DataNode {s[0]} and AmountType {s[1]}.\",", - "\n (Error.MissingCoverageUnit , 1) => $\"Missing Coverage Unit cash flow for {s[0]} DataNode.\",", - "\n // Index", - "\n (Error.NegativeIndex , 0) => $\"Index was out of range. Must be non-negative.\",", - "\n // Default", - "\n (Error.Generic , _) => $\"{s[0]}\",", - "\n (_ , _) => $\"Error not found.\"", - "\n};", - "\n" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public static string Get (Warning w, params string[] s) => (w, s.Length) switch {", - "\n // Import", - "\n (Warning.ActiveDataNodeWithCashflowBOPI , 1) => $\"Cash flow with AoC Type: {AocTypes.BOP} and Novelty: {Novelties.I} for Group of Contract {s[0]} is not allowed because previous period data are available.\",", - "\n (Warning.VariablesAlreadyImported , 0) => $\"The import of the current file does not contain any new data. Hence, no data will be saved or calculations will be performed.\",", - "\n (Warning.MandatoryAocStepMissing , 3) => $\"The AoC step ({s[0]}, {s[1]}) is not imported for ({s[2]}).\",", - "\n (Warning.ScenarioReCalculations , 1) => $\"The present Best Estimate import makes the result of dependent Scenarios out of date. Hence, the following Scenarios are re-calculated: {s[0]}.\", ", - "\n // Default", - "\n (Warning.Generic , _) => $\"{s[0]}\",", - "\n (_ , _) => $\"Warning not found.\"", - "\n};" + "\n // Exchange Rate", + "\n (nameof(ExchangeRateNotFound), 2) => $\"Exchange Rate for {s[0]} {s[1]} is not present.\",", + "\n (nameof(ExchangeRateCurrency), 1) => $\"{s[0]} does not have any Exchange Rate defined.\",", + "\n", + "\n // Data Node State", + "\n (nameof(ChangeDataNodeState), 0) => $\"Data Node State can not change from Inactive state into Active state.\",", + "\n (nameof(ChangeDataNodeState), 1) => $\"Data Node State for {s[0]} can not change from Inactive state into Active state.\",", + "\n (nameof(ChangeDataNodeState), 3) => $\"Data Node State for {s[0]} can not change from {s[1]} state into {s[2]} state.\",", + "\n (nameof(InactiveDataNodeState), 1) => $\"Data imported for inactive Data Node {s[0]}.\",", + "\n", + "\n //Parameters", + "\n (nameof(ReinsuranceCoverageDataNode), 2) => $\"Invalid Reinsurance Coverage parameter does not link a GroupOfReinsuranceContract to a GroupOfInsuranceContract. Provided GroupOfContracts are: {s[0]}, {s[1]}.\",", + "\n (nameof(DuplicateInterDataNode), 2) => $\"Duplicated Inter-DataNode parameter for {s[0]}-{s[1]} is found.\",", + "\n (nameof(DuplicateSingleDataNode), 1) => $\"Duplicated Single-DataNode parameter for {s[0]} is found.\",", + "\n (nameof(MissingSingleDataNodeParameter), 1) => $\"Single DataNode Parameter for Data Node {s[0]} is not found.\",", + "\n (nameof(InvalidDataNode), 1) => $\"Data imported for invalid Data Node {s[0]}.\",", + "\n (nameof(InvalidDataNodeForOpening), 1) => $\"Data imported for invalid Data Node or for a Data Node after its inception year {s[0]}.\",", + "\n (nameof(InvalidCashFlowPeriodicity), 1) => $\"Invalid CashFlowPeriodicity parameter for Data Node {s[0]}.\",", + "\n (nameof(MissingInterpolationMethod), 1) => $\"Missing InterpolationMethod parameter for Data Node {s[0]}.\",", + "\n (nameof(InvalidInterpolationMethod), 1) => $\"Invalid InterpolationMethod parameter for Data Node {s[0]}.\",", + "\n (nameof(InvalidEconomicBasisDriver), 1) => $\"Invalid EconomicBasisDriver parameter for Data Node {s[0]}.\",", + "\n (nameof(InvalidReleasePattern), 1) => $\"Invalid ReleasePattern parameters for Data Node {s[0]}.\",", + "\n ", + "\n // Storage", + "\n (nameof(DataNodeNotFound), 1) => $\"DataNode {s[0]} not found.\",", + "\n (nameof(PartnerNotFound), 1) => $\"Partner not found for DataNode {s[0]}.\",", + "\n (nameof(PeriodNotFound), 1) => $\"Invalid Period {s[0]} used during calculation. Allowed values are Current Period (0) and Previous Period (-1).\",", + "\n (nameof(RatingNotFound), 1) => $\"Rating not found for Partner {s[0]}.\",", + "\n (nameof(CreditDefaultRateNotFound), 1) => $\"Credit Default Rate not found for rating {s[0]}.\",", + "\n (nameof(MissingPremiumAllocation), 1) => $\"Premium Allocation Rate not found for Group of Contract {s[0]}.\", // TODO: this is now a warning to be produced by a validation in the importers (default is 1)", + "\n (nameof(ReinsuranceCoverage), 1) => $\"Reinsurance Allocation Rate not found for Group of Insurance Contract {s[0]}.\",", + "\n (nameof(YieldCurveNotFound), 6) => $\"Yield Curve not found for DataNode {s[0]}, Currency {s[1]}, Year {s[2]}, Month {s[3]}, Scenario {(s[4] == null ? \"Best Estimate\" : s[4])} and Name {s[5]}.\",", + "\n (nameof(YieldCurvePeriodNotApplicable), 2) => $\"YieldCurve period NotApplicable not valid for AoC Step with AoC Type {s[0]} and Novelty {s[1]}.\",", + "\n (nameof(EconomicBasisNotFound), 1) => $\"EconomicBasis not valid for DataNode {s[0]}.\",", + "\n (nameof(AccountingVariableTypeNotFound), 1) => $\"AccountingVariableType {s[0]} not found.\",", + "\n (nameof(InvalidGric), 1) => $\"Invalid Group of Reinsurance Contract {s[0]} has been requested during calculation.\",", + "\n (nameof(InvalidGic), 1) => $\"Invalid Group of Insurance Contract {s[0]} has been requested during calculation.\",", + "\n (nameof(ReleasePatternNotFound), 2) => $\"Release pattern for Group of Contract {s[0]} and AmountType {s[1]} is not found.\",", + "\n (nameof(MissingPreviousPeriodData), 3) => $\"Data for previous period (Year: {s[0]}, Month: {s[1]}) is missing for Group of contracts: {s[2]}.\",", + "\n", + "\n // Scopes", + "\n (nameof(NotSupportedAocStepReference), 1) => $\"Unsupported reference AoC Step for AoC Type {s[0]}.\",", + "\n (nameof(MultipleEoP), 0) => $\"Closing Balance for both Csm and Lc are computed.\",", + "\n", + "\n // Data Completeness", + "\n (nameof(MissingDataAtPosting), 1) => $\"Missing imported data for {s[0]} DataNode.\",", + "\n (nameof(MissingCombinedLiability), 2) => $\"Missing Combined Liability AoC Type for DataNode {s[0]} and AmountType {s[1]}.\",", + "\n (nameof(MissingCoverageUnit), 1) => $\"Missing Coverage Unit cash flow for {s[0]} DataNode.\",", + "\n", + "\n // Index", + "\n (nameof(NegativeIndex), 0) => $\"Index was out of range. Must be non-negative.\", ", + "\n", + "\n // Default", + "\n (nameof(Generic), 1) => $\"{s[0]}\", ", + "\n _ => DefaultMessage", + "\n };", + "\n}" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 770e66c4..d15c14ae 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -886,6 +886,7 @@ "\n Activity.Start();", "\n var primaryArgs = GetArgsFromMain(dataSet) with {ImportFormat = ImportFormats.YieldCurve};", "\n primaryArgs.ValidateArgsForPeriodAsync(options.TargetDataSource);", + "\n if (!dataSet.Tables.Contains(primaryArgs.ImportFormat)) ApplicationMessage.Log(Error.TableNotFound, primaryArgs.ImportFormat);", "\n if(ApplicationMessage.HasErrors()) return Activity.Finish();", "\n var workspace = Workspace.CreateNew();", "\n workspace.Initialize(x => x.FromSource(options.TargetDataSource)", @@ -985,6 +986,7 @@ "\n ", "\n Activity.Start();", "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, targetDataSource);", + "\n", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var storage = new ParsingStorage(args, targetDataSource, workspace);", @@ -1014,7 +1016,6 @@ "\n .ExecuteAsync();", "\n ", "\n var portfolios = await workspace.Query().ToDictionaryAsync(x => x.SystemName);", - "\n", "\n var yieldCurveColumnGroupOfInsuranceContract = dataSet.Tables.Contains(nameof(GroupOfInsuranceContract)) && dataSet.Tables[nameof(GroupOfInsuranceContract)].Columns.Any(x => x.ColumnName == nameof(GroupOfInsuranceContract.YieldCurveName));", "\n var yieldCurveColumnGroupOfReinsuranceContract = dataSet.Tables.Contains(nameof(GroupOfReinsuranceContract)) && dataSet.Tables[nameof(GroupOfReinsuranceContract)].Columns.Any(x => x.ColumnName == nameof(GroupOfReinsuranceContract.YieldCurveName));", "\n", @@ -1117,6 +1118,7 @@ "\n .DisableInitialization());", "\n Activity.Start();", "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, targetDataSource) with {ImportFormat = ImportFormats.DataNodeState};", + "\n if (!dataSet.Tables.Contains(args.ImportFormat)) ApplicationMessage.Log(Error.TableNotFound, args.ImportFormat);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var storage = new ParsingStorage(args, targetDataSource, workspace);", @@ -1288,6 +1290,8 @@ "\n Activity.Start();", "\n var primaryArgs = GetArgsFromMain(dataSet) with {ImportFormat = ImportFormats.DataNodeParameter};", "\n primaryArgs.ValidateArgsForPeriodAsync(options.TargetDataSource);", + "\n if (!dataSet.Tables.Contains(nameof(SingleDataNodeParameter)) && !dataSet.Tables.Contains(nameof(InterDataNodeParameter))) ", + "\n ApplicationMessage.Log(Error.TableNotFound, nameof(SingleDataNodeParameter), nameof(InterDataNodeParameter));", "\n if(ApplicationMessage.HasErrors()) return Activity.Finish();", "\n var workspace = Workspace.CreateNew();", "\n workspace.Initialize(x => x.FromSource(options.TargetDataSource).DisableInitialization().DisableInitialization());", @@ -1478,6 +1482,7 @@ "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Cashflow);", + "\n if(!dataSet.Tables.Contains(primaryArgs.ImportFormat)) ApplicationMessage.Log(Error.TableNotFound, primaryArgs.ImportFormat);", "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Cashflow, primaryArgs, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", @@ -1603,6 +1608,7 @@ "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Actual);", + "\n if(!dataSet.Tables.Contains(primaryArgs.ImportFormat)) ApplicationMessage.Log(Error.TableNotFound, primaryArgs.ImportFormat);", "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Actual, primaryArgs, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", @@ -1730,6 +1736,7 @@ "Import.DefineFormat(ImportFormats.SimpleValue, async (options, dataSet) => {", "\n Activity.Start();", "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, options.TargetDataSource) with {ImportFormat = ImportFormats.SimpleValue};", + "\n if(!dataSet.Tables.Contains(args.ImportFormat)) ApplicationMessage.Log(Error.TableNotFound, args.ImportFormat);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n await DataNodeFactoryAsync(dataSet, ImportFormats.SimpleValue, args, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", @@ -1769,6 +1776,7 @@ "\n Activity.Start();", "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet, options.TargetDataSource) with {ImportFormat = ImportFormats.Opening};", "\n if(primaryArgs.Scenario != default(string)) ApplicationMessage.Log(Error.NoScenarioOpening);", + "\n if(!dataSet.Tables.Contains(primaryArgs.ImportFormat)) ApplicationMessage.Log(Error.TableNotFound, primaryArgs.ImportFormat);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Opening);", @@ -1793,6 +1801,15 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Report/ParameterReportsQueries.ipynb b/ifrs17/Report/ParameterReportsQueries.ipynb index 52fc8ad4..187dbcda 100644 --- a/ifrs17/Report/ParameterReportsQueries.ipynb +++ b/ifrs17/Report/ParameterReportsQueries.ipynb @@ -277,22 +277,27 @@ "\n Name = x.Value.Name }", "\n )", "\n .ToArray();", - "\n ", - "\n var vfaYieldCurves = (await workspace.LoadVFAYieldCurveAsync(args, dataNodeData))", - "\n .Select(x => new YieldCurveReportParameter{", - "\n GroupOfContract = x.Key, ", - "\n YieldCurveType = \"VFA\", ", - "\n Year = x.Value.Year, ", - "\n Month = x.Value.Month, ", - "\n Currency = x.Value.Currency, ", - "\n Name = x.Value.Name", - "\n })", - "\n .ToArray();", - "\n", - "\n var vfaAndLockedYc = vfaYieldCurves.Concat(lockedYieldCurves);", "\n", "\n var currentYieldCurves = (await workspace.LoadCurrentYieldCurveAsync(args, dataNodeData))", - "\n .Values", + "\n .SelectMany(kvp => kvp.Value.Select(kvpInner => new YieldCurveReportParameter{", + "\n GroupOfContract = kvp.Key, ", + "\n YieldCurveType = \"CurrentCurve\", ", + "\n Year = kvpInner.Value.Year, ", + "\n Month = kvpInner.Value.Month, ", + "\n Scenario = kvpInner.Value.Scenario, ", + "\n Currency = kvpInner.Value.Currency, ", + "\n Name = kvpInner.Value.Name", + "\n })); ", + "\n /*", + "\n GroupOfContract = x.Key, ", + "\n YieldCurveType = \"CurrentCurve\", ", + "\n Year = x.Value.Year, ", + "\n Month = x.Value.Month, ", + "\n Scenario = x.Value.Scenario, ", + "\n Currency = x.Value.Currency, ", + "\n Name = x.Value.Name", + "\n }); */", + "\n /*.Values", "\n .SelectMany(x => x.Select(y => new YieldCurveReportParameter {", "\n Period = ((Period)y.Key),", "\n YieldCurveType = \"Current Curve\",", @@ -301,9 +306,9 @@ "\n Scenario = y.Value.Scenario,", "\n Currency = y.Value.Currency,", "\n Name = y.Value.Name}", - "\n ));", + "\n ));*/", "\n", - "\n var allYieldCurves = vfaAndLockedYc.Concat(vfaAndLockedYc.SelectMany(loc => currentYieldCurves.Select(cuc => new YieldCurveReportParameter {", + "\n /*var allYieldCurves = lockedYieldCurves.Concat(lockedYieldCurves.SelectMany(loc => currentYieldCurves.Select(cuc => new YieldCurveReportParameter {", "\n GroupOfContract = loc.GroupOfContract,", "\n Period = cuc.Period,", "\n YieldCurveType = cuc.YieldCurveType,", @@ -315,7 +320,8 @@ "\n )))", "\n .ToArray();", "\n ", - "\n return allYieldCurves;", + "\n return allYieldCurves; */", + "\n return currentYieldCurves.Concat(lockedYieldCurves).ToArray();", "\n}" ], "metadata": {}, diff --git a/ifrs17/Test/DataNodeParameterTest.ipynb b/ifrs17/Test/DataNodeParameterTest.ipynb index 758bf7e4..ed0263c0 100644 --- a/ifrs17/Test/DataNodeParameterTest.ipynb +++ b/ifrs17/Test/DataNodeParameterTest.ipynb @@ -186,9 +186,9 @@ "\nDataNodeInvalid1,DTR1.1,1", "\nDTR1.1,DataNodeInvalid2,1\";", "\n", - "\nvar errorsBm = new List(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),", - "\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),", - "\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};" + "\nvar errorsBm = new List(){Error.InvalidDataNode.GetMessage(\"DataNodeInvalid0\"),", + "\n Error.InvalidDataNode.GetMessage(\"DataNodeInvalid1\"),", + "\n Error.InvalidDataNode.GetMessage(\"DataNodeInvalid2\")};" ], "metadata": {}, "execution_count": 0, @@ -231,8 +231,8 @@ "\nDTR1.1,DT1.1,1", "\nDT1.1,DTR1.1,1", "\n\";", - "\nvar errorsBm = new List(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),", - "\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};" + "\nvar errorsBm = new List(){Error.DuplicateSingleDataNode.GetMessage(\"DT1.1\"),", + "\n Error.DuplicateInterDataNode.GetMessage(\"DT1.1\",\"DTR1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -273,7 +273,7 @@ "\nDataNode,LinkedDataNode,ReinsuranceCoverage", "\nDT1.1,DT1.1,1", "\n\";", - "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};" + "\nvar errorsBm = new List(){Error.ReinsuranceCoverageDataNode.GetMessage(\"DT1.1\",\"DT1.1\")};" ], "metadata": {}, "execution_count": 0, @@ -319,7 +319,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,Monthly,InvalidEntry", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidInterpolationMethod, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidInterpolationMethod.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -393,7 +393,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,Yearly,,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidInterpolationMethod, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidInterpolationMethod.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -439,7 +439,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,A,,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidCashFlowPeriodicity, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidCashFlowPeriodicity.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -477,7 +477,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,,Uniform,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidCashFlowPeriodicity, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidCashFlowPeriodicity.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -514,7 +514,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,,,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidCashFlowPeriodicity, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidCashFlowPeriodicity.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -560,7 +560,7 @@ "\nDataNode,PremiumAllocation,EconomicBasisDriver", "\nDT1.1,0.85,A", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidEconomicBasisDriver, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidEconomicBasisDriver.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -687,7 +687,7 @@ "\nDataNode,PremiumAllocation,ReleasePattern0,ReleasePattern1", "\nDT1.1,0.85,InvalidValue0,InvalidValue1", "\n\";", - "\nvar errorsBm = new List(){Get(Error.ParsingInvalidOrScientificValue, \"InvalidValue0\"),Get(Error.ParsingInvalidOrScientificValue, \"InvalidValue1\")};" + "\nvar errorsBm = new List(){Error.ParsingInvalidOrScientificValue.GetMessage(\"InvalidValue0\"), Error.ParsingInvalidOrScientificValue.GetMessage(\"InvalidValue1\")};" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index 7232f5c1..0d55a8ec 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -783,7 +783,7 @@ { "cell_type": "code", "source": [ - "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"DT1.1\", \"EUR\",\"2016\",\"12\",\"Best Estimate\",\"A\");", + "var expectedErrorMessage = Error.YieldCurveNotFound.GetMessage(\"DT1.1\", \"EUR\",\"2016\",\"12\",\"Best Estimate\",\"A\");", "\nvar errorMessage = activity.Errors.First().ToString();", "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true);" ], @@ -822,7 +822,7 @@ { "cell_type": "code", "source": [ - "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"DT1.1\", \"EUR\",\"2016\",\"9\",\"Best Estimate\",\"A\");", + "var expectedErrorMessage = Error.YieldCurveNotFound.GetMessage(\"DT1.1\", \"EUR\",\"2016\",\"9\",\"Best Estimate\",\"A\");", "\nvar errorMessage = activity.Errors.First().ToString();", "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true);" ], diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index 64c766ed..8e59018c 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -51,8 +51,8 @@ "\n ApplicationMessage.activity = activity;", "\n }", "\n ", - "\n public static Object Log (Error e, params string[] s) { log.LogError(Get(e,s)); return null; }", - "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(Get(w,s)); return null; }", + "\n public static Object Log (Error e, params string[] s) { log.LogError(e.GetMessage(s)); return null; }", + "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(w.GetMessage(s)); return null; }", "\n ", "\n public static Object Log (ActivityLog activityLog) {", "\n foreach(var error in activityLog.Errors) log.LogError(error.ToString());", diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index 086abc37..593b57bc 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -213,35 +213,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "# Data Nodes with VFA valuation" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public static async Task> LoadVFAYieldCurveAsync(this IQuerySource querySource, Args args, IEnumerable dataNodes)", - "\n{", - "\n var YiieldCurveByGoc = new Dictionary();", - "\n foreach(var dn in dataNodes.Where(x => x.ValuationApproach == ValuationApproaches.VFA)){", - "\n var monthUpperLimit = args.Year == dn.Year ? args.Month : MonthInAYear;", - "\n var argsNew = args with {Year = dn.Year, Month = monthUpperLimit, Scenario = args.Scenario};", - "\n var loadedYc = await querySource.LoadCurrentParameterAsync(argsNew, x => x.Currency, x => x.Currency == dn. ContractualCurrency && x.Name == dn.YieldCurveName);", - "\n if (loadedYc.TryGetValue(dn.ContractualCurrency, out var vfaYc)) YiieldCurveByGoc[dn.DataNode] = vfaYc;", - "\n // Should we load an error or a warning if the did not succeed to get value? - A.K. ", - "\n }", - "\n return YiieldCurveByGoc;", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ From 6d5eee5e4e378f0556554c7d968081e73f3e330e Mon Sep 17 00:00:00 2001 From: Andrey Katz Date: Thu, 10 Aug 2023 09:30:56 +0200 Subject: [PATCH 4/4] cleanup --- ifrs17/Report/ParameterReportsQueries.ipynb | 33 +-------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/ifrs17/Report/ParameterReportsQueries.ipynb b/ifrs17/Report/ParameterReportsQueries.ipynb index 187dbcda..7ed8af8a 100644 --- a/ifrs17/Report/ParameterReportsQueries.ipynb +++ b/ifrs17/Report/ParameterReportsQueries.ipynb @@ -281,6 +281,7 @@ "\n var currentYieldCurves = (await workspace.LoadCurrentYieldCurveAsync(args, dataNodeData))", "\n .SelectMany(kvp => kvp.Value.Select(kvpInner => new YieldCurveReportParameter{", "\n GroupOfContract = kvp.Key, ", + "\n Period = (Period)kvpInner.Key, ", "\n YieldCurveType = \"CurrentCurve\", ", "\n Year = kvpInner.Value.Year, ", "\n Month = kvpInner.Value.Month, ", @@ -288,39 +289,7 @@ "\n Currency = kvpInner.Value.Currency, ", "\n Name = kvpInner.Value.Name", "\n })); ", - "\n /*", - "\n GroupOfContract = x.Key, ", - "\n YieldCurveType = \"CurrentCurve\", ", - "\n Year = x.Value.Year, ", - "\n Month = x.Value.Month, ", - "\n Scenario = x.Value.Scenario, ", - "\n Currency = x.Value.Currency, ", - "\n Name = x.Value.Name", - "\n }); */", - "\n /*.Values", - "\n .SelectMany(x => x.Select(y => new YieldCurveReportParameter {", - "\n Period = ((Period)y.Key),", - "\n YieldCurveType = \"Current Curve\",", - "\n Year = y.Value.Year,", - "\n Month = y.Value.Month,", - "\n Scenario = y.Value.Scenario,", - "\n Currency = y.Value.Currency,", - "\n Name = y.Value.Name}", - "\n ));*/", - "\n", - "\n /*var allYieldCurves = lockedYieldCurves.Concat(lockedYieldCurves.SelectMany(loc => currentYieldCurves.Select(cuc => new YieldCurveReportParameter {", - "\n GroupOfContract = loc.GroupOfContract,", - "\n Period = cuc.Period,", - "\n YieldCurveType = cuc.YieldCurveType,", - "\n Year = cuc.Year,", - "\n Month = cuc.Month,", - "\n Scenario = cuc.Scenario,", - "\n Currency = cuc.Currency,", - "\n Name = cuc.Name}", - "\n )))", - "\n .ToArray();", "\n ", - "\n return allYieldCurves; */", "\n return currentYieldCurves.Concat(lockedYieldCurves).ToArray();", "\n}" ],