merton 1.0.0__tar.gz

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.
Files changed (248) hide show
  1. merton-1.0.0/.gitignore +97 -0
  2. merton-1.0.0/CHANGELOG.md +286 -0
  3. merton-1.0.0/LICENSE +201 -0
  4. merton-1.0.0/PKG-INFO +255 -0
  5. merton-1.0.0/README.md +130 -0
  6. merton-1.0.0/docs/_static/.gitkeep +0 -0
  7. merton-1.0.0/docs/blog/announcing-1.0.md +112 -0
  8. merton-1.0.0/docs/changelog.md +2 -0
  9. merton-1.0.0/docs/conf.py +190 -0
  10. merton-1.0.0/docs/contributing/api-stability.md +81 -0
  11. merton-1.0.0/docs/contributing/migrating-to-1.0.md +76 -0
  12. merton-1.0.0/docs/cookbook/bloomberg.md +63 -0
  13. merton-1.0.0/docs/cookbook/excel-dashboard.md +104 -0
  14. merton-1.0.0/docs/cookbook/jax-acceleration.md +71 -0
  15. merton-1.0.0/docs/cookbook/large-panels.md +92 -0
  16. merton-1.0.0/docs/cookbook/observability.md +72 -0
  17. merton-1.0.0/docs/cookbook/panel-fitting.md +86 -0
  18. merton-1.0.0/docs/cookbook/spark-dask.md +108 -0
  19. merton-1.0.0/docs/cookbook/yfinance.md +50 -0
  20. merton-1.0.0/docs/excel/functions.md +75 -0
  21. merton-1.0.0/docs/excel/installation.md +74 -0
  22. merton-1.0.0/docs/excel/sample-workbook.md +35 -0
  23. merton-1.0.0/docs/getting-started/excel-quickstart.md +40 -0
  24. merton-1.0.0/docs/getting-started/first-fit.md +81 -0
  25. merton-1.0.0/docs/getting-started/install.md +56 -0
  26. merton-1.0.0/docs/index.md +136 -0
  27. merton-1.0.0/docs/performance/apple-silicon.md +40 -0
  28. merton-1.0.0/docs/performance/backend-selection.md +58 -0
  29. merton-1.0.0/docs/performance/benchmarks.md +66 -0
  30. merton-1.0.0/docs/performance/free-threaded.md +49 -0
  31. merton-1.0.0/docs/references.bib +66 -0
  32. merton-1.0.0/docs/references.md +7 -0
  33. merton-1.0.0/docs/theory/bayesian-mcmc.md +90 -0
  34. merton-1.0.0/docs/theory/calibration.md +138 -0
  35. merton-1.0.0/docs/theory/extensions/black-cox.md +51 -0
  36. merton-1.0.0/docs/theory/extensions/climate.md +94 -0
  37. merton-1.0.0/docs/theory/extensions/creditgrades.md +68 -0
  38. merton-1.0.0/docs/theory/extensions/geske.md +45 -0
  39. merton-1.0.0/docs/theory/extensions/jump-diffusion.md +82 -0
  40. merton-1.0.0/docs/theory/extensions/leland-toft.md +76 -0
  41. merton-1.0.0/docs/theory/extensions/longstaff-schwartz.md +70 -0
  42. merton-1.0.0/docs/theory/kmv.md +26 -0
  43. merton-1.0.0/docs/theory/merton-1974.md +93 -0
  44. merton-1.0.0/docs/theory/metrics.md +35 -0
  45. merton-1.0.0/docs/theory/portfolio/copulas.md +35 -0
  46. merton-1.0.0/docs/theory/portfolio/vasicek.md +64 -0
  47. merton-1.0.0/docs/theory/scenarios.md +78 -0
  48. merton-1.0.0/docs/tutorials/01_single_firm_aapl.md +132 -0
  49. merton-1.0.0/docs/tutorials/02_climate_scenarios.md +128 -0
  50. merton-1.0.0/pyproject.toml +326 -0
  51. merton-1.0.0/recipe/README.md +26 -0
  52. merton-1.0.0/src/merton/__init__.py +130 -0
  53. merton-1.0.0/src/merton/__main__.py +13 -0
  54. merton-1.0.0/src/merton/_backend/__init__.py +144 -0
  55. merton-1.0.0/src/merton/_backend/_cupy.py +87 -0
  56. merton-1.0.0/src/merton/_backend/_jax.py +97 -0
  57. merton-1.0.0/src/merton/_backend/_mlx.py +91 -0
  58. merton-1.0.0/src/merton/_backend/_numba.py +185 -0
  59. merton-1.0.0/src/merton/_backend/_numpy.py +110 -0
  60. merton-1.0.0/src/merton/_backend/_registry.py +65 -0
  61. merton-1.0.0/src/merton/_backend/_survival.py +75 -0
  62. merton-1.0.0/src/merton/_config.py +117 -0
  63. merton-1.0.0/src/merton/_deprecation.py +94 -0
  64. merton-1.0.0/src/merton/_typing.py +31 -0
  65. merton-1.0.0/src/merton/_version.py +24 -0
  66. merton-1.0.0/src/merton/backtest/__init__.py +35 -0
  67. merton-1.0.0/src/merton/backtest/backtest.py +124 -0
  68. merton-1.0.0/src/merton/backtest/calibration.py +106 -0
  69. merton-1.0.0/src/merton/backtest/metrics.py +123 -0
  70. merton-1.0.0/src/merton/backtest/roc.py +58 -0
  71. merton-1.0.0/src/merton/backtest/rolling.py +100 -0
  72. merton-1.0.0/src/merton/batch/__init__.py +7 -0
  73. merton-1.0.0/src/merton/batch/dispatch.py +129 -0
  74. merton-1.0.0/src/merton/batch/panel.py +143 -0
  75. merton-1.0.0/src/merton/cache.py +77 -0
  76. merton-1.0.0/src/merton/calibration/__init__.py +76 -0
  77. merton-1.0.0/src/merton/calibration/_solvers.py +93 -0
  78. merton-1.0.0/src/merton/calibration/base.py +119 -0
  79. merton-1.0.0/src/merton/calibration/bayesian_mcmc.py +296 -0
  80. merton-1.0.0/src/merton/calibration/bootstrap.py +135 -0
  81. merton-1.0.0/src/merton/calibration/covariance.py +135 -0
  82. merton-1.0.0/src/merton/calibration/duan_mle.py +353 -0
  83. merton-1.0.0/src/merton/calibration/jmr_iterative.py +93 -0
  84. merton-1.0.0/src/merton/calibration/kmv_iterative.py +151 -0
  85. merton-1.0.0/src/merton/calibration/naive.py +88 -0
  86. merton-1.0.0/src/merton/calibration/vassalou_xing.py +218 -0
  87. merton-1.0.0/src/merton/cli/__init__.py +15 -0
  88. merton-1.0.0/src/merton/cli/commands/__init__.py +1 -0
  89. merton-1.0.0/src/merton/cli/commands/config.py +91 -0
  90. merton-1.0.0/src/merton/cli/commands/doctor.py +161 -0
  91. merton-1.0.0/src/merton/cli/commands/excel.py +179 -0
  92. merton-1.0.0/src/merton/cli/commands/fit.py +88 -0
  93. merton-1.0.0/src/merton/cli/main.py +50 -0
  94. merton-1.0.0/src/merton/core/__init__.py +32 -0
  95. merton-1.0.0/src/merton/core/default_point.py +101 -0
  96. merton-1.0.0/src/merton/core/distance.py +166 -0
  97. merton-1.0.0/src/merton/core/firm.py +201 -0
  98. merton-1.0.0/src/merton/core/model.py +215 -0
  99. merton-1.0.0/src/merton/core/panel.py +267 -0
  100. merton-1.0.0/src/merton/core/physical.py +58 -0
  101. merton-1.0.0/src/merton/core/pricing.py +89 -0
  102. merton-1.0.0/src/merton/core/result.py +394 -0
  103. merton-1.0.0/src/merton/core/spread.py +59 -0
  104. merton-1.0.0/src/merton/core/term_structure.py +58 -0
  105. merton-1.0.0/src/merton/excel/__init__.py +56 -0
  106. merton-1.0.0/src/merton/excel/functions.py +332 -0
  107. merton-1.0.0/src/merton/excel/installer.py +78 -0
  108. merton-1.0.0/src/merton/excel/manifest.py +126 -0
  109. merton-1.0.0/src/merton/excel/sample.py +169 -0
  110. merton-1.0.0/src/merton/excel/server.py +212 -0
  111. merton-1.0.0/src/merton/excel/udf.py +60 -0
  112. merton-1.0.0/src/merton/exceptions.py +140 -0
  113. merton-1.0.0/src/merton/extensions/__init__.py +75 -0
  114. merton-1.0.0/src/merton/extensions/base.py +58 -0
  115. merton-1.0.0/src/merton/extensions/black_cox.py +226 -0
  116. merton-1.0.0/src/merton/extensions/climate.py +122 -0
  117. merton-1.0.0/src/merton/extensions/creditgrades.py +233 -0
  118. merton-1.0.0/src/merton/extensions/geske.py +350 -0
  119. merton-1.0.0/src/merton/extensions/jump_diffusion.py +251 -0
  120. merton-1.0.0/src/merton/extensions/leland_toft.py +353 -0
  121. merton-1.0.0/src/merton/extensions/longstaff_schwartz.py +255 -0
  122. merton-1.0.0/src/merton/greeks/__init__.py +38 -0
  123. merton-1.0.0/src/merton/greeks/autodiff.py +146 -0
  124. merton-1.0.0/src/merton/greeks/equity.py +187 -0
  125. merton-1.0.0/src/merton/greeks/pd_sensitivity.py +74 -0
  126. merton-1.0.0/src/merton/greeks/spread_sensitivity.py +61 -0
  127. merton-1.0.0/src/merton/logging.py +59 -0
  128. merton-1.0.0/src/merton/obs.py +204 -0
  129. merton-1.0.0/src/merton/portfolio/__init__.py +32 -0
  130. merton-1.0.0/src/merton/portfolio/concentration.py +82 -0
  131. merton-1.0.0/src/merton/portfolio/copulas/__init__.py +8 -0
  132. merton-1.0.0/src/merton/portfolio/copulas/gaussian.py +70 -0
  133. merton-1.0.0/src/merton/portfolio/copulas/student_t.py +60 -0
  134. merton-1.0.0/src/merton/portfolio/correlation.py +58 -0
  135. merton-1.0.0/src/merton/portfolio/loss_distribution.py +148 -0
  136. merton-1.0.0/src/merton/portfolio/portfolio.py +234 -0
  137. merton-1.0.0/src/merton/portfolio/vasicek_factor.py +195 -0
  138. merton-1.0.0/src/merton/py.typed +0 -0
  139. merton-1.0.0/src/merton/reports/__init__.py +7 -0
  140. merton-1.0.0/src/merton/reports/html.py +143 -0
  141. merton-1.0.0/src/merton/scenarios/__init__.py +50 -0
  142. merton-1.0.0/src/merton/scenarios/base.py +89 -0
  143. merton-1.0.0/src/merton/scenarios/climate.py +287 -0
  144. merton-1.0.0/src/merton/scenarios/predefined/__init__.py +18 -0
  145. merton-1.0.0/src/merton/scenarios/predefined/ngfs.py +199 -0
  146. merton-1.0.0/src/merton/scenarios/shocks.py +138 -0
  147. merton-1.0.0/tests/__init__.py +0 -0
  148. merton-1.0.0/tests/benchmarks/__init__.py +0 -0
  149. merton-1.0.0/tests/benchmarks/conftest.py +53 -0
  150. merton-1.0.0/tests/benchmarks/test_backtest.py +55 -0
  151. merton-1.0.0/tests/benchmarks/test_calibration.py +55 -0
  152. merton-1.0.0/tests/benchmarks/test_panel.py +42 -0
  153. merton-1.0.0/tests/benchmarks/test_portfolio.py +38 -0
  154. merton-1.0.0/tests/benchmarks/test_single_firm.py +65 -0
  155. merton-1.0.0/tests/conftest.py +58 -0
  156. merton-1.0.0/tests/data/reference/README.md +16 -0
  157. merton-1.0.0/tests/data/reference/bharath_shumway_2008.csv +5 -0
  158. merton-1.0.0/tests/data/reference/vassalou_xing_2004_table2.csv +5 -0
  159. merton-1.0.0/tests/golden/__init__.py +0 -0
  160. merton-1.0.0/tests/golden/test_bharath_shumway_2008.py +80 -0
  161. merton-1.0.0/tests/golden/test_duan_synthetic.py +82 -0
  162. merton-1.0.0/tests/golden/test_vassalou_xing_2004.py +93 -0
  163. merton-1.0.0/tests/performance/__init__.py +0 -0
  164. merton-1.0.0/tests/performance/test_import_time.py +88 -0
  165. merton-1.0.0/tests/property/__init__.py +0 -0
  166. merton-1.0.0/tests/property/test_invariants.py +93 -0
  167. merton-1.0.0/tests/unit/__init__.py +0 -0
  168. merton-1.0.0/tests/unit/_backend/__init__.py +0 -0
  169. merton-1.0.0/tests/unit/_backend/test_cupy_dispatch_warning.py +55 -0
  170. merton-1.0.0/tests/unit/_backend/test_dispatch.py +80 -0
  171. merton-1.0.0/tests/unit/_backend/test_jax_dispatch_warning.py +35 -0
  172. merton-1.0.0/tests/unit/_backend/test_mlx_dispatch_warning.py +45 -0
  173. merton-1.0.0/tests/unit/_backend/test_numba_direct.py +38 -0
  174. merton-1.0.0/tests/unit/_backend/test_numba_kernels.py +64 -0
  175. merton-1.0.0/tests/unit/_backend/test_registry.py +42 -0
  176. merton-1.0.0/tests/unit/_backend/test_survival.py +40 -0
  177. merton-1.0.0/tests/unit/_backend/test_warm_cache.py +24 -0
  178. merton-1.0.0/tests/unit/backends/__init__.py +0 -0
  179. merton-1.0.0/tests/unit/backends/test_jax_consistency.py +44 -0
  180. merton-1.0.0/tests/unit/backtest/__init__.py +0 -0
  181. merton-1.0.0/tests/unit/backtest/test_metrics.py +101 -0
  182. merton-1.0.0/tests/unit/backtest/test_roc_and_calibration.py +117 -0
  183. merton-1.0.0/tests/unit/backtest/test_rolling.py +32 -0
  184. merton-1.0.0/tests/unit/batch/__init__.py +0 -0
  185. merton-1.0.0/tests/unit/batch/test_dispatch.py +53 -0
  186. merton-1.0.0/tests/unit/batch/test_panel_fit.py +74 -0
  187. merton-1.0.0/tests/unit/calibration/__init__.py +0 -0
  188. merton-1.0.0/tests/unit/calibration/test_base_registry.py +43 -0
  189. merton-1.0.0/tests/unit/calibration/test_bayesian_mcmc.py +115 -0
  190. merton-1.0.0/tests/unit/calibration/test_bootstrap.py +62 -0
  191. merton-1.0.0/tests/unit/calibration/test_calibration.py +138 -0
  192. merton-1.0.0/tests/unit/calibration/test_covariance.py +76 -0
  193. merton-1.0.0/tests/unit/calibration/test_duan_mle.py +89 -0
  194. merton-1.0.0/tests/unit/calibration/test_kmv_iterative.py +56 -0
  195. merton-1.0.0/tests/unit/calibration/test_solver_error_paths.py +96 -0
  196. merton-1.0.0/tests/unit/cli/__init__.py +0 -0
  197. merton-1.0.0/tests/unit/cli/test_cli.py +90 -0
  198. merton-1.0.0/tests/unit/core/__init__.py +0 -0
  199. merton-1.0.0/tests/unit/core/test_distance.py +83 -0
  200. merton-1.0.0/tests/unit/core/test_firm.py +87 -0
  201. merton-1.0.0/tests/unit/core/test_firm_edge_cases.py +121 -0
  202. merton-1.0.0/tests/unit/core/test_model_paths.py +66 -0
  203. merton-1.0.0/tests/unit/core/test_panel.py +104 -0
  204. merton-1.0.0/tests/unit/core/test_panel_edge_cases.py +90 -0
  205. merton-1.0.0/tests/unit/core/test_pricing.py +61 -0
  206. merton-1.0.0/tests/unit/core/test_result.py +63 -0
  207. merton-1.0.0/tests/unit/core/test_result_exports.py +43 -0
  208. merton-1.0.0/tests/unit/core/test_validation_branches.py +92 -0
  209. merton-1.0.0/tests/unit/excel/__init__.py +0 -0
  210. merton-1.0.0/tests/unit/excel/test_cli.py +66 -0
  211. merton-1.0.0/tests/unit/excel/test_functions.py +159 -0
  212. merton-1.0.0/tests/unit/excel/test_installer.py +42 -0
  213. merton-1.0.0/tests/unit/excel/test_installer_platforms.py +41 -0
  214. merton-1.0.0/tests/unit/excel/test_manifest.py +52 -0
  215. merton-1.0.0/tests/unit/excel/test_sample_workbook.py +41 -0
  216. merton-1.0.0/tests/unit/excel/test_server.py +106 -0
  217. merton-1.0.0/tests/unit/excel/test_udf_module.py +51 -0
  218. merton-1.0.0/tests/unit/extensions/__init__.py +0 -0
  219. merton-1.0.0/tests/unit/extensions/test_black_cox.py +88 -0
  220. merton-1.0.0/tests/unit/extensions/test_climate_overlay.py +166 -0
  221. merton-1.0.0/tests/unit/extensions/test_creditgrades.py +105 -0
  222. merton-1.0.0/tests/unit/extensions/test_geske.py +119 -0
  223. merton-1.0.0/tests/unit/extensions/test_jump_diffusion.py +110 -0
  224. merton-1.0.0/tests/unit/extensions/test_leland_toft.py +169 -0
  225. merton-1.0.0/tests/unit/extensions/test_longstaff_schwartz.py +172 -0
  226. merton-1.0.0/tests/unit/greeks/__init__.py +0 -0
  227. merton-1.0.0/tests/unit/greeks/test_autodiff_parity.py +46 -0
  228. merton-1.0.0/tests/unit/greeks/test_greeks_extras.py +40 -0
  229. merton-1.0.0/tests/unit/greeks/test_spread_sensitivity.py +40 -0
  230. merton-1.0.0/tests/unit/portfolio/__init__.py +0 -0
  231. merton-1.0.0/tests/unit/portfolio/test_concentration.py +52 -0
  232. merton-1.0.0/tests/unit/portfolio/test_copulas.py +70 -0
  233. merton-1.0.0/tests/unit/portfolio/test_correlation.py +45 -0
  234. merton-1.0.0/tests/unit/portfolio/test_loss_distribution.py +81 -0
  235. merton-1.0.0/tests/unit/portfolio/test_portfolio.py +120 -0
  236. merton-1.0.0/tests/unit/portfolio/test_vasicek.py +116 -0
  237. merton-1.0.0/tests/unit/reports/__init__.py +0 -0
  238. merton-1.0.0/tests/unit/reports/test_html_report.py +37 -0
  239. merton-1.0.0/tests/unit/scenarios/__init__.py +0 -0
  240. merton-1.0.0/tests/unit/scenarios/test_climate.py +219 -0
  241. merton-1.0.0/tests/unit/scenarios/test_ngfs.py +87 -0
  242. merton-1.0.0/tests/unit/scenarios/test_shocks.py +137 -0
  243. merton-1.0.0/tests/unit/test_cache.py +65 -0
  244. merton-1.0.0/tests/unit/test_deprecation.py +73 -0
  245. merton-1.0.0/tests/unit/test_exceptions.py +53 -0
  246. merton-1.0.0/tests/unit/test_logging.py +27 -0
  247. merton-1.0.0/tests/unit/test_obs.py +154 -0
  248. merton-1.0.0/tests/unit/test_public_api.py +66 -0
