Research on Binance Futures Multi-currency Hedging Strategy Part 1

Author: 善, Created: 2020-05-09 11:14:50, Updated: 2020-05-09 11:52:03

Research on Binance Futures Multi-currency Hedging Strategy Part 1

Click the research button on the Dashboard page, and then click the arrow to enter. Open the uploaded .pynb suffix file and press shift + enter to run line by line. There are basic tutorials in the usage help of the research environment.

Strategy reasons

Binance has listed many altcoins on the spot. Although the short-term fluctuations are uncertain, if you look at the daily line for a long time, you will find that they have basically fallen by more than 90%, and some even only have fractions of the highest price fraction. However, there is no universal short selling method for the spot, and there is no special recommendation except for not touching the altcoin. In the past two months, Binance Futures has launched more than 20 perpetual contracts, most of which are mainstream currencies, and some are unknown. This gives us the means to short these altcoin combinations. Using the correlation coefficient between altcoins and BTC will be a effective analysis method, two strategies can be designed.

Strategy principles

The first strategy: Selling short the selected basket of altcoins in a decentralized equivalent, and at the same time buy long the same amount of position BTC to hedge, in order to reduce risks and volatility. As prices fluctuate, constantly adjust positions to keep short positions values ​​constant and equal to long positions. Essentially it is a operation that selling short the altcoin-bitcoin price index.

The second strategy: shorting currencies with a price higher than the altcoin-bitcoin price index, and longing with currencies lower than the index, the greater the deviation, the greater the position. At the same time, hedging unhedged positions with BTC (or not).

First, let ’s study the price movement of altcoins to Bitcoin in the past year. I have downloaded the data in advance and posted it to the forum, which can be directly cited in the research environment.

First draw the prices of these currencies to see the trend, the data should be normalized. It can be seen that except for four currencies, the price trends of the other currencies are basically the same, showing a downward trend.

By sorting the last price changes, you can find several coins that are obviously different, namely LINK, XTZ, BCH, ETH. Explain that they can often running their own trend, and shorting them has a higher risk and needs to be excluded from the strategy.

Draw a heat map of the correlation coefficient of the remaining currencies, and find that the trend of ETC and ATOM is also relatively special and can be excluded.

The last remaining currency fell by an average of 66% a year, obviously there is ample room for shorting. Synthesizing the trend of these coins into the altcoin price index, it was found that it basically fell all the way, it was more stable in the second half of last year, and began to fall all the way this year. This study screened out ‘LINK’, ‘XTZ’, ‘BCH’, ‘ETH’, ‘ETC’, ‘ATOM’, ‘BNB’, ‘EOS’, ‘LTC’ did not participate in the short of the first strategy, specific details can be backtest by yourself.

It should be noted that the current altcoin index is at the low point of the past year. Perhaps it is not a short opportunity, rather a buying long opportunity. you have to decide it by yourself.

trade_symbols = list(set(symbols)-set(['LINK','XTZ','BCH', 'ETH', 'ETC','ATOM','BNB','EOS','LTC'])) # You can set the remaining currencies, which you want to subtract.
1-price_btc_norm[trade_symbols].iloc[-1,].mean()

Binance Sustainability Data

Similarly, the data on Binance Sustainability has been collated, you can also directly quote it in your notebook, the data is the 1h market K line from January 28 to March 31, 2020, because most of Binance perpetual contract have been lunched only two months, so the data is sufficient for backtest.

First look at the overall trend with normalized data. In the March plunge, relative to the price in early February, the price was generally cut, showing that the risk of perpetual contract is also very high. This wave of decline is also a big challenge test for the strategy.

Backtest engine

Because the FMZ local backtest does not have data for all currencies and does not support multi-currency backtest, it is necessary to reimplement a backtest engine. So i wrote a new backtest engine, it is relatively simple, but basically enough. Taking into account the transaction fee, but basically ignored the capital rate, did not consider the situation of maintaining the margin capital. The total equity, occupied margin, and leverage were recorded. Since this strategy has the attribute that long position equals short position, so the impact of capital rates is not significant.

The backtest does not take into account the price slippage situation, you can increase the transaction fee simulation by yourself, considering the low transaction fee of Binance maker, even the price gap difference in the unpopular currency market is very small, you can use the iceberg commission method in the real market when placing an order, the impact should not be significant.

When creating an exchange object, you need to specify the currency to be traded. Buy is long and Sell is short. Due to the perpetual contract limitation, when opening position, the long and short positions are automatically closed together. When selling short position and the number of currencies are negative. The parameters are as follows:

The first strategy code

Strategy logic:

Check the currency price, if not “nan”, you can trade

Check the value of the altcoin contract. If it is less than the target value trade_value, the corresponding difference will be short sold, and if it is greater, the corresponding amount will be bought to close the position.

Add the short value of all altcoins and adjust the BTC position to hedge against it.

The short trade_value position determines the size of the position. Setting log = True will print the transaction log

The yellow in the net worth curve is the effect of 1x leverage shorting the altcoin index. It can be seen that the strategy basically amplifies the fluctuation of the index, which is in line with expectations. The final two-month return is 60%, the maximum retracement is 20%, and the maximum leverage is about 8 times. Most of the time, it is less than 6 times. It is still safe. Most importantly, complete hedging has made the strategy lose little in the March 12th plunge.

When the short-selling currency price rises and the contract value increases, the position is reduced, on the other hand, when gaining profit, the position is increased. This keeps the total value of the contract constant, even if the skyrocketing falls have limited losses.

But the risks were also mentioned earlier, altcoins are very likely to run their own trend, and may rise a lot from the bottom. It depends on how to use it. If you are optimistic about the altcoin and think that it has reached the bottom, you can operate in the direction and buying long this index. Or if you are optimistic about certain currencies, you can hedge with them.

The return of the second strategy is much better than the first strategy. In the past two months, it has 100% return, but still has a 20% retracement. In the past week, due to the small market fluctuations, the return is not obvious. The overall leverage is not much. This strategy is worth trying. Depending on the degree of deviation, more than 7800 USDT position was opened at most.

Note that if a currency runs out a independent trend, for example, it has increased several times relative to the index, it will accumulate a large number of short positions in the currency, and the same sharp decline will also make the strategy to buy long, which can limit the maximum opening position.

Summary and Risk

The first strategy takes advantage of the fact that the overall value of altcoins is not as good as bitcoin. If you buying long bitcoins, you may wish to stick to this strategy for a long time. Due to the long and short positions equivalence, you are basically not afraid of the funding rate of 8h. In the long run, the winning rate is relatively high. But I also worry that the altcoin is currently at the bottom, and it may runs out of a rising trend and cause a loss of this strategy.

The second strategy uses the altcoin’s price regression feature, which rises more than the index and has a high probability of falling back. However, it may accumulate too many positions in a single currency. If a certain currency really does not fall back, it will cause a large loss.

Due to the different start-up time of the strategy and the specific parameters, the impact of people who use this strategy for a long time should not be great.

In short, there is no perfect strategy, only a correct attitude to the strategy, it ultimately depends on the user’s understanding of risks and judgment of the future.