## reserving.Ifrs17Group


A group of insurance contracts under IFRS 17's general measurement


Usage

``` python
reserving.Ifrs17Group()
```


model, recognised from its expected cash flows and rolled forward a period at a time (`docs/design/reserving-ifrs17-measurement.md`).

The group holds its state: [roll_forward()](reserving.PaaGroup.md#prospicio.reserving.PaaGroup.roll_forward) changes it, and [to_json()](models.Terms.md#prospicio.models.Terms.to_json) (or `pickle`) saves it to roll forward next period.


## Parameters


`expected: dict`  
The expected cash flows by future period, the next first: lists under [premiums](credibility.BuhlmannStraubFit.md#prospicio.credibility.BuhlmannStraubFit.premiums), [claims](distributions.SizeOfLoss.md#prospicio.distributions.SizeOfLoss.claims), [expenses](pricing.Quote.md#prospicio.pricing.Quote.expenses), `acquisition` and `investment_component` (absent ones nil), and optionally `premium_timing`, `claim_timing` and `acquisition_timing` (`"start"`, `"mid"` or `"end"`; premiums and acquisition at the start and claims at the end by default).

`risk_adjustment: float`  
The RA at recognition.

`curve: DiscountCurve`  
The locked-in curve.

`coverage_units: list of float`  
One per period of coverage; equal by default.

`discount_coverage_units: bool = ``False`  

`period_years: float = ``1.0`  

`oci: bool = ``False`  
Disaggregate insurance finance income or expense: profit or loss takes it at the [allocation](reinsurance.Layer.md#prospicio.reinsurance.Layer.allocation)'s rates, OCI the rest.

`accretion_curve: DiscountCurve`  
The curve the CSM accretes at, when it differs.

`allocation: str = ``"locked_in"`  
How profit or loss takes the finance expense under `oci`: `"locked_in"` (B131), or for cash flows that vary with financial risk `"effective_yield"` (B132(a)(i)) or `"projected_crediting"` (B132(a)(ii)); see the Rust reference of `FinanceAllocation`.

`crediting_rates: list of float`  
For `"projected_crediting"`: the crediting rates expected at recognition, one per period, as fractions.


## Examples

``` python
>>> from prospicio.reserving import DiscountCurve, Ifrs17Group
>>> # IFRS 17 Example 1A: premium 900 at once, claims of 200 a year, RA 120.
>>> g = Ifrs17Group({"premiums": [900.0, 0.0, 0.0], "claims": [200.0] * 3}, 120.0,
...                 DiscountCurve.flat(0.05))
>>> round(g.balances["csm"])
```

235

``` python
>>> year = g.roll_forward(g.as_expected(), {"claims": [200.0] * 2}, 80.0)
>>> round(year["closing"]["csm"]), round(year["closing"]["liability"])
```

(165, 617)


## Attributes

| Name | Description |
|----|----|
| [allocation_rates](#allocation_rates) | The rates per period at which profit or loss accretes the present |
| [balances](#balances) | The balances after the last period (at recognition before the |
| [locked_in_curve](#locked_in_curve) | The locked-in curve: the curve at recognition, or the weighted |
| [period](#period) | The periods rolled forward. |

------------------------------------------------------------------------


#### allocation_rates


The rates per period at which profit or loss accretes the present


`allocation_rates: list[float]`


value over the remaining periods under `"effective_yield"` or `"projected_crediting"`, the next first; empty under `"locked_in"`.


------------------------------------------------------------------------


#### balances


The balances after the last period (at recognition before the


`balances: dict`


first): `present_value`, `present_value_locked_in`, `present_value_allocated` (at the allocation's rates), [risk_adjustment](reserving.DiscountedReserves.md#prospicio.reserving.DiscountedReserves.risk_adjustment), `csm`, `loss_component`, `liability` and `accumulated_oci`.


------------------------------------------------------------------------


#### locked_in_curve


The locked-in curve: the curve at recognition, or the weighted


`locked_in_curve: DiscountCurve`


average after [add_contracts()](reserving.Ifrs17Group.md#prospicio.reserving.Ifrs17Group.add_contracts).


------------------------------------------------------------------------


#### period


The periods rolled forward.


`period: int`


## Methods

| Name | Description |
|----|----|
| [add_contracts()](#add_contracts) | Add contracts sold within the cohort's year, at the current period |
| [as_expected()](#as_expected) | The next period's cash flows as expected, a dict for |
| [from_json()](#from_json) | The group a [to_json()](models.Terms.md#prospicio.models.Terms.to_json) document describes. |
| [roll_forward()](#roll_forward) | Roll the group forward over one period. |
| [to_json()](#to_json) | The state as a JSON document (format `risk_rs.ifrs17_group`) that |

------------------------------------------------------------------------


#### add_contracts()


Add contracts sold within the cohort's year, at the current period


Usage

``` python
add_contracts(expected, risk_adjustment, curve, coverage_units)
```


end (at recognition before the first period).

The contracts are measured at their own [curve](esg.Scenarios.md#prospicio.esg.Scenarios.curve) (maturities from the period end): a net inflow adds to the CSM, a net outflow to the loss component, both on the next period's `new_contracts` line. The group's locked-in curve becomes the weighted average of its own and [curve](esg.Scenarios.md#prospicio.esg.Scenarios.curve), weighted by the present values of the claims and expenses (B72(b), B73); the change in the locked-in present value is finance income or expense of the next period.


##### Parameters


`expected: dict`  
The contracts' expected cash flows from the next period, as for the constructor, with the group's timings.

`risk_adjustment: float`  

`curve: DiscountCurve`  

`coverage_units: list of float`  
The contracts' coverage units by future period, added to the group's.


##### Examples

``` python
>>> from prospicio.reserving import DiscountCurve, Ifrs17Group
>>> flat = DiscountCurve.flat(0.0)
>>> g = Ifrs17Group({"premiums": [900.0, 0.0], "claims": [400.0] * 2}, 30.0, flat,
...                 coverage_units=[1.0, 1.0])
>>> g.add_contracts({"premiums": [450.0, 0.0], "claims": [200.0] * 2}, 15.0, flat,
...                 [0.5, 0.5])
>>> round(g.balances["csm"])
```

105

------------------------------------------------------------------------


#### as_expected()


The next period's cash flows as expected, a dict for


Usage

``` python
as_expected()
```


[roll_forward()](reserving.PaaGroup.md#prospicio.reserving.PaaGroup.roll_forward)'s `actual`.


------------------------------------------------------------------------


#### from_json()


The group a [to_json()](models.Terms.md#prospicio.models.Terms.to_json) document describes.


Usage

``` python
from_json(text)
```


------------------------------------------------------------------------


#### roll_forward()


Roll the group forward over one period.


Usage

``` python
roll_forward(
    actual,
    expected,
    risk_adjustment,
    risk_adjustment_released=None,
    acquisition_recovered=None,
    future_coverage_units=None,
    current_curve=None,
    financial_revision=None,
    crediting_rates=None
)
```


##### Parameters


`actual: dict`  
What happened in the period: [premiums](credibility.BuhlmannStraubFit.md#prospicio.credibility.BuhlmannStraubFit.premiums), `premiums_for_future_service`, [claims](distributions.SizeOfLoss.md#prospicio.distributions.SizeOfLoss.claims), [expenses](pricing.Quote.md#prospicio.pricing.Quote.expenses), `acquisition` and `investment_component` (absent ones nil).

`expected: dict`  
The expected cash flows as at the period end, as for the constructor.

`risk_adjustment: float`  
The RA at the period end.

`risk_adjustment_released: float = None`  
By coverage units when not given.

`acquisition_recovered: float = None`  
By coverage units when not given.

`future_coverage_units: list of float = None`  

`current_curve: DiscountCurve = None`  
The curve at the period end, maturities from then.

`financial_revision: dict = None`  
The opening view revised for financial assumptions.

`crediting_rates: list of float = None`  
For `"projected_crediting"`: the rate credited in the period, then those expected after it; the opening ones when not given.


##### Returns


`dict`  
The profit or loss lines, `by_component` and `by_coverage` (the two reconciliations, as columns with a `line` name), and `closing`.


------------------------------------------------------------------------


#### to_json()


The state as a JSON document (format `risk_rs.ifrs17_group`) that


Usage

``` python
to_json()
```


[from_json()](models.Terms.md#prospicio.models.Terms.from_json) reads, to roll forward from where it stopped.


##### Examples

``` python
>>> from prospicio.reserving import DiscountCurve, Ifrs17Group
>>> g = Ifrs17Group({"premiums": [900.0, 0.0], "claims": [400.0] * 2}, 30.0,
...                 DiscountCurve.flat(0.0))
>>> Ifrs17Group.from_json(g.to_json()).balances == g.balances
```

True
