A Beginner’s Guide to Crypto Arbitrage

The Ocean
The Ocean
Sep 11, 2018 · 11 min read

Welcome to our first installment in our new Generating Alpha series! Every week, we’ll be diving into various technical topics in the cryptocurrency market from a beginner’s perspective. Each article will include some foundational knowledge, market data, and the occasional sample code to jumpstart your foray into more advanced concepts and strategies in trading.

What is alpha?

In finance, alpha is the measure of performance. It is the excess return of an investment relative to a benchmark index (i.e. market movement as a whole). In other words, it compares your returns to the relevant market over the same time period. Let’s say your portfolio of ZRX, thanks to a multitude of diverse trading strategies, jumped 10% in value over a week. During that same time frame, the ZRX market only moved 2% upwards–your alpha would be 8%.

The objective of this series is not to guarantee alpha but to serve as a starting resource for different methods (beyond a simple HODL strategy) for generating returns.

Let’s start with arbitrage

While there are numerous trading strategies out there with varying degrees of complexity and success, two-fold arbitrage is conceptually simple. In a general sense, two-fold arbitrage profits from the simultaneous sale and purchase of an asset to exploit differences in prices across markets. Within the context of cryptocurrency, it refers to buying coins on an exchange where the price is lower and selling the coins on another exchange where the price is higher.

Arbitrage profits from the spread–also known as the difference between the buy and sell prices–across two exchanges. This can be automatically executed by an algorithm or can be done manually by the trader themself.

The main benefit of the arbitrage is that it’s independent of market performance. Regardless of volatility–how drastically an asset’s price can change–in the crypto ecosystem, arbitrage can always make a profit at the point of execution. This is because arbitrage is not a predictive model but relies on immediate price discrepancies to make small gains.

*Learn more about arbitrage in the traditional financial market.

Step 1: Finding opportunity

Within an “ideal” world, information relevant to asset prices would be freely, widely, and universally-shared between investors. In a utopian efficient market, a level playing field would create a market where all assets would sell at their fair market value or equilibrium price, neither undervalued or overvalued.

An inefficient market, according to efficient market theory, is one in which an asset’s market prices do not always accurately reflect its true value.

In contrast, the cryptocurrency market is highly fragmented, hosting hundreds of both regulated and unregulated 24/7 exchanges across the globe. Different time zones, regulations, and geography contribute to the uneven movement of speculative information. This means that prices across exchanges deviate wildly from their equilibrium, signaling a highly inefficient and immature market rife with arbitrage opportunities.

Arbitrage opportunities ahead!

Now let’s take a look at an example using ZRX and the top ten 0x markets. On CoinMarketCap, there is a huge price gap between Bithumb (a strictly South Korean exchange) and Binance (an international exchange). Let’s presume you have access to both markets and pay no fees:

  • While on Binance, you have $1000 dollars to buy ZRX. You buy as many tokens as possible at a price of $0.71. You receive about 1408 ZRX.
+ — — — — — — — + — — — — — — — +
| BINANCE | BUY ZRX/BTC |
+ — — — — — — — + — — — — — — — +
| Size / Price | $1000 / $0.71 |
| ~~~~~~~~~~~~ | |
| TOTAL ZRX | ~1408 |
+ — — — — — — — + — — — — — — — +
  • Now you immediately move your tokens to Bithumb. You sell your 1408 ZRX at a price of $1.63. You receive $2295.77 in returns, or $1295.77 in immediate, (almost) risk-free profit!
+ — — — — — — — + — — — — — — — +
| BITHUMB | SELL ZRX/KRW |
+ — — — — — — — + — — — — — - — +
| Size * Price | 1408 ZRX |
| | * $1.63 |
| ~~~~~~~~~~~~ | |
| PROFIT | $2295.77 |
| RETURN | $1295.77 |
| ROI | 129.58% |
+ — — — — — — — + — — — — — — — +

However, trading on Korean exchanges is off-limits to international traders, so this arbitrage opportunity is a bit too good to be true for the average buyer. So, let’s look at the next best deal:

  • While on BitMart, you have $1000 dollars to buy ZRX. You buy as many tokens as possible at a price of $0.69 on their ZRX/ETH order book. You receive about 1437 ZRX.
