Lately, lots of posts have been talking about how traders get rich from arbitrage opportunities in the crypto market. I have been trying to do arbitrage for months, but I could never obtain a profitable strategy. Therefore, I will tell you here the problems I found while attempting to do it. This might be helpful for those who are starting with it, so they dont have to travel through the same painful path. Summarizing, here is what I found:
Most of the arbitrage opportunities disappear after considering exchange fees and transaction commissions.
Most of the arbitrage opportunities appear between exchanges where wallets are on maintenance, which makes deposits and withdrawals impossible.
Transaction times between exchanges cause arbitrage to become a lottery due to market volatility.
Keep reading to find out how to build an arbitrage monitor from scratch with python and related useful information.
Arbitrage(bydefinition) is the practice of taking advantage of a price difference between two or more markets. For example, if you find that stocks from some company are traded at a lower price in one market than in others, then you can buy those stocks at that market and sell them in the other markets at a higher price, thus making a profit from the price difference. Simple. Unfortunately, too simple.
This simplicity gives many traders the opportunity to take advantage of the situation; this increases the demand of the stocks in markets where prices are lower and, at the same time, increases the offer in markets with higher prices. Hence, they unintentionally stabilize price inequality, which decreases opportunities. Besides, the more traders a market has, the more efficiently they work to stabilize the prices. In fact, finance models assume an arbitrage-freecondition, which implies that, in efficient markets, there are no arbitrage opportunities right there waiting for you.
But, lets be honest, crypto assets markets are relatively green. New exchanges with low trading volumes appear constantly. This market is far from being efficient.
There are many tools that can help you find an arbitrage opportunity. Lets start with the simplest: websites that monitor these opportunities (for example,this). The problem with these websites is that you cant control which exchanges and which assets you monitor. And, in practice, this is definitely something you need to do, because in order to take an advantage of an opportunity, you have to have your investment assets in the right moment, in the right exchange.
So, lets build our own monitor from scratch.It will look for the opportunities that we really care for. To do this, we will use theccxtPython library, which allows us to connect to several exchanges (currently 115) and trade cryptos in an standarized way (ccxt developers, you have really done a great job). We are going to use this library to requestask/bidprices for different assets in different exchanges, compare them and think about an arbitrage strategy.
Now lets get started. First of all, import the libraries:
We are going to usenumpylater on to make computations. Now, lets define some exchanges:
exchanges = [Allcoin, Binance, Bitfinex, Bittrex, Cex, Cryptopia, Exmo, Gatecoin, Hitbtc, Huobipro, Kraken, Kucoin, Livecoin, Okex, Poloniex, Qryptos, Quadrigacx, Southxchange, Yobit]
Withexchangesdefined, we can now initialize the corresponding clients to request data from them. You can define them like this:
Or better, you can do this and avoid writing a lot:
Soclientsis a list containing all the clients we need. Now, lets define some pairs of interest:
symbols = [ADA/BTC, BCH/BTC, BTG/BTC, BTS/BTC, CLAIM/BTC, DASH/BTC, DOGE/BTC, EDO/BTC, EOS/BTC, ETC/BTC,ETH/BTC, FCT/BTC, ICX/BTC, IOTA/BTC, LSK/BTC, LTC/BTC, MAID/BTC, NEO/BTC, OMG/BTC, QTUM/BTC, STR/BTC, TRX/BTC,VEN/BTC, XEM/BTC, XLM/BTC, XMR/BTC, XRP/BTC, ZEC/BTC]
You can modify the previous variables with your preferred choices. Then we define some useful variables:
Finally, request the data from the clients. We are going to use thefetch_order_bookfunction in each client, which returns the full order book, but we are only going to care about thebidandaskvalues at the top (this is a first approach, we could explore better options computing the mean value of our trading investment).
Assuming you have not modified theexchangeslist, the following lines could take a while. To speed them up, go back and define less clients.
for row, symbol in enumerate(symbols): for col, client in enumerate(clients): try: book = client.fetch_order_book(symbol) ask[row, col] = book[asks] bid[row, col] = book[bids] except: pass
Ive defined the request inside atryblock because some symbols are not traded in all exchanges, and bad requests raise errors, which are bothersome. Another source of error could berate request limits, which we are just passing now. We can also implement a delay to decrease the request rate for each exchange. That delay should be adjusted depending on which exchanges we are connecting to, because each one has its own limit. To dig deeper into it you can check out each exchanges documentation later. Ive also defined theaskandbidndarraysinside thetryblock because some requests could return empty arrays, and for now we are trying to avoid dealing with this.
In a more efficient approach, we dont want to wait until the whole loop finishes to look for an arbitrage opportunity, but for now, well leave it as it is and continue exploring the data to further understand what our best options could be.
Having defined thebidandaskvalues for each coin in each exchange, we can now define our strategy and compute the profits and losses. Our strategy to trade coin C between exchangesE1andE2implies buyingCatE1, transferring C coins toE2and selling them there. We want to perform all these steps as quickly as we can because we dont want somebody taking advantage of us, so we are going to execute each trade immediately, where immediately means buying at the lowest price somebody is willing to sell, i.e. lowestaskvalue, and selling at the highest price somebody is willing to buy, i.e. highestbidvalue. So, lets define the steps:
In practice, you should also pay for fees in exchanges. SoROIshould be better defined as:
Then, lets define afeevariable to computeROIthis way. We can define an array or a dictionary of fees for each exchange, but right now, for the sake of simplicity, we are just going to define a general (conservative) percentage fee:
Finally, we should also discount the transaction commission. But for now we are going to proceed without taking this into account, because commissions depend on coins and network loads, and were not going to bother with that right now.
Lets compute this, and count how many profitable opportunities weve found:
opportunities =  for i, symbol in enumerate(symbols): for j1, exchange1 in enumerate(exchanges): for j2, exchange2 in enumerate(exchanges): roi = 0 if j1 != j2 and ask[i, j1]0: roi = ((bid[i, j2]*(1-fee/100)) / (ask[i, j1]*(1+fee/100)) – 1) * 100 if roi0: opportunities.append([symbol, exchange1, ask[i, j1], exchange2, bid[i, j2], round(roi,2)]) print(Number of profitable opportunities:, len(opportunities))
We have found 108 opportunities! Promising, isnt it? Lets sort them by origin and take a look at the best ones:
At the time of writing this article the best option is to buyQTUM/BTCatBitfinexand sell it atQryptos. For eachQTUM/BTCtraded, we could get a ROI of 75.45%.
Now that weve found some opportunities, we can start arbitraging. The first opportunities weve found all have to do with buying someQTUMat certain exchanges and sellng them atQryptos. The return of that arbitrage is something about 75%. 75%!! Were going to be trading all day. Were going to became rich. So easy.
Just for curiositys sake, lets search qryptos+qtum+deposit on Google to see if everything is going to be this easy when we try to deposit ourQTUMcoins there. I found:
It seems like not everything is going so well. Lets look at thethird link: FAQQryptosexplaining why out wallet is not going to be compatible with theQTUMtokens that we bought there.
So lets not waste our time here, we have 101 more possibilities. Lets take the next one. We can buy someBTGcoins atYobitand sell them onCex. Wait a moment the two opportunities after this one also imply sellingBTGcoins bought atYobit. This is suspicious.
I open myYobitaccount and I try to withdraw someBTGto see if everything works fine. When I click on thewithdrawlbutton, I find this notification:
Wallet Status: Maintenance. OK, we are not going anywhere around here. Lets look for another choices.
Another interesting opportunity on the list: buy someBCHcoins onBinanceand sell them onYobit. This time with less profit, something like aROIof 4%. So this one could be real. First of all, we need some availableBTCinBinancein order to buy there. If we fortunately have them, we are starting with the right foot. Otherwise, start praying for ourBTCto arrive before the opportunity disappears.
Fortunately, I have someBTCinBinance, so I buy 1BCHthere and then I look for myBCHaddress on myYobitaccount in order to send my new coins there. When I click on the deposit button, I find this notification:
Guess what? Wallet is on maintenance. We can see this when we try to withdraw some coins, which gives us this notification:
And nothing happens. Nothing in 5 minutes, 10 minutes or 30 minutes. Even if I had had a previousBCHaddress, deposits would have a significant delay (trust me, this is not my first time doing this). So, I have no other choice than to keep myBCH. Anyway,buy and holdhas always been a good trading strategy in crypto markets, at least until the last quarter of 2017.
So, lets try with another option in our list with a similarROI. The last one,BTGfromHuobitoCex. What happens when I try to withdrawBTGfromHuobi? Another wallet on maintenance. This time there are not warnings, but deposit and withdraw are just disabled.
Ive been trying to find a profitable arbitrage approach for months. And Im not going to lie, Ive never found it. There were some opportunities, but I could never find a consistent way to spot them with just a bot monitor, and without checking each wallet on each exchange on my own. Aside from the fact that a lot of opportunities are discarded right at the beginning due to not being profitable (on account of exchange fees and transference commissions), we have to deal with wallet maintenance.
And you are lucky if your exchange even warns you about that maintenance. Some exchanges dont do it at all. For example, I once tried an arbitrage betweenExmoand some other exchange. I waited for myBTCdeposit onExmofor 2 hours until I wrote to them. 3 hours later, they answered me:
Finally, myBTCtook 2 more days to be deposited. So you never know if everything is going to be as planned when your transfer crypto assets.
And even when you find an arbitrage opportunity between exchanges where everything works fine, you have to deal with transfer time. Most exchanges dont allow you to trade cryptos until theyve been through a good number of confirmations. This almost always takes several dozen minutes. And if you expect prices to remain stable after that time, you have probably never traded cryptos before. When the arbitrage profit is about 2% (yes, dont expect to find a better opportunity without a wallet under maintenance), and, after exchange fees and transaction commissions, goes down to about 1.5%, or even lower, expecting prices not to shift more than that amount in as little as 20 minutes is absurd. Its even crazier if you also take into account that there will be traders who are aware of that difference and will implement algorithms that take faster advantage of the situation, thus leaving you empty handed.
When you are analyzing arbitrage opportunities, always be aware of:
Time of transactions and estimated changing value in prices during this time.
Some exchanges dont allow you to withdraw your funds unless you have done the full verification.
Do some research on google about that arbitrage, to know if there is something you are missing.
Always suspect if you find an arbitrage opportunity involving fiat to crypto pairs, like
. That sounds like another good opportunity, doesnt it? Well, I have bad news for you: once you transfer your
, the only currency you can exchange them with over there is
). Only if you have a validated account and if you have a bank account in South Korea are you going to be able to withdraw your fiat money. And then, you should also think about a strategy to transfer your money from South Korea to your country.
Always, always suspect before giving away your money.
And, before I leave, Im going to try once again to deposit myBCHcoins onYobit:
In ournext article, we are going to analyze a better way to approach arbitrage opportunities. I mean, this time for real.
If you liked this article, you might also like:
Value at Risk & Expected Shortfall of Cryptocurrencies
Emerging New Trends in Blockchain Technologies
Disclaimer: CoinFabrik does not provide financial advice. This material has been prepared for educational purposes only, and is not intended to provide, and should not be relied on for, financial advice. Consult your own financial advisors before engaging in any investment.
It is important to have an estimate of risk for a portfolio when trading with
Transactions in Bitcoin are recorded in its blockchain. This makes it possible to see whether
By Pablo Yabo and Ismael Bejarano Introduction CoinFabriks smart contract audit team was requested to
desarrollo blockchainWindows Driver Development
Cryptocup: Auditora Contrato Inteligente Token ERC721 CoinFabrik Blog
Review of AppeCoin: An Alternative Anonymous Cryptocurrency – CoinFabrik Blog
Live Updated Cryptocurrency Investment Spreadsheet (Update 3) – CoinFabrik Blog
onLive Updated Cryptocurrency Portfolio Tracking Spreadsheet (Update 2)
Blockchain: Links And Resources (192) Angel Java Lopez on Blog
onERC20 Token Development on RSK with OpenZeppelin
ERC20 Token Development on RSK with OpenZeppelin and Web3.Py Deluxe World
onERC20 Token Development on RSK with OpenZeppelin and Web3.py