## reinsurance.Layer


A per-occurrence excess-of-loss layer: [limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment) on each


Usage


``` python
reinsurance.Layer()
```


loss, then annual terms.

For one year, `ceded = share * min(max(sum of per-loss recoveries - aggregate_deductible, 0), aggregate_limit)`, less any loss corridor ([with_loss_corridor](reinsurance.Layer.md#prospicio.reinsurance.Layer.with_loss_corridor)) before the annual limit.


## Parameters


`name: str`  

`limit: float`  
Per-occurrence limit; may be `inf`.

`attachment: float`  

`share: float = ``1.0`  
Placed share, in `(0, 1]`.

`aggregate_deductible: float = ``0.0`  

`aggregate_limit: float = inf`  

`reinstatements: int`  
Free reinstatements: sets [aggregate_limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.aggregate_limit) to `limit * (reinstatements + 1)`; cannot be combined with [aggregate_limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.aggregate_limit).

`premium: float = ``0.0`  
Upfront premium for the placed share; used only by [reinstatement_rates](reinsurance.Layer.md#prospicio.reinsurance.Layer.reinstatement_rates).

`reinstatement_rates: list of float`  
Paid reinstatements, one rate per reinstatement as a fraction of [premium](pricing.Price.md#prospicio.pricing.Price.premium) (1.0 is 100%), pro rata as to amount. Sets [aggregate_limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.aggregate_limit) to `limit * (len(reinstatement_rates) + 1)`; cannot be combined with [aggregate_limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.aggregate_limit) or `reinstatements`.

`pro_rata_time: bool = ``False`  
Paid reinstatements also pro rata as to time: the limit a loss at time [t](distributions.Pareto.md#prospicio.distributions.Pareto.t) (the fraction of the year elapsed) uses up is charged at `1 - t`. Needs [reinstatement_rates](reinsurance.Layer.md#prospicio.reinsurance.Layer.reinstatement_rates), and events with times ([EventSet.with_uniform_times](aggregate.EventSet.md#prospicio.aggregate.EventSet.with_uniform_times), or `times=` in [EventSet.from_years](aggregate.EventSet.md#prospicio.aggregate.EventSet.from_years)).


## Raises


`ValueError`  
If a term is out of range, or more than one of [aggregate_limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.aggregate_limit), `reinstatements` and [reinstatement_rates](reinsurance.Layer.md#prospicio.reinsurance.Layer.reinstatement_rates) is given.


## Examples

``` python
>>> from prospicio.reinsurance import Layer
>>> layer = Layer("5x5", 5e6, 5e6, reinstatements=1)
>>> layer.ceded([7e6])
```

2000000.0

``` python
>>> layer.ceded([12e6, 20e6, 30e6])
```

10000000.0

``` python
>>> paid = Layer("10x10", 10.0, 10.0, premium=2.0, reinstatement_rates=[1.0, 0.5])
>>> paid.reinstatement_premium([22.0, 12.0])
```

2.2

``` python
>>> timed = Layer("10x10", 10.0, 10.0, premium=2.0, reinstatement_rates=[1.0, 0.5],
...               pro_rata_time=True)
>>> round(timed.reinstatement_premium([22.0, 12.0], times=[0.25, 0.5]), 12)
```

1.6


## Attributes

| Name | Description |
|----|----|
| [aggregate_deductible](#aggregate_deductible) | Annual aggregate deductible. |
| [aggregate_limit](#aggregate_limit) | Annual aggregate limit. |
| [attachment](#attachment) | Per-occurrence attachment. |
| [limit](#limit) | Per-occurrence limit. |
| [loss_corridor](#loss_corridor) | The loss corridor as `(lower, upper, retained)`, or `None`. |
| [name](#name) | Layer name. |
| [needs_sums_insured](#needs_sums_insured) | Whether the layer is a surplus treaty, which needs sums insured. |
| [premium](#premium) | Upfront premium for the placed share. |
| [pro_rata_time](#pro_rata_time) | Whether paid reinstatements are pro rata as to time. |
| [reinstatement_rates](#reinstatement_rates) | Rate of each paid reinstatement; empty when reinstatements are free. |
| [share](#share) | Placed share. |

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


#### aggregate_deductible


Annual aggregate deductible.


`aggregate_deductible: float`


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


#### aggregate_limit


Annual aggregate limit.


`aggregate_limit: float`


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


#### attachment


Per-occurrence attachment.


`attachment: float`


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


#### limit


Per-occurrence limit.


`limit: float`


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


#### loss_corridor


The loss corridor as `(lower, upper, retained)`, or `None`.


`loss_corridor: tuple[float, float, float] | None`


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


#### name


Layer name.


`name: str`


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


#### needs_sums_insured


Whether the layer is a surplus treaty, which needs sums insured.


`needs_sums_insured: bool`


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


#### premium


Upfront premium for the placed share.


`premium: float`


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


#### pro_rata_time


Whether paid reinstatements are pro rata as to time.


`pro_rata_time: bool`


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


#### reinstatement_rates


Rate of each paid reinstatement; empty when reinstatements are free.


`reinstatement_rates: list[float]`


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


#### share


Placed share.


`share: float`


## Methods

| Name | Description |
|----|----|
| [ceded()](#ceded) | Ceded loss for one year's losses. |
| [ceded_by_event()](#ceded_by_event) | Ceded loss per event for one year, taking losses as chronological. |
| [ceded_with_sums_insured()](#ceded_with_sums_insured) | Ceded loss for one year's losses on risks with the given sums |
| [quota_share()](#quota_share) | A quota share ceding `cession` of every loss. |
| [reinstatement_premium()](#reinstatement_premium) | Reinstatement premium for one year's losses. |
| [stop_loss()](#stop_loss) | An aggregate stop-loss: [limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.limit) xs `retention` on the year's total. |
| [surplus()](#surplus) | A surplus treaty: each risk cedes the part of its sum insured above |
| [with_loss_corridor()](#with_loss_corridor) | The same layer with a loss corridor. |

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


#### ceded()


Ceded loss for one year's losses.


Usage


``` python
ceded(losses)
```


##### Parameters


`losses: list of float`  


##### Returns


`float`  


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


#### ceded_by_event()


Ceded loss per event for one year, taking losses as chronological.


Usage


``` python
ceded_by_event(losses)
```


The annual deductible absorbs the first recoveries and the annual limit stops the last ones; the entries sum to `ceded(losses)`.


##### Parameters


`losses: list of float`  


##### Returns


`list of float`  


##### Examples

``` python
>>> from prospicio.reinsurance import Layer
>>> layer = Layer("L", 10.0, 5.0, aggregate_deductible=4.0, aggregate_limit=15.0)
>>> layer.ceded_by_event([8.0, 20.0, 12.0])
```

\[0.0, 9.0, 6.0\]

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


#### ceded_with_sums_insured()


Ceded loss for one year's losses on risks with the given sums


Usage


``` python
ceded_with_sums_insured(losses, sums_insured)
```


insured, one per loss.


##### Parameters


`losses: list of float`  

`sums_insured: list of float`  


##### Returns


`float`  


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


#### quota_share()


A quota share ceding `cession` of every loss.


Usage


``` python
quota_share(name, cession)
```


Unlimited cover from the first unit with `share = cession`.


##### Parameters


`name: str`  

`cession: float`  
In `(0, 1]`.


##### Returns


`Layer`  


##### Examples

``` python
>>> from prospicio.reinsurance import Layer
>>> Layer.quota_share("QS", 0.4).ceded([10.0, 5.0])
```

6.0

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


#### reinstatement_premium()


Reinstatement premium for one year's losses.


Usage


``` python
reinstatement_premium(losses, times=None)
```


With layer loss `L` at 100% after annual terms, `premium * sum(rate_k * min(max(L - k * limit, 0), limit) / limit)`; zero when reinstatements are free. Pro rata as to time, the limit each loss uses up is charged at `1 - t`, its time's share of the year left.


##### Parameters


`losses: list of float`  
In time order.

`times: list of float = None`  
Each loss's time, as the fraction of the year elapsed; needed (and only used) when the layer is pro rata as to time.


##### Returns


`float`  
NaN for a layer pro rata as to time without [times](aggregate.EventSet.md#prospicio.aggregate.EventSet.times).


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


#### stop_loss()


An aggregate stop-loss: [limit](reinsurance.Layer.md#prospicio.reinsurance.Layer.limit) xs `retention` on the year's total.


Usage


``` python
stop_loss(name, limit, retention)
```


Covers the total of the losses it sees: gross, or net of earlier stages in an inuring [Tower](reinsurance.Tower.md#prospicio.reinsurance.Tower).


##### Parameters


`name: str`  

`limit: float`  
Annual limit; may be `inf`.

`retention: float`  


##### Returns


`Layer`  


##### Examples

``` python
>>> from prospicio.reinsurance import Layer
>>> Layer.stop_loss("SL", 50.0, 100.0).ceded([60.0, 70.0])
```

30.0

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


#### surplus()


A surplus treaty: each risk cedes the part of its sum insured above


Usage


``` python
surplus(name, retention, lines)
```


the retention line `retention`, up to `lines` lines, and the same share of every loss on it.

With a retention of 1m and 9 lines (a capacity of 9m), a 5m risk cedes 80% and a 20m risk 45%. The events must carry sums insured (`EventSet.from_years(..., sums_insured=...)`); it can inure to a per-risk excess of loss in a later stage of a [Tower](reinsurance.Tower.md#prospicio.reinsurance.Tower).


##### Parameters


`name: str`  

`retention: float`  
The retention line; positive.

`lines: float`  
Number of lines of capacity; positive.


##### Returns


`Layer`  


##### Examples

``` python
>>> from prospicio.reinsurance import Layer
>>> s = Layer.surplus("surplus", 1e6, 9.0)
>>> round(s.ceded_with_sums_insured([2e6, 2e6], [5e6, 20e6]))
```

2500000

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


#### with_loss_corridor()


The same layer with a loss corridor.


Usage


``` python
with_loss_corridor(lower, upper, retained=1.0)
```


Of the annual layer loss at 100% after the annual deductible, the cedant keeps `retained` of the part between [lower](distributions.Grid.md#prospicio.distributions.Grid.lower) and [upper](distributions.Custom.md#prospicio.distributions.Custom.upper); the annual limit then caps what is left, so the reinsurer still pays up to the full annual limit. Reinstatement premiums follow the loss after the corridor. A corridor quoted as loss ratios `lr` on the reinsurer's premium `P` for a placed share `s` is `lr * P / s` (for a quota share, `P / s` is the subject premium).


##### Parameters


`lower: float`  
Non-negative.

`upper: float`  
Finite, above [lower](distributions.Grid.md#prospicio.distributions.Grid.lower).

`retained: float = ``1.0`  
Share of the band the cedant keeps, in `(0, 1]`.


##### Returns


`Layer`  


##### Examples

``` python
>>> from prospicio.reinsurance import Layer
>>> qs = Layer.quota_share("QS", 0.3).with_loss_corridor(70.0, 90.0)
>>> round(qs.ceded([50.0, 30.0]), 12), round(qs.ceded([120.0]), 12)
```

(21.0, 30.0)
