Skip to main content

nirvana-quant: A Statistical and Econometric Framework for Multivariate Cyclical Time Series

PyPI Version Downloads Python Versions C++20 License: MIT Open In Colab


nirvana-quant is an open-source Python and C++ research framework for multivariate time-series econometrics, state-space filtering, directional network spillover modeling, and counterfactual panel reconstruction.

The library bridges classical econometric foundations (Vector Autoregressions, Diebold–Yılmaz connectedness, Kalman filters) with modern non-parametric methods (piecewise regression trees, Fisher Information regularization, and finite-sample Split Conformal Prediction).


🚀 Interactive Notebook Demo (1-Click Run)

Test the complete end-to-end systemic risk pipeline across 27 commercial banks with interactive network graphs, SVD market decoupling, domino default contagion, and Basel IV macroprudential capital surcharge calibration:

Open In Colab


📊 Visualizations & Topological Risk Analytics

The engine extracts systemic interbank connections from multivariate asset price series:

Pairwise Spillover Intensity Heatmap (27x27) Directed Systemic Risk Network Topology
Net Transmitter vs. Receiver Ranking Hub vs. Authority Scatterplot

⚡ Quickstart in 3 Lines

pip install nirvana-quant
import pandas as pd
from nirvana import NirvanaConnectedness

# Fit a TVP-VAR causal Kalman network model
model = NirvanaConnectedness(kalman_q=1e-3, kalman_r=1e-2, orthogonalize_market=True)
results = model.fit(df_asset_returns)

print(f"Total Connectedness Index (TCI): {results.total_connectedness_index:.2f}%")
print("Top Shock Transmitters:", results.top_transmitters[:5])
print("Top Shock Receivers:", results.top_receivers[:5])

🔬 Core Methodological Modules

1. Harmonic Feature Mapping (nirvana.manifold)

  • Maps multi-frequency cyclical signals (such as quarterly financial reporting and annual cycles) onto periodic manifold coordinates ($\mathbb{T}^2 = S^1 \times S^1$).
  • Incorporates Discrete Fourier Transform (DFT) power spectral estimation to identify dominant frequencies empirically.

2. Causal State-Space Filtering & TVP (nirvana.kalman)

  • Implements sequential Kalman state-space estimation with strictly causal updates (zero lookahead bias).
  • Utilizes the Joseph-stabilized covariance formulation: $$P_t = (I - K_t H) P_{t|t-1} (I - K_t H)^T + K_t R K_t^T$$ to ensure positive semi-definiteness under ill-conditioned measurement environments.
  • Employs Huber-type innovation bounds to limit sensitivity to fat-tailed shocks.

3. Regularized Piecewise Regression (nirvana.tree)

  • Captures non-linear residual structures via bounded piecewise regression trees.
  • Utilizes Fisher Information Matrix metrics and sample-margin density criteria to guide terminal-node pruning and mitigate finite-sample overfitting.

4. Directional Spillover & Network Topology (nirvana.network)

  • Computes directional connectedness matrices via Causal Kalman Innovation dynamics and Multi-Lag Asymmetric Lead-Lag transmission (Diebold–Yılmaz framework adapted for large-N banking panels).
  • Employs Truncated SVD to isolate pervasive common market factors from idiosyncratic bank-specific innovations.
  • Integrates Circular Block Bootstrap Edge Apoptosis ($p < 0.05$) to excise statistically spurious links.
  • Evaluates Kleinberg graph centrality measures (Hub and Authority scores) and metric-information Betweenness to distinguish net transmitters from net receivers of shocks.

5. Counterfactual Panel Reconstruction (nirvana.multiverse)

  • Implements counterfactual imputation for unbalanced historical panels (such as pre-listing asset periods) using Tier-Adaptive Peer Anchoring.
  • Eliminates look-ahead bias by conditioning synthesis strictly on contemporaneous peer dynamics and macroeconomic benchmarks.
  • Uses cubic Hermite transition polynomials ($3t^2 - 2t^3$) to ensure boundary continuity between reconstructed and observed sample periods.

