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
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
{
"metadata": {
"authors": [],
"id": "qeOnUAhRJ0ihlDezHlrM-w",
"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": "markdown",
"source": [
"<p style=\"font-weight:bold;\"> <span style=\"font-size: 36px\"> Interact With Import Scope Calculation</span> </p>",
"\n",
"\n<br><br>",
"\nAfter successfully loading the parsed data in the dataSource, the import scopes with for a specific partition can be re-evaluated in this notebook. ",
"\nThe import scopes can then be displayed, examined and used for further calculations."
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Basic Initialization"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#!import \"../../Constants/CalculationEngine\""
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var mystring = $\"#!eval-notebook \\\"//{projectName}/{environmentName}/{notebookName}\\\"\";",
"\nmystring"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#!eval mystring"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#!eval-notebook \"../../Initialization/InitSystemorphBaseToMemory\"",
"\nWorkspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());",
"\nWorkspace.InitializeFrom(DataSource);"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Import of parsed data"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"Debug.Enable = true;"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"await Import.FromFile(\"../../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")",
"\n .WithFormat(ImportFormats.Cashflow)",
"\n .WithTarget(DataSource)",
"\n .WithActivityLog()",
"\n .ExecuteAsync()"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Args"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Primary Args"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var reportingNode = \"CH\";",
"\nvar year = 2020;",
"\nvar month = 12;",
"\nvar importFormat = ImportFormats.Cashflow;",
"\nvar scenario = (string)null;",
"\n",
"\nImportArgs args = new ImportArgs(reportingNode, year, month, default(Periodicity), scenario, importFormat);",
"\nargs"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Secondary Args"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var allArgs = await GetAllArgsAsync(args, DataSource, ImportFormats.Cashflow);",
"\nallArgs"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"// var workspaceToCompute = Workspace.CreateNew();",
"\n// workspaceToCompute.InitializeFrom(DataSource);"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"// await ComputeAsync(args, Workspace, workspaceToCompute, true)"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Construct ImportStorage"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var storage = new ImportStorage(args, DataSource, Workspace);",
"\nawait storage.InitializeAsync();"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Create universe and Identities"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var universe = Scopes.ForStorage(storage).ToScope<IModel>();",
"\nvar identities = universe.GetScopes<GetIdentities>(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var ret = universe.GetScopes<CumulatedNominal>(identities)",
"\n .SelectMany(x => x.PresentValues)",
"\n .Select(x => new {Value= x.Value, ",
"\n Id = x.Identity.Id, ",
"\n AmoutType = x.Identity.AmountType,",
"\n EstimateType = x.Identity.EstimateType,",
"\n AccidentYear = x.Identity.AccidentYear});",
"\nret.ToArray();"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"var ivs = Scopes.ForIdentities(identities, storage).ToScopes<ComputeAllScopes>().SelectMany(x => x.CalculatedIfrsVariables).ToArray();"
],
"metadata": {},
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"source": [
"await Workspace.UpdateAsync<IfrsVariable>(ivs.Where(x => storage.DefaultPartition != storage.TargetPartition || Math.Abs(x.Value) >= Precision));"
],
"metadata": {},
"execution_count": 0,
"outputs": []
}
]
}
Loading