A lightweight pairs trading bot. Made to quickly and accurately backtest strategies.
Pairs trading models the logarithmic prices of two assets as such:
where
The spread
For risk management, we use a stop loss of 5% and assumes 0.1% commissions.
The bot buys the spread when the z-score is below -1, and shorts the spread when the z-score is above 1. Positions are exited when -0.5
Below are two backtests on daily prices at 9:00am from Jan 1, 2023 - Feb 19, 2024.
Bitcoin and Etherem:
Two meme coins: