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.2.tar.gz (8.4 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.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mrv_lib-0.0.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mrv_lib-0.0.2.tar.gz
Algorithm Hash digest
SHA256 dffffd49cbdbc6d11ec142d838ee57f8f6f449eecefd4d2f0b703d59c2e135c2
MD5 3569f0fb676ce3577991a1050db2ce8b
BLAKE2b-256 e26d35fcb72b78a447de640ad6a287f1667b4ec743714c56e7a29397af4538a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrv_lib-0.0.2.tar.gz:

Publisher: publish.yml on modelguard-lab/mrv-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: mrv_lib-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mrv_lib-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 457fc8838acdfb2ae742652236ee1acd64582fc28684c57a361893db66ed7e3f
MD5 888b861e69535edf7befcf8b261f59dc
BLAKE2b-256 92002e07d8f099267eb15a0f67ad1f8e1b4ca59d1ab9bf150d2c2b94a171f573

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrv_lib-0.0.2-py3-none-any.whl:

Publisher: publish.yml on modelguard-lab/mrv-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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