+ — — — — — — — + — — — — — - +
| BITMART | BUY ZRX/ETH |
+ — — — — — — — + — — — — - - +
| Size / Price | $1000 |
| | / $0.69 |
| ~~~~~~~~~~~~ | |
| TOTAL ZRX | ~1437 ZRX |
+ — — — — — — — + — — — - - - +
  • You immediately move your tokens to Bittrex. You sell your 1437 ZRX at a price of $0.72. You receive $1034.64 in profit, or $34.64 in returns.
+ — — — — — — — + — — — — — — — +
| BITTREX | SELL ZRX/BTC |
+ — — — — — — — + — — — — — — — +
| Size * Price | 1437 ZRX |
| | * $0.72 |
| ~~~~~~~~~~~~ | |
| PROFIT | $1034.64 |
| RETURN | $34.64 |
| ROI | 3.46% |
+ — — — — — — — + — — — — — — — +

While $34.64 may seem like a meager sum compared to our first example, let’s reiterate that arbitrage is one of the most risk-free strategies out there. As long as your execution is quick and you buy/sell at the prices that you intend on (much easier said than done!), you can usually come out on top. And if you’re targeting several arbitrage opportunities at a time or throughout the day, these small returns can quickly build up.

Step 2: Calculating fees

However, not all your profits will be yours at the end of the day. Centralized exchange fees (deposits and withdrawals from marketplace to marketplace) and transaction costs can add up, eating a good portion of your returns. That’s why it’s crucial to examine your costs before executing trades. Either tally up your fees or find unique ways to avoid them all together.

One method to avoid the typical transfer fees is to use decentralized exchanges and a software or hardware wallet. Some DEXs offer discounted fees or even no fees at times. This means that you have a plethora of exchanges to arbitrage across with no pesky transfer times and only transaction and gas costs to consider. Now let’s look at an example using EtherScan’s nifty DEX price comparison tool and ZRX:

Best Bid/Ask prices (in ETH) for ZRX across DEXs — $0.51 vs $0.52

There are countless arbitrage opportunities across all exchanges at any given time. However, specific prices and spreads are naturally fleeting as traders (just like you) seek easy profit. Eventually, spreads reduce in size as prices balance out to an equilibrium–that is, until the next opportunity arises!

Let’s create a hypothetical arbitrage opportunity across DEXs by taking some values from the table above. Because we’ll be deducting fees from our returns, we’ll also need to be more precise:

  • The price of 1 ETH is set at $181.48.
  • While on DDEX, let’s say you buy 100 ZRX. You buy the tokens at a price of 0.0028145 ETH.
  • The trading fee (0.05%) and gas fee are automatically taken in ZRX.
  • You receive 99.84425 ZRX to your MetaMask wallet after fees are accounted for.
+ — — — — — — — + — — — — — — — +
| DDEX | BUY ZRX/ETH |
+ — — — — — — — + — — — — — — - +
| Size * Price | 100 |
| | * 0.0028145 |
| | = 0.28145 ETH |
| ~~~~~~~~~~~~ | |
| Trading Fee | 0.05 ZRX |
| Gas Fee | 0.10575 ZRX |
| ~~~~~~~~~~~ | |
| TOTAL ZRX | 99.84425 ZRX |
+ — — — — — — — + — — — — — — - +
  • Because DEX trading is usually done wallet-to-wallet without any deposits or transfers required, you can quickly swap to The Ocean to dump your ~99.8 ZRX.
  • You sell your tokens at 0.002841 ETH, pay the discounted trading and gas fee (assuming it stays stable) in ETH, and receive .283657 ETH back.
  • You instantly make a profit of 35 cents from a tiny spread of 0.0000265 ETH.
+--------------+----------------+
| The Ocean | SELL ZRX / ETH |
+--------------+----------------+
| Size * Price | 99.84425 ZRX |
| | * 0.002841 ETH |
| | = 0.283657 ETH |
| ~~~~~~~~~~~~ | |
| Trading Fee | 0.00014 ETH |
| Gas Fee | 0.00015 ETH |
| ~~~~~~~~~~~ | |
| RETURN | 0.283367 ETH |
| PROFIT | 0.00197 ETH |
| PROFIT IN $ | $0.35 |
+--------------+----------------+

Step 3: Intra- and inter-exchange trading with triangular arbitrage

And not all arbitrage opportunities have to be with the same coin. Let’s take a look at Dai and TUSD, two stablecoins pegged to $1 U.S. dollar.

+------------+--------+--------+
| THE OCEAN | DAI | TUSD |
+------------+--------+--------+
| BUY 1 ETH | 180.71 | 182.12 |
| SELL 1 ETH | 179.57 | 183.68 |
+------------+--------+--------+

