• The title of this article refers to the Bronze Age: The Confusion of Satoshi Nakamoto
  • This article does not represent the views of any of the organizations I work for
  • This article does not offer any trading advice
  • This article is completely true on a technical level

I have been working on cryptocurrency quantitative trading for the last year, but it finally came to an end recently. Due to various reasons, I will retire from this field. I wanted to write a nuggets book before this accumulation, but there was no feedback from the Nuggets, so I just wrote it. Here I’d like to show you how to write a quantitative arbitrage strategy in Python with an annual return of 50%.

introduce

Colloquially speaking, quantitative trading is the use of programming language to achieve automatic buying and selling profits. At present, the common strategies are market making, high frequency, trend, arbitrage, grid, etc., each has its own advantages, this paper only introduces arbitrage. Arbitrage strategy itself is also a strategy with very low risk, which can be understood as the reverse operation of the short-term unreasonable pricing behavior of the market for profit.

In the article “Bronze Age: Satoshi Nakamoto’s Confusion”, it is no longer feasible to carry the brick arbitrage. After the large-scale entry of institutions, it is more and more difficult for individual quantitative traders, but there is still room for arbitrage at present. We open the website www.okex.com/spot/trade#… www.okex.com/future/trad… It can be seen that the price of BTC/USDT is 10887, and the quarterly contract price of BTC/USD is 11085, so there is a price difference of 200USD. Why did this happen? Because of the leverage multiple between spot and contract, spot is up to 5 times leveraged, while contract is 20-100 times. This results in the upcycle contract price being higher than the spot price and the downcycle contract price being lower than the spot price. It’s all leverage. Ideally, the contract price would be equal to the spot price, but the market is always volatile, so the arbitrage strategy is to make money from the spot contract being mispriced.

The principle of

If we define the spread as diFF = the contract price minus the spot price, then two things will happen.

  1. diff > 0
  2. diff < 0

When diFF > 0, it indicates that the contract is at a premium, pricing is not reasonable, short the contract, long the spot. When diFF < 0, it indicates that the contract is at a discount, pricing is not reasonable, long contracts, short spot.

The specific principle is: assuming the current contract price of 10000, spot price of 9400, DIFF = 600, the pricing is not reasonable, we short the contract, do long spot. So if I priced it right, diff would be zero, so if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, if I priced it right, I priced it right. So that’s 6%.

Does the opportunity really exist?

I wrote a monitoring robot that tracked the 2019 spread from a minimum of -3% to a maximum of 5% (based on the daily closing price), and combined with the fluctuation in the middle, it actually accumulated more than 20%, where the gains were generated.

The actual situation

Pseudo code

Initialize the client
spot = spotClient()
future = futureClient()
# Current price and spread in acquisition period
spot_price = spot.get_price()
future_price = future.get_price()
diff_price = future_price - spot_price

# Explain contract premium, short contract, long spot
if diff_price > 0:
    future.sell(future_price, 1)
    spot.buy(spot_price, 1)
# Explain the contract discount, long contracts, short spot
if diff_price < 0:
    future.buy(future_price, 1)
    spot.sell(spot_price, 1)
Copy the code

In practice, contracts can be leveraged multiple times, but cash cannot, resulting in low capital utilization. In fact, on Okex, Huobi and Binance, you can short or long cash by borrowing money. That is, high utilization rate can be achieved.

Fluctuation or regression

The spread curve is unordered and the risk can be reduced through grid linear opening. Grid opening is necessary because it is impossible to predict the limit of the spread.

But how to unwind? Do you wait for full regression, or do you flatten out the specified value every time you converge? I personally prefer the latter, to profit from the spread.

feeling

As cryptocurrency quant trading leaves less room for individual participation, head players are starting to drive the regular quanters with their financial advantages, low fees, and low latency. Strategies like the leek harvester are gone. Have fun in this highly speculative market.