## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(solvency2) ## ----context------------------------------------------------------------------ ctx <- Context("2025-01-17", "2026-09-23", "EUR", "EU-S2-DOCUMENTS-2024-2025-v0.1") names(rule_profiles()$profiles) result <- intangible_risk(100, context = ctx) result result$sources ## ----formula------------------------------------------------------------------ aggregate_risk(list(premium_reserve = 3, lapse = 4), matrix_id = "health_nslt", context = ctx)$value ## ----graph-------------------------------------------------------------------- nodes <- list( intangible = list("function" = "intangible_risk", inputs = list(amount = 100)) ) # Reference cases provide the exact input names for any formula: case <- Filter(function(x) x[["function"]] == "intangible_risk" && is.null(x$expected_error), reference_cases()$cases)[[1]] nodes$intangible$inputs <- case$kwargs runner <- Engine() runner$run(nodes, context = ctx)$results$intangible$value runner$run(nodes, context = ctx)$cache_hits ## ----curve-------------------------------------------------------------------- curve <- DiscountCurve("synthetic-one-year", "2025-01-17", "EUR", "custom", "invented example", list(list("2026-01-17", 0.97))) discount_curve_factor(curve, "2026-01-17") cashflows <- list("2026-01-17" = list(expected_inflows = 10, expected_outflows = 100)) best_estimate_with_curve(cashflows, curve, runoff_complete = TRUE, cashflow_reference = "synthetic complete runoff", context = ctx)$value ## ----scenario----------------------------------------------------------------- scenario <- ctx scenario$overrides <- list(NumericOverride( "profile.json", list("scalars", "intangible", "value"), 0.70, "Synthetic analyst sensitivity" )) intangible_risk(100, context = scenario)$status parameter("scalars/intangible", scenario)$analyst_overrides intangible_risk(100, context = ctx)$value ## ----reporting---------------------------------------------------------------- bindings <- list(v1 = list(value = 1005, decimals = 0), v2 = list(values = list(list(value = 1000, decimals = 0)))) reporting_bound_rule_check("BV1053-1", bindings, "2.8.2", "synthetic selection")$value reporting_bound_rule_check("BV1053-1", bindings, "2.10.0", "synthetic selection")$value ## ----failure------------------------------------------------------------------ tryCatch(intangible_risk(Inf, context = ctx), CalculationError = function(error) { list(code = error$code, field = error$field) }) length(reference_cases()$cases) length(reference_portfolios()$portfolios) reference_datasets()