6. Two-Stage Estimation & Conformal Prediction (nirvana.static, nirvana.proof)

  • Combines parametric base estimators (OLS, Ridge, Lasso) with non-linear residual trees in a two-stage additive framework.
  • Incorporates Ancestral Fallback Apoptosis Pruning (_get_healthy_node_value) to eradicate overfitted noise memorization.
  • Computes exact finite-sample distribution-free prediction intervals via Vovk's order statistic Conformal Prediction, satisfying finite-sample coverage guarantees: $$P\Big(Y_{n+1} \in [\hat{Y}{n+1} - q, \hat{Y}{n+1} + q]\Big) \ge 1 - \alpha$$

🏛️ Domain Extensions (nirvana.domains)

Domain-specific structural parameters are maintained in modular extensions:

  • banking: Empirical asset-scaling adjustments, exchange price-band limits, and interbank liquidity position mappings for systemic risk studies.
  • cybersecurity: Directed network graph modeling for anomalous traffic flows and node centrality analysis.
  • supply_chain: Multi-tier propagation models for inventory volatility and supplier dependency shocks.

💻 C++ Implementation (nirvana_cpp/)

For low-latency execution and integration into compiled pipelines, the repository includes a self-contained C++20 header library:

  • Header-only: #include <nirvana/nirvana.hpp>.
  • Self-contained linear algebra routines (matrix decomposition, SVD, pseudoinverse) without mandatory external dependencies.
  • Compatible with standard C++20 compilers (GCC 12+, Clang 15+, MSVC 19.30+).

📦 Installation Options

pip install nirvana-quant

From GitHub

pip install git+https://github.com/yinyusi65/nirvana-quant.git

From Local Source

git clone https://github.com/yinyusi65/nirvana-quant.git
cd nirvana-quant
pip install -e .

📖 Usage Examples

1. Two-Stage Regression with Conformal Prediction Intervals

import numpy as np
from nirvana import NirvanaTwoStageRegressor

# Cross-sectional sample
np.random.seed(42)
X = np.random.randn(120, 3)
y = 1.8 * X[:, 0] - 0.7 * (X[:, 1] ** 2) + np.random.randn(120) * 0.15

# Fit two-stage additive model
regressor = NirvanaTwoStageRegressor(base_estimator="ols", max_depth=4)
regressor.fit(X, y)

# Compute 95% conformal prediction intervals
y_pred, y_lower, y_upper = regressor.predict_interval(X, alpha=0.05)
print(f"Point Forecast: {y_pred[0]:.3f}, 95% Interval: [{y_lower[0]:.3f}, {y_upper[0]:.3f}]")

👤 Authors & Maintainers

  • yinyusi65

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for nirvana-quant 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nirvana-quant 1.1.3
File Size Uploaded Provenance Actions
nirvana_quant-1.1.3.tar.gz 91.1 kB Without provenance Details for nirvana_quant-1.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nirvana-quant 1.1.3
File Interpreter ABI Platform Actions
nirvana_quant-1.1.3-py3-none-any.whl Python 3 none any Details for nirvana_quant-1.1.3-py3-none-any.whl

Total release size: 187.4 kB

Release files / nirvana_quant-1.1.3.tar.gz

Download URL nirvana_quant-1.1.3.tar.gz
Size 91.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d3c37594d452d4e60bb7b92e0a22c04b9c766522f1546812f6ca4db94b605332
BLAKE2b-256 checksum
How to use checksums
d4a9c0afa6b6fa74b28ace3da57d9a62f8f069767b6c9198c93a6931396e68b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / nirvana_quant-1.1.3-py3-none-any.whl

Download URL nirvana_quant-1.1.3-py3-none-any.whl
Size 96.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3a6699be2fc74cfdc1beb08c26a3b68bddf6a2e197f2af81beeab60c3198857
BLAKE2b-256 checksum
How to use checksums
c98896ba2497336010964629f5852465353f0227bed8d454c2679ddc1e036217
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Security for nirvana-quant 1.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page