Skip to main content

Market Regime Validity Library for Model Risk Governance

Project description

mrv-lib: Market Regime Validity Library

The Gold Standard for Model Risk Diagnostics in Non-Stationary Markets.

mrv-lib is an open-source Python library designed to quantify and diagnose the stability of market regime identification models. Built upon the theoretical framework of Inference Collapse and Ordinal Robustness, it provides financial institutions with a rigorous toolset to meet Basel IV and SR 11-7 model risk governance requirements.

Why mrv-lib?

Traditional market regime models often suffer from "Stability Illusions." A model may appear robust at daily resolutions but fail to capture structural shifts during high-frequency intraday stress events. mrv-lib exposes these vulnerabilities by measuring:

  • Representation Sensitivity: How sensitive are your regime labels to feature engineering and preprocessing?
  • Resolution Dissonance: Does your model's daily output contradict its high-frequency signals?
  • Identifiability Boundaries: Is the market currently in a "Zone of Collapse" where absolute labels are mathematically unreliable?

Key Features

1. Sensitivity Diagnostic (RSS)

Automated stress-testing of regime labels across multiple feature sets (Representation) and temporal scales (Resolution). It calculates the RSS (Representation Stability Score) to quantify model robustness.

2. Identifiability Index

Calculates the Identifiability Index (\(\mathcal{I}\)) based on structural drift and regime separation. It identifies the "Phase Boundaries" where model inference begins to collapse.

3. Ordinal Robustness

When absolute labels (ARI) collapse, mrv-lib measures Ordinal Consistency (Spearman's Rho) to determine if the risk ranking remains valid for fail-safe hedging.

Installation

pip install mrv-lib

Quick Start

import mrv_lib as mrv
import pandas as pd

# Load your market data (OHLCV)
data = pd.read_csv("market_data.csv")

# Initialize the diagnostic scanner
scanner = mrv.Scanner(resolution=['5m', '1h', '1d'])

# Run representation stability test
results = scanner.run_representation_test(data, model="HMM")

# Get the RSS (Representation Stability Score)
print(f"Model RSS: {results.rss_score}")

# Detect Identifiability Boundaries
boundary = mrv.detect_boundary(data)
if boundary.is_collapsed:
    print(f"Warning: Entering Inference Collapse Zone. Identifiability Index: {boundary.index}")

Command-Line Interface

After installation, you can run diagnostics from the shell:

mrv-lib market_data.csv --resolution 5m 1h 1d --model HMM

Project Layout

mrv-lib/
├── src/
│   └── mrv_lib/
│       ├── __init__.py
│       └── core.py
├── tests/
├── README.md
├── LICENSE
└── pyproject.toml

Theoretical Foundation

The methodology of mrv-lib is documented in a series of peer-reviewed research papers:

  • Regime Labels Are Not Representation-Invariant: Evidence of instability across feature sets.
  • Regime Labels Are Not Resolution-Invariant: Documentation of the 14-hour lag in daily risk reporting.
  • Inference Collapse and Ordinal Robustness: Defining the phase boundaries of market state identification.

For academic citations, please refer to the documentation.

Commercial Support & SaaS

For enterprise-grade features including real-time alerting, Basel IV Compliance Reporting, and the Fail-Safe Actuator engine, please visit ModelGuard.co.nz.

  • ModelGuard Sentinel: Real-time monitoring for institutional trading desks.
  • ModelGuard Advisory: Professional consulting for RBNZ/APRA regulatory alignment.

Maintainers

Maintained by ModelGuard Lab. Lead Architect: Kai Zheng.

License

mrv-lib is released under the MIT License. See LICENSE for details.

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

mrv_lib-0.0.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

mrv_lib-0.0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file mrv_lib-0.0.1.tar.gz.

File metadata

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

File hashes

Hashes for mrv_lib-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9e96586565b43fbd9fe4e67566dc756e345b5b294ba3ca5763ae9c968c894753
MD5 6cc6459d72a0a21eb99e689c5bd52ff2
BLAKE2b-256 dbcda0975630c06b357e7c4c3f7a68760ead2f220b7d78ee3a8ce38d498675ce

See more details on using hashes here.

File details

Details for the file mrv_lib-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mrv_lib-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mrv_lib-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b15a489d150694f1edb06f833eda61a74c238d7550a12667dada65c532341e23
MD5 38dbb3eec76fe14f66145c84eac27c7b
BLAKE2b-256 a04e845e2f60b6323b35040cc9d1c79c90aaad04817090080c9faa0406d86827

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