You can observe that despite being stablecoins pinned to $1.00, there are spreads between both the bid/ask and the prices of both tokens themselves.

This is partially due to an inefficient market and their differing mechanisms to ensure low price movements: TrueUSD maintains its value by ensuring each token is backed by one, real U.S. dollar in trusted banks. Dai lives entirely on the blockchain and is collateralized by ETH held in smart contracts. While their volatility is extremely stable compared to other cryptocurrencies, there are slight fluctuations that can occur and thus, price differences within marketplaces and between tokens is entirely possible.

One arbitrage strategy that could take advantage of stablecoin prices would look like ETH → DAI → TUSD → ETH on The Ocean and another exchange.

  • Let’s assume 1 ETH = $180.71 USD.
  • Buy 180.71 DAI with 1 ETH on The Ocean.
  • Exchange 1 ETH’s worth of DAI for 1 ETH’s worth of TUSD on another marketplace.
  • Sell your TUSD at 183.68 for ETH on The Ocean.

Without fees, this triangular arbitrage (exploiting price discrepancies between three currencies) strategy would generate a quick profit of $2.97 using just 1 ETH. However, it’s important to note that more complex arbitrage is not that simple.

Step 4: Moving your arbitrage to algorithms

Arbitrage opportunities might exist for only a short period of time. Sometimes, these periods can sometimes be calculated in the seconds or milliseconds. It can be very hard (particularly in the fragmented cryptocurrency market) to buy and sell ‘simultaneously,’ and transaction costs are tricky and time-consuming to calculate on the spot. Settlement speed, execution, transfer times, and other outside factors can interfere with buying or selling at desired prices.

This is where algorithmic trading comes in — it can account for many of the timing, risk, and transaction costs issues more easily than a human trader and let you capture more of the risk-free spread. Some benefits of letting a computer execute your strategies are:

  • Cost: Algorithms can automatically help determine when it’s most cost-effective to enter the market, saving you money.
  • Speed: If you want to buy or sell at a particular price, it’s much faster for a computer to automatically enter a market or limit order than to do it manually. This is crucial when crypto is prone to large movements based on breaking news and events.
  • Accuracy: It’s easy for human beings to make mistakes when placing orders — much less so for computers.
  • Time: If you’re running an algorithm, you don’t have to stay glued to your screen. You can program your strategy, let it run, and spend that time researching even better approaches. Plus, you can even trade while you sleep!
  • Discipline: Anyone can get caught up in the highs and lows of trading, even the best fund managers. It’s difficult for your emotions to override logic when you’re following computerized rules.

To learn more about arbitrage and algorithmic trading, check out our Algo Trading 101 series.

The Ocean / Binance arbitrage code by mindfullynumb

Of course, this isn’t to say that arbitrage is impossible without knowing how to program! Arbitrage is a rabbit-hole of complexity in itself, and we’ve only scratched the surfaced. Experimenting manually is oftentimes the first step to more sophisticated methods, and we encourage you to do your own research and actively learn. Until next time!

Additional resources

__________________________

If you have any questions or comments, join our community of traders on Discord. We’d be more than happy to help.

Follow us on Twitter at @TheOceanTrade or subscribe to our newsletter to stay in the loop.


The information contained in this document is not (and should not be construed as) investment advice or a solicitation. The information is not necessarily verified nor is it provided under any sort of warranty, including as to completeness or accuracy. The information is subject to change without notice. The Ocean is not a licensed financial advisor. Trading virtual currencies or digital assets is volatile and risky: recipients of this information should do their own due diligence, considering their specific financial circumstances, investment objectives, capabilities, and risk tolerance, before taking any action. Pursuant to The Ocean’s internal policies, individuals who contribute to this information may have positions in digital assets, including those discussed herein. Any comments or statements made in this communication do not necessarily reflect the views of The Ocean or its affiliates. This information does not constitute an offer to buy or sell any of the assets referenced herein.

The Ocean

The Ocean is a high performance 0x-based Ethereum ERC20 token trading platform. | theocean.trade

The Ocean

Written by

The Ocean

The Ocean is a high performance 0x-based Ethereum ERC20 token trading platform. Sign up for launch news: www.theocean.trade

The Ocean

The Ocean

The Ocean is a high performance 0x-based Ethereum ERC20 token trading platform. | theocean.trade

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade