Brian Ustas

Brian Ustas

Entrepreneur and software engineer based in Cambridge, MA.

Crafted with care.
back to portfolio

Cryptocurrency Pairs Trading

  • Python
  • NumPy
  • Pandas
  • Matplotlib
  • 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, Matplotlib, Scikit-learn, TA-Lib, and Peewee.

Key resources:

Screenshots

V1: Pairs Trading + machine learning on technical indicators.
V2: Technical indicators aren’t very helpful. Revert to basic Pairs Trading.
backtest logs
Python source code files (source code is private)