merton.backtest.rolling

Rolling-window backtester for PD models on a panel of firms.

Classes

RollingBacktestResult

Per-window metric values.

Functions

rolling_window(→ RollingBacktestResult)

Roll a window across panel and compute AUC/Brier/KS per window.

Module Contents

class merton.backtest.rolling.RollingBacktestResult[source]

Per-window metric values.

window_starts: pandas.DatetimeIndex[source]
auc: numpy.ndarray[source]
accuracy_ratio: numpy.ndarray[source]
brier: numpy.ndarray[source]
ks: numpy.ndarray[source]
to_pandas() pandas.DataFrame[source]
merton.backtest.rolling.rolling_window(panel: pandas.DataFrame, *, pd_col: str = 'pd', default_col: str = 'default', date_col: str = 'date', window: str = '252D', step: str = '21D') RollingBacktestResult[source]

Roll a window across panel and compute AUC/Brier/KS per window.

Parameters:
  • panel – Long-form DataFrame with at minimum date_col, pd_col, and default_col columns. pd_col is the model’s predicted PD for that (firm, date) and default_col is the realised 0/1 default indicator over the next observation period.

  • window – Pandas frequency strings; the window slides step forward at each iteration.

  • step – Pandas frequency strings; the window slides step forward at each iteration.