Skip to content

A Statistical Arbitrage Strategy to trade Cryptocurrency Pairs

Notifications You must be signed in to change notification settings

coderaashir/Crypto-Pairs-Trading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto-Pairs-Trading

This is a code exploring a statistical arbitrage strategy to trade crypto pairs.

First, the code (cointegration_analsis.py) analyzes the performance of 8 cryptocurrencies from 1-1-2020 to 5-31-2020 with respect to their intial values: Alt text

Then, the code tests for cointegration of the cryptocurrencies against each other.

Cointegration implies that the ratio of two stationary time series will vary around a mean. This is the basis for trading pairs. For example, if BTC and ETH are highly cointegrated, and BTC diverts up from the mean while ETH diverts down from the mean, we can go long on ETH and short on BTC because they will revert back.

The code finds the p values of each pair, and plots a heat map that allows us to pick highly cointegrated pairs for trading:

Alt text

We can see that the best trades are BTC-ETH, BTC-LTC, and BTC-XRP

We can calculate the z-scores for these pairs (how many standard deviations the asset has moved from the mean) and place trades accordingly.

Results

Sharpe Ratio Table (> 1 is ideal)

BTC-ETH BTC-LTC BTC-XRP
Training Set 4.744124 3.182864 3.630110
Testing Set 1.158460 -1.808723 2.060752

Cumulative PNL:

Alt text

About

A Statistical Arbitrage Strategy to trade Cryptocurrency Pairs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages