Repo cleanup: README with full stack summary + .gitignore + remove stale backups
This commit is contained in:
@@ -1,59 +1,168 @@
|
||||
# FTDT Quant Lab — Quantitative Trading Strategies
|
||||
# FTDT Quant Lab
|
||||
|
||||
A collection of quantitative trading strategies running on
|
||||
**Hyperliquid Testnet** via **Nautilus Trader**. Built as part of
|
||||
my professional portfolio to demonstrate algorithmic trading,
|
||||
market microstructure, and risk management skills.
|
||||
Production multi-strategy quant trading system running on Hyperliquid.
|
||||
Live testnet node, paper trading simulator, historical backtesting, and real-time dashboard.
|
||||
|
||||
## What's inside
|
||||
**Live:** https://ftdt.io/cv
|
||||
|
||||
Five strategies, from simple to advanced:
|
||||
---
|
||||
|
||||
| # | Strategy | Concept |
|
||||
|---|----------|---------|
|
||||
| 1 | Order Book Imbalance | Trades on L2 bid/ask pressure |
|
||||
| 2 | Iceberg / TWAP Detection | Follows whale accumulation patterns |
|
||||
| 3 | Funding Rate Arbitrage | Delta-neutral carry trade |
|
||||
| 4 | Pairs Trading (BTC/ETH) | Cointegration-based stat arb |
|
||||
| 5 | Avellaneda-Stoikov Market Making | Stochastic optimal control |
|
||||
## Stack
|
||||
|
||||
All strategies share a common risk manager and portfolio tracker.
|
||||
| Layer | Technology |
|
||||
|-------|-----------|
|
||||
| **Runtime** | Python 3.13 (async trading) |
|
||||
| **API Client** | nautilus_trader (Hyperliquid SDK, Rust bindings) |
|
||||
| **Dashboard** | Next.js 16 (static export) + shadcn/ui + Framer Motion |
|
||||
| **Design System** | Hallmark Cobalt — Ubuntu font, hairline borders, cool paper palette |
|
||||
| **Reverse Proxy** | Caddy → auto HTTPS |
|
||||
| **WebSocket** | FastAPI (live/paper streaming) |
|
||||
| **Data** | PostgreSQL 17 (`ftdt_quant`), JSON metrics files |
|
||||
| **Backtesting** | Custom dollar-bar engine + numpy |
|
||||
| **Infra** | OVH VPS (4 vCPU, 8GB RAM, Debian 13), 2GB swap |
|
||||
|
||||
## Quick start
|
||||
~5,300 lines of Python + TypeScript. 67 commits since July 2026.
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
---
|
||||
|
||||
# Set your Hyperliquid testnet key
|
||||
export HYPERLIQUID_TESTNET_PK=0x...
|
||||
|
||||
# Run live (testnet only)
|
||||
python live/node.py
|
||||
```
|
||||
|
||||
## Project layout
|
||||
## Repository Structure
|
||||
|
||||
```
|
||||
ftdt-quant-lab/
|
||||
├── config/ # Per-strategy YAML configuration
|
||||
├── strategies/ # Strategy implementations
|
||||
├── common/ # Risk manager, portfolio tracker, metrics
|
||||
├── backtests/ # Historical backtest runners
|
||||
├── live/ # Live trading node (Hyperliquid Testnet)
|
||||
├── docs/ # Documentation and strategy writeups
|
||||
└── notebooks/ # Analysis notebooks
|
||||
├── live/
|
||||
│ ├── node.py # Live trading node — testnet, 9 strategies
|
||||
│ └── paper_trader.py # Paper trading — mainnet data, 10 strategies
|
||||
├── strategies/
|
||||
│ ├── orderbook_imbalance.py # L2 bid/ask volume skew (OBI)
|
||||
│ ├── iceberg_detection.py # Whale TWAP accumulation detection
|
||||
│ ├── funding_arb.py # Delta-neutral carry — spot/perp funding
|
||||
│ ├── pairs_trading.py # BTC/ETH ratio Z-score (1.5σ)
|
||||
│ ├── avellaneda_stoikov.py # Dual-sided stochastic control MM
|
||||
│ ├── kalman_pairs/ # Kalman-filter adaptive hedge ratio
|
||||
│ ├── hawkes_ofi.py # Hawkes process order flow
|
||||
│ ├── deep_lob.py # Deep LOB CNN feature extraction
|
||||
│ ├── queue_imbalance.py # Weighted queue dynamics
|
||||
│ ├── hurst_vpin.py # Hurst exponent + VPIN directional
|
||||
│ ├── hurst_vpin_live.py # Lightweight Hurst/VPIN for live tick stream
|
||||
│ └── quant_report.py # QF-Lib style quant analytics
|
||||
├── dashboard/
|
||||
│ ├── server.py # FastAPI backend — WS, REST, static files
|
||||
│ └── next/
|
||||
│ └── src/
|
||||
│ ├── app/ # Main page + layout
|
||||
│ ├── components/ # QuantReport, StrategyCard, L2Terminal
|
||||
│ └── lib/ # Types, API client
|
||||
├── backtests/
|
||||
│ ├── run.py # Backtest runner
|
||||
│ └── results/
|
||||
│ └── historical/ # JSON backtest snapshots (32 entries)
|
||||
├── common/ # Shared utilities
|
||||
│ ├── risk.py, risk_manager.py
|
||||
│ ├── hyperliquid_api.py
|
||||
│ └── portfolio.py, metrics.py
|
||||
├── config/
|
||||
│ └── fee_tiers.py # Perp/spot fee schedules
|
||||
└── infrastructure/
|
||||
├── Caddyfile # Reverse proxy config
|
||||
└── systemd/ # Service units (pending)
|
||||
```
|
||||
|
||||
## Strategy details
|
||||
---
|
||||
|
||||
See `docs/STRATEGIES.md` for a walkthrough of each strategy.
|
||||
## Strategies — Current State
|
||||
|
||||
## Risk warning
|
||||
### Live Node (Hyperliquid Testnet — 9 strategies, $100 each)
|
||||
|
||||
This is **testnet only**. These strategies are educational — they
|
||||
are not financial advice and have no alpha guarantee. Never run
|
||||
them on mainnet without thorough backtesting and your own due diligence.
|
||||
| # | Strategy | Type | Asset | Size | PnL | Trades | Win |
|
||||
|---|----------|------|-------|------|-----|--------|-----|
|
||||
| 1 | Order Book Imbalance | reversal | BTC | 0.000200 | $0.00 | 0 | — |
|
||||
| 2 | Iceberg Detection | momentum | BTC | 0.000210 | $0.00 | 2 | 0% |
|
||||
| 3 | Funding Rate Arb | carry | BTC | 0.000220 | $0.00 | 0 | — |
|
||||
| 4 | Pairs Trading | stat_arb | ETH | 0.006000 | **+$0.74** | 9 | 67% |
|
||||
| 5 | Avellaneda-Stoikov | market_making | BTC | 0.000230 | -$1.35 | 32 | 0% |
|
||||
| 6 | Momentum Breakout | momentum | ETH | 0.000500 | $0.00 | 0 | — |
|
||||
| 7 | Mean Reversion | reversal | ETH | 0.000500 | $0.00 | 0 | — |
|
||||
| 8 | Kalman Pairs | stat_arb | ETH | 0.005000 | $0.00 | 0 | — |
|
||||
| 9 | Hurst VPIN | momentum | BTC | 0.000240 | $0.00 | 0 | — |
|
||||
|
||||
**Execution:** GTC POST-ONLY limit orders. Signals every 5 ticks (5s), dual-sided for A-S.
|
||||
**Fee model:** Maker 0.02% (testnet).
|
||||
|
||||
### Paper Trader (Hyperliquid Mainnet data — 10 strategies, $100 each)
|
||||
|
||||
Same set + Queue Imbalance. Real mainnet orderbook + funding data. Fee model: taker 0.05% / maker 0.02%. Trades simulated with 1bps slippage.
|
||||
|
||||
---
|
||||
Built by [Ramses Echikh](https://git.ftdt.io/rams) · Part of my quant trading portfolio
|
||||
|
||||
## Historical Backtests
|
||||
|
||||
32 backtest snapshots across 8 strategies × 4 coins (BTC, ETH, HYPE, VVV).
|
||||
Hurst/VPIN BTC: **46 trades, 96% win rate, +1.10%** on synthetic trending data.
|
||||
|
||||
---
|
||||
|
||||
## Priority Analysis
|
||||
|
||||
### Strategies showing real signal
|
||||
|
||||
| Strategy | Signal | Status |
|
||||
|----------|--------|--------|
|
||||
| **Pairs Trading** | ✅ | +$0.74, 67% win rate — only profitable live strategy |
|
||||
| **Avellaneda-Stoikov** | ⚠️ | 32 trades but losing — spread capture not covering fees |
|
||||
| **Iceberg Detection** | ⚠️ | 2 trades — rare signals, needs threshold tuning |
|
||||
| **Hurst VPIN** | 🔬 | 96% win in backtest, 0 live trades — very selective |
|
||||
| **Mean Reversion** | ⏳ | 0 trades — VWAP deviation not crossing 1.0σ |
|
||||
| **Momentum** | ⏳ | 0 trades — Bollinger 1.2σ too tight for ETH |
|
||||
|
||||
### Recommendation: focus investment here
|
||||
|
||||
1. **Pairs Trading** — `#1 priority`. Only live winner. Extend to more pairs (SOL, ARB, OP). Add Kalman dynamic hedge ratio. This is the clearest path to sustained PnL.
|
||||
|
||||
2. **Hurst/VPIN** — `#2 priority`. Backtest shows strong edge (96% win). Needs real market data (not synthetic) and 3-day candle feed to trigger more signals. The selectivity IS the edge — don't dilute it.
|
||||
|
||||
3. **Avellaneda-Stoikov** — Needs inventory control. 32 trades losing because adverse selection. Add skew-aware quoting (update reserve price based on queue imbalance).
|
||||
|
||||
4. **Iceberg Detection** — Lower detection threshold. Currently requires 7/10 consecutive ticks same direction — too strict.
|
||||
|
||||
5. **Funding Rate Arb** — Real Hyperliquid funding data already plumbed. Test threshold from 3% → 1% APR. Prefunding detection (predict next rate before announcement).
|
||||
|
||||
6. **Backtest engine** — Replace synthetic data with real Hyperliquid candles. Add walk-forward optimization. The `hurst_vpin.py` infrastructure is ready.
|
||||
|
||||
### Skip for now
|
||||
|
||||
- OBI / Mean Reversion / Momentum — 0 trades. Signal thresholds need fundamental redesign, not just tuning.
|
||||
- Cartea-Jaimungal / Gueant MM — academic models, not adapted to crypto microstructure.
|
||||
- DeepLOB / Hawkes OFI — dependency-heavy, no live integration.
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
```bash
|
||||
# Clone and deploy
|
||||
git clone https://git.ftdt.io/rams/ftdt-quant-lab.git
|
||||
cd ftdt-quant-lab
|
||||
python3 -m venv .venv && source .venv/bin/activate
|
||||
pip install -r requirements.txt # (pending — currently manual)
|
||||
|
||||
# Start services
|
||||
python live/node.py & # Trading node
|
||||
python live/paper_trader.py & # Paper simulator
|
||||
python dashboard/server.py --port 9175 # Dashboard backend
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Roadmap
|
||||
|
||||
- [ ] Docker Compose for reproducible deployment
|
||||
- [ ] Walk-forward backtest on real Hyperliquid candle data
|
||||
- [ ] Extend Pairs Trading to BTC/SOL, BTC/ARB
|
||||
- [ ] Hurst/VPIN 3-day candle feed → real live signals
|
||||
- [ ] Memory leak proofing — current guard at 512MB RSS
|
||||
- [ ] systemd service unit files for auto-restart
|
||||
- [ ] Grafana + Prometheus monitoring dashboard
|
||||
|
||||
---
|
||||
|
||||
*Built with Hermes Agent · Hallmark Cobalt · Ubuntu fonts*
|
||||
|
||||
Reference in New Issue
Block a user