Premchan369's picture
Upload README.md
5d5ab7d verified
|
Raw
History Blame
4.55 kB
# AlphaForge - Multi-Asset Quantitative Trading System
A comprehensive quantitative trading system that combines price-based alpha signals, financial sentiment analysis, volatility forecasting, portfolio optimization, and ML-based options pricing.
## Features
### 1. Multi-Asset Alpha Model
- **LSTM** neural network for sequential pattern recognition
- **Transformer** architecture for attention-based forecasting
- **XGBoost** ensemble for robust feature-based predictions
- **Ensemble** combining all three with IC-weighted blending
- **IC Tracking**: Information Coefficient monitoring over time
- **Feature Drift Detection**: XGBoost importance divergence tracking
### 2. News + Sentiment Alpha (FinBERT)
- Uses `ProsusAI/finbert` for financial sentiment analysis
- Converts news/social media into numerical alpha signals
- Confidence-weighted aggregation per asset per day
- Synthetic news generation for testing
### 3. Volatility Forecasting Engine
- **GARCH(1,1)** with Student-t errors for baseline
- **LSTM** with skewed Student's t distributional output
- **EWMA covariance** matrix construction
- Positive definite enforcement
### 4. Portfolio Optimizer
- Mean-variance optimization with transaction costs
- Max Sharpe ratio optimization
- Minimum volatility with return constraints
- **Robust optimization** with uncertainty sets
- **Black-Litterman** model for incorporating views
- Efficient frontier computation
### 5. Options Pricing with ML
- 4-layer neural network (256-128-64-32)
- Black-Scholes baseline for comparison
- Implied volatility prediction
- **Mispricing detection** for arbitrage signals
- Synthetic data generation for training
### 6. Backtest Engine
- Transaction cost and slippage simulation
- Comprehensive metrics:
- Sharpe, Sortino, Calmar ratios
- Max drawdown, win rate
- Alpha, Beta, Information Ratio
- Turnover and cost analysis
- Regime detection (bull/bear/high-vol)
- Rolling performance metrics
## Installation
```bash
git clone https://huggingface.co/Premchan369/alphaforge-quant-system
cd alphaforge-quant-system
pip install -r requirements.txt
```
## Usage
### Train Alpha Model
```bash
python main.py --mode train --tickers SPY QQQ AAPL MSFT --epochs 50
```
### Run Full Backtest
```bash
python main.py --mode backtest --start 2020-01-01 --end 2024-01-01
```
### Train Options Model
```bash
python main.py --mode options
```
## Pipeline Architecture
```
Market Data (OHLCV)
|
+---> Technical Indicators (RSI, MACD, Bollinger, etc.)
+---> Cross-Asset Features (beta, correlation, spreads)
|
v
Alpha Model (LSTM + Transformer + XGBoost Ensemble)
|---> Predicted Returns (mu)
|---> IC Tracking
|
News Data
|
v
Sentiment Model (FinBERT)
|---> Sentiment Alpha (S_t)
|
v
Combined Alpha = w1 * Price Alpha + w2 * Sentiment Alpha
Market Data
|
v
Volatility Engine (GARCH + LSTM)
|---> Covariance Matrix (Sigma)
|
v
Portfolio Optimizer (Mean-Variance / Max Sharpe / Robust)
|---> Optimal Weights (w)
|
v
Backtest Engine
|---> PnL, Sharpe, Drawdown, etc.
```
## Key Metrics
| Metric | Description |
|--------|-------------|
| **IC** | Information Coefficient (rank correlation between predicted and actual returns) |
| **Sharpe** | Risk-adjusted return (excess return / volatility) |
| **Sortino** | Downside risk-adjusted return |
| **Max DD** | Maximum peak-to-trough decline |
| **Calmar** | Annualized return / max drawdown |
| **Alpha** | Excess return vs benchmark |
| **Beta** | Market sensitivity |
## File Structure
| File | Description |
|------|-------------|
| `main.py` | Entry point and orchestration |
| `market_data.py` | Data fetching and feature engineering |
| `alpha_model.py` | LSTM/Transformer/XGBoost ensemble |
| `sentiment_model.py` | FinBERT sentiment analysis |
| `volatility_model.py` | GARCH + LSTM volatility forecasting |
| `portfolio_optimizer.py` | Mean-variance and robust optimization |
| `options_pricer.py` | ML options pricing and mispricing detection |
| `backtest_engine.py` | Backtesting with comprehensive metrics |
## Research Backing
- **Alpha Models**: xLSTM-TS with wavelet denoising (Lopez Gil et al., 2024)
- **Sentiment**: FinBERT (Araci, 2019) with ChatGPT benchmarking (Fatouros et al., 2023)
- **Volatility**: LSTM with skewed Student's t (Michankow, 2025)
- **Portfolio**: Multi-task learning for joint optimization (Ong & Herremans, 2023)
- **Options**: 5-layer FNN outperforming Black-Scholes (Berger et al., 2023)
## License
MIT