I'm curious as how one would go about arbitraging crypto currencies - How does it work? what do I need to look out for? What are the risks and caveats?
Arbitrage - What it is and how it works
Arbitrage refers to the process of instantly trading one or more pairs of currencies or odds for a nigh risk-free profit.
Usually, this involves two exchanges (this is then called a two-legged arbitrage); although more are, of course, possible.
There are several steps when executing an arbitrage:
- Find a suitable opportunity
- Execute trades
- Rebalance accounts
Step 1: Find a suitable opportunity
This step is relatively easy. Simply check the
order books of as many exchanges as you like, compare
asks, and check if you can find a
A small discourse into what a spread is
I will assume you're familiar with
asks and what an
order book is - if not, you should definitely look up those first.
As for the negative spread, I'll elaborate a bit more on that. The
spread is what is used to refer to the difference between bids and asks -
lowest ask - highest bid = spread. This should be (and typically is) a positive value, since the best
bid at an exchange must be lower than the lowest
ask of an exchange - otherwise the matching engine of the exchange would settle these orders automatically.
In a perfect world, all markets and all market participants would have the same information, hence all top bids and all top asks of all exchanges would be the exact same, after fees were applied.
If you've seen the recent US elections, however, you're probably aware that the world isn't perfect, though. Hence, not all participants of a market know the same thing as the others, resulting in
bids at exchanges which are higher than the
asks at other exchanges - and this is what is called a
Step 2: Execute trades
Let's assume you've found an amazing opportunity at exchange A and exchange B - a
negative spread of 100$!
Exchange A: Ask 1BTC@450$ Exchange B: Bid 1BTC@550$
Luckily, you have proper funding at both to match these instantly - but how do you go about doing that? Easy! Just place an order on the opposite side at each exchange with the quote's prices!
Exchange A: Place Bid of 1BTC@450$ Exchange B: Place Ask of 1BTC@550$
Since your placed order match an order on the opposite side of the book, the trading engine matches them and the trade is settled, leaving you with a theoretical profit of a smooth 100$! Why theoretically, you ask? I'll get to that point further below.
Step 3: Rebalance Accounts
Unfortunately, you were only able to trade once today, but hey! Tomorrow's another day - but in order to be able to properly trade, you need to even out your balances. Right now, your accounts look like this:
Exchange A: 2 BTC | 50$ Exchange B: 0 BTC | 1050$
Hence, you go about and send 1 BTC from Exchange A to Exchange B, and 550$ dollars to Exchange A from Exchange B. No magic here - all accounts are re-balanced and you're ready to make a fortune again, tomorrow.
Exchange A: 1 BTC | 550$ Exchange B: 1 BTC | 550$
Arbitrage - Why everyone's not doing it
This all sounded wonderful? That's exactly what I thought when I first set out with my own arbitrage bot. However, there a some technical aspects that can really turn a sunny day into a poopy rain on your parade.
Caveats and risks
1. It needs to be as close to real-time as possible
This is possibly one of the hardest things to get right, and also the most underestimated aspect of arbitrage in crypto currency. The markets, compared to ForEx trading, are ridiculously slow - at busy exchanges, there may be a couple of dozen trades executed. Which gives the illusion, that polling data for bots via the most common API type, RESTful, is enough to trade risk-free. This is a misconception. Maybe for today this may appear to be enough - but what if markets picked up the pace? just 1 trade (or simply a placed order) within one second can change your opportunity from profit to loss.
2. Always trade limits, never market orders
Under the aspect of being the fastest, it might seem like a good idea to use market orders in order to be settled asap - you'd be terribly wrong. As discussed above, your data could be as old as 1 second (with above mentioned one order messing up your opportunity) - perhaps someone cleared the entire top level and all you're left with is a bid for twice the price you intended. Yikes.
2. REST API call rates make your life hard
Many exchanges employ a API call rate limit - that is, you're allowed to query data at the exchange X times every Y seconds. The differences are wide and nearly every exchange does its own little thing when it comes to limits. The problem with them is, they severely limit your actions. If you don't constantly keep an eye on how often you send a request, you might run into the limit when it seriously counts - for example when you have to cancel an order, because you couldn't place its counter part at another exchange. Unfortunately, websocket APIs are still rare and their brother on steroids, FIX sockets, even rarer - leaving you stuck with the turtle of programmable interfaces.
3. Integration with APIs can be a nightmare
There is no unified, standard definition for what an exchange API can do, or what data it returns. Which technically wouldn't be a problem, if they were documented properly. Incidentally, the exchanges with seemingly many opportunities also have the worst documentation (take btc-e.com's Documentation for example - heresy!). Of course, also the opposite is true - GDAX, Kraken, Bitfinex all have excellent documentation. But nonetheless you have to dig through them to understand how they work, what their rates are, how they handle data types, authentication and so forth. That is, if they even mention anything about that.
4. Fees will minimize, if not eliminate your profits
In my above step-by-step guide, I purposely omitted fees of all kind. But of course, they're essential to successfully arbitraging. The most commonly known fees, are trade commission fees - these range anywhere from 0.1% to 0.6% and need to be considered in
Step 1: Find a suitable Opportunity. On top come fees for deposits and withdrawals during
Step 3: Rebalancing Accounts. Depending on your preferred pair, these may range from feasible (transferring crypto currencies usually is cheap enough) to quite steep.
For example, a deposit / withdrawal at Bitfinex entails the following fees:
Bank wire withdrawal & Deposit: 0.1% of amount deposited/withdrawn, 20$ minimum
And this does not include processing fees of your house bank - for me, for example, that's an additional 10€ for deposits, plus a 1% conversion fee. If you do the math you'll quickly realize that you don't even have to bother starting to trade at Bitfinex, unless you have a really big stack to trade with.
But this does not just apply to BTC-Fiat pairs. Alt-coins suffer a similar fate. In order to make arbitraging worthwhile, you will have to have enough funds at as many exchanges to make trades AND re-balancing worthwhile. And this quickly gets to a point where you realize your last month's savings aren't equipped to get the job done.
To give you a further example on how fees affect your profits, let's take a look back at the example from step 2, this time factoring in all fees. I'll walk you through it. For the argument's sake, we'll pretend to be a european trading BTCUSD at Bitfinex (Exchange A) and Kraken (Exchange B).
Bitfinex: Ask 1BTC@450$
Kraken: Bid 1BTC@550$ These prices are raw- they do not include trade commission fees, not transaction fees. Let's add those.
We'll define a taker fee of 0.25% at both exchange - the taker fee applies whenever you remove liquidity from the order book. Next, let's add deposit & withdrawal fees to the mix. At Bitfinex, we pay a minimum of 20$ for each fiat withdrawal & deposit, or 0.1% of the moved amount (if its more than 500$). At Kraken, we pay 0.09€ per fiat withdrawal, deposits are free. In addition, btc withdrawals cost 0.0005 BTC at kraken, while Bitfinex charges no fees for this. Deposits cost nothing at both exchanges. Furthermore, we can't transfer fiat directly from exchange to exchange - an additional 10€ fee per sent out transaction needs to be facotred in, as well as 1% conversion fee whenever we receive or send fiat from our bank account (2 times total).
Let's list these fees to try and maintain an overview
- Profit from arbitrage (bid - fee - ask + fee )
- Withdrawal Fee Bitfinex (20$)
- Deposit Fee Kraken (0.0$)
- Miner Fee for withdrawal at Kraken (0.0005BTC)
- Transaction Cost of our house bank (10€) (Bank to Bitfinex)
- Conversion Fee of our house Bank (1% of transfer amount x 2)
Let's put some numbers to these:
- (550 - 550*0.0025) - (450 + 450 * 0.0025) = 97.5$
- Move ~497$ to House bank = 20$
- 0.0005BTC * 500$ = 0.25$ # Assuming this is the end of day price of the coin
- 10€ * 1.05 = 10.05$
- (497 * 0.02) = 9.94$
Which brings us to net profit of: 57.26$ This translates to 42.74% reduction of your originally seen profit.
This is neither a worst, nor a best case scenario - it's merely designed to show you how many hidden fees are involved in an arbitrage. Also, keep in mind that a 22% arbitrage opportunity is practically non-existant.
As a matter of fact, had the spread been anything less than 40$, the fixed fees of our house bank and Bitfinex alone would have made our supposed arbirtrage opportunity a loss.
5. Volatility of coins is your enemy
"No matter where the market goes, arbitrage makes a profit anyway!"
This is true - if your currencies don't tend to drop or rise by 50% within 24 hours. Ideally, both currencies you trade in should be relatively stable, while still showing a certain volatility - no volatility would mean the chart is a flat line, resulting in no opportunities for you.
The problem with pure crypto currency arbitrage (LTCBTC), however, is that Alt-coins can go completely fubar - as opposed to a fiat-based crypto arbitrage (i.e. BTCUSD). A personal anecdote:
When ZEC launched, I was instantly fascinated at the terrible market efficiency and arbitrage opportunities of almost 5% regularly. Hence, I bought in at 1ZEC@1.2BTC, thinking this is probably where market will stay at (at least it's not as bad as the guy who bought a ZEC for 3k BTC). I started arbitraging and immediately increased the amount of ZEC I was holding - completely oblivious to the fact that since I started trading, the price had fallen to 1ZEC@0.1BTC. My ZEC was worth 90% less, and I lost almost half a bitcoin worth of money.
Some volatility is great for arbitrage - too much volatility isn't.
6. Exchanges aren't as technically robust as they ought to be
Most of the time, you will find that smaller exchanges offer opportunities more often than big exchanges. This is in part due to the previously mentioned slow movement of information, but also their (often significantly lower) trading volume. Initially, this may appear like a steal - but there's usually a reason that particular exchange only has the low volume it currently does.
In a time where any one in the world can open up an exchange running on his Raspberry Pi and Ethereum, trading on the more alternative exchanges can be a serious risk to your investment.
From things like DDOS attacks and overloaded matching engines not matching your orders, to more serious issues like stuck withdrawals due to too low miner fees, or even theft - and the latter is a very real issue not exclusively affecting small exchanges, as the Bitfinex Heist has shown summer 2016; the list of potential technical failures is long and you should be aware of these at all times.
I'm aware this answer is overtly negative - this was intentional. Arbitrage, as well as crypto currency in general, is not the quick buck everyone on forums and dubious sites advertising trading bots make you believe. While its inner mechanisms and workings are still quite cryptic* to even the most professional traders (sorry for the pun), even the fabled cryptocurrencies adhere to some basic principles, afterall. The 'quick way to wealth' usually will just end up quickly making you wealthless.
(*) Another great myth is that the chinese dictate the BTCUSD market. There is no empirical proven correlation between chinese and american markets. The only defacto correlation that has been found was that of google searches for bitcoin to btc trading volume - but whether this was positive or negative was inclonclusive.
Please feel free to add, comment or make improvement suggestions!