Brian Ustas

Brian Ustas

Entrepreneur and software engineer based in Cambridge, MA.

Crafted with care.
back to portfolio

Cryptocurrency Pairs Trading

  • Python
  • NumPy
  • Pandas
  • Scikit-learn
  • statistics
  • machine learning
  • algorithmic trading
  • pairs trading
  • cryptocurrency

During 2017’s Bitcoin bull run, the price of many cryptocurrencies changed rapidly. Bitcoin grew to nearly $20,000 and the high levels of excitement and FOMO created many arbitrage opportunities.

With friends, I took advantage of the US–Korea arbitrage opportunity as well as built a simple arbitrage bot in Ruby that watched GDAX and Kraken for price differences. Those opportunities don’t seem to be easily exploitable now.

One takeaway from that experience is that cryptocurrency trading is driven largely by speculation—many don’t have real-world adoption yet. Given that many cryptocurrencies respond to similar market pressures and regulation, I wondered if prices moved together in any predictable way.

This led me to the idea of Pairs Trading. The idea is simple: find a pair of assets whose prices “move together” and bet against deviations in that relationship. How you confidently define the pair’s relationship is one of the hard problems.

After studying the theory behind Pairs Trading and reading a few papers, I built a high frequency statistical arbitrage bot and backtesting pipeline. I implemented Distance and Cointegration Pairs Trading strategies on Poloniex’s Margin Trading Exchange. It looks for cryptocurrencies whose prices move together and bets against trend anomalies. It’s built with Python, NumPY, Pandas, Scikit-learn, and Peewee.

Note that it’s extremely difficult to find an “edge” in the market. It’s hard to know if your strategy will actually be successful or if you just overfit your training data. My bot is live and I’ll report back once it’s had time to make a significant number of trades.

Key resources:

Screenshots

V1: Pairs Trading + machine learning on technical indicators.
V1: Pairs Trading + machine learning on technical indicators.
V2: Technical indicators aren’t very helpful. Revert to basic Pairs Trading.
V2: Technical indicators aren’t very helpful. Revert to basic Pairs Trading.
sample backtest logs
sample backtest logs