Skip to main content

Conformal recalibration audit for tail quantile forecasters

Project description

conformal-oracle

PyPI version Python License: MIT Downloads

Conformal recalibration audit for tail quantile forecasters.

Given any return series and either a forecaster object or a pre-computed quantile path, conformal-oracle computes a one-parameter conformal correction (static or rolling), classifies the forecast as signal-preserving or replacement, and reports a full backtest panel.

The core install is dependency-agnostic: it needs only NumPy, pandas, SciPy, statsmodels, and matplotlib. No forecaster library is required unless you use the built-in benchmark wrappers.

Implements the methodology from:

Pele, D.T., Bolovaneanu, V., Ginavar, A.T., Lessmann, S., Hardle, W.K. "Recalibrating Tail Event Forecasts under Temporal Dependence" (2026).

What's new in 0.3.1

Coverage bugfix (rolling mode). The rolling conformal correction now uses the finite-sample split-conformal quantile — the ceil((w+1)(1-alpha))-th order statistic of the trailing-window scores — rather than the plain empirical (1-alpha) quantile. Releases up to and including 0.3.0 systematically under-covered in mode="rolling"; if you produced rolling-mode results on an earlier version, re-run on 0.3.1 or later. Static mode is affected only negligibly (large calibration window).

New diagnostics. recalibration.diagnose_scale / ScaleDiagnostic (a location–scale decomposition of the conformal shift) and recalibration.ACICalibrator (an Adaptive Conformal Inference baseline with step size selected by first-half validation). See the changelog for details.

Install

pip install conformal-oracle                 # core (no arch dep)
pip install conformal-oracle[benchmarks]     # + GJR-GARCH, GARCH-Normal
pip install conformal-oracle[chronos]        # + Chronos TSFM
pip install conformal-oracle[all]            # everything

For development:

git clone https://github.com/QuantLet/Conformal_Oracle.git
cd Conformal_Oracle/python
pip install -e ".[dev,benchmarks]"

Quickstart -- agnostic audit (no forecaster dependency)

import pandas as pd
from conformal_oracle import audit

returns = pd.read_csv("returns.csv", index_col=0, parse_dates=True).squeeze()
# q_lo: your model's predicted 1% quantile, same index as returns
q_lo = pd.read_csv("my_var_forecast.csv", index_col=0, parse_dates=True).squeeze()

result = audit(returns, forecast=q_lo, alpha=0.01, mode="static")
print(result.summary())

# Rolling mode: re-estimates the conformal correction from a
# trailing 250-day window (more realistic for live deployment)
result_roll = audit(returns, forecast=q_lo, alpha=0.01, mode="rolling")
print(result_roll.summary())

No arch, no torch, no heavyweight dependency -- just your quantile series.

Quickstart -- with a forecaster object

from conformal_oracle import audit
from conformal_oracle.contrib.benchmarks import GJRGARCHForecaster

result = audit(returns, GJRGARCHForecaster(), alpha=0.01, mode="rolling")
print(result.summary())

Regime classification

from conformal_oracle import classify_regime

verdict = classify_regime(returns, forecast=q_lo, mode="rolling")
print(verdict.regime)       # "signal-preserving" or "replacement"
print(verdict.R)            # replacement ratio
print(verdict.basel_zone)   # "green", "yellow", or "red"

Compare multiple forecasters

from conformal_oracle import compare_forecasters

comp = compare_forecasters(
    returns,
    {"model_A": q_lo_A, "model_B": q_lo_B},
    mode="rolling",
)
print(comp.comparison_table())
print(comp.dm_matrix())

Custom forecaster

Any object implementing fit(returns) and forecast(returns, t) works:

from conformal_oracle._types import SampleDistribution

class MyForecaster:
    def fit(self, returns): pass
    def forecast(self, returns, t):
        hist = returns.iloc[max(0, t-250):t]
        return SampleDistribution(samples=hist.values)

result = audit(returns, MyForecaster(), alpha=0.01)

Worked examples

Documentation

Requirements

Python 3.10+, numpy, pandas, scipy, statsmodels, matplotlib.

GARCH benchmarks require arch>=6.0 (install with [benchmarks]). TSFM wrappers require PyTorch and model-specific packages (see extras).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conformal_oracle-0.3.2.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conformal_oracle-0.3.2-py3-none-any.whl (81.2 kB view details)

Uploaded Python 3

File details

Details for the file conformal_oracle-0.3.2.tar.gz.

File metadata

  • Download URL: conformal_oracle-0.3.2.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for conformal_oracle-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7d66a554f82518a7a6783f93bc554fc1e406829431a4a8655eab560e70a6794b
MD5 0e49a724bb271b4dc218d79e18a15a1d
BLAKE2b-256 54818dd0de09c9c3154605c204ff7a8c15ac2c521734b4ff9f3087e1d690d312

See more details on using hashes here.

File details

Details for the file conformal_oracle-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for conformal_oracle-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9f2cae85e84fe7cbe8d98a24c7fc494df3f0486499c33f3a222f829571afe9f
MD5 088fb0392f45174d691126e51bb59253
BLAKE2b-256 de5903f1007092f363c9233b0148d23e2c36d1e0c3c53b87b26f76248dc53377

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page