merton
A production-grade Python package for the Merton structural credit-risk model and its industry-standard descendants (KMV, Black-Cox, Geske, Longstaff-Schwartz, CreditGrades, Leland-Toft, jump-diffusion, Vasicek portfolio, climate overlays).
🚀 New in 1.0 — first stable release. API frozen per semver, cold
import mertondown to ~500 ms (from ~1.1 s), conda-forge feedstock in review. See the announcement post and the migration guide.
Highlights
- Vectorized core — single-firm and panel-scale (10 000+ firms × decades) with NumPy by default and optional Numba / JAX / CuPy / MLX backends.
- Multiple calibration methods — Vassalou-Xing iterative MLE, Duan transformed-data MLE (with survivorship-bias correction), Jones-Mason-Rosenfeld, Bharath-Shumway naive, KMV iterative (Crosbie-Bohn).
- Full extensions library — Black-Cox first-passage, Geske compound options, Longstaff-Schwartz stochastic rates, CreditGrades, Leland-Toft endogenous default, Zhou jump-diffusion, hybrid structural/reduced-form, climate overlays.
- Portfolio engine — Vasicek single-factor (Basel IRB closed-form), Gaussian / t / Clayton / factor copulas, Monte Carlo loss distribution with VaR / ES / economic capital.
- Backtesting harness — AUC, Brier, KS, accuracy ratio, reliability / calibration curves, rolling-window and walk-forward validation.
- Excel integration —
=MERTON_DD(equity, σE, debt, rf, T)and friends, available in Excel Web, Excel Mac (M365), and Excel Windows via xlwings Server. - Climate stress — composable
Scenarioframework with packaged NGFS Phase V (2024) scenarios (net_zero_2050,delayed_transition,current_policies,fragmented_world);ClimateOverlaywraps any structural model with carbon-price paths and sectoral PD multipliers. - OpenTelemetry observability — opt-in via
merton.obs.enable(...); pipes spans to any OTLP-compatible backend (Datadog, Honeycomb, Tempo, …). - Modern Python — type hints, Pydantic settings, structured logging, Apache-2.0 license, cross-platform wheels for Python 3.11-3.14 (incl. free-threaded).
Quickstart
uv pip install merton # or: pip install merton
from merton import Firm, fit
firm = Firm(
equity=100_000_000, # $100M market cap
debt_short=20_000_000,
debt_long=30_000_000,
equity_vol=0.30,
rf=0.045,
horizon=1.0,
)
result = fit(firm, method="vassalou_xing")
print(result.summary())
# MertonResult
# distance_to_default : 3.142
# probability_of_default : 0.000839
# asset_value : 148.6M
# asset_vol : 0.207
# implied_spread (LGD=0.6) : 5.0 bps
Excel integration
merton excel install
merton excel server start --port 8000
Then in any Excel workbook (Web / Mac / Windows):
=MERTON_DD(B2, B3, B4+B5, B6, B7) # distance to default
=MERTON_PD(B2, B3, B4+B5, B6, B7) # probability of default
=MERTON_SPREAD(B2, B3, B4+B5, B6, B7, 0.6)
See the Excel docs for the full reference.
Performance
- Single-firm fit: <50 ms
- 10 000-firm × 10-year daily panel: <60 s on 8 cores (Numba backend)
- 100 000-sim portfolio VaR: <30 s with GPU (CuPy)
Documentation
Full docs at https://merton.readthedocs.io including:
- Theory deep-dives (Merton 1974, KMV, Black-Cox, Geske, …)
- Executable tutorials (AAPL time series, panel backtest, portfolio VaR, climate stress test, GPU acceleration, Excel integration)
- API reference
- Performance benchmarks and backend-selection guide
Installation matrix
| Goal | Command |
|---|---|
| Minimum (CPU NumPy) | pip install merton |
| Numba JIT (default fast path) | pip install merton (Numba is a hard dep) |
| GPU acceleration | pip install "merton[gpu]" (requires CUDA 12) |
| JAX autodiff calibration | pip install "merton[jax]" |
| Apple Silicon GPU | pip install "merton[mlx]" |
| Excel integration | pip install "merton[excel]" |
| Visualization (matplotlib + plotly) | pip install "merton[viz]" |
| Bayesian MCMC calibration | pip install "merton[mcmc]" |
| OpenTelemetry tracing | pip install "merton[obs]" |
| Everything | pip install "merton[all]" |
License
Apache-2.0 — see LICENSE.
Citing
If you use merton in academic work, please cite via the
CITATION.cff file or the package's Zenodo DOI (assigned on first
tagged release).
Metadata
Release files for merton 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| merton-1.0.2.tar.gz | 215.8 kB | With provenance | Details for merton-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| merton-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for merton-1.0.2-py3-none-any.whl |
Total release size: 381.7 kB
Release files / merton-1.0.2.tar.gz
| Download URL | merton-1.0.2.tar.gz |
|---|---|
| Size | 215.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
530fbe82a16616ee9c12704ee422698fb687e6ea7b9dafb82cdee4d520667f34
|
|
BLAKE2b-256 checksum How to use checksums |
be7a383e0dd4a46caacc0f9bf4eb813403c6beb5437342a28d853d10d102836b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logRelease files / merton-1.0.2-py3-none-any.whl
| Download URL | merton-1.0.2-py3-none-any.whl |
|---|---|
| Size | 165.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
254c224ba43ca3533a8d0301a085f0c7c5de6554648d306c2239c40da812485e
|
|
BLAKE2b-256 checksum How to use checksums |
69b07e59033818f7032cef559ef06e1615007e90985a52c1355d99a67539ea6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logSecurity for merton 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for merton-1.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.