A Statistical Arbitrage Strategy Based on Bitcoin Price Spreads

·

Statistical arbitrage is a common strategy in quantitative trading, favored for its stability and independence from absolute price levels. This is particularly true in the digital asset market, where the absence of daily price limits and 24/7 trading often leads to significant price differences across exchanges, creating ideal conditions for programmatic trading. While traditional arbitrage is a relatively simple and low-risk strategy, this article shares a statistical arbitrage approach that, while carrying more risk, offers the potential for higher returns.

Statistical arbitrage involves using statistical analysis tools to study historical data of the price relationship between two correlated assets. The goal is to analyze the historical stability of this relationship, estimate its probability distribution, and identify extreme regions within that distribution—the rejection region. When the actual market price relationship enters this rejection region, it is assumed that the relationship is unsustainable, and the arbitrageur has a high probability of success by entering the market.

It is crucial to note that statistical arbitrage only works with stable price relationships. Those without stability carry significant risk. The stability of a price relationship directly determines whether statistical arbitrage is viable. Therefore, when performing statistical analysis on historical data, the first step is to test whether the price relationship has been stable historically.

A stable set of price relationships must be underpinned by an equilibrium maintenance mechanism. Once the price relationship deviates from its equilibrium level, this mechanism activates, pulling the relationship back to equilibrium, either quickly or slowly. Thus, analyzing whether a price relationship is stable requires first qualitatively assessing if such an equilibrium maintenance mechanism exists, and then verifying it through statistical analysis of historical data to confirm that this mechanism has indeed been effective in the past.

It's important to understand that statistical arbitrage is a risky strategy and differs from the commonly understood concept of "risk-free arbitrage."

This article analyzes the price difference between the Huobi spot market (BTC/CNY) and the OKCoin spot market (BTC/CNY). It investigates whether this price difference maintains a stable equilibrium relationship (i.e., a stationary process in stochastic terms) and concludes that the difference is indeed a stationary process. Based on this conclusion, a prototype system for statistical arbitrage on this spread is designed. The article also discusses the source code implementation, providing valuable insights for those interested in Bitcoin spread arbitrage.

Cointegration Analysis

We performed a cointegration analysis on Huobi's best bid price and OKCoin's best ask price. The resulting curve is as follows:

[Image: Chart of Huobi Best Bid vs. OKCoin Best Ask Price Relationship]

We then statistically analyzed the price spread (Huobi best bid minus OKCoin best ask). The resulting curve is as follows:

[Image: Chart of the Price Spread Time Series]

We conducted an Augmented Dickey-Fuller (ADF) test on this price spread. The results were as follows:

[Image: ADF Test Results Table]

The cointegration p-value was an extremely small number, allowing us to conclude that there is a very strong cointegration relationship between these two price series. This means a statistical arbitrage strategy can be applied to this spread.

The specific strategy is as follows: When the spread is positive and deviates from its mean by a certain threshold, we can buy Bitcoin on OKCoin (at the best ask price) and simultaneously sell an equal amount of Bitcoin on Huobi (at the best bid price). When the spread contracts close to zero, we perform a reverse trade to close the positions.

Conversely, if the spread (Huobi best bid minus OKCoin best ask) becomes negative and deviates significantly from its mean, it indicates that Huobi's price is lower than OKCoin's. In this case, we need to perform a cointegration analysis on Huobi's best ask price and OKCoin's best bid price. The resulting curve is as follows:

[Image: Chart of Huobi Best Ask vs. OKCoin Best Bid Price Relationship]

We statistically analyzed this new spread (OKCoin best bid minus Huobi best ask). The resulting curve is as follows:

[Image: Chart of the Second Price Spread Time Series]

The results of the ADF test were as follows:

[Image: ADF Test Results Table for Second Spread]

The cointegration p-value for this relationship was also extremely small, confirming a very strong cointegration relationship. Therefore, a statistical arbitrage strategy can also be applied to this spread.

Specifically, when this spread is positive and deviates from its mean by a certain threshold, we can buy Bitcoin on Huobi (at the best ask price) and simultaneously sell an equal amount of Bitcoin on OKCoin (at the best bid price). When the spread contracts close to zero, we perform a reverse trade to close the positions.

From this, a two-way spread arbitrage model emerges.

Source Code Implementation

For a practical implementation of this strategy, you can refer to the open-source code available in the WeQuant project repository. 👉 Explore the open-source strategy engine for live trading

Hedging to Mitigate Bitcoin Spot Position Risk

Executing this arbitrage strategy exposes you to the directional risk of Bitcoin's price. To hedge this risk, you can use Bitcoin perpetual swap contracts or futures contracts.

Here is a basic method for calculating the required hedge:

  1. Calculate the total market value of your Bitcoin spot holdings: This includes the total market value of all Bitcoin held on spot exchanges involved in the arbitrage (e.g., Huobi and OKCoin), calculated in your base currency (e.g., CNY).
  2. Calculate the market value of your Bitcoin margin on the futures exchange: This is the value of the collateral you have posted for your futures positions.
  3. Select a leverage multiplier on the futures platform (e.g., 5x).
  4. The goal of the hedge is to ensure that: The notional value of your short position on the futures platform (in your base currency) equals the total market value of your spot Bitcoin holdings plus the market value of your Bitcoin margin on the futures platform. This creates a market-neutral position.

The formula is:
Futures Short Position Notional Value = (Total Spot Market Value + Futures Margin Value) * Leverage Multiplier

By maintaining this hedge, the profit and loss from your spot arbitrage positions should be largely isolated from the overall price movements of Bitcoin, as losses (or gains) on the spot holdings will be offset by gains (or losses) on the short futures position.

Frequently Asked Questions

What is the main difference between traditional and statistical arbitrage?
Traditional arbitrage aims to be risk-free by exploiting price differences for the same asset at the exact same time across markets. Statistical arbitrage, however, is based on probability; it bets that a historical price relationship will reassert itself after a deviation, but this mean reversion is not guaranteed, introducing risk.

Why is cointegration analysis crucial for this strategy?
Cointegration analysis tests whether two price series move together over the long term, even if they drift apart in the short term. A significant cointegrating relationship confirms the existence of a stable equilibrium, which is the foundational assumption that the spread will eventually revert to its mean.

How do I determine the optimal threshold for entering a trade?
The entry threshold is typically based on the historical standard deviation of the spread. A common method is to enter a trade when the spread moves beyond a certain number of standard deviations (e.g., 1.5 or 2) from its historical mean. This requires backtesting to optimize for the specific asset and time period.

What are the biggest risks involved in this strategy?
The primary risk is "mean aversion," where the spread continues to widen instead of reverting, potentially causing significant losses. Other risks include exchange solvency risk, execution latency (slippage), and funding costs on futures positions used for hedging.

Can this strategy be applied to other cryptocurrencies or pairs?
Yes, the core principle of statistical arbitrage based on cointegration can be applied to any two correlated assets, such as different crypto pairs (e.g., ETH/BTC) or the same asset trading on different exchanges (e.g., BTC/USDT on Binance vs. BTC/USD on Coinbase).

Is a perfect hedge possible, and what are its limitations?
A perfect hedge is difficult to achieve due to factors like basis risk (the difference between the spot price and the futures price), funding rates on perpetual swaps, and transaction costs. The hedge must be monitored and adjusted periodically to maintain its effectiveness.

Remember, all investment carries risk. It is essential to act within your means, employ scientific methods, and prioritize risk management above all else.