catagg 0.1.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
catagg/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Catastrophe loss aggregation, from event loss tables to net exceedance probability curves."""
2
+
3
+ __version__ = "0.1.0.dev0"
4
+
5
+ __all__ = ["__version__"]
@@ -0,0 +1 @@
1
+ """Cross-peril dependence: Gaussian and Student-t copulas over annual losses."""
@@ -0,0 +1 @@
1
+ """Reinsurance structures: quota share, excess of loss with reinstatements, stop-loss."""
@@ -0,0 +1 @@
1
+ """Event-count samplers: Poisson and negative binomial."""
catagg/io/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """ELT readers, schema validation, and the Parquet YELT writer."""
@@ -0,0 +1 @@
1
+ """EP curves, AAL, TVaR, return-period tables and Monte Carlo standard errors."""
catagg/py.typed ADDED
File without changes
@@ -0,0 +1 @@
1
+ """Secondary uncertainty: beta-with-point-mass sampler and moment fitting."""
@@ -0,0 +1 @@
1
+ """The year loop: ELT to YELT to YLT."""
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.5
2
+ Name: catagg
3
+ Version: 0.1.0.dev0
4
+ Summary: Catastrophe loss aggregation, from event loss tables to net exceedance probability curves.
5
+ Project-URL: Homepage, https://github.com/John-Amal/catagg
6
+ Project-URL: Documentation, https://john-amal.github.io/catagg/
7
+ Project-URL: Source, https://github.com/John-Amal/catagg
8
+ Project-URL: Changelog, https://github.com/John-Amal/catagg/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/John-Amal/catagg/issues
10
+ Author: Amal John
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: actuarial,catastrophe-modelling,exceedance-probability,monte-carlo,reinsurance
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: numpy>=1.26
23
+ Requires-Dist: pandas>=2.1
24
+ Requires-Dist: pyarrow>=15.0
25
+ Requires-Dist: scipy>=1.11
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.11; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.6; extra == 'dev'
30
+ Provides-Extra: docs
31
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
32
+ Requires-Dist: mkdocs<2,>=1.6; extra == 'docs'
33
+ Requires-Dist: mkdocstrings[python]>=0.26; extra == 'docs'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # catagg
37
+
38
+ **Catastrophe loss aggregation, from event loss tables to net exceedance probability curves.**
39
+
40
+ [![CI](https://github.com/John-Amal/catagg/actions/workflows/ci.yml/badge.svg)](https://github.com/John-Amal/catagg/actions)
41
+ [![PyPI](https://img.shields.io/pypi/v/catagg.svg)](https://pypi.org/project/catagg/)
42
+ [![Docs](https://img.shields.io/badge/docs-catagg-blue)](https://john-amal.github.io/catagg/)
43
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
44
+
45
+ ---
46
+
47
+ ## The question this answers
48
+
49
+ A reinsurer holds a portfolio exposed to several perils. The catastrophe models produce an **event loss table** — for each modelled event, an annual rate and a loss distribution. Two questions follow immediately, and every pricing, capital and reinsurance-purchase decision depends on them:
50
+
51
+ **How much loss should we expect in a bad year, and how much of it do we actually keep after our reinsurance programme responds?**
52
+
53
+ `catagg` answers both. It simulates the year loss table, builds the gross exceedance probability curves, applies the reinsurance structures in the correct order, and returns gross, ceded and net views — with the validation checks that show the answer can be trusted.
54
+
55
+ ![Gross versus net OEP curve for the example Swiss multi-peril portfolio](docs/img/gross_vs_net_oep.png)
56
+
57
+ *Example portfolio: three perils, 20% quota share, a 50m xs 50m per-occurrence layer with two reinstatements, and a 100m aggregate stop-loss. The programme removes roughly two thirds of the 200-year occurrence loss — and the reinstatement cap is visible as the point where the net curve stops flattening.*
58
+
59
+ ---
60
+
61
+ ## Install
62
+
63
+ ```bash
64
+ pip install catagg
65
+ ```
66
+
67
+ Python 3.11+. Runtime dependencies are numpy, pandas, pyarrow and scipy — nothing else.
68
+
69
+ ---
70
+
71
+ ## Quickstart
72
+
73
+ ```python
74
+ import catagg as ca
75
+
76
+ # 1. Load an event loss table
77
+ elt = ca.read_elt("portfolio.parquet")
78
+
79
+ # 2. Simulate 100,000 years
80
+ yelt = ca.simulate(
81
+ elt,
82
+ n_years=100_000,
83
+ frequency="negative_binomial", # or "poisson"
84
+ secondary_uncertainty=True,
85
+ seed=42,
86
+ )
87
+
88
+ # 3. Gross view
89
+ gross = ca.ep_curve(yelt)
90
+ print(gross.at_return_period([10, 50, 100, 200, 250]))
91
+
92
+ # 4. Apply a reinsurance programme
93
+ programme = ca.Programme([
94
+ ca.QuotaShare(cession=0.20),
95
+ ca.ExcessOfLoss(attachment=50e6, limit=50e6, reinstatements=2, basis="occurrence"),
96
+ ca.AggregateStopLoss(attachment=100e6, limit=100e6),
97
+ ])
98
+
99
+ result = programme.apply(yelt)
100
+ net = ca.ep_curve(result.net)
101
+
102
+ # 5. Compare
103
+ ca.plot.ep_comparison({"Gross": gross, "Net": net}, kind="OEP")
104
+ ```
105
+
106
+ Everything runs from a clean clone — the example portfolio is generated synthetically by a documented generator, so there are no data dependencies and no licensing questions.
107
+
108
+ ---
109
+
110
+ ## Concepts
111
+
112
+ If you already work in cat modelling, skip this. If you're reading the code to learn, this is the map.
113
+
114
+ | Object | What it is |
115
+ |---|---|
116
+ | **ELT** | Event loss table. One row per modelled event: annual rate λ, mean loss, standard deviation, exposed value. |
117
+ | **YELT** | Year event loss table. One row per event *occurrence* per simulated year. The engine's central output. |
118
+ | **YLT** | Year loss table. One row per simulated year: aggregate loss and maximum occurrence loss. |
119
+ | **OEP** | Occurrence exceedance probability. The distribution of the *largest single event* in a year. Drives per-occurrence cover. |
120
+ | **AEP** | Aggregate exceedance probability. The distribution of *total annual* loss. Drives aggregate cover and capital. |
121
+ | **AAL** | Average annual loss. The mean of the AEP distribution, and the cleanest check on the whole pipeline. |
122
+ | **TVaR** | Tail value at risk. The mean loss given exceedance of a return period. What capital regimes actually ask for. |
123
+
124
+ ---
125
+
126
+ ## What's in the engine
127
+
128
+ **Frequency.** Poisson, or negative binomial where event clustering matters — European windstorm and hurricane seasons are both over-dispersed, and a Poisson assumption understates the aggregate tail.
129
+
130
+ **Secondary uncertainty.** Loss given occurrence is sampled from a beta distribution on `[0, exposed_value]`, fitted by moments to the ELT's mean and standard deviation, with probability mass at zero and at full exposure. Degenerate cases — zero variance, or a variance the beta support cannot accommodate — are handled explicitly rather than silently clipped.
131
+
132
+ **Dependence.** Perils are correlated through a Gaussian or Student-t copula applied to annual losses. Independence is the default; the example shows what assuming it costs you in the tail.
133
+
134
+ **Financial structures.** Applied in programme order:
135
+
136
+ - Quota share, with optional ceding commission
137
+ - Per-occurrence excess of loss: attachment, limit, *n* reinstatements at stated percentages, pro-rata to amount, with the aggregate cap of `limit × (1 + n)` enforced
138
+ - Aggregate excess of loss and stop-loss
139
+ - Franchise deductible
140
+
141
+ **Metrics.** OEP, AEP, AAL, TVaR at any return period, full return-period tables, and Monte Carlo standard errors on every tail statistic.
142
+
143
+ ---
144
+
145
+ ## Validation
146
+
147
+ Numerical libraries in this domain live or die on whether you can show they're right. `catagg` ships a validation suite that runs in CI and as a readable notebook:
148
+
149
+ - Simulated AAL converges to the analytic `Σ λᵢ · μᵢ`
150
+ - Sampled frequency moments match the specified Poisson or negative binomial
151
+ - Sampled severity recovers the input mean and standard deviation
152
+ - Ceded loss never exceeds the aggregate reinstatement cap
153
+ - Net + ceded = gross, exactly, in every simulated year
154
+ - Tail-metric standard error as a function of simulation count
155
+
156
+ That last one matters more than it looks. A 200-year return period estimated from 10,000 simulation years carries a standard error large enough to change decisions, and most workflows never report it. `catagg` reports it by default.
157
+
158
+ See [docs/validation](https://john-amal.github.io/catagg/validation/).
159
+
160
+ ---
161
+
162
+ ## Scope
163
+
164
+ **In scope:** everything above.
165
+
166
+ **Deliberately out of scope for v0.1:** hazard modelling, vulnerability curves, location-level financial terms, exposure data management, a graphical interface, cloud orchestration.
167
+
168
+ `catagg` starts where the cat model stops. If you need the full modelling stack, use [Oasis LMF](https://oasislmf.org/). If you need to understand, audit or prototype the aggregation and financial layer, use this.
169
+
170
+ ---
171
+
172
+ ## Roadmap
173
+
174
+ - **v0.2** — location and policy-level terms, surplus share, reinstatement premium calculation
175
+ - **v0.3** — OED-compatible ELT ingest, `oasislmf` interoperability
176
+ - **v0.4** — event-level correlation across sub-perils, seasonality in event timing
177
+
178
+ Issues and pull requests are welcome, particularly from anyone who has implemented reinstatement logic in production and disagrees with this one.
179
+
180
+ ---
181
+
182
+ ## Citing
183
+
184
+ If you use `catagg` in published work, cite the Zenodo record: *(DOI added on first release.)*
185
+
186
+ ## Licence
187
+
188
+ MIT.
@@ -0,0 +1,13 @@
1
+ catagg/__init__.py,sha256=r1ingaJGXcMb9agz7ozOt_3Ps6oJjvplx9g7CnwVLmY,152
2
+ catagg/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ catagg/dependence/__init__.py,sha256=_OiYFQbbpt7bVPo0dArxoGqD9zaqDMj1Lc_O9e8B_4Q,81
4
+ catagg/financial/__init__.py,sha256=A20y9MitooHRpKo9Nv1CAy1iMb0eDMN-6Fq7vsaQ57A,90
5
+ catagg/frequency/__init__.py,sha256=jyI3VOcDZK4x6YHr5RIdCz2dvbYA8tNHDXDNHLNm8tw,59
6
+ catagg/io/__init__.py,sha256=I1DkH4qAG3t2mAMZhu8GrZH90nYu0ZRgxK6pQWMGhws,67
7
+ catagg/metrics/__init__.py,sha256=GjmlbJehg0RBbhF41YFQh0XvtJ884HhwbTXoWPvYpRI,82
8
+ catagg/severity/__init__.py,sha256=9CHacaQrQ_EPDifX8xjAiRY1tvfaCq4EgHi8mRwNLgU,78
9
+ catagg/simulate/__init__.py,sha256=FKqqwh8h3rQrDeDP8JeG3fLaguh_PWDhYX9zDk5nsAE,41
10
+ catagg-0.1.0.dev0.dist-info/METADATA,sha256=9bYp2nZ2T1Vllyw1LfYmUeSG-xEfBWOAlkUaAXcAfeM,8345
11
+ catagg-0.1.0.dev0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
12
+ catagg-0.1.0.dev0.dist-info/licenses/LICENSE,sha256=v3CiP3Pdeg_Zdj3PKP2aokZECtiRBPYA7vgBV95VVTs,1066
13
+ catagg-0.1.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amal John
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.