Spaces:
Running
on
Zero
Running
on
Zero
File size: 12,808 Bytes
a4a6e76 7b4c6ac a4a6e76 0f7bbef a4a6e76 0f7bbef eb30d21 7b4c6ac 0f7bbef a4a6e76 7b4c6ac f5e0821 7b4c6ac f5e0821 7b4c6ac f5e0821 8481b42 55ce26a fe5cebb f5e0821 fe5cebb 55ce26a fe5cebb f5e0821 55ce26a 2665f90 55ce26a 8481b42 7b4c6ac 8481b42 55ce26a 8481b42 55ce26a 8481b42 55ce26a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
---
title: Advanced Stock Prediction Analysis with Amazon Chronos
emoji: π
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: true
license: mit
short_description: stock prediction with Amazon/Chronos
tags:
- mcp-server-track
- finance
- machine-learning
- time-series
- stock-prediction
- chronos
- market
- yfinance
- amazon
- forecasting
- ensemble
---
# π Advanced Stock Prediction Analysis with Amazon Chronos
A cutting-edge AI-powered stock prediction and analysis system with **580M+ parameters**, designed to analyze and predict stock prices across multiple timeframes. Equipped with **Amazon's Chronos foundation model** and **advanced ensemble methods**, it excels in both short-term trading and long-term investment analysis.
## π Key Features
### Market Status Monitoring
- **Real-Time Market Status**: Check if markets are open or closed with a simple click
- **Multi-Market Support**: Monitor US Stocks, European Markets, Asian Markets, Forex, Crypto, Futures, and Commodities
- **Timezone-Aware**: Accurate status based on each market's local timezone
- **Trading Hours**: Detailed information about market hours and next trading days
- **24/7 Markets**: Support for continuous trading markets like Forex and Crypto
- **User-Friendly Interface**: Simple dropdown menu and click-to-check functionality
### Core Prediction Engine
- **Amazon Chronos Integration**: Uses the state-of-the-art Chronos T5 foundation model for probabilistic time series forecasting
- **Multi-Timeframe Analysis**: Support for daily, hourly, and 15-minute timeframes
- **Advanced Ensemble Methods**: Combines multiple algorithms including Random Forest, Gradient Boosting, SVR, and Neural Networks
### Enhanced Covariate Data
- **Market Indices**: S&P 500, Dow Jones, NASDAQ, VIX, Treasury yields
- **Sector ETFs**: Financial, Technology, Energy, Healthcare, and more
- **Commodities**: Gold, Silver, Oil, Natural Gas, Corn, Soybeans
- **Currencies**: EUR/USD, GBP/USD, JPY/USD, CHF/USD, CAD/USD
- **Economic Indicators**: Inflation proxies, volatility indices, dollar strength
### Advanced Uncertainty Calculations
- **Multiple Uncertainty Methods**:
- Basic quantile-based uncertainty
- Skewness-adjusted uncertainty
- Volatility-scaled uncertainty
- Market condition adjusted uncertainty
- Time-decay uncertainty
- Ensemble uncertainty (combines all methods)
- **Regime-Aware Uncertainty**: Adjusts uncertainty based on market regime detection
- **Confidence Intervals**: 95% confidence bands with multiple calculation methods
### Enhanced Volume Prediction
- **Price-Volume Relationship Modeling**: Analyzes the relationship between price movements and volume
- **Volume Momentum**: Incorporates volume momentum and trends
- **Market Condition Adjustments**: Adjusts volume predictions based on market volatility
- **Uncertainty Quantification**: Provides volume prediction uncertainty estimates
### Sentiment Analysis
- **News Sentiment Scoring**: Analyzes news articles for sentiment polarity
- **Confidence Levels**: Provides confidence scores for sentiment analysis
- **Real-time Integration**: Incorporates sentiment data into prediction models
### Market Regime Detection
- **Hidden Markov Models**: Detects bull, bear, and sideways market regimes
- **Volatility Clustering**: Identifies periods of high and low volatility
- **Regime-Aware Predictions**: Adjusts predictions based on current market regime
### Advanced Algorithms
- **Multi-Algorithm Ensemble**:
- Random Forest Regressor
- Gradient Boosting Regressor
- Ridge Regression
- Lasso Regression
- Support Vector Regression (SVR)
- Multi-Layer Perceptron (MLP)
- **Time Series Cross-Validation**: Uses expanding window validation for robust model evaluation
- **Weighted Ensemble**: Combines predictions using uncertainty-weighted averaging
### Financial Smoothing
- **Multiple Smoothing Methods**:
- Exponential smoothing (trend following)
- Moving average (noise reduction)
- Kalman filter (adaptive smoothing)
- Savitzky-Golay (preserves peaks/valleys)
- Double exponential (trend + level)
- Triple exponential (complex patterns)
- Adaptive smoothing (volatility-based)
## π Technical Indicators
### Price-Based Indicators
- **RSI (Relative Strength Index)**: Momentum oscillator with regime-adjusted thresholds
- **MACD (Moving Average Convergence Divergence)**: Trend-following momentum indicator
- **Bollinger Bands**: Volatility indicator with position analysis
- **Moving Averages**: SMA 20, SMA 50 with crossover analysis
### Volume-Based Indicators
- **Volume-Price Trend**: Analyzes the relationship between volume and price movements
- **Volume Momentum**: Tracks volume changes over time
- **Volume Volatility**: Measures volume stability
- **Volume Ratio**: Compares current volume to historical averages
### Risk Metrics
- **Sharpe Ratio**: Risk-adjusted return measure
- **Value at Risk (VaR)**: Maximum expected loss at given confidence level
- **Maximum Drawdown**: Largest peak-to-trough decline
- **Beta**: Market correlation measure
- **Volatility**: Historical and implied volatility measures
## π οΈ Installation
1. **Install Dependencies**:
```bash
pip install -r requirements.txt
```
2. **Key Dependencies**:
- `chronos-forecasting>=1.0.0`: Amazon's Chronos foundation model
- `torch>=2.1.2`: PyTorch for deep learning
- `yfinance>=0.2.0`: Yahoo Finance data
- `scikit-learn>=1.3.0`: Machine learning algorithms
- `plotly>=5.0.0`: Interactive visualizations
- `gradio>=4.0.0`: Web interface
- `textblob>=0.17.1`: Sentiment analysis
- `arch>=6.2.0`: GARCH modeling
- `hmmlearn>=0.3.0`: Hidden Markov Models
## π Usage
### Web Interface
```bash
python app.py
```
The application provides a comprehensive web interface with three main tabs:
1. **Daily Analysis**: Long-term investment analysis (up to 365 days)
2. **Hourly Analysis**: Medium-term trading analysis (up to 7 days)
3. **15-Minute Analysis**: Short-term scalping analysis (up to 3 days)
### Market Status Check
The application includes a simple market status monitoring feature:
1. **Quick Market Status Check**: Located at the top of the interface
2. **Market Selection**: Dropdown menu with all supported markets:
- US Stock Market (NYSE, NASDAQ, AMEX)
- European Markets (London, Frankfurt, Paris)
- Asian Markets (Tokyo, Hong Kong, Shanghai)
- Forex Market (24/7 Global Currency Exchange)
- Cryptocurrency Market (24/7 Bitcoin, Ethereum, Altcoins)
- US Futures Market (24/7 CME, ICE, CBOT)
- Commodities Market (24/7 Gold, Silver, Oil, Natural Gas)
3. **One-Click Check**: Click "Check Market Status" to get real-time information
4. **Detailed Information**: Shows current status, trading hours, next trading day, and time until open/close
**Example Output:**
```
π’ US Stock Market Status: OPEN
Current Status: US Stock Market is currently open
Market Details:
- Type: Stocks
- Symbol: ^GSPC
- Current Time: 14:30:00 EDT
- Last Updated: 2024-01-15 14:30:00 EDT
Trading Information:
- Next Trading Day: 2024-01-16
- Time Until Open: N/A (Market is open)
- Time Until Close: 1h 30m
Market Description: NYSE, NASDAQ, AMEX
```
### Advanced Settings
- **Ensemble Methods**: Enable/disable multi-algorithm ensemble
- **Regime Detection**: Enable/disable market regime detection
- **Stress Testing**: Enable/disable scenario analysis
- **Enhanced Covariate Data**: Include market indices, sectors, commodities
- **Sentiment Analysis**: Include news sentiment analysis
- **Smoothing**: Choose from multiple smoothing algorithms
### Ensemble Weights
Configure the weights for different prediction methods:
- **Chronos Weight**: Weight for Amazon Chronos predictions
- **Technical Weight**: Weight for technical analysis
- **Statistical Weight**: Weight for statistical models
## π Prediction Features
### Enhanced Uncertainty Quantification
The system provides multiple uncertainty calculation methods:
1. **Basic Uncertainty**: Standard quantile-based uncertainty
2. **Skewness-Adjusted**: Accounts for asymmetric return distributions
3. **Volatility-Scaled**: Scales uncertainty based on historical volatility
4. **Market-Adjusted**: Adjusts uncertainty based on VIX and market conditions
5. **Time-Decay**: Uncertainty increases with prediction horizon
6. **Ensemble Uncertainty**: Combines all methods for robust estimates
### Volume Prediction Improvements
- **Price-Volume Relationship**: Models the relationship between price movements and volume
- **Momentum Effects**: Incorporates volume momentum and trends
- **Market Condition Adjustments**: Adjusts predictions based on market volatility
- **Uncertainty Quantification**: Provides confidence intervals for volume predictions
### Covariate Integration
The system automatically collects and integrates:
- **Market Indices**: S&P 500, Dow Jones, NASDAQ, VIX
- **Sector Performance**: Financial, Technology, Energy, Healthcare ETFs
- **Economic Indicators**: Treasury yields, dollar index, commodity prices
- **Global Markets**: International indices and currencies
## π¬ Advanced Features
### Regime Detection
Uses Hidden Markov Models to detect market regimes:
- **Bull Market**: High returns, low volatility
- **Bear Market**: Low returns, high volatility
- **Sideways Market**: Low returns, low volatility
### Stress Testing
Performs scenario analysis under various market conditions:
- **Market Crash**: -20% market decline
- **Volatility Spike**: 50% increase in VIX
- **Interest Rate Shock**: 100 basis point rate increase
- **Sector Rotation**: Major sector performance shifts
### Sentiment Analysis
- **News Sentiment**: Analyzes recent news articles for sentiment
- **Confidence Scoring**: Provides confidence levels for sentiment analysis
- **Integration**: Incorporates sentiment into prediction models
## π Output Metrics
### Trading Signals
- **RSI Signals**: Oversold/Overbought with confidence levels
- **MACD Signals**: Buy/Sell with strength indicators
- **Bollinger Bands**: Position within bands with breakout signals
- **SMA Signals**: Trend following with crossover analysis
### Risk Metrics
- **Sharpe Ratio**: Risk-adjusted return measure
- **VaR**: Value at Risk at 95% confidence
- **Maximum Drawdown**: Largest historical decline
- **Beta**: Market correlation coefficient
- **Volatility**: Historical and implied volatility
### Enhanced Features
- **Covariate Data Usage**: Indicates which external data was used
- **Sentiment Analysis**: News sentiment scores and confidence
- **Advanced Uncertainty Methods**: List of uncertainty calculation methods used
- **Regime-Aware Uncertainty**: Whether regime detection was applied
- **Enhanced Volume Prediction**: Whether advanced volume modeling was used
## π― Use Cases
### Long-Term Investment (Daily Analysis)
- Portfolio management and asset allocation
- Strategic investment decisions
- Risk management and hedging
- Sector rotation strategies
### Medium-Term Trading (Hourly Analysis)
- Swing trading strategies
- Position sizing and timing
- Intraday volatility analysis
- Momentum-based trading
### Short-Term Trading (15-Minute Analysis)
- Scalping strategies
- High-frequency trading
- Micro-pattern recognition
- Ultra-short-term momentum
## π§ Configuration
### Model Parameters
- **Chronos Model**: `amazon/chronos-t5-large` (default)
- **Context Window**: 64 time steps
- **Prediction Length**: Configurable up to model limits
- **Quantile Levels**: [0.1, 0.5, 0.9] for uncertainty estimation
### Data Sources
- **Primary**: Yahoo Finance (yfinance)
- **Covariates**: Market indices, ETFs, commodities, currencies
- **Sentiment**: News articles via yfinance
- **Economic Data**: Treasury yields, VIX, dollar index
## π Notes
- **Market Hours**: Hourly and 15-minute data only available during market hours
- **Data Limitations**: Yahoo Finance has specific limits for intraday data
- **Model Performance**: Chronos performs best with sufficient historical data
- **Uncertainty**: All predictions include comprehensive uncertainty estimates
- **Ensemble Weights**: Should sum to 1.0 for optimal performance
## π€ Contributing
This system is designed to be extensible. Key areas for enhancement:
- Additional covariate data sources
- New uncertainty calculation methods
- Advanced sentiment analysis techniques
- Custom technical indicators
- Alternative ensemble methods
## π License
This project is licensed under the Apache-2.0 License.
## π Acknowledgments
- **Amazon Chronos**: Foundation model for time series forecasting
- **Yahoo Finance**: Market data provider
- **Gradio**: Web interface framework
- **Plotly**: Interactive visualizations
- **Scikit-learn**: Machine learning algorithms
|