⚠️ Research project — NOT financial advice. Personal research codebase exploring systematic crypto trading. Backtests carry look-ahead, survivorship, and overfit risks even when we try to avoid them. Live results may differ substantially from backtests. Do not trade real money based on this code without doing your own validation. Past performance does not predict future results. You can and will lose money.
Statistical arbitrage on Binance spot pairs using Ornstein–Uhlenbeck process modeling of mean-reverting spreads.
- Data — pull historical 1h klines from Binance public REST (no API key needed).
- Pair screen — Engle–Granger cointegration test on a candidate basket.
- OU fit — fit an OU SDE
dXt = θ(μ − Xt)dt + σ dWtto the spread of each surviving pair via MLE. - Recency-weighted variant — refit OU with exponential weights on recent observations to track regime shifts.
- Backtest — z-score band entries/exits with realistic fees + slippage; in-sample + out-of-sample split.
src/ strategy code
data/ cached raw + processed market data (gitignored)
results/ backtest outputs (gitignored)
pip install -r requirements.txt
cp .env.example .env # only needed for live trading later
python -m src.download --symbols BTCUSDT ETHUSDT --interval 1h --days 365Scaffolding in progress.