nirvana-quant 1.0.2__tar.gz → 1.0.3__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.
Files changed (33) hide show
  1. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/PKG-INFO +1 -3
  2. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/__init__.py +78 -76
  3. nirvana_quant-1.0.3/nirvana/ensemble/__init__.py +7 -0
  4. nirvana_quant-1.0.3/nirvana/ensemble/pyramid.py +106 -0
  5. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana_quant.egg-info/PKG-INFO +1 -3
  6. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana_quant.egg-info/SOURCES.txt +2 -0
  7. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/pyproject.toml +30 -33
  8. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/LICENSE +0 -0
  9. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/README.md +0 -0
  10. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/domains/__init__.py +0 -0
  11. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/domains/banking.py +0 -0
  12. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/domains/consumer.py +0 -0
  13. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/domains/cybersecurity.py +0 -0
  14. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/domains/substitute.py +0 -0
  15. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/domains/supply_chain.py +0 -0
  16. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/experimental/__init__.py +0 -0
  17. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/experimental/multiverse_invariance.py +0 -0
  18. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/kalman.py +0 -0
  19. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/manifold.py +0 -0
  20. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/multiplex.py +0 -0
  21. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/multiverse.py +0 -0
  22. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/network.py +0 -0
  23. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/proof.py +0 -0
  24. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/stata.py +0 -0
  25. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/static.py +0 -0
  26. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/tree.py +0 -0
  27. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana/volatility.py +0 -0
  28. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana_quant/__init__.py +0 -0
  29. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana_quant.egg-info/dependency_links.txt +0 -0
  30. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana_quant.egg-info/requires.txt +0 -0
  31. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/nirvana_quant.egg-info/top_level.txt +0 -0
  32. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/setup.cfg +0 -0
  33. {nirvana_quant-1.0.2 → nirvana_quant-1.0.3}/setup.py +0 -0
@@ -1,11 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nirvana-quant
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Nirvana: Chrono-Cancer Meta-Architecture for High-Dimensional Cyclical Time-Series & Dynamical Network Analysis
5
5
  Home-page: https://github.com/yinyusi65/nirvana-quant
6
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
7
  Classifier: Programming Language :: Python :: 3
10
8
  Classifier: License :: OSI Approved :: MIT License
11
9
  Classifier: Operating System :: OS Independent
@@ -1,76 +1,78 @@
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
- ]
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.3"
12
+
13
+ from .manifold import Base12Manifold, FractionalBase12Manifold, DualClockCoordinates
14
+ from .kalman import CausalOnlineKalman, MultivariateCausalKalman, CausalKalmanTVPRegressor
15
+ from .tree import NirvanaTreeEngine, TrainingSample
16
+ from .ensemble import NirvanaPyramidEnsemble
17
+ from .network import (
18
+ NirvanaConnectedness,
19
+ SystemicRiskReport,
20
+ DynamicSystemicRiskReport,
21
+ DEFAULT_ASSET_WEIGHTS,
22
+ DEFAULT_EXCHANGE_BANDS,
23
+ )
24
+ from .multiplex import MultiplexNetworkEngine
25
+ from .multiverse import MultiverseReconstructor
26
+ from .volatility import compute_parkinson, compute_garman_klass, compute_yang_zhang
27
+ from .static import (
28
+ NirvanaStaticBooster,
29
+ StaticEconometricReport,
30
+ NirvanaTreeRegressor,
31
+ NirvanaTwoStageRegressor,
32
+ parse_formula,
33
+ )
34
+ from .stata import stata_regress, StataRegressionResult, stata_summarize, stata_pwcorr
35
+ from .proof import (
36
+ prove_phase2_variable,
37
+ Phase2MultiverseProofReport,
38
+ rank_phase2_discovered_variables,
39
+ Phase2RankedVariablesReport,
40
+ DiscoveredVariableItem,
41
+ )
42
+ from . import domains
43
+
44
+ __all__ = [
45
+ "Base12Manifold",
46
+ "FractionalBase12Manifold",
47
+ "DualClockCoordinates",
48
+ "CausalOnlineKalman",
49
+ "MultivariateCausalKalman",
50
+ "NirvanaTreeEngine",
51
+ "TrainingSample",
52
+ "NirvanaPyramidEnsemble",
53
+ "NirvanaStaticBooster",
54
+ "StaticEconometricReport",
55
+ "NirvanaTreeRegressor",
56
+ "NirvanaTwoStageRegressor",
57
+ "parse_formula",
58
+ "stata_regress",
59
+ "StataRegressionResult",
60
+ "stata_summarize",
61
+ "stata_pwcorr",
62
+ "prove_phase2_variable",
63
+ "Phase2MultiverseProofReport",
64
+ "rank_phase2_discovered_variables",
65
+ "Phase2RankedVariablesReport",
66
+ "DiscoveredVariableItem",
67
+ "NirvanaConnectedness",
68
+ "SystemicRiskReport",
69
+ "DynamicSystemicRiskReport",
70
+ "DEFAULT_ASSET_WEIGHTS",
71
+ "DEFAULT_EXCHANGE_BANDS",
72
+ "MultiplexNetworkEngine",
73
+ "MultiverseReconstructor",
74
+ "compute_parkinson",
75
+ "compute_garman_klass",
76
+ "compute_yang_zhang",
77
+ "domains",
78
+ ]
@@ -0,0 +1,7 @@
1
+ """
2
+ Nirvana Ensemble Subpackage.
3
+ """
4
+
5
+ from nirvana.ensemble.pyramid import NirvanaPyramidEnsemble
6
+
7
+ __all__ = ["NirvanaPyramidEnsemble"]
@@ -0,0 +1,106 @@
1
+ """
2
+ Nirvana Ensemble Module: Multi-Scale Pyramid and Advanced Ensembling Architecture.
3
+ """
4
+
5
+ from typing import Dict, List, Optional, Union
6
+ import numpy as np
7
+ import pandas as pd
8
+ from sklearn.base import BaseEstimator, RegressorMixin
9
+
10
+ from nirvana.static import NirvanaTreeRegressor
11
+
12
+
13
+ class NirvanaPyramidEnsemble(BaseEstimator, RegressorMixin):
14
+ """
15
+ KIM TỰ THÁP ĐA TẦNG NIRVANA (MULTI-SCALE PYRAMID ENSEMBLE)
16
+
17
+ Quét dải quang phổ độ sâu từ vĩ mô (Tầng 8) đến vi mô cực hạn (Tầng 18)
18
+ nhằm triệt tiêu nhiễu và chiết xuất các đặc trưng kích hoạt van phi tuyến
19
+ cho các mô hình sau huấn luyện (Downstream Models).
20
+ """
21
+
22
+ def __init__(
23
+ self,
24
+ depth_schedule: Optional[Dict[int, int]] = None,
25
+ subsample_ratio: float = 0.85,
26
+ apoptosis_start_depth: int = 6,
27
+ cancer_sensitivity: float = 1.0,
28
+ random_state: int = 42,
29
+ ):
30
+ if depth_schedule is None:
31
+ self.depth_schedule = {
32
+ 8: 25, 9: 25, 10: 25, # Vĩ mô cốt lõi: Neo giữ xu hướng chính
33
+ 11: 15, 12: 15, 13: 15, # Vùng bùng nổ phương sai Nirvana
34
+ 14: 10, 15: 10, 16: 10, # Vùng biên thử nghiệm
35
+ 17: 5, 18: 5 # Vi mô cực hạn: Bắt tín hiệu đuôi rủi ro
36
+ }
37
+ else:
38
+ self.depth_schedule = depth_schedule
39
+
40
+ self.subsample_ratio = subsample_ratio
41
+ self.apoptosis_start_depth = apoptosis_start_depth
42
+ self.cancer_sensitivity = cancer_sensitivity
43
+ self.random_state = random_state
44
+
45
+ self.trees_: List[NirvanaTreeRegressor] = []
46
+ self.tree_depths_: List[int] = []
47
+
48
+ def fit(self, X: Union[np.ndarray, pd.DataFrame], y: Union[np.ndarray, pd.Series]):
49
+ """Huấn luyện quần thể cây đa tầng trên các mẫu con Bootstrap."""
50
+ X_mat = getattr(X, "values", X)
51
+ y_vec = getattr(y, "values", y)
52
+ X_mat = np.asarray(X_mat, dtype=float)
53
+ y_vec = np.asarray(y_vec, dtype=float).ravel()
54
+
55
+ np.random.seed(self.random_state)
56
+ n_samples = len(X_mat)
57
+ sub_size = max(4, int(self.subsample_ratio * n_samples))
58
+
59
+ self.trees_ = []
60
+ self.tree_depths_ = []
61
+
62
+ for depth, n_loops in sorted(self.depth_schedule.items()):
63
+ for _ in range(n_loops):
64
+ boot_idx = np.random.choice(n_samples, size=sub_size, replace=True)
65
+ tree = NirvanaTreeRegressor(
66
+ max_depth=depth,
67
+ apoptosis_start_depth=self.apoptosis_start_depth,
68
+ cancer_sensitivity=self.cancer_sensitivity,
69
+ )
70
+ tree.fit(X_mat[boot_idx], y_vec[boot_idx])
71
+ self.trees_.append(tree)
72
+ self.tree_depths_.append(depth)
73
+
74
+ return self
75
+
76
+ def predict(self, X: Union[np.ndarray, pd.DataFrame]) -> np.ndarray:
77
+ """Dự báo trung bình cộng từ toàn bộ quần thể cây kim tự tháp."""
78
+ X_mat = getattr(X, "values", X)
79
+ X_mat = np.asarray(X_mat, dtype=float)
80
+ all_preds = np.array([tree.predict(X_mat) for tree in self.trees_])
81
+ return np.mean(all_preds, axis=0)
82
+
83
+ def extract_valve_features(self, X: Union[np.ndarray, pd.DataFrame]) -> pd.DataFrame:
84
+ """
85
+ Chiết xuất ma trận đặc trưng van đa tầng cho các mô hình giai đoạn 2.
86
+ Xuất ra: (Kỳ vọng tín hiệu Mean, Độ bất định tín hiệu Uncertainty) ứng với từng tầng độ sâu.
87
+ """
88
+ X_mat = getattr(X, "values", X)
89
+ X_mat = np.asarray(X_mat, dtype=float)
90
+ all_preds = np.array([tree.predict(X_mat) for tree in self.trees_])
91
+
92
+ valve_features = []
93
+ feature_names = []
94
+ unique_depths = sorted(list(set(self.tree_depths_)))
95
+
96
+ for d in unique_depths:
97
+ d_indices = [i for i, depth in enumerate(self.tree_depths_) if depth == d]
98
+ depth_mean = np.mean(all_preds[d_indices], axis=0)
99
+ depth_var = np.var(all_preds[d_indices], axis=0)
100
+
101
+ valve_features.append(depth_mean)
102
+ valve_features.append(depth_var)
103
+ feature_names.append(f"Valve_Depth_{d}_Mean")
104
+ feature_names.append(f"Valve_Depth_{d}_Uncertainty")
105
+
106
+ return pd.DataFrame(np.array(valve_features).T, columns=feature_names)
@@ -1,11 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nirvana-quant
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Nirvana: Chrono-Cancer Meta-Architecture for High-Dimensional Cyclical Time-Series & Dynamical Network Analysis
5
5
  Home-page: https://github.com/yinyusi65/nirvana-quant
6
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
7
  Classifier: Programming Language :: Python :: 3
10
8
  Classifier: License :: OSI Approved :: MIT License
11
9
  Classifier: Operating System :: OS Independent
@@ -19,6 +19,8 @@ nirvana/domains/consumer.py
19
19
  nirvana/domains/cybersecurity.py
20
20
  nirvana/domains/substitute.py
21
21
  nirvana/domains/supply_chain.py
22
+ nirvana/ensemble/__init__.py
23
+ nirvana/ensemble/pyramid.py
22
24
  nirvana/experimental/__init__.py
23
25
  nirvana/experimental/multiverse_invariance.py
24
26
  nirvana_quant/__init__.py
@@ -1,33 +1,30 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "nirvana-quant"
7
- version = "1.0.2"
8
- authors = [
9
- { name="yinyusi65" },
10
- ]
11
- description = "Nirvana: Chrono-Cancer Meta-Architecture for High-Dimensional Cyclical Time-Series & Dynamical Network Analysis"
12
- readme = "README.md"
13
- requires-python = ">=3.9"
14
- classifiers = [
15
- "Programming Language :: Python :: 3",
16
- "License :: OSI Approved :: MIT License",
17
- "Operating System :: OS Independent",
18
- "Topic :: Scientific/Engineering :: Mathematics",
19
- "Topic :: Scientific/Engineering :: Information Analysis",
20
- ]
21
- dependencies = [
22
- "numpy>=1.22.0,<2.3.0",
23
- "pandas>=1.4.0,<3.0.0",
24
- "scipy>=1.8.0",
25
- ]
26
-
27
- [project.urls]
28
- "Homepage" = "https://github.com/yinyusi65/nirvana-quant"
29
- "Bug Tracker" = "https://github.com/yinyusi65/nirvana-quant/issues"
30
-
31
- [tool.setuptools.packages.find]
32
- include = ["nirvana*"]
33
-
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nirvana-quant"
7
+ version = "1.0.3"
8
+ authors = [
9
+ { name="yinyusi65" },
10
+ ]
11
+ description = "Nirvana: Chrono-Cancer Meta-Architecture for High-Dimensional Cyclical Time-Series & Dynamical Network Analysis"
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Topic :: Scientific/Engineering :: Mathematics",
19
+ "Topic :: Scientific/Engineering :: Information Analysis",
20
+ ]
21
+ dependencies = [
22
+ "numpy>=1.22.0,<2.3.0",
23
+ "pandas>=1.4.0,<3.0.0",
24
+ "scipy>=1.8.0",
25
+ ]
26
+
27
+ [tool.setuptools.packages.find]
28
+ where = ["."]
29
+ include = ["nirvana*", "nirvana_quant*"]
30
+ exclude = ["tests*", "docs*", "scratch*"]
File without changes
File without changes
File without changes
File without changes