Cryptocurrency Arbitrage (1): Some Ideas


Coinbase has just launched BCH as an alternative to BTC because of the high transaction fees and annoying delays of the latter one. As a result, the exchange rate of USD/BCH rocketed tenfolds within 24 hours. Together with BTC, mainstream altcoins like ETH and ETC faced significant slump since a week ago. On contrary, XRP, because of the rumored endorcement from big companies like Amazon, is experiencing a straight appreciation of almost 100% since two weeks ago.

This is the cryptocurrency market. Notorious for its incredible risks with comparatively high volatility and liquidity (within the exchange, while for the special case of inter-exchange liquidity of BTC markets, you can check out this previous post of mine), the huge market is also globally desirable for any quant trader -- well maintained APIs, low fees, free information including 3rd-level order books, and various order types allowing for any kind of derivative you’d like to give a try. Earlier this year, I took a brief look into this market and its varied properties did attract me. Different from then when I mainly focused on the inefficiency of the market as a whole, I’d like to write some real stategies this time, as basically all my grad school applications are finished and there’s a wonderful holiday waiting for me. I’ll have enough time to build my own wheel, develop and test my lovely strategies.

There’re already some codes being written since yesterday, I don’t intend to present them here as they’re highly unstable and need way more tests and perfection. However, I do have a framework for now, which I’d like to write down here so that I can proceed everything in a more orderly way. This is gonna be a series, as I’ve already put in the title, and hopefully I can finish everything below by 2018.

Trading System

This part is actually already finished. This is a framework (for now) specifically designed for the Poloniex API which requires private keys so that the bot can send real orders. Due to the fact that there’s no market order in Poloniex’s API, I had to write my own based on limit orders and order book information. This is now still a commandline version, which of course can be easily embedded into a web-based or desktop software, but I don’t think that’s of any practical necessity now. ANSI colors are enough for efficient while enjoyable monitoring. The only issue now is the speed of the system. However, the delays are almost 95% from web data requests rather than the strategies themselves, and thus rewriting the whole system into a C++ one seems not helping either.

Strategy 1: Dynamic Forecasting

The first strategy is almost done and is currently under non-trading testing. It is based on a Long-Short-Term-Memory neural network with an uncertain number of sigmoid activation layers. Although I named it as forecasting, it is in fact not a regression. Rather, I hot-coded the optimum weighted portfolio posteriorly determined by the historical Sharpe ratio on a minute basis. By doing so, I successfully translated the multivariate regression problem (which is, according to my experience, fairly hard for most models) into a categorical classification problem. By using a sigmoid activation layer for outputs I can interpret/use the classification probabilities as the predicted weight vector and validate it using loss functions like MSE or cross-entropy. The result is interesting, and I’ll keep it for the next post.

Strategy 2: Polygon Arbitrage

I got this inspiration from the so-called “triangular arbitrage” in foreign exchange markets. Because however transparent information is across the whole market, traders cannot access and digest everything at the very same time, price discrepancy occurs from time to time. By trading USD for EUR and then for CNY and then back for USD, due to such discrepancy in between, arbitrage opportunities may exist. However, as this is quite classic a strategy, of course thousands of traders are already doing this sort of thing in the cryptocurrency market, and thus for length 4 (including both beginning and ending currencies) paths, arbitrage opportunities are only too transient to be caught. Based on this idea, by extending the trading path’s length to a larger but bounded, uncertain number, I expect to find more such opportunities with a sacrifice of higher slippage. I’m considering whether theories about Markov chains and graph theory can be applied in this story but have not yet figured out any concrete idea.

Strategy 3: Dynamic Polygon Arbitrage

As the name implies, this is merely the combination of strategy 1 and 2. The insight behind it is also quite simple -- by basing our trasactions on a coin, e.g. BTC, we’re binding our excess returns to the absolute performance of the coin itself. There’re two solutions for this dilemma:

  1. Dynamically choose the best coin you guess for the future period.
  2. Open a margin account and trade only in margin, which is definitely preferable to the first solution… but

I cannot open a margin account, period.

Merry Christmas!