quactuary.entities module

Insurance entity models for policy terms, inforce buckets, and portfolios.

This module defines the core business objects for representing insurance policy terms (PolicyTerms), aggregation buckets (Inforce), and collections of buckets (Portfolio).

Examples

>>> from quactuary.entities import PolicyTerms, Inforce, Portfolio
>>> terms = PolicyTerms(per_occ_deductible=100.0, coinsurance=0.8)
>>> bucket = Inforce(n_policies=50, freq=freq_model, sev=sev_model, terms=terms)
>>> portfolio = Portfolio([bucket])
class quactuary.entities.Inforce(n_policies: int, freq: FrequencyModel, sev: SeverityModel, terms: PolicyTerms, name: str = 'Unnamed Bucket')

Bases: object

Bucket of policies sharing frequency and severity characteristics.

Parameters:
  • n_policies (int) – Number of policies in this bucket.

  • freq (FrequencyModel) – Claim count distribution.

  • sev (SeverityModel) – Claim severity distribution.

  • terms (PolicyTerms) – Policy terms and layer definitions.

  • name (str, optional) – Bucket label. Defaults to “Unnamed Bucket”.

classical_sample(n_sims

int) -> np.ndarray: Monte Carlo aggregate loss sample.

classical_sample(n_sims: int = 100000)

Generate Monte Carlo aggregate loss samples for the bucket.

Parameters:

n_sims (int, optional) – Number of simulation runs. Defaults to 100000.

Returns:

Aggregate loss per simulation.

Return type:

np.ndarray

Examples

>>> samples = bucket.classical_sample(n_sims=50000)
freq: FrequencyModel
n_policies: int
name: str
sev: SeverityModel
terms: PolicyTerms
class quactuary.entities.PolicyTerms(per_occ_deductible: float = 0.0, coinsurance: float = 1.0, per_occ_limit: float | None = None, agg_limit: float | None = None, attachment: float = 0.0, coverage: str = 'OCC')

Bases: object

Terms defining insurance policy layer details.

per_occ_deductible

Deductible per occurrence.

Type:

float

coinsurance

Insurer share proportion (1.0 = 100%).

Type:

float

per_occ_limit

Per-occurrence limit.

Type:

Optional[float]

agg_limit

Aggregate limit.

Type:

Optional[float]

attachment

Attachment point for excess-of-loss.

Type:

float

coverage

Coverage type (e.g., “OCC”, “CLAIMS-MADE”).

Type:

str

agg_limit: float | None
attachment: float
coinsurance: float
coverage: str
per_occ_deductible: float
per_occ_limit: float | None
class quactuary.entities.Portfolio(iterable=(), /)

Bases: list

Portfolio of in-force buckets.

Extends list to include portfolio-level operations.

Examples

>>> p1 = Portfolio([bucket1])
>>> p2 = Portfolio([bucket2])
>>> combined = p1 + p2
total_policies() int

Compute the total number of policies in the portfolio.

Returns:

Sum of n_policies across all buckets.

Return type:

int

Examples

>>> portfolio.total_policies()
1500