Using the bybit API (see docs) we try to find cointegrated coin pairs to do arbitrage. Register on testnet.bybit.com to get an API key and secret.
Run the individual steps in ./Strategy/main_strategy.py:
- Get all tradeable pairs.
- Get their price history
- Find cointegrated pairs
- Calculate and visualize spread/zscore
Outputs and statistics are stored as .csv files for further backtesting.
Within an infinite loop in the file ./Execution/main_execution.py:
- Monitor z-score signal
- Place long and short orders if z-score threshold is reached.
- Order size is calculated depending on the liquidity of the assets.
- Once an order is filled, new order gets placed until capital limit is reached or signal disappeared.
- Wait for mean reversion (z-score reaching 0) and close all positions.