nirvana-quant 1.0.0__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nirvana_quant-1.0.2/PKG-INFO +188 -0
- nirvana_quant-1.0.2/README.md +165 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/__init__.py +76 -75
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/manifold.py +286 -184
- nirvana_quant-1.0.2/nirvana_quant/__init__.py +25 -0
- nirvana_quant-1.0.2/nirvana_quant.egg-info/PKG-INFO +188 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana_quant.egg-info/SOURCES.txt +1 -0
- nirvana_quant-1.0.2/nirvana_quant.egg-info/requires.txt +3 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana_quant.egg-info/top_level.txt +1 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/pyproject.toml +33 -33
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/setup.py +41 -41
- nirvana_quant-1.0.0/PKG-INFO +0 -168
- nirvana_quant-1.0.0/README.md +0 -145
- nirvana_quant-1.0.0/nirvana_quant.egg-info/PKG-INFO +0 -168
- nirvana_quant-1.0.0/nirvana_quant.egg-info/requires.txt +0 -3
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/LICENSE +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/domains/__init__.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/domains/banking.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/domains/consumer.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/domains/cybersecurity.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/domains/substitute.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/domains/supply_chain.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/experimental/__init__.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/experimental/multiverse_invariance.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/kalman.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/multiplex.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/multiverse.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/network.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/proof.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/stata.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/static.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/tree.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana/volatility.py +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/nirvana_quant.egg-info/dependency_links.txt +0 -0
- {nirvana_quant-1.0.0 → nirvana_quant-1.0.2}/setup.cfg +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nirvana-quant
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Nirvana: Chrono-Cancer Meta-Architecture for High-Dimensional Cyclical Time-Series & Dynamical Network Analysis
|
|
5
|
+
Home-page: https://github.com/yinyusi65/nirvana-quant
|
|
6
|
+
Author: yinyusi65
|
|
7
|
+
Project-URL: Homepage, https://github.com/yinyusi65/nirvana-quant
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/yinyusi65/nirvana-quant/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: numpy<2.3.0,>=1.22.0
|
|
18
|
+
Requires-Dist: pandas<3.0.0,>=1.4.0
|
|
19
|
+
Requires-Dist: scipy>=1.8.0
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
|
|
24
|
+
# nirvana-quant: A Statistical and Econometric Framework for Multivariate Cyclical Time Series
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<a href="https://pypi.org/project/nirvana-quant/"><img src="https://img.shields.io/pypi/v/nirvana-quant.svg?color=007ec6&logo=pypi&logoColor=white" alt="PyPI Version"></a>
|
|
28
|
+
<a href="https://pypi.org/project/nirvana-quant/"><img src="https://img.shields.io/pypi/dm/nirvana-quant?color=blue&logo=python&logoColor=white" alt="Downloads"></a>
|
|
29
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg?logo=python&logoColor=white" alt="Python Versions"></a>
|
|
30
|
+
<a href="nirvana_cpp/"><img src="https://img.shields.io/badge/C%2B%2B-20%20Header--Only-purple.svg?logo=cplusplus&logoColor=white" alt="C++20"></a>
|
|
31
|
+
<a href="https://www.gnu.org/licenses/gpl-3.0"><img src="https://img.shields.io/badge/License-GPLv3-green.svg" alt="License: GPL v3"></a>
|
|
32
|
+
<a href="https://colab.research.google.com/github/yinyusi65/nirvana-quant/blob/main/test_nirvana_netbank_full_pipeline.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
`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.
|
|
38
|
+
|
|
39
|
+
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).
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🚀 Interactive Notebook Demo (1-Click Run)
|
|
44
|
+
|
|
45
|
+
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:
|
|
46
|
+
|
|
47
|
+
[](https://colab.research.google.com/github/yinyusi65/nirvana-quant/blob/main/test_nirvana_netbank_full_pipeline.ipynb)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📊 Visualizations & Topological Risk Analytics
|
|
52
|
+
|
|
53
|
+
The engine extracts systemic interbank connections from multivariate asset price series:
|
|
54
|
+
|
|
55
|
+
| Pairwise Spillover Intensity Heatmap (27x27) | Directed Systemic Risk Network Topology |
|
|
56
|
+
| :---: | :---: |
|
|
57
|
+
| <img src="docs/images/banking_pairwise_spillover_heatmap.png" width="450"/> | <img src="docs/images/banking_network_directed_topology.png" width="450"/> |
|
|
58
|
+
|
|
59
|
+
| Net Transmitter vs. Receiver Ranking | Hub vs. Authority Scatterplot |
|
|
60
|
+
| :---: | :---: |
|
|
61
|
+
| <img src="docs/images/banking_net_spillover_ranking.png" width="450"/> | <img src="docs/images/banking_hub_vs_authority_scatter.png" width="450"/> |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## ⚡ Quickstart in 3 Lines
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install nirvana-quant
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import pandas as pd
|
|
73
|
+
from nirvana import NirvanaConnectedness
|
|
74
|
+
|
|
75
|
+
# Fit a TVP-VAR causal Kalman network model
|
|
76
|
+
model = NirvanaConnectedness(kalman_q=1e-3, kalman_r=1e-2, orthogonalize_market=True)
|
|
77
|
+
results = model.fit(df_asset_returns)
|
|
78
|
+
|
|
79
|
+
print(f"Total Connectedness Index (TCI): {results.total_connectedness_index:.2f}%")
|
|
80
|
+
print("Top Shock Transmitters:", results.top_transmitters[:5])
|
|
81
|
+
print("Top Shock Receivers:", results.top_receivers[:5])
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🔬 Core Methodological Modules
|
|
87
|
+
|
|
88
|
+
### 1. Harmonic Feature Mapping (`nirvana.manifold`)
|
|
89
|
+
* 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$).
|
|
90
|
+
* Incorporates Discrete Fourier Transform (DFT) power spectral estimation to identify dominant frequencies empirically.
|
|
91
|
+
|
|
92
|
+
### 2. Causal State-Space Filtering & TVP (`nirvana.kalman`)
|
|
93
|
+
* Implements sequential Kalman state-space estimation with strictly causal updates (zero lookahead bias).
|
|
94
|
+
* Utilizes the Joseph-stabilized covariance formulation:
|
|
95
|
+
$$P_t = (I - K_t H) P_{t|t-1} (I - K_t H)^T + K_t R K_t^T$$
|
|
96
|
+
to ensure positive semi-definiteness under ill-conditioned measurement environments.
|
|
97
|
+
* Employs Huber-type innovation bounds to limit sensitivity to fat-tailed shocks.
|
|
98
|
+
|
|
99
|
+
### 3. Regularized Piecewise Regression (`nirvana.tree`)
|
|
100
|
+
* Captures non-linear residual structures via bounded piecewise regression trees.
|
|
101
|
+
* Utilizes Fisher Information Matrix metrics and sample-margin density criteria to guide terminal-node pruning and mitigate finite-sample overfitting.
|
|
102
|
+
|
|
103
|
+
### 4. Directional Spillover & Network Topology (`nirvana.network`)
|
|
104
|
+
* Computes directional connectedness matrices via Vector Autoregressions (VAR) and Generalized Forecast Error Variance Decomposition (GFEVD, Koop–Pesaran–Potter).
|
|
105
|
+
* Employs Singular Value Decomposition (SVD) to isolate pervasive common market factors from idiosyncratic innovations.
|
|
106
|
+
* Evaluates Kleinberg graph centrality measures (Hub and Authority scores) to distinguish net transmitters from net receivers of shocks.
|
|
107
|
+
|
|
108
|
+
### 5. Counterfactual Panel Reconstruction (`nirvana.multiverse`)
|
|
109
|
+
* Implements counterfactual imputation for unbalanced historical panels (such as pre-listing asset periods).
|
|
110
|
+
* Evaluates sensitivity across structured simulation paths anchored on peer-group dynamics and macroeconomic benchmarks.
|
|
111
|
+
* Uses cubic Hermite transition polynomials ($3t^2 - 2t^3$) to ensure boundary continuity between reconstructed and observed sample periods.
|
|
112
|
+
|
|
113
|
+
### 6. Two-Stage Estimation & Conformal Prediction (`nirvana.static`, `nirvana.proof`)
|
|
114
|
+
* Combines parametric base estimators (OLS, Ridge, Lasso) with non-linear residual trees in a two-stage additive framework.
|
|
115
|
+
* Computes distribution-free prediction intervals via Split Conformal Prediction, satisfying finite-sample coverage guarantees:
|
|
116
|
+
$$P\Big(Y_{n+1} \in [\hat{Y}_{n+1} - q, \hat{Y}_{n+1} + q]\Big) \ge 1 - \alpha$$
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 🏛️ Domain Extensions (`nirvana.domains`)
|
|
121
|
+
|
|
122
|
+
Domain-specific structural parameters are maintained in modular extensions:
|
|
123
|
+
|
|
124
|
+
* **`banking`**: Empirical asset-scaling adjustments, exchange price-band limits, and interbank liquidity position mappings for systemic risk studies.
|
|
125
|
+
* **`cybersecurity`**: Directed network graph modeling for anomalous traffic flows and node centrality analysis.
|
|
126
|
+
* **`supply_chain`**: Multi-tier propagation models for inventory volatility and supplier dependency shocks.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 💻 C++ Implementation (`nirvana_cpp/`)
|
|
131
|
+
|
|
132
|
+
For low-latency execution and integration into compiled pipelines, the repository includes a self-contained C++20 header library:
|
|
133
|
+
|
|
134
|
+
* Header-only: `#include <nirvana/nirvana.hpp>`.
|
|
135
|
+
* Self-contained linear algebra routines (matrix decomposition, SVD, pseudoinverse) without mandatory external dependencies.
|
|
136
|
+
* Compatible with standard C++20 compilers (GCC 12+, Clang 15+, MSVC 19.30+).
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 📦 Installation Options
|
|
141
|
+
|
|
142
|
+
### From PyPI (Recommended)
|
|
143
|
+
```bash
|
|
144
|
+
pip install nirvana-quant
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### From GitHub
|
|
148
|
+
```bash
|
|
149
|
+
pip install git+https://github.com/yinyusi65/nirvana-quant.git
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### From Local Source
|
|
153
|
+
```bash
|
|
154
|
+
git clone https://github.com/yinyusi65/nirvana-quant.git
|
|
155
|
+
cd nirvana-quant
|
|
156
|
+
pip install -e .
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 📖 Usage Examples
|
|
162
|
+
|
|
163
|
+
### 1. Two-Stage Regression with Conformal Prediction Intervals
|
|
164
|
+
```python
|
|
165
|
+
import numpy as np
|
|
166
|
+
from nirvana import NirvanaTwoStageRegressor
|
|
167
|
+
|
|
168
|
+
# Cross-sectional sample
|
|
169
|
+
np.random.seed(42)
|
|
170
|
+
X = np.random.randn(120, 3)
|
|
171
|
+
y = 1.8 * X[:, 0] - 0.7 * (X[:, 1] ** 2) + np.random.randn(120) * 0.15
|
|
172
|
+
|
|
173
|
+
# Fit two-stage additive model
|
|
174
|
+
regressor = NirvanaTwoStageRegressor(base_estimator="ols", max_depth=4)
|
|
175
|
+
regressor.fit(X, y)
|
|
176
|
+
|
|
177
|
+
# Compute 95% conformal prediction intervals
|
|
178
|
+
y_pred, y_lower, y_upper = regressor.predict_interval(X, alpha=0.05)
|
|
179
|
+
print(f"Point Forecast: {y_pred[0]:.3f}, 95% Interval: [{y_lower[0]:.3f}, {y_upper[0]:.3f}]")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 👤 Authors & Maintainers
|
|
185
|
+
* **yinyusi65**
|
|
186
|
+
|
|
187
|
+
## 📄 License
|
|
188
|
+
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# nirvana-quant: A Statistical and Econometric Framework for Multivariate Cyclical Time Series
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pypi.org/project/nirvana-quant/"><img src="https://img.shields.io/pypi/v/nirvana-quant.svg?color=007ec6&logo=pypi&logoColor=white" alt="PyPI Version"></a>
|
|
5
|
+
<a href="https://pypi.org/project/nirvana-quant/"><img src="https://img.shields.io/pypi/dm/nirvana-quant?color=blue&logo=python&logoColor=white" alt="Downloads"></a>
|
|
6
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg?logo=python&logoColor=white" alt="Python Versions"></a>
|
|
7
|
+
<a href="nirvana_cpp/"><img src="https://img.shields.io/badge/C%2B%2B-20%20Header--Only-purple.svg?logo=cplusplus&logoColor=white" alt="C++20"></a>
|
|
8
|
+
<a href="https://www.gnu.org/licenses/gpl-3.0"><img src="https://img.shields.io/badge/License-GPLv3-green.svg" alt="License: GPL v3"></a>
|
|
9
|
+
<a href="https://colab.research.google.com/github/yinyusi65/nirvana-quant/blob/main/test_nirvana_netbank_full_pipeline.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
`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.
|
|
15
|
+
|
|
16
|
+
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).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🚀 Interactive Notebook Demo (1-Click Run)
|
|
21
|
+
|
|
22
|
+
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:
|
|
23
|
+
|
|
24
|
+
[](https://colab.research.google.com/github/yinyusi65/nirvana-quant/blob/main/test_nirvana_netbank_full_pipeline.ipynb)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📊 Visualizations & Topological Risk Analytics
|
|
29
|
+
|
|
30
|
+
The engine extracts systemic interbank connections from multivariate asset price series:
|
|
31
|
+
|
|
32
|
+
| Pairwise Spillover Intensity Heatmap (27x27) | Directed Systemic Risk Network Topology |
|
|
33
|
+
| :---: | :---: |
|
|
34
|
+
| <img src="docs/images/banking_pairwise_spillover_heatmap.png" width="450"/> | <img src="docs/images/banking_network_directed_topology.png" width="450"/> |
|
|
35
|
+
|
|
36
|
+
| Net Transmitter vs. Receiver Ranking | Hub vs. Authority Scatterplot |
|
|
37
|
+
| :---: | :---: |
|
|
38
|
+
| <img src="docs/images/banking_net_spillover_ranking.png" width="450"/> | <img src="docs/images/banking_hub_vs_authority_scatter.png" width="450"/> |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## ⚡ Quickstart in 3 Lines
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install nirvana-quant
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import pandas as pd
|
|
50
|
+
from nirvana import NirvanaConnectedness
|
|
51
|
+
|
|
52
|
+
# Fit a TVP-VAR causal Kalman network model
|
|
53
|
+
model = NirvanaConnectedness(kalman_q=1e-3, kalman_r=1e-2, orthogonalize_market=True)
|
|
54
|
+
results = model.fit(df_asset_returns)
|
|
55
|
+
|
|
56
|
+
print(f"Total Connectedness Index (TCI): {results.total_connectedness_index:.2f}%")
|
|
57
|
+
print("Top Shock Transmitters:", results.top_transmitters[:5])
|
|
58
|
+
print("Top Shock Receivers:", results.top_receivers[:5])
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🔬 Core Methodological Modules
|
|
64
|
+
|
|
65
|
+
### 1. Harmonic Feature Mapping (`nirvana.manifold`)
|
|
66
|
+
* 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$).
|
|
67
|
+
* Incorporates Discrete Fourier Transform (DFT) power spectral estimation to identify dominant frequencies empirically.
|
|
68
|
+
|
|
69
|
+
### 2. Causal State-Space Filtering & TVP (`nirvana.kalman`)
|
|
70
|
+
* Implements sequential Kalman state-space estimation with strictly causal updates (zero lookahead bias).
|
|
71
|
+
* Utilizes the Joseph-stabilized covariance formulation:
|
|
72
|
+
$$P_t = (I - K_t H) P_{t|t-1} (I - K_t H)^T + K_t R K_t^T$$
|
|
73
|
+
to ensure positive semi-definiteness under ill-conditioned measurement environments.
|
|
74
|
+
* Employs Huber-type innovation bounds to limit sensitivity to fat-tailed shocks.
|
|
75
|
+
|
|
76
|
+
### 3. Regularized Piecewise Regression (`nirvana.tree`)
|
|
77
|
+
* Captures non-linear residual structures via bounded piecewise regression trees.
|
|
78
|
+
* Utilizes Fisher Information Matrix metrics and sample-margin density criteria to guide terminal-node pruning and mitigate finite-sample overfitting.
|
|
79
|
+
|
|
80
|
+
### 4. Directional Spillover & Network Topology (`nirvana.network`)
|
|
81
|
+
* Computes directional connectedness matrices via Vector Autoregressions (VAR) and Generalized Forecast Error Variance Decomposition (GFEVD, Koop–Pesaran–Potter).
|
|
82
|
+
* Employs Singular Value Decomposition (SVD) to isolate pervasive common market factors from idiosyncratic innovations.
|
|
83
|
+
* Evaluates Kleinberg graph centrality measures (Hub and Authority scores) to distinguish net transmitters from net receivers of shocks.
|
|
84
|
+
|
|
85
|
+
### 5. Counterfactual Panel Reconstruction (`nirvana.multiverse`)
|
|
86
|
+
* Implements counterfactual imputation for unbalanced historical panels (such as pre-listing asset periods).
|
|
87
|
+
* Evaluates sensitivity across structured simulation paths anchored on peer-group dynamics and macroeconomic benchmarks.
|
|
88
|
+
* Uses cubic Hermite transition polynomials ($3t^2 - 2t^3$) to ensure boundary continuity between reconstructed and observed sample periods.
|
|
89
|
+
|
|
90
|
+
### 6. Two-Stage Estimation & Conformal Prediction (`nirvana.static`, `nirvana.proof`)
|
|
91
|
+
* Combines parametric base estimators (OLS, Ridge, Lasso) with non-linear residual trees in a two-stage additive framework.
|
|
92
|
+
* Computes distribution-free prediction intervals via Split Conformal Prediction, satisfying finite-sample coverage guarantees:
|
|
93
|
+
$$P\Big(Y_{n+1} \in [\hat{Y}_{n+1} - q, \hat{Y}_{n+1} + q]\Big) \ge 1 - \alpha$$
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🏛️ Domain Extensions (`nirvana.domains`)
|
|
98
|
+
|
|
99
|
+
Domain-specific structural parameters are maintained in modular extensions:
|
|
100
|
+
|
|
101
|
+
* **`banking`**: Empirical asset-scaling adjustments, exchange price-band limits, and interbank liquidity position mappings for systemic risk studies.
|
|
102
|
+
* **`cybersecurity`**: Directed network graph modeling for anomalous traffic flows and node centrality analysis.
|
|
103
|
+
* **`supply_chain`**: Multi-tier propagation models for inventory volatility and supplier dependency shocks.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 💻 C++ Implementation (`nirvana_cpp/`)
|
|
108
|
+
|
|
109
|
+
For low-latency execution and integration into compiled pipelines, the repository includes a self-contained C++20 header library:
|
|
110
|
+
|
|
111
|
+
* Header-only: `#include <nirvana/nirvana.hpp>`.
|
|
112
|
+
* Self-contained linear algebra routines (matrix decomposition, SVD, pseudoinverse) without mandatory external dependencies.
|
|
113
|
+
* Compatible with standard C++20 compilers (GCC 12+, Clang 15+, MSVC 19.30+).
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 📦 Installation Options
|
|
118
|
+
|
|
119
|
+
### From PyPI (Recommended)
|
|
120
|
+
```bash
|
|
121
|
+
pip install nirvana-quant
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### From GitHub
|
|
125
|
+
```bash
|
|
126
|
+
pip install git+https://github.com/yinyusi65/nirvana-quant.git
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### From Local Source
|
|
130
|
+
```bash
|
|
131
|
+
git clone https://github.com/yinyusi65/nirvana-quant.git
|
|
132
|
+
cd nirvana-quant
|
|
133
|
+
pip install -e .
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 📖 Usage Examples
|
|
139
|
+
|
|
140
|
+
### 1. Two-Stage Regression with Conformal Prediction Intervals
|
|
141
|
+
```python
|
|
142
|
+
import numpy as np
|
|
143
|
+
from nirvana import NirvanaTwoStageRegressor
|
|
144
|
+
|
|
145
|
+
# Cross-sectional sample
|
|
146
|
+
np.random.seed(42)
|
|
147
|
+
X = np.random.randn(120, 3)
|
|
148
|
+
y = 1.8 * X[:, 0] - 0.7 * (X[:, 1] ** 2) + np.random.randn(120) * 0.15
|
|
149
|
+
|
|
150
|
+
# Fit two-stage additive model
|
|
151
|
+
regressor = NirvanaTwoStageRegressor(base_estimator="ols", max_depth=4)
|
|
152
|
+
regressor.fit(X, y)
|
|
153
|
+
|
|
154
|
+
# Compute 95% conformal prediction intervals
|
|
155
|
+
y_pred, y_lower, y_upper = regressor.predict_interval(X, alpha=0.05)
|
|
156
|
+
print(f"Point Forecast: {y_pred[0]:.3f}, 95% Interval: [{y_lower[0]:.3f}, {y_upper[0]:.3f}]")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 👤 Authors & Maintainers
|
|
162
|
+
* **yinyusi65**
|
|
163
|
+
|
|
164
|
+
## 📄 License
|
|
165
|
+
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
|
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
"""
|
|
2
|
-
NIRVANA: Chrono-Cancer Meta-Architecture for High-Dimensional Financial Risk & Network Dynamics
|
|
3
|
-
================================================================================================
|
|
4
|
-
A causal, manifold-based quantitative engine for financial time-series, volatility spillover,
|
|
5
|
-
and systemic risk analysis across interconnected banking systems.
|
|
6
|
-
|
|
7
|
-
Author: yinyusi65 & Nirvana Quant Team
|
|
8
|
-
License: MIT / Academic Research
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
__version__ = "1.0.
|
|
12
|
-
|
|
13
|
-
from .manifold import Base12Manifold, DualClockCoordinates
|
|
14
|
-
from .kalman import CausalOnlineKalman, MultivariateCausalKalman, CausalKalmanTVPRegressor
|
|
15
|
-
from .tree import NirvanaTreeEngine, TrainingSample
|
|
16
|
-
from .network import (
|
|
17
|
-
NirvanaConnectedness,
|
|
18
|
-
SystemicRiskReport,
|
|
19
|
-
DynamicSystemicRiskReport,
|
|
20
|
-
DEFAULT_ASSET_WEIGHTS,
|
|
21
|
-
DEFAULT_EXCHANGE_BANDS,
|
|
22
|
-
)
|
|
23
|
-
from .multiplex import MultiplexNetworkEngine
|
|
24
|
-
from .multiverse import MultiverseReconstructor
|
|
25
|
-
from .volatility import compute_parkinson, compute_garman_klass, compute_yang_zhang
|
|
26
|
-
from .static import (
|
|
27
|
-
NirvanaStaticBooster,
|
|
28
|
-
StaticEconometricReport,
|
|
29
|
-
NirvanaTreeRegressor,
|
|
30
|
-
NirvanaTwoStageRegressor,
|
|
31
|
-
parse_formula,
|
|
32
|
-
)
|
|
33
|
-
from .stata import stata_regress, StataRegressionResult, stata_summarize, stata_pwcorr
|
|
34
|
-
from .proof import (
|
|
35
|
-
prove_phase2_variable,
|
|
36
|
-
Phase2MultiverseProofReport,
|
|
37
|
-
rank_phase2_discovered_variables,
|
|
38
|
-
Phase2RankedVariablesReport,
|
|
39
|
-
DiscoveredVariableItem,
|
|
40
|
-
)
|
|
41
|
-
from . import domains
|
|
42
|
-
|
|
43
|
-
__all__ = [
|
|
44
|
-
"Base12Manifold",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
1
|
+
"""
|
|
2
|
+
NIRVANA: Chrono-Cancer Meta-Architecture for High-Dimensional Financial Risk & Network Dynamics
|
|
3
|
+
================================================================================================
|
|
4
|
+
A causal, manifold-based quantitative engine for financial time-series, volatility spillover,
|
|
5
|
+
and systemic risk analysis across interconnected banking systems.
|
|
6
|
+
|
|
7
|
+
Author: yinyusi65 & Nirvana Quant Team
|
|
8
|
+
License: MIT / Academic Research
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "1.0.2"
|
|
12
|
+
|
|
13
|
+
from .manifold import Base12Manifold, FractionalBase12Manifold, DualClockCoordinates
|
|
14
|
+
from .kalman import CausalOnlineKalman, MultivariateCausalKalman, CausalKalmanTVPRegressor
|
|
15
|
+
from .tree import NirvanaTreeEngine, TrainingSample
|
|
16
|
+
from .network import (
|
|
17
|
+
NirvanaConnectedness,
|
|
18
|
+
SystemicRiskReport,
|
|
19
|
+
DynamicSystemicRiskReport,
|
|
20
|
+
DEFAULT_ASSET_WEIGHTS,
|
|
21
|
+
DEFAULT_EXCHANGE_BANDS,
|
|
22
|
+
)
|
|
23
|
+
from .multiplex import MultiplexNetworkEngine
|
|
24
|
+
from .multiverse import MultiverseReconstructor
|
|
25
|
+
from .volatility import compute_parkinson, compute_garman_klass, compute_yang_zhang
|
|
26
|
+
from .static import (
|
|
27
|
+
NirvanaStaticBooster,
|
|
28
|
+
StaticEconometricReport,
|
|
29
|
+
NirvanaTreeRegressor,
|
|
30
|
+
NirvanaTwoStageRegressor,
|
|
31
|
+
parse_formula,
|
|
32
|
+
)
|
|
33
|
+
from .stata import stata_regress, StataRegressionResult, stata_summarize, stata_pwcorr
|
|
34
|
+
from .proof import (
|
|
35
|
+
prove_phase2_variable,
|
|
36
|
+
Phase2MultiverseProofReport,
|
|
37
|
+
rank_phase2_discovered_variables,
|
|
38
|
+
Phase2RankedVariablesReport,
|
|
39
|
+
DiscoveredVariableItem,
|
|
40
|
+
)
|
|
41
|
+
from . import domains
|
|
42
|
+
|
|
43
|
+
__all__ = [
|
|
44
|
+
"Base12Manifold",
|
|
45
|
+
"FractionalBase12Manifold",
|
|
46
|
+
"DualClockCoordinates",
|
|
47
|
+
"CausalOnlineKalman",
|
|
48
|
+
"MultivariateCausalKalman",
|
|
49
|
+
"NirvanaTreeEngine",
|
|
50
|
+
"TrainingSample",
|
|
51
|
+
"NirvanaStaticBooster",
|
|
52
|
+
"StaticEconometricReport",
|
|
53
|
+
"NirvanaTreeRegressor",
|
|
54
|
+
"NirvanaTwoStageRegressor",
|
|
55
|
+
"parse_formula",
|
|
56
|
+
"stata_regress",
|
|
57
|
+
"StataRegressionResult",
|
|
58
|
+
"stata_summarize",
|
|
59
|
+
"stata_pwcorr",
|
|
60
|
+
"prove_phase2_variable",
|
|
61
|
+
"Phase2MultiverseProofReport",
|
|
62
|
+
"rank_phase2_discovered_variables",
|
|
63
|
+
"Phase2RankedVariablesReport",
|
|
64
|
+
"DiscoveredVariableItem",
|
|
65
|
+
"NirvanaConnectedness",
|
|
66
|
+
"SystemicRiskReport",
|
|
67
|
+
"DynamicSystemicRiskReport",
|
|
68
|
+
"DEFAULT_ASSET_WEIGHTS",
|
|
69
|
+
"DEFAULT_EXCHANGE_BANDS",
|
|
70
|
+
"MultiplexNetworkEngine",
|
|
71
|
+
"MultiverseReconstructor",
|
|
72
|
+
"compute_parkinson",
|
|
73
|
+
"compute_garman_klass",
|
|
74
|
+
"compute_yang_zhang",
|
|
75
|
+
"domains",
|
|
76
|
+
]
|