Hummingbot’s Spot-Perpetual Arbitrage Strategy

July 02, 2021 | 

Hummingbot’s Spot-Perpetual Arbitrage Strategy

What is a Futures Market?

In a traditional spot market, you can choose to directly buy or sell an asset at a predetermined price level or at the best price available at that time.

When dealing in futures markets, the price of a contract is derived from an underlying asset. In a futures market, you are not trading directly for an asset but exchanging contracts that represent the expected future value of the underlying asset.

While speculators are widely active in the futures markets, it’s important to understand why they actually exist. Futures markets were created to give commodity producers an avenue to protect the value of their inventory from downward price movements.

For example, a corn producer knows that it takes about 100 days before their products can be harvested and delivered. Instead of leaving it up to chance, the farmer takes to the corn futures markets to engage with a contract that expires in the same month that the corn will be ready. This way, the farmer is not exposed to the risk of the price of corn dropping significantly in the 100 days that it takes to harvest the inventory.

The farmer may discover that the price ended up being higher when the corn was harvested and realize that some profits were left on the table. But, this is acceptable as the farmer avoided the risk of losing money on their crops in the event that the price of corn went down.

Contract Expiration

The futures market for an asset is completely separate from the spot market of that same asset. The price of a futures contract and move independently of the spot market and vice versa.

As mentioned, the futures price represents the value of the underlying asset that market participants are expecting at a given date in the future. If the market’s traders expect the underlying asset to be worth more at a later date, the futures contract will likely be trading at a higher price. Conversely, when the market thinks that an asset’s price will be lower in the future, the futures market will most often trade at a lower price.

Traditional futures contracts have an expiration date. This date determines when the contract must be executed and underlying assets are delivered. As the expiration date reduces through time, the price of a futures contract will begin converging toward the price of the spot asset.

This gap between the futures and spot price will eventually reach zero when the expiration date arrives. At that point, there is no difference between the spot and futures contract as the delivery of the asset would happen immediately. Put differently, the spread between the futures contract and spot price will continue to converge until the expiration date is raches and the spread is zero.

Perpetual Futures Contracts

A perpetual futures market is where futures contracts with no expiration date are traded. These types of non-expiring futures contracts were originally proposed by Robert Shiller in 1992. But, there was no practical use case for this type of futures contract until the emergence of bitcoin trading. By 2016, BitMEX had implemented the first perpetual futures contracts for bitcoin.

“How does the spread between the futures and spot markets converge to zero if there’s no expiration date?” you may ask yourself.

Enter funding. Funding is a process that occurs on a perpetual futures exchange. Typically, funding is executed once every 8 hours or as frequently as once per hour depending on the exchange you are using. When funding is executed, long and short traders pay each other based on the size of their position at that time.

The converge in the case of the perpetual contract occurs as the funding rates are adjusted. The rates are determined based on the difference between the spot and futures price at that time. For instance, the funding rate is positive when the perpetual price is higher than the spot price.

When funding is positive, traders with long positions pay the funding rate to those with short positions. On the other hand, the funding rate will be negative when the spot price is higher than the perpetual price. In this case, traders are expecting the future price of the asset to be lower and the short traders will have to pay the funding rate to the traders with active long positions.

The anticipated convergence is generated through the funding rate. Since perpetual contracts are traded with leverage and liquidations are sure to happen, the perpetual market pierce of an asset will be pushed closer to the spot price.

Spot-Perpetual Arbitrage Opportunities

The convergence between the spot and the perpetual futures price is key. Since we know that the spot and futures prices will most often converge towards each other, we can look at an example of how this arbitrage works without considering trading fees.

On the first day of this trade setup, the hypothetical prices are:

  • BTC-USDT perpetual price: $41,000
  • BTC spot price: $40,000

To execute the arbitrage with this setup, begin by opening a short position on the perpetual contract and buying the same BTC amount in a spot market. In this example, our position size is 1 BTC for each side of the arbitrage.

The next day, the price of these assets finally converge:

  • BTC-USDT perpetual price: $42,000
  • BTC spot price: $42,000

At this point, the two positions that were opened can be closed with a profit. The short position that was opened in the perpetual market resulted in a loss of $1,000 but the spot long position made $2,000 in profit. This arbitrage resulted in a net profit of $1,000.

Now, imagine that the price converged at $39,000 on the second day. In this case, the short position would gain $2,000 and the spot trade would lose $1,000. Here, the trade still made a profit of $1,000.

To profit with Hummingbot’s Spot-Perp Arbitrage strategy, it doesn’t matter if the price on each market goes up or down. The profit from this trade is generated by the spot and perpetual prices converging.

Getting Started with Hummingbot

Arbitraging the spread between crypto’s spot and futures markets has never been easier. Visit Hummingbot to get the free open-source platform and check out this guide to have it set up and running on Beaxy in minutes!

To get started on Beaxy, click below and complete the setup for your new trading account. Beaxy’s traders get verified in 5 minutes or less on average.
 

While you were away, new posts appeared on our blog.