merton.excel.functions¶
Excel-facing Python wrappers around the merton math primitives.
Each function below mirrors a public =MERTON_* formula exposed to Excel
and accepts simple scalar or 1-D array inputs (the natural shape of Excel
cell ranges). When xlwings is installed, merton.excel.server
applies the @func / @arg decorators to the same functions so they
become available as Office.js custom functions.
The wrappers also act as the single source of truth for the formula docstrings and parameter names — the manifest XML and the function-wizard help text are derived from these signatures.
Attributes¶
|
Functions¶
|
Distance to default under the Merton (1974) structural model. |
|
Risk-neutral probability of default at the horizon |
|
Implied credit spread (basis points) given LGD. |
|
Inferred firm asset value |
|
Inferred annualised asset volatility |
|
Returns a 1×6 array of Greeks: Δ, Γ, Vega, Θ, ρ, ∂PD/∂L. |
|
PD term structure across horizons. Returns a 2-column dynamic array |
|
Compute a single backtest metric over two equal-length ranges. |
|
Basel-IRB Vasicek single-factor VaR (Loss / Exposure). |
|
Black-Cox first-passage PD with optional barrier-growth rate. |
Module Contents¶
- merton.excel.functions.merton_dd(equity: float, equity_vol: float, debt: float, rf: float, T: float) float[source]¶
Distance to default under the Merton (1974) structural model.
Inverts the equity-as-call-option pricing to recover the asset value and asset volatility, then returns
DD = d₂.
- merton.excel.functions.merton_pd(equity: float, equity_vol: float, debt: float, rf: float, T: float) float[source]¶
Risk-neutral probability of default at the horizon
T.
- merton.excel.functions.merton_spread(equity: float, equity_vol: float, debt: float, rf: float, T: float, lgd: float = 0.6) float[source]¶
Implied credit spread (basis points) given LGD.
- merton.excel.functions.merton_asset_value(equity: float, equity_vol: float, debt: float, rf: float, T: float) float[source]¶
Inferred firm asset value
A(currency units).
- merton.excel.functions.merton_asset_vol(equity: float, equity_vol: float, debt: float, rf: float, T: float) float[source]¶
Inferred annualised asset volatility
σ_A(decimal).
- merton.excel.functions.merton_greeks(equity: float, equity_vol: float, debt: float, rf: float, T: float) list[list[float]][source]¶
Returns a 1×6 array of Greeks: Δ, Γ, Vega, Θ, ρ, ∂PD/∂L.
The first row is the labels (when the Excel range is 2 rows tall) and the second is the values; Excel’s dynamic-array engine will spill the result automatically.
- merton.excel.functions.merton_pd_term(equity: float, equity_vol: float, debt: float, rf: float, horizons: collections.abc.Sequence[float]) list[list[float]][source]¶
PD term structure across horizons. Returns a 2-column dynamic array with headers
[horizon_years, pd].
- merton.excel.functions.merton_backtest(pd_predictions: collections.abc.Sequence[float], defaults: collections.abc.Sequence[float], metric: str = 'AUC') float[source]¶
Compute a single backtest metric over two equal-length ranges.
- merton.excel.functions.merton_portfolio_var(pd: float, lgd: float = 0.45, rho: float | None = None, alpha: float = 0.999, maturity: float = 1.0) float[source]¶
Basel-IRB Vasicek single-factor VaR (Loss / Exposure).