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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dffffd49cbdbc6d11ec142d838ee57f8f6f449eecefd4d2f0b703d59c2e135c2
|
|
| MD5 |
3569f0fb676ce3577991a1050db2ce8b
|
|
| BLAKE2b-256 |
e26d35fcb72b78a447de640ad6a287f1667b4ec743714c56e7a29397af4538a9
|
Provenance
The following attestation bundles were made for mrv_lib-0.0.2.tar.gz:
Publisher:
publish.yml on modelguard-lab/mrv-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrv_lib-0.0.2.tar.gz -
Subject digest:
dffffd49cbdbc6d11ec142d838ee57f8f6f449eecefd4d2f0b703d59c2e135c2 - Sigstore transparency entry: 1102065623
- Sigstore integration time:
-
Permalink:
modelguard-lab/mrv-lib@2b1980faabb2df6d494d8550d4e2b57d2b492635 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/modelguard-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2b1980faabb2df6d494d8550d4e2b57d2b492635 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
457fc8838acdfb2ae742652236ee1acd64582fc28684c57a361893db66ed7e3f
|
|
| MD5 |
888b861e69535edf7befcf8b261f59dc
|
|
| BLAKE2b-256 |
92002e07d8f099267eb15a0f67ad1f8e1b4ca59d1ab9bf150d2c2b94a171f573
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrv_lib-0.0.2-py3-none-any.whl -
Subject digest:
457fc8838acdfb2ae742652236ee1acd64582fc28684c57a361893db66ed7e3f - Sigstore transparency entry: 1102065662
- Sigstore integration time:
-
Permalink:
modelguard-lab/mrv-lib@2b1980faabb2df6d494d8550d4e2b57d2b492635 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/modelguard-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2b1980faabb2df6d494d8550d4e2b57d2b492635 -
Trigger Event:
workflow_dispatch
-
Statement type: