f4c8bca15a014ccafe281cac160256294c9e031e
Core engine (pure NumPy, zero external deps beyond NumPy): - kalman_filter.py: KalmanFilter + KalmanPairsTrader - Time-varying observation matrix H_t = [1, X_t] - RTS smoother for offline analysis - Properties: alpha, beta, spread = Y - (alpha + beta*X) - Signal: z-score crossing z_entry/z_exit/z_stop thresholds Pair discovery (pure NumPy): - pair_discovery.py: Engle-Granger cointegration + OU half-life - ADF test with MacKinnon critical values (no statsmodels) - Half-life estimation via OLS on AR(1) residuals - Pair screening: cointegrated + 1-20 period half-life - Rolling OLS hedge ratio for baseline comparison Production system: - trading_system.py: KalmanPairsTradingSystem - Multi-pair orchestration with risk overlay - Capital allocation, stop-loss, drawdown controls - KalmanPairsConfig dataclass (YAML-compatible) Backtesting: - backtest.py: Walk-forward backtest with realistic execution - Transaction costs, capital tracking, per-trade PnL - Side-by-side Kalman vs rolling OLS comparison - Metrics: CAGR, Sharpe, Sortino, max DD, win rate, turnover Tuning: - tuning.py: Grid search over transition_covariance - Train/validation split (chronological) - Objective: maximize Sharpe - penalty * max_drawdown Regime-shift test results: Kalman: Sharpe 2.17, beta adapts from 2.0 -> 0.5 in ~50 bars OLS 60d: Sharpe 0.17 (stuck on old beta) OLS 120d: Sharpe 0.66 (even slower adaptation) Integration: Added to historical_runner.py as kalman_pairs strategy
FTDT Quant Lab — Quantitative Trading Strategies
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.
What's inside
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 |
All strategies share a common risk manager and portfolio tracker.
Quick start
# 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
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
Strategy details
See docs/STRATEGIES.md for a walkthrough of each strategy.
Risk warning
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.
Built by Ramses Echikh · Part of my quant trading portfolio
Description
Quantitative trading lab — Nautilus Trader strategies on Hyperliquid Testnet. Part of my professional portfolio.
Languages
Python
52.8%
HTML
25.2%
TypeScript
21%
CSS
0.6%
JavaScript
0.4%