Regime-switching Avellaneda-Stoikov + Advanced Strategies research doc
Implemented regime detection in paper trader: - Rolling 30-tick volatility classifies market as LOW_VOL/NORMAL/HIGH_VOL - A-S fill probability adapts: 25% (low vol), 15% (normal), 8% (high vol) - HIGH_VOL with spreads >$30: skip trading (adverse selection protection) - Regime shown on dashboard header with color-coded badge Added docs/ADVANCED_STRATEGIES.md — comprehensive research covering: 1. Deep Learning LOB Prediction (Transformers/TLOB) 2. Latency Arbitrage in Fragmented Markets 3. Hawkes Process OFI Modeling 4. Cross-Chain MEV Arbitrage 5. Institutional Capital Flow Arbitrage (ETF flows) 6. Hybrid Transformer + Hawkes Fusion 7. Implementation Roadmap (Phase 1-4) All strategies referenced with papers from arXiv, SSRN, and empirical studies.
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
# Advanced Strategy Research
|
||||
|
||||
> Forward-looking strategies for next-generation quantitative trading.
|
||||
> Implemented status: Regime-Switching A-S (live), others (research).
|
||||
|
||||
---
|
||||
|
||||
## 1. Regime-Switching Adaptive Market Making ✅ IMPLEMENTED
|
||||
|
||||
**Status:** Live in paper trading engine.
|
||||
|
||||
### Concept
|
||||
The classic Avellaneda-Stoikov model assumes constant market parameters (volatility, liquidity). In reality, market regimes shift — a flash crash requires radically different behavior than a quiet Sunday.
|
||||
|
||||
### Implementation
|
||||
- **Regime detection:** 30-tick rolling volatility classifies market as LOW_VOL (<15% ann.), NORMAL (15-60%), or HIGH_VOL (>60%)
|
||||
- **Adaptive behavior:**
|
||||
- LOW_VOL: fill probability 25%, aggressive spread capture
|
||||
- NORMAL: baseline 15% fill probability
|
||||
- HIGH_VOL: 8% fill probability, skip when spread >$30 (adverse selection protection)
|
||||
- Based on research showing static makers lost catastrophically during Oct 2025 flash crash while adaptive taker strategies profited from the directional move
|
||||
|
||||
### Where to find it
|
||||
- `live/paper_trader.py` → `detect_regime()`, `simulate_avellaneda()`
|
||||
- Dashboard → Paper Trading tab → Avellaneda-Stoikov card shows regime-dependent behavior
|
||||
|
||||
---
|
||||
|
||||
## 2. Deep Learning LOB Prediction 🔬 RESEARCH
|
||||
|
||||
### Concept
|
||||
Transformer-based model (e.g., TLOB architecture) to forecast short-term mid-price movements from the full Limit Order Book. The collective structure of resting orders contains latent information about future liquidity provision and adverse selection risk.
|
||||
|
||||
### Architecture
|
||||
```
|
||||
Input: LOB snapshots (10 levels × 100 timesteps) → Transformer Encoder → Price Direction (UP/DOWN/FLAT)
|
||||
```
|
||||
|
||||
### Key Papers
|
||||
- TLOB: A Novel Transformer Model with Dual Attention for Stock Price Trend Prediction (arXiv)
|
||||
- CatBoost on LOB features showed statistically significant alpha vs buy-and-hold
|
||||
|
||||
### Implementation Path
|
||||
1. Collect tick-level LOB data from Hyperliquid (via WebSocket or API)
|
||||
2. Feature engineering: price levels, volumes, queue positions, order flow imbalance
|
||||
3. Train Transformer on GPU (A100 recommended)
|
||||
4. Deploy with ONNX Runtime for inference
|
||||
5. FPGA acceleration for sub-ms parsing → order placement pipeline
|
||||
|
||||
### Challenges
|
||||
- GPU resources for training (estimated 40h on A100 for 1 month of data)
|
||||
- Real-time inference latency must be <1ms for HFT
|
||||
- Model drift requires periodic retraining
|
||||
|
||||
---
|
||||
|
||||
## 3. Latency Arbitrage in Fragmented Markets 🔬 RESEARCH
|
||||
|
||||
### Concept
|
||||
Exploit microsecond/nanosecond price discrepancies across multiple trading venues. Modern equity markets have 12+ lit venues for the same security.
|
||||
|
||||
### Economics
|
||||
- Cboe recently reduced latency from 50μs to 20μs — the arms race continues
|
||||
- Latency arbitrage contributes to tighter spreads and faster price discovery but may increase volatility
|
||||
- Success depends on physical proximity, not prediction accuracy
|
||||
|
||||
### Infrastructure Requirements
|
||||
- Co-location in exchange data centers (NYSE Mahwah, CME Aurora, etc.)
|
||||
- FPGA-based market data parsing (sub-μs)
|
||||
- Direct market access to all relevant venues
|
||||
- Microwave networks between NJ and Chicago data centers
|
||||
|
||||
### Regulatory
|
||||
- SEC Rule 611 (Order Protection Rule) requires best execution
|
||||
- Latency arbitrage is legal but faces increasing scrutiny as a "tax" on slower participants
|
||||
|
||||
### Backtesting Caveat
|
||||
Must model venue-specific latencies and network delays; naive backtests overstate profitability by 100-1000x.
|
||||
|
||||
---
|
||||
|
||||
## 4. Hawkes Process Order Flow Imbalance 🔬 RESEARCH
|
||||
|
||||
### Concept
|
||||
Model order arrivals as self-exciting point processes. Unlike Poisson (independent arrivals), Hawkes processes recognize trade clustering — a large buy triggers a cascade of further buying. This produces a mathematically rigorous Order Flow Imbalance (OFI) signal.
|
||||
|
||||
### Mathematical Foundation
|
||||
```
|
||||
λ(t) = μ + Σ α·e^(-β(t-t_i)) for t_i < t
|
||||
```
|
||||
Where μ is baseline intensity, α is self-excitation, β is decay rate.
|
||||
|
||||
### Empirical Validation
|
||||
- Systematic study on NIFTY50 showed consistent predictive power (SSRN)
|
||||
- Multiple academic papers demonstrate OFI forecasting with Hawkes processes
|
||||
|
||||
### Implementation
|
||||
- Continuous calibration of Hawkes parameters on incoming trade data
|
||||
- Compute predicted OFI → directional signal
|
||||
- Less computationally intensive than deep learning but more rigorous than simple OFI
|
||||
|
||||
### Regime Sensitivity
|
||||
- Excels during trending/volatile periods (pronounced order clustering)
|
||||
- Underperforms in quiet, range-bound markets (Hawkes degenerates toward Poisson)
|
||||
|
||||
---
|
||||
|
||||
## 5. Cross-Chain MEV Arbitrage 🔬 RESEARCH
|
||||
|
||||
### Concept
|
||||
Capture value from price discrepancies of the same asset across different blockchains. Execute transactions atomically across chains before competitors.
|
||||
|
||||
### Market Size
|
||||
- One-year study (Sep 2023-Aug 2024) across 9 blockchains: 242,000 cross-chain arbitrages
|
||||
- Generated $9.4M profit on $466M volume
|
||||
|
||||
### Types
|
||||
- **SIA (Sequence-Independent Arbitrage):** Trades on separate chains independently
|
||||
- **SDA (Sequence-Dependent Arbitrage):** Uses bridges to move funds, requires sequencing
|
||||
|
||||
### Key Infrastructure
|
||||
- Jito Bundles (Solana): auction-based MEV extraction with ordered transaction bundles
|
||||
- Multiple chain RPCs and node operators
|
||||
- Smart contracts for atomic execution
|
||||
|
||||
### Challenges
|
||||
- Cross-chain finality times vary (Solana ~0.4s, Ethereum ~12s)
|
||||
- Bridge security risks
|
||||
- Gas optimization critical for profitability
|
||||
|
||||
---
|
||||
|
||||
## 6. Institutional Capital Flow Arbitrage 🔬 RESEARCH
|
||||
|
||||
### Concept
|
||||
The January 2024 Bitcoin ETF approval created a causal relationship between ETF flows and BTC price. Research shows ETF net flows explained ~95% of Bitcoin's price variance (R² ≈ 0.95) post-launch.
|
||||
|
||||
### Signal Pipeline
|
||||
```
|
||||
SEC Filings (Form N-CEN) → ETF Flow Data → Anticipate Market Impact → Trade
|
||||
```
|
||||
|
||||
### Timing
|
||||
- More medium-frequency (minutes/hours) than true HFT
|
||||
- Key source: regulatory filing data parsed before market digests it
|
||||
|
||||
### Market Impact
|
||||
- Bitcoin correlation with S&P 500 increased significantly post-ETF
|
||||
- Gold correlation remained weak — BTC adopted as "tech-like" risk asset by institutions
|
||||
|
||||
---
|
||||
|
||||
## 7. Hybrid: Transformer + Hawkes Process 🔬 RESEARCH
|
||||
|
||||
### Concept
|
||||
Fuse deep learning pattern recognition with point process rigor. Two independent models produce signals that are combined with dynamic regime-dependent weights.
|
||||
|
||||
### Architecture
|
||||
```
|
||||
LOB Data ─┬─ Transformer → P(UP) ┐
|
||||
│ ├─ Weighted Fusion → Final Signal
|
||||
└─ Hawkes OFI → Direction ───┘
|
||||
```
|
||||
|
||||
### Fusion Logic
|
||||
- Trending markets: weight Hawkes OFI higher (order clustering signal)
|
||||
- Sideways/chop: weight Transformer higher (subtle pattern detection)
|
||||
- Weights determined by regime detection module
|
||||
|
||||
### Advantages
|
||||
- More robust than single-model approach
|
||||
- Better interpretability than pure deep learning
|
||||
- Mirrors real-world practice (teams combine multiple quant tools)
|
||||
|
||||
### Complexity
|
||||
- Requires expertise in both deep learning (PyTorch/TF) and stochastic processes
|
||||
- Parallel inference of both models must stay within latency budget
|
||||
|
||||
---
|
||||
|
||||
## Implementation Roadmap
|
||||
|
||||
| Phase | Timeline | Focus |
|
||||
|-------|----------|-------|
|
||||
| **Phase 1** ✅ | Current | Regime-switching A-S, basic strategies, dashboard |
|
||||
| **Phase 2** | Next | Hawkes OFI implementation, enhanced regime detection |
|
||||
| **Phase 3** | Future | Deep learning LOB predictor, cross-chain MEV |
|
||||
| **Phase 4** | Research | Hybrid models, ETF flow integration, latency arb |
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
|
||||
- TLOB: Dual Attention Transformer for LOB (arXiv: 2024)
|
||||
- Hawkes Processes for High-Frequency Trading (SSRN)
|
||||
- Jito Bundles: MEV on Solana (Jito Labs, 2024)
|
||||
- Cross-Chain Arbitrage: 9 Blockchains, 242K Trades (arXiv: 2024)
|
||||
- Post-ETF Bitcoin: Flows, Correlations, and Market Structure (arXiv: 2024)
|
||||
- Flash Crash 2025: Market Maker vs Taker Performance (arXiv)
|
||||
- Rule 611 and Fragmentation Economics (QuestDB/DeltaStrategy)
|
||||
Reference in New Issue
Block a user