@@ -0,0 +1,97 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ dist/
13
+ wheelhouse/
14
+ develop-eggs/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ *.egg
24
+ MANIFEST
25
+ src/merton/_version.py
26
+
27
+ # Virtual environments
28
+ .venv/
29
+ venv/
30
+ env/
31
+ ENV/
32
+
33
+ # uv
34
+ .uv-cache/
35
+ uv.lock.bak
36
+
37
+ # Testing / coverage
38
+ .coverage
39
+ .coverage.*
40
+ htmlcov/
41
+ .cache/
42
+ .pytest_cache/
43
+ .tox/
44
+ .nox/
45
+ .hypothesis/
46
+ coverage.xml
47
+ *.cover
48
+ .mypy_cache/
49
+ .ruff_cache/
50
+ .dmypy.json
51
+ dmypy.json
52
+
53
+ # IDE
54
+ .idea/
55
+ .vscode/
56
+ *.swp
57
+ *.swo
58
+ .DS_Store
59
+
60
+ # Jupyter
61
+ .ipynb_checkpoints/
62
+ *.ipynb_meta
63
+
64
+ # Docs
65
+ docs/_build/
66
+ docs/api/_autoapi/
67
+ docs/jupyter_execute/
68
+ docs/.doctrees/
69
+
70
+ # Numba cache
71
+ __pycache__/
72
+ *.nbi
73
+ *.nbc
74
+
75
+ # Benchmarks
76
+ .benchmarks/
77
+ benchmarks/results/
78
+
79
+ # Local environment
80
+ .env
81
+ .env.local
82
+ *.local
83
+
84
+ # Local Claude project instructions (never tracked)
85
+ CLAUDE.md
86
+
87
+ # Excel artifacts
88
+ *.xlsx.bak
89
+ ~$*.xlsx
90
+ ~$*.xlsm
91
+
92
+ # Cache directories
93
+ .merton-cache/
94
+
95
+ # Profiling
96
+ *.prof
97
+ *.lprof
@@ -0,0 +1,286 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added (Phase 1.0 — Public launch)
11
+
12
+ - **First stable release**: dev-status classifier bumped to
13
+ `5 - Production/Stable`; `merton.__all__` is the v1.0 API surface
14
+ governed by [SemVer](https://semver.org/) (see
15
+ `docs/contributing/api-stability.md`).
16
+ - **Lazy submodule loading**: `backtest`, `portfolio`, `reports`, and
17
+ `batch_fit` are now resolved on first access via `__getattr__`. Cold
18
+ `import merton` drops from ~1.1 s to ~500 ms on a 2024 M-series
19
+ MacBook. `merton.calibration.covariance`, `merton.core.result`,
20
+ `merton.core.term_structure`, and `merton._backend._numpy` defer
21
+ scipy/pandas imports to first use.
22
+ - **conda-forge recipe** (`recipe/meta.yaml`) ready for the
23
+ `conda-forge/staged-recipes` PR. Once merged, `conda install -c
24
+ conda-forge merton` will be live.
25
+ - **Launch documentation**: `docs/blog/announcing-1.0.md` (release
26
+ announcement), `docs/contributing/migrating-to-1.0.md` (migration
27
+ guide for 0.x users).
28
+ - **`tests/performance/test_import_time.py`** locks the cold-import
29
+ budget (`< 750 ms` on the dev workstation) so future PRs that
30
+ re-introduce eager heavy imports fail CI.
31
+
32
+ ### Added (Phase 0.9 — RC)
33
+
34
+ - **API stability surface**: `docs/contributing/api-stability.md` is the
35
+ canonical reference for the v1.0 public API contract. Names in
36
+ `merton.__all__` are stable from 1.0; underscore-prefixed modules are
37
+ internal.
38
+ - **Deprecation helper** (`merton._deprecation`): `deprecated`,
39
+ `deprecated_alias`, and `warn_deprecated` route renamed/retired public
40
+ names through a `DeprecationWarning` with the removal target stamped in.
41
+ - **Security CI** (`.github/workflows/security.yml`): weekly `bandit`,
42
+ `pip-audit`, and OSV scanner runs on `main`; also runs on PRs that
43
+ touch dependencies or the security config.
44
+ - **Public-API surface tests** (`tests/unit/test_public_api.py`): every
45
+ name in `merton.__all__` resolves; `__all__` is sorted and excludes
46
+ private names; the package version is PEP 440.
47
+ - **Slow-test gating**: long MCMC tests are tagged `@pytest.mark.slow`
48
+ and deselected from the default `pytest` invocation; full suite now
49
+ runs in ~15 s. Run the slow tier with `pytest -m slow`.
50
+
51
+ ### Changed (Phase 0.9 — RC)
52
+
53
+ - `merton.__init__.__getattr__` no longer advertises `io`, `diagnostics`,
54
+ or `viz` — those namespaces are roadmapped for 1.x and their helpers
55
+ currently live on `FirmPanel`, `MertonResult.summary`, and
56
+ `merton.reports`.
57
+ - `merton.greeks.autodiff` enables `jax_enable_x64` at import so the
58
+ autodiff Greeks match the closed-form values to single-precision
59
+ tolerance; `equity_theta_ad` now follows the option-pricing convention
60
+ (returns `-∂E/∂T`).
61
+ - Bandit suppressions added inline (`obs.py` teardown, `bootstrap.py`
62
+ resample exception path, `cli/commands/excel.py` subprocess launcher).
63
+
64
+ ### Added (Phase 0.8)
65
+
66
+ - **OpenTelemetry observability** (`merton.obs`): opt-in OTel tracing
67
+ via `enable()` / `disable()` with `span()` context manager and
68
+ `traced()` decorator. Auto-enable through `MERTON_OBS=1`; endpoint
69
+ override via `MERTON_OTLP_ENDPOINT`; optional console mirror via
70
+ `MERTON_OBS_CONSOLE=1`. Pulls in `opentelemetry-{api,sdk,exporter-otlp}`
71
+ via the new `[obs]` extra.
72
+ - **Scenarios package** (`merton.scenarios`):
73
+ - `Scenario` ABC + `CompositeScenario` (chain with `|`) +
74
+ `ScenarioResult` audit record.
75
+ - Atomic shocks `equity_shock`, `vol_shock`, `rate_shock`, `debt_shock`
76
+ for ad-hoc stress.
77
+ - `ClimateScenario` with carbon-price path + sectoral PD multipliers,
78
+ pass-through, and chronic physical-risk parameters. `Sector` enum
79
+ with default emission-intensity table; `carbon_price_curve`
80
+ piecewise-linear helper; `carbon_price_to_writedown` standalone.
81
+ - **NGFS Phase V (2024) scenarios**
82
+ (`merton.scenarios.predefined.ngfs`): `net_zero_2050`,
83
+ `delayed_transition`, `current_policies`, `fragmented_world`.
84
+ - **ClimateOverlay structural model** (`merton.extensions.climate`):
85
+ wraps any `StructuralModel` / `MertonModel` with a `ClimateScenario`
86
+ + sector tag; writes down equity before calibration and scales PD by
87
+ the sectoral multiplier.
88
+ - **Docs**: `docs/theory/scenarios.md` (general framework overview),
89
+ `docs/theory/extensions/climate.md`,
90
+ `docs/tutorials/02_climate_scenarios.md`,
91
+ `docs/cookbook/observability.md`, `docs/cookbook/spark-dask.md`.
92
+ Phase 0.8 features (`Scenario` framework, NGFS climate stress,
93
+ OpenTelemetry) are now called out in the README Highlights block.
94
+
95
+ ### Added (Phase 0.7)
96
+
97
+ - **CreditGrades model** (`merton.extensions.creditgrades`):
98
+ Finger-Finkelstein-Pan-Lardy-Ta-Tierney 2002 closed-form survival /
99
+ PD / implied CDS spread plus `CreditGradesModel.fit`. Random
100
+ default-barrier widens short-horizon credit spreads vs Merton.
101
+ - **Leland-Toft endogenous-default model**
102
+ (`merton.extensions.leland_toft`): optimal default boundary
103
+ ``V_B^*``, PD, equity / debt values, and `LelandToftModel` calibrator
104
+ on coupon-paying perpetual debt with taxes and bankruptcy costs.
105
+ - **Zhou / Merton jump-diffusion**
106
+ (`merton.extensions.jump_diffusion`): Poisson-weighted series PD,
107
+ Monte Carlo path simulator (`simulate_jump_diffusion`), and
108
+ `JumpDiffusionModel` that calibrates ``(A, σ_A)`` via JMR and adds
109
+ the jump contribution.
110
+ - **Longstaff-Schwartz two-factor model**
111
+ (`merton.extensions.longstaff_schwartz`): Vasicek short-rate
112
+ dynamics + asset GBM with correlation; closed-form PD at
113
+ ``ρ = 0`` and vectorised Monte Carlo first-passage estimator
114
+ otherwise.
115
+ - **Bayesian MCMC calibrator**
116
+ (`merton.calibration.bayesian_mcmc`): `bayesian_mcmc` and
117
+ `BayesianMCMCCalibrator` wrap `emcee.EnsembleSampler` around the
118
+ Duan log-likelihood. Returns a `BayesianCalibrationResult` exposing
119
+ the full posterior chain, log-probabilities, autocorrelation time,
120
+ acceptance fraction, and percentile credible intervals.
121
+ - **Theory docs**: `docs/theory/extensions/{creditgrades, leland-toft,
122
+ jump-diffusion, longstaff-schwartz}.md` and
123
+ `docs/theory/bayesian-mcmc.md`.
124
+
125
+ ### Added (Phase 0.6)
126
+
127
+ - **Excel integration via xlwings Server (FastAPI)**:
128
+ - `merton.excel.functions` — pure-Python wrappers for every formula:
129
+ `merton_dd`, `merton_pd`, `merton_spread`, `merton_asset_value`,
130
+ `merton_asset_vol`, `merton_greeks`, `merton_pd_term`,
131
+ `merton_backtest`, `merton_portfolio_var`, `merton_black_cox`.
132
+ - `merton.excel.server` — FastAPI app exposing ``/healthz``,
133
+ ``/functions.json``, ``/static/functions.{js,html}``,
134
+ ``/taskpane.html``, and ``/call``. Lazy FastAPI import.
135
+ - `merton.excel.manifest` — Office.js manifest XML generator with
136
+ deterministic add-in UUID per base URL.
137
+ - `merton.excel.installer` — write / remove the manifest in the OS's
138
+ Excel sideload directory (macOS / Windows / Linux fallback).
139
+ - **Classic xlwings UDF fallback** (`merton.excel.udf`): registers
140
+ every formula via the legacy `@xw.func` decorator for Windows
141
+ desktop where running a local HTTP server isn't convenient.
142
+ - **CLI commands** (`merton excel ...`):
143
+ - `install --url <BASE_URL>` writes the manifest.
144
+ - `uninstall` removes the manifest.
145
+ - `status` reports manifest + server PID.
146
+ - `server start [--host --port --reload --background]` runs uvicorn.
147
+ - `server stop` graceful SIGTERM via a PID file under
148
+ `platformdirs.user_runtime_dir`.
149
+ - `sample-workbook --out=<PATH>` writes a worked-example workbook.
150
+ - **Sample workbook** (`merton.excel.sample.write_sample_workbook`):
151
+ programmatic openpyxl file with *Read me*, *Single firm*, *Portfolio*,
152
+ *Backtest*, and *Function reference* sheets.
153
+ - **`python -m merton`** entrypoint via `src/merton/__main__.py`.
154
+ - **Docs**: `docs/excel/{installation, functions, sample-workbook}.md`,
155
+ cookbook `excel-dashboard.md` with a full live-dashboard recipe.
156
+
157
+ ### Added (Phase 0.5)
158
+
159
+ - **CuPy backend** (`merton._backend._cupy`): NVIDIA-GPU implementations of
160
+ `d1_d2`, `equity_value`, `distance_to_default_kernel`,
161
+ `prob_of_default_kernel`. Lazy-imported under `merton[gpu]`. Backend
162
+ dispatch routes CuPy-array inputs to the GPU automatically.
163
+ - **MLX backend** (`merton._backend._mlx`): Apple Silicon Metal kernels
164
+ via `mlx.core`. Normal CDF derived from `mx.erf`. Lazy-imported under
165
+ `merton[mlx]`. Unified-memory model means zero-copy from NumPy.
166
+ - **AOT-warmed Numba cache**: `merton.warm_cache()` now exercises every
167
+ `@njit` kernel with representative inputs. `wheels.yml` runs this in
168
+ `CIBW_BEFORE_TEST` so the compiled `.nbi/.nbc` files ship inside the
169
+ wheel — users pay zero first-call JIT cost.
170
+ - **100k-firm benchmark suite** (`tests/benchmarks/`): pytest-benchmark
171
+ coverage of single-firm fits, 1k/10k/100k panels, calibration on a
172
+ 252-day series, portfolio Monte Carlo, and backtest metrics on
173
+ 1 000 000 (PD, default) pairs. Excluded from the default `pytest`
174
+ run via `addopts = "--ignore=tests/benchmarks"`.
175
+ - **Free-threaded CI**: dedicated `cp313t` job in `.github/workflows/test.yml`
176
+ that asserts `sys._is_gil_enabled() == False` and runs the full unit +
177
+ property + golden test suites under GIL-free Python.
178
+ - **Performance docs**: `docs/performance/{benchmarks, backend-selection,
179
+ apple-silicon, free-threaded}.md` and `docs/cookbook/large-panels.md`.
180
+
181
+ ### Added (Phase 0.4)
182
+
183
+ - **Extensions**:
184
+ - `merton.extensions.BlackCoxModel` and `black_cox_pd` — first-passage
185
+ barrier model with constant or exponentially-decaying barrier
186
+ (closed-form risk-neutral PD via the reflection principle).
187
+ - `merton.extensions.GeskeModel` and `geske_equity_value` /
188
+ `geske_pd` — 2-period compound-option pricing using the
189
+ bivariate-normal CDF.
190
+ - `merton.extensions.StructuralModel` / `StructuralResult` — shared
191
+ ABC + result dataclass for all non-vanilla structural models.
192
+ - **Portfolio**:
193
+ - `merton.portfolio.Portfolio` — container plus Monte Carlo +
194
+ analytic-Vasicek engines. Accepts a list of `Firm` objects *or* a
195
+ pre-computed PD vector.
196
+ - `merton.portfolio.LossDistribution` — VaR, expected shortfall,
197
+ economic capital, per-firm contribution decomposition.
198
+ - `merton.portfolio.VasicekFactor` — Vasicek single-factor analytics.
199
+ - `merton.portfolio.basel_irb_correlation` + `basel_irb_capital` —
200
+ BCBS-prescribed asset correlation and IRB unexpected-loss capital
201
+ with the standard maturity adjustment.
202
+ - `merton.portfolio.copulas.GaussianCopula` and `TCopula` for
203
+ correlated-default sampling.
204
+ - `merton.portfolio.asset_correlation_from_equity` and
205
+ `granularity_adjustment` / `hhi` / `effective_n`.
206
+ - **Backtest harness**:
207
+ - `merton.backtest.{auc, accuracy_ratio, brier, ks_statistic,
208
+ hosmer_lemeshow}` — implementations validated against sklearn's
209
+ equivalents (no sklearn dependency).
210
+ - `merton.backtest.ROCCurve` and `roc_curve`; `CalibrationCurve` and
211
+ `calibration_curve` / `calibration_plot`.
212
+ - `merton.backtest.rolling_window` — slide AUC/Brier/KS over a panel.
213
+ - `merton.backtest.Backtest` + `BacktestResult` orchestrator with
214
+ `add_metric`, `to_dict`, `summary`.
215
+ - **Reports**:
216
+ - `merton.reports.render_backtest_report` — dependency-light
217
+ standalone HTML report with embedded ROC + calibration SVGs.
218
+ - **Docs**: theory pages for Black-Cox, Geske, Vasicek, copulas, and
219
+ metrics; cookbook recipes for `yfinance` and Bloomberg ingestion.
220
+ - **Testing**: extensive test coverage (336 tests, 90.87% coverage),
221
+ with the gate held at 90% via `fail_under` in `pyproject.toml`.
222
+
223
+ ### Added (Phase 0.3)
224
+
225
+ - JAX-backed kernels (`merton._backend._jax`): `jit`-compiled `d1_d2`,
226
+ `equity_value`, `distance_to_default_kernel`, `prob_of_default_kernel`.
227
+ Lazy-imported; only loaded when JAX is installed.
228
+ - Backend dispatch transparently routes JAX arrays to the JAX backend
229
+ (zero-copy stay on device).
230
+ - JAX autodiff Greeks (`merton.greeks.autodiff`): `equity_delta_ad`,
231
+ `equity_gamma_ad`, `equity_vega_ad`, `equity_theta_ad`, `equity_rho_ad`,
232
+ `pd_leverage_sensitivity_ad`, `pd_vol_sensitivity_ad`,
233
+ `pd_rate_sensitivity_ad`. Each is `jit`-compiled and `vmap`-friendly.
234
+ - `merton.FirmPanel` — Arrow-backed columnar container with constructors
235
+ for pandas / polars / Arrow / CSV / Parquet / dict, columnar accessors,
236
+ Firm-row iteration, boolean masks, and zero-copy slicing.
237
+ - `merton.batch_fit(panel_or_df, *, method, n_jobs, dispatch, progress,
238
+ on_error, …)` — joblib-threaded panel calibration; returns the same
239
+ dataframe type you handed in (pandas / polars / Arrow).
240
+ - `merton.batch.dispatch.parallel_map` — pluggable joblib / sequential /
241
+ dask / ray dispatcher.
242
+ - `merton` CLI (typer): `merton --version`, `merton doctor` (Python build,
243
+ GIL status, installed backends, GPU/MLX/JAX devices, dependency
244
+ versions, suggested extras), `merton config show|set|reset`,
245
+ `merton fit <input>` for single-firm and panel calibration.
246
+ - `MERTON_CONFIG_DIR` env var lets users / tests redirect the persisted
247
+ config file location.
248
+ - Added `pyarrow>=15` and `tomli-w>=1.0` to core dependencies.
249
+ - Cookbook: `docs/cookbook/panel-fitting.md`, `docs/cookbook/jax-acceleration.md`.
250
+
251
+ ### Added (Phase 0.2)
252
+
253
+ - Duan (1994) transformed-data MLE calibrator (`merton.calibration.duan_mle`).
254
+ - Survivorship-bias correction via closed-form first-passage probability
255
+ for geometric Brownian motion (`merton._backend._survival`).
256
+ - KMV / Crosbie-Bohn iterative calibrator (`merton.calibration.kmv_iterative`)
257
+ with hookable empirical `edf_map`.
258
+ - MLE asymptotic standard errors, Wald confidence intervals, and a generic
259
+ delta-method propagator (`merton.calibration.covariance`).
260
+ - Block-bootstrap CIs for time-series calibrators
261
+ (`merton.calibration.block_bootstrap_calibration`); wired into
262
+ `MertonModel(n_bootstrap=…)`.
263
+ - `MertonResult.confidence_interval(level, method)` lazy method (asymptotic
264
+ or bootstrap).
265
+ - `MertonResult` now exposes `dd_series` / `pd_series` / `asset_value_series`
266
+ for time-series calibrations; the scalar `dd` / `pd` are the most-recent
267
+ observation.
268
+ - Paper-replication test suite (`tests/golden/`) covering Bharath-Shumway
269
+ 2008, Vassalou-Xing 2004, and a synthetic Duan MLE recovery test.
270
+ - Executable AAPL-style tutorial (`docs/tutorials/01_single_firm_aapl.md`).
271
+
272
+ ### Added (Phase 0.1)
273
+
274
+ - Initial release scaffolding (pyproject.toml, CI, docs skeleton).
275
+ - Core single-firm Merton model: `Firm`, `MertonModel`, `MertonResult`.
276
+ - Calibration methods: Vassalou-Xing iterative MLE, Jones-Mason-Rosenfeld
277
+ iterative, Bharath-Shumway naive.
278
+ - Vectorized math primitives: `distance_to_default`, `prob_of_default`,
279
+ `implied_credit_spread`, `physical_pd`, `term_structure_pd`.
280
+ - Closed-form equity Greeks: delta, gamma, vega, theta, rho.
281
+ - PD sensitivities to leverage, asset volatility, and risk-free rate.
282
+ - Default-point formulas: KMV (ST + 0.5·LT), total debt, short-only, custom.
283
+ - NumPy backend (default) with backend-dispatch infrastructure ready for
284
+ Numba, CuPy, JAX, and MLX in subsequent phases.
285
+
286
+ [Unreleased]: https://github.com/ItsSypher/merton/compare/HEAD...HEAD
merton-1.0.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed" comment as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 The Merton Authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.