Education

Crypto Arbitrage Trading & Bitcoin Arbitrage Bots

, July 18, 2022

Crypto arbitrage bots are computer programs that simultaneously buy and sell the same cryptocurrency on two different exchanges to gain a profit off the exchange rate difference. Usually, an equal cryptocurrency amount is used on both transactions. 

As an example, Bitcoin can be traded for $20,000 at one exchange and traded at $20,600 at another exchange. A crypto arbitrage bot can return you a riskless 3% profit minus the trading fees.   

Price gaps among exchanges can be closed in as little as a few seconds (especially for large cryptocurrencies) so a crypto arbitrage bot has to execute the two transactions at the same time without sending coins from one exchange account to the other.

Crypto and Bitcoin arbitrage bots need to connect to cryptocurrency exchanges via an application programming interface (API). You can connect arbitrage bots to the CEX.IO exchange by using a crypto trading API.

CEX.IO APIs allow you to receive real-time price feeds for over 200 different cryptocurrency trading pairs, subscribe to order books, and view your trade history.

What is a crypto arbitrage bot? 

A cryptocurrency arbitrage bot consists of a set of commands which continuously scans prices on different exchanges and automatically takes action whenever there is a price gap on two or more exchanges for the same cryptocurrency trading pair.

Purpose of arbitrage bots

The goal is to buy cryptocurrency on the cheaper exchange and sell it on the expensive one for a profit. To achieve that, a crypto arbitrage bot typically short-sells the cryptocurrency on the more expensive exchange and buys the same amount on the cheaper one. 

The two transactions are opened and closed simultaneously in order not to carry any position risks.   

Cryptocurrencies have some of the biggest volatility among all asset classes where it is common to see prices surge or drop by as much as 50% on a single day. This usually makes it impossible for traders to manually place or cancel their orders.

 

crypto_volatility

Making use of exchange liquidity differences

Exchanges may react slower or faster to sudden price movements due to their liquidity differences, especially during volatile days. For example, prices can drop more abruptly on less liquid exchanges due to fewer outstanding market orders. 

On the other hand, it could take the price longer on larger exchanges to drop to the same level as there are more orders to be filled on the way down. Find out how CEX.IO ensures high-liquid markets in this blog post.       

Differences in exchange trading fees can also present arbitrage opportunities even if the asset price is uniform across the exchanges. That way, a crypto arbitrage bot would profit from the spread between the buying and selling fees across the exchanges.   

How does a crypto arbitrage bot work?

As price gaps usually appear for a very short time, buying cryptocurrency on one exchange and transferring it to the other will likely take too long to realize the arbitrage opportunity. Due to this, assets are not transferred in between exchanges. Instead, a short-sell position and a buy position are opened and closed at the same time. 

To execute these transactions simultaneously, you must have an available balance at both exchanges in the quote currency of the trading pair that you would like to arbitrage trade.

For example, if you want to make a Bitcoin trading arbitrage, you must have available fiat currency (USD) at both exchanges so that you can short-sell BTC with your USD balance at one exchange and buy BTC with your USD balance at the other exchange. BTC to USD is the most commonly traded arbitrage pair in the crypto market. 

 

Define conditions and formulas 

To execute arbitrage transactions, you need to input the necessary conditions and formulas into the cryptocurrency arbitrage software. Once activated, it will continuously scan the exchanges and the cryptocurrency trading pairs you identified in your algorithms. Whenever a condition defined in your formulas is met on the exchanges, the arbitrage bot will execute the trades.  

Crypto arbitrage bots can be programmed in many different languages including JavaScript, Node.js, Python, C#, and Java programming languages.

As price gaps may close very quickly, especially for large crypto assets, you may define thresholds for the price differences as conditions for your bot to take action. The logic is significantly large deviations may take longer to be closed so it would be safer for the arbitrage bot to execute the buy and sell transactions in that case. 

Otherwise, the bot may not generate a meaningful profit when chasing minuscule price gaps. It could even turn into a loss because of the trade fees it accumulates when opening and closing positions.  

Traders can typically find bigger price spreads among less-popular cryptocurrencies that have smaller trading volumes as these currencies would be less liquid with more drastic gaps in their order books. 

On the downside, smaller cryptocurrencies are much more speculative and thus subject to very violent price moves. Due to this, an arbitrage bot can end up with substantial losses while trying to take advantage of the exchange price differences for small cryptocurrencies. 

Connecting to cryptocurrency exchanges

Two other critical ingredients for operating crypto arbitrage bots are live data feeding and real-time connectivity to cryptocurrency exchanges. 

A crypto arbitrage bot needs to be constantly fed with both real-time and historical data as input. Real-time data includes price information and exchange order books while historical data includes past transactions as well as your trade history and account balances.

Connection to crypto exchanges (for feeding data and executing transactions) can be established via a crypto trading API.

CEX.IO provides the two most commonly used APIs in the industry – WebSocket API and REST API. Using these two APIs, you can connect crypto arbitrage bots to the CEX.IO exchange and let them simultaneously execute trades on multiple markets and trading pairs.

cex_io_api_solutions

With the WebSocket API, you can directly subscribe to order books on the exchange, receive live market data about outstanding buy and sell orders, and place market and limit trade orders. 

This means you can buy Bitcoin with a credit card or buy Ethereum on CEX.IO by connecting your arbitrage bot via the WebSocket API channel.

With the REST API, you can receive real-time price feeds for over 200 different cryptocurrency trading pairs and historical data about past transactions, as well as access your trade history and account balances. 

CEX.IO offers over 200 cryptocurrency trading pairs with a 0% maker fee if you can manage to generate a volume of $10 million per month. 

For a complete and detailed breakdown of the trading fee schedule at CEX.IO, including deposit and withdrawal fees, please visit this link – https://cex.io/fee-schedule 

Arbitrage types in cryptocurrencies

The most common arbitrage opportunities in cryptocurrency exchanges include spot arbitrage, triangular arbitrage, and cash and carry arbitrage.  

Spot arbitrage

This is the classic arbitrage type that we have been discussing so far. You buy a cryptocurrency from one exchange and sell it for higher on another exchange.

As discussed, there are no asset transfers between exchanges in this type of arbitrage trading instead, there are at least two separate and simultaneous transactions. 

High volatility conditions may present more profitable spot arbitrage opportunities but they also bring higher short-term price fluctuations which can more than offset your arbitrage profits if you momentarily get stuck in the opposite position. 

Triangular arbitrage

Triangular arbitrage takes advantage of pricing inefficiencies between three different cryptocurrency trading pairs on the same exchange

For example, on a cryptocurrency exchange, the ratio between the Bitcoin (BTC/USD) and Ethereum (ETH/USD) spot prices may be higher compared to the BTC/ETH parity price. This gives you a quick arbitrage opportunity to buy the BTC/ETH parity with an Ethereum balance (quote currency) and then sell the Bitcoin proceeds to fiat currency for a profit.  

On the other hand, there can often be a discrepancy between an altcoin’s US Dollar trading pair and its BTC trading pair. As an example, while the altcoin’s dollar price increases, its BTC parity price may lag (assuming the BTC/USD price is pretty much stable in the meantime). This gives you a triangular arbitrage opportunity to buy that altcoin with the cheaper BTC trading pair (by keeping a BTC balance) and then sell it for US dollars with a profit. 

You can use CEX.IO’s Bitcoin calculator to quickly determine whether a cryptocurrency’s BTC trading pair is relatively cheap compared to its US Dollar price.

The rule of thumb in triangular arbitrage trading is that a trader starts with one cryptocurrency (quote currency), buys the cheaper crypto-to-crypto parity to get the other cryptocurrency (base currency), and then sells the proceeds to fiat currency with a profit. So like spot arbitrage, triangular arbitrage also involves dual transactions.  

Cash and carry arbitrage

Cash and carry arbitrage is a form of financial arbitrage wherein a trader buys a cryptocurrency in the spot market and then short-sells the future contract of that asset. This type of arbitrage takes place when the future contract price of a crypto asset is higher than the spot price.

What is the best crypto arbitrage bot?

Speed is the utmost critical factor in arbitrage trading as the opportunity window can usually be quite narrow. Therefore, when choosing an arbitrage robot, you need to look for one that provides some of the highest code processing capacities per second.

Besides the capabilities of crypto arbitrage bots, exchanges that these bots transact with will also impact your profitability. Some of these exchange-related factors include

  • Orderbook liquidity
  • Trading fees
  • API latency in receiving commands from your bot
  • Average transaction execution time
  • Withdrawal fees from your exchange account

HaasOnline, one of the oldest and most reputable bot platforms in the industry, offers some of the most popular and advanced arbitrage robots.  

HaasOnline 

HaasOnline is widely preferred by Bitcoin arbitrage traders and provides API connectivity for 24 different exchanges including CEX.IO.

Unlike most other offerings, HaasOnline keeps all your data and codes private.  

You can configure HaasOnline’s crypto arbitrage bots to continuously monitor the price of two cryptocurrency trading pairs on two different exchanges. When an arbitrage bot identifies an opportunity to sell high on one exchange and buy lower on the other, it executes both orders at the same time.

On the downside, there is no available market screener function on HaasOnline for the arbitrage bots to concurrently screen multiple cryptocurrency trading pairs on multiple exchanges and automatically execute trades when there is a spread discrepancy. 

You can check HaasOnline’s crypto arbitrage website for more detailed information.

How to connect a crypto arbitrage bot with API

To connect an arbitrage bot to an exchange via API, you need to generate an API key on your cryptocurrency exchange account. It is very simple to generate API keys on CEX.IO. Just follow these four simple steps to get your key and activate your API: 

1. Scroll to the Profile symbol on the top right corner of your CEX.IO account homepage and click on API in the dropdown menu.

2. On the next page, select the functions and data streams you want to import – place order, cancel order, account balance, open orders. Once you are done selecting, click on the Generate Key button.

3. Clicking the Generate Key button generates your API key. You will see on the table below the button, a Key and a Secret. You need those codes to connect your trading bot to the CEX.IO exchange.

4. Finally, click on the Activate button on the right side and finish the API setup process for your account.

activation_api

The specific algorithms you need to connect to the CEX.IO REST API and WebSocket API channels can be found at this link – CEX.IO/CEX-API

You can either copy and paste the relevant algorithms directly to your bot application, if you have NodeJS, or adapt them accordingly to your programming language. 

Additionally, CEX.IO has a Github repository, where you can access all the API instructions developed in different programming languages to date. These include integrations to your trading bot in Python, Node.js, Java, and C# languages.  

Use arbitrage bots to profit from price gaps

Due to the high volatility in cryptocurrencies, arbitrage opportunities happen frequently since large volatility also creates considerable discrepancies in exchange order book liquidities.  

In the earlier days of cryptocurrency when order book sizes and trading volumes were less than even one-tenth of their present figures, you could manually transfer funds from one exchange to another before the price gap eventually closed. 

Since then hundreds of millions of investors have joined the space and made the exchange order books much thicker. Exchange technologies have also developed dramatically in the meantime in terms of instantaneous data feeding. 

These developments have significantly reduced the lifespan of arbitrage opportunities as price gaps can now close in as little as a few seconds. Due to this, you will likely need a crypto arbitrage bot to take advantage of the price discrepancies. 

A crypto arbitrage bot can realize arbitrage opportunities without sending coins from one exchange account to the other. Instead, it executes two transactions on two different exchanges by short-selling a crypto asset on the more expensive exchange and buying the same amount on the cheaper one simultaneously.

As timing is quite sensitive in the execution of transactions, the processing capacity of arbitrage bots is very critical for profitable arbitrage trading. Besides that, exchange trading fees, order book liquidities, API latency, and average transaction settlement time will also impact your arbitrage profitability. 

The key is to not lose your potential profits to operational latencies and high trading fees.

Disclaimer: Information provided by CEX.IO is not intended to be, nor should it be construed as financial, tax or legal advice. The risk of loss in trading or holding digital assets can be substantial. You should carefully consider whether interacting with, holding, or trading digital assets is suitable for you in light of the risk involved and your financial condition. You should take into consideration your level of experience and seek independent advice if necessary regarding your specific circumstances. CEX.IO is not engaged in the offer, sale, or trading of securities. Please refer to the Terms of Use for more details.

Related

Education

3 Key Events in the DeFi Ecosystem That Continue to Unfold in 2022

We triangulated the top three events that contributed to the DeFi ecosystem’s shakeup. Find out about Q2’s defining moments and what may lie ahead.

Aug 23, 2022 | 15 min read
CEX.IO News Education

What is a Coinbase Transaction?

All transactions on the bitcoin network are not created equally. A coinbase transaction is a unique type of bitcoin transaction that can only be created by a miner. This type of transaction has no inputs, and there is one created with each new block that is mined on the

Oct 29, 2014 | 3 min read
CEX.IO News Education

Is Bitcoin Secure?

One of the main issues that has been holding back mass adoption of Bitcoin as a payment system and currency is the notion that it is not secure. There have been plenty of hacks and frauds in the Bitcoin ecosystem, so people who are unsure of the digital currency

Jun 13, 2015 | 5 min read