|
1 | 1 | """ |
2 | | -MeridianAlgo v4.0.0 - Quantum Edition 🚀 |
| 2 | +MeridianAlgo v4.0.3 - Quantum Edition 🚀 |
3 | 3 |
|
4 | 4 | Meridian Quant: The Ultimate Quantitative Development Platform |
5 | 5 |
|
6 | 6 | The most advanced Python platform for quantitative finance, integrating cutting-edge |
7 | 7 | machine learning, institutional-grade portfolio management, and high-performance computing. |
8 | 8 | Built for quantitative analysts, portfolio managers, algorithmic traders, and financial researchers. |
9 | 9 |
|
10 | | -Version: 4.0.0-quantum |
| 10 | +Version: 4.0.3 |
11 | 11 | """ |
12 | 12 |
|
13 | | -__version__ = '4.0.0-quantum' |
14 | | - |
15 | | -# Import unified API |
16 | | -from .api import ( |
17 | | - MeridianAlgoAPI, |
18 | | - get_api, |
19 | | - get_market_data as api_get_market_data, |
20 | | - optimize_portfolio as api_optimize_portfolio, |
21 | | - calculate_risk_metrics as api_calculate_risk_metrics, |
22 | | - calculate_rsi as api_calculate_rsi, |
23 | | - calculate_macd as api_calculate_macd, |
24 | | - price_option |
25 | | -) |
26 | | - |
27 | | -# Core modules |
28 | | -from .core import ( |
29 | | - PortfolioOptimizer, |
30 | | - TimeSeriesAnalyzer, |
31 | | - get_market_data, |
32 | | - calculate_metrics, |
33 | | - calculate_max_drawdown |
34 | | -) |
35 | | - |
36 | | -# Statistics modules |
37 | | -from .statistics import ( |
38 | | - StatisticalArbitrage, |
39 | | - calculate_value_at_risk, |
40 | | - calculate_expected_shortfall, |
41 | | - hurst_exponent, |
42 | | - calculate_autocorrelation, |
43 | | - rolling_volatility |
44 | | -) |
45 | | - |
46 | | -# ML modules |
47 | | -from .ml import ( |
48 | | - FeatureEngineer, |
49 | | - LSTMPredictor, |
50 | | - prepare_data_for_lstm |
51 | | -) |
52 | | - |
53 | | -# Technical Indicators |
54 | | -from .technical_indicators import ( |
55 | | - RSI, Stochastic, WilliamsR, ROC, Momentum, |
56 | | - SMA, EMA, MACD, ADX, Aroon, ParabolicSAR, Ichimoku, |
57 | | - BollingerBands, ATR, KeltnerChannels, DonchianChannels, |
58 | | - OBV, ADLine, ChaikinOscillator, MoneyFlowIndex, EaseOfMovement, |
59 | | - PivotPoints, FibonacciRetracement, SupportResistance |
60 | | -) |
61 | | - |
62 | | -# TA Library Integration (if available) |
63 | | -try: |
64 | | - from .technical_indicators import ( |
65 | | - TAIntegration, add_all_ta_features, |
66 | | - get_ta_volume_indicators, get_ta_volatility_indicators, |
67 | | - get_ta_trend_indicators, get_ta_momentum_indicators, |
68 | | - get_all_ta_indicators |
69 | | - ) |
70 | | - TA_LIBRARY_AVAILABLE = True |
71 | | -except ImportError: |
72 | | - TA_LIBRARY_AVAILABLE = False |
73 | | - |
74 | | -# Portfolio Management |
75 | | -from .portfolio_management import ( |
76 | | - PortfolioOptimizer as PM_PortfolioOptimizer, |
77 | | - EfficientFrontier, BlackLitterman, RiskParity |
78 | | -) |
79 | | - |
80 | | -# Risk Analysis |
81 | | -from .risk_analysis import ( |
82 | | - VaRCalculator, ExpectedShortfall as Risk_ExpectedShortfall, |
83 | | - HistoricalVaR, ParametricVaR, MonteCarloVaR |
84 | | -) |
85 | | - |
86 | | -# Data Processing |
87 | | -from .data_processing import ( |
88 | | - DataCleaner, OutlierDetector, MissingDataHandler, |
89 | | - FeatureEngineer as DP_FeatureEngineer, TechnicalFeatures, |
90 | | - DataValidator, MarketDataProvider |
91 | | -) |
| 13 | +__version__ = '4.0.3' |
| 14 | + |
| 15 | +import warnings |
| 16 | +import sys |
| 17 | + |
| 18 | +# Suppress warnings for cleaner output |
| 19 | +warnings.filterwarnings('ignore') |
| 20 | + |
| 21 | +# Core functionality that always works |
| 22 | +def get_system_info(): |
| 23 | + """Get system information.""" |
| 24 | + import platform |
| 25 | + return { |
| 26 | + 'python_version': sys.version, |
| 27 | + 'platform': platform.platform(), |
| 28 | + 'package_version': __version__ |
| 29 | + } |
92 | 30 |
|
93 | 31 | # Configuration |
94 | 32 | config = { |
@@ -116,102 +54,168 @@ def enable_distributed_computing(): |
116 | 54 | """Enable distributed computing if available.""" |
117 | 55 | config['distributed_computing'] = True |
118 | 56 |
|
119 | | -def get_system_info(): |
120 | | - """Get system information and available modules.""" |
121 | | - api = get_api() |
122 | | - return api.get_system_info() |
123 | | - |
124 | | -__all__ = [ |
125 | | - # Unified API (v4.0) |
126 | | - 'MeridianAlgoAPI', |
127 | | - 'get_api', |
128 | | - 'api_get_market_data', |
129 | | - 'api_optimize_portfolio', |
130 | | - 'api_calculate_risk_metrics', |
131 | | - 'api_calculate_rsi', |
132 | | - 'api_calculate_macd', |
133 | | - 'price_option', |
134 | | - |
135 | | - # Core (backward compatibility) |
136 | | - 'PortfolioOptimizer', |
137 | | - 'TimeSeriesAnalyzer', |
138 | | - 'get_market_data', |
139 | | - 'calculate_metrics', |
140 | | - 'calculate_max_drawdown', |
141 | | - |
142 | | - # Statistics (backward compatibility) |
143 | | - 'StatisticalArbitrage', |
144 | | - 'calculate_value_at_risk', |
145 | | - 'calculate_expected_shortfall', |
146 | | - 'hurst_exponent', |
147 | | - 'calculate_autocorrelation', |
148 | | - 'rolling_volatility', |
149 | | - |
150 | | - # ML (backward compatibility) |
151 | | - 'FeatureEngineer', |
152 | | - 'LSTMPredictor', |
153 | | - 'prepare_data_for_lstm', |
154 | | - |
155 | | - # Technical Indicators (backward compatibility) |
156 | | - 'RSI', 'Stochastic', 'WilliamsR', 'ROC', 'Momentum', |
157 | | - 'SMA', 'EMA', 'MACD', 'ADX', 'Aroon', 'ParabolicSAR', 'Ichimoku', |
158 | | - 'BollingerBands', 'ATR', 'KeltnerChannels', 'DonchianChannels', |
159 | | - 'OBV', 'ADLine', 'ChaikinOscillator', 'MoneyFlowIndex', 'EaseOfMovement', |
160 | | - 'PivotPoints', 'FibonacciRetracement', 'SupportResistance', |
161 | | - |
162 | | - # Portfolio Management (backward compatibility) |
163 | | - 'PM_PortfolioOptimizer', 'EfficientFrontier', 'BlackLitterman', 'RiskParity', |
| 57 | +# Import modules with error handling |
| 58 | +try: |
| 59 | + from .statistics import ( |
| 60 | + StatisticalArbitrage, |
| 61 | + calculate_value_at_risk, |
| 62 | + calculate_expected_shortfall, |
| 63 | + hurst_exponent, |
| 64 | + calculate_autocorrelation, |
| 65 | + rolling_volatility, |
| 66 | + calculate_metrics as stats_calculate_metrics |
| 67 | + ) |
| 68 | + STATISTICS_AVAILABLE = True |
| 69 | +except ImportError as e: |
| 70 | + STATISTICS_AVAILABLE = False |
| 71 | + print(f"Statistics module not fully available: {e}") |
| 72 | + |
| 73 | +try: |
| 74 | + from .core import ( |
| 75 | + PortfolioOptimizer, |
| 76 | + TimeSeriesAnalyzer, |
| 77 | + get_market_data, |
| 78 | + calculate_max_drawdown |
| 79 | + ) |
| 80 | + CORE_AVAILABLE = True |
| 81 | +except ImportError as e: |
| 82 | + CORE_AVAILABLE = False |
| 83 | + print(f"Core module not fully available: {e}") |
| 84 | + |
| 85 | +try: |
| 86 | + from .technical_indicators import ( |
| 87 | + RSI, SMA, EMA, MACD, BollingerBands, Stochastic, WilliamsR, |
| 88 | + ROC, Momentum, ADX, Aroon, ParabolicSAR, Ichimoku, |
| 89 | + ATR, KeltnerChannels, DonchianChannels, |
| 90 | + OBV, ADLine, ChaikinOscillator, MoneyFlowIndex, EaseOfMovement, |
| 91 | + PivotPoints, FibonacciRetracement, SupportResistance |
| 92 | + ) |
| 93 | + TECHNICAL_INDICATORS_AVAILABLE = True |
| 94 | +except ImportError as e: |
| 95 | + TECHNICAL_INDICATORS_AVAILABLE = False |
| 96 | + print(f"Technical indicators not fully available: {e}") |
| 97 | + |
| 98 | +try: |
| 99 | + from .ml import ( |
| 100 | + FeatureEngineer, |
| 101 | + LSTMPredictor, |
| 102 | + prepare_data_for_lstm |
| 103 | + ) |
| 104 | + ML_AVAILABLE = True |
| 105 | +except ImportError as e: |
| 106 | + ML_AVAILABLE = False |
| 107 | + print(f"ML module not fully available: {e}") |
| 108 | + |
| 109 | +try: |
| 110 | + from .portfolio_management import ( |
| 111 | + PortfolioOptimizer as PM_PortfolioOptimizer, |
| 112 | + EfficientFrontier, BlackLitterman, RiskParity |
| 113 | + ) |
| 114 | + PORTFOLIO_MANAGEMENT_AVAILABLE = True |
| 115 | +except ImportError as e: |
| 116 | + PORTFOLIO_MANAGEMENT_AVAILABLE = False |
| 117 | + print(f"Portfolio management not fully available: {e}") |
| 118 | + |
| 119 | +try: |
| 120 | + from .risk_analysis import ( |
| 121 | + VaRCalculator, ExpectedShortfall as Risk_ExpectedShortfall, |
| 122 | + HistoricalVaR, ParametricVaR, MonteCarloVaR |
| 123 | + ) |
| 124 | + RISK_ANALYSIS_AVAILABLE = True |
| 125 | +except ImportError as e: |
| 126 | + RISK_ANALYSIS_AVAILABLE = False |
| 127 | + print(f"Risk analysis not fully available: {e}") |
| 128 | + |
| 129 | +try: |
| 130 | + from .backtesting import BacktestEngine |
| 131 | + BACKTESTING_AVAILABLE = True |
| 132 | +except ImportError as e: |
| 133 | + BACKTESTING_AVAILABLE = False |
| 134 | + print(f"Backtesting not fully available: {e}") |
| 135 | + |
| 136 | +# Simple API class |
| 137 | +class MeridianAlgoAPI: |
| 138 | + """Unified API for MeridianAlgo functionality.""" |
164 | 139 |
|
165 | | - # Risk Analysis (backward compatibility) |
166 | | - 'VaRCalculator', 'Risk_ExpectedShortfall', 'HistoricalVaR', 'ParametricVaR', 'MonteCarloVaR', |
| 140 | + def __init__(self): |
| 141 | + self.available_modules = { |
| 142 | + 'statistics': STATISTICS_AVAILABLE, |
| 143 | + 'core': CORE_AVAILABLE, |
| 144 | + 'technical_indicators': TECHNICAL_INDICATORS_AVAILABLE, |
| 145 | + 'ml': ML_AVAILABLE, |
| 146 | + 'portfolio_management': PORTFOLIO_MANAGEMENT_AVAILABLE, |
| 147 | + 'risk_analysis': RISK_ANALYSIS_AVAILABLE, |
| 148 | + 'backtesting': BACKTESTING_AVAILABLE |
| 149 | + } |
167 | 150 |
|
168 | | - # Data Processing (backward compatibility) |
169 | | - 'DataCleaner', 'OutlierDetector', 'MissingDataHandler', |
170 | | - 'DP_FeatureEngineer', 'TechnicalFeatures', 'DataValidator', 'MarketDataProvider', |
| 151 | + def get_available_modules(self): |
| 152 | + """Get available modules.""" |
| 153 | + return self.available_modules |
171 | 154 |
|
172 | | - # Configuration |
173 | | - 'config', |
174 | | - 'set_config', |
175 | | - 'get_config', |
176 | | - 'enable_gpu_acceleration', |
177 | | - 'enable_distributed_computing', |
178 | | - 'get_system_info' |
179 | | -] |
180 | | - |
181 | | -# Add TA integration to exports if available |
182 | | -if TA_LIBRARY_AVAILABLE: |
183 | | - __all__.extend([ |
184 | | - 'TAIntegration', |
185 | | - 'add_all_ta_features', |
186 | | - 'get_ta_volume_indicators', |
187 | | - 'get_ta_volatility_indicators', |
188 | | - 'get_ta_trend_indicators', |
189 | | - 'get_ta_momentum_indicators', |
190 | | - 'get_all_ta_indicators' |
191 | | - ]) |
| 155 | + def get_system_info(self): |
| 156 | + """Get system information.""" |
| 157 | + return get_system_info() |
| 158 | + |
| 159 | +# Global API instance |
| 160 | +_api_instance = None |
| 161 | + |
| 162 | +def get_api(): |
| 163 | + """Get the global API instance.""" |
| 164 | + global _api_instance |
| 165 | + if _api_instance is None: |
| 166 | + _api_instance = MeridianAlgoAPI() |
| 167 | + return _api_instance |
| 168 | + |
| 169 | +# Build __all__ dynamically |
| 170 | +__all__ = ['__version__', 'get_api', 'MeridianAlgoAPI', 'get_system_info', |
| 171 | + 'config', 'set_config', 'get_config', 'enable_gpu_acceleration', |
| 172 | + 'enable_distributed_computing'] |
| 173 | + |
| 174 | +if STATISTICS_AVAILABLE: |
| 175 | + __all__.extend(['StatisticalArbitrage', 'calculate_value_at_risk', |
| 176 | + 'calculate_expected_shortfall', 'hurst_exponent', |
| 177 | + 'calculate_autocorrelation', 'rolling_volatility', 'calculate_metrics', |
| 178 | + 'stats_calculate_metrics']) |
| 179 | + |
| 180 | +if CORE_AVAILABLE: |
| 181 | + __all__.extend(['PortfolioOptimizer', 'TimeSeriesAnalyzer', 'get_market_data', 'calculate_max_drawdown']) |
| 182 | + |
| 183 | +if TECHNICAL_INDICATORS_AVAILABLE: |
| 184 | + __all__.extend(['RSI', 'SMA', 'EMA', 'MACD', 'BollingerBands', 'Stochastic', 'WilliamsR', |
| 185 | + 'ROC', 'Momentum', 'ADX', 'Aroon', 'ParabolicSAR', 'Ichimoku', |
| 186 | + 'ATR', 'KeltnerChannels', 'DonchianChannels', |
| 187 | + 'OBV', 'ADLine', 'ChaikinOscillator', 'MoneyFlowIndex', 'EaseOfMovement', |
| 188 | + 'PivotPoints', 'FibonacciRetracement', 'SupportResistance']) |
| 189 | + |
| 190 | +if ML_AVAILABLE: |
| 191 | + __all__.extend(['FeatureEngineer', 'LSTMPredictor', 'prepare_data_for_lstm']) |
| 192 | + |
| 193 | +if PORTFOLIO_MANAGEMENT_AVAILABLE: |
| 194 | + __all__.extend(['PM_PortfolioOptimizer', 'EfficientFrontier', 'BlackLitterman', 'RiskParity']) |
| 195 | + |
| 196 | +if RISK_ANALYSIS_AVAILABLE: |
| 197 | + __all__.extend(['VaRCalculator', 'Risk_ExpectedShortfall', 'HistoricalVaR', 'ParametricVaR', 'MonteCarloVaR']) |
| 198 | + |
| 199 | +if BACKTESTING_AVAILABLE: |
| 200 | + __all__.extend(['BacktestEngine']) |
192 | 201 |
|
193 | 202 | # Welcome message |
194 | 203 | def _show_welcome(): |
195 | 204 | """Show welcome message on first import.""" |
196 | | - print("🚀 MeridianAlgo v4.0.0 - Quantum Edition") |
| 205 | + print("🚀 MeridianAlgo v4.0.3 - Quantum Edition") |
197 | 206 | print("âš¡ Meridian Quant: The Ultimate Quantitative Development Platform") |
198 | 207 | print("📊 Ready for institutional-grade quantitative finance!") |
199 | 208 |
|
200 | 209 | try: |
201 | | - available_modules = get_api().get_available_modules() |
| 210 | + api = get_api() |
| 211 | + available_modules = api.get_available_modules() |
202 | 212 | enabled_count = sum(available_modules.values()) |
203 | 213 | total_count = len(available_modules) |
204 | 214 |
|
205 | 215 | print(f"✅ {enabled_count}/{total_count} modules available") |
206 | 216 |
|
207 | 217 | if enabled_count < total_count: |
208 | | - print("💡 Install optional dependencies for full functionality:") |
209 | | - if not available_modules.get('data'): |
210 | | - print(" pip install yfinance alpha_vantage") |
211 | | - if not available_modules.get('machine_learning'): |
212 | | - print(" pip install torch scikit-learn") |
213 | | - if not available_modules.get('hpc'): |
214 | | - print(" pip install dask ray cupy") |
| 218 | + print("💡 Some modules may need optional dependencies") |
215 | 219 | except: |
216 | 220 | print("✅ Core functionality ready") |
217 | 221 |
|
|
0 commit comments