Recent FMZ official charging strategy introduction
Tags: strategy, fmzquant, trading, platform
Published: 2024-05-11 01:11:43

**The strategy is risky, and investment should be cautious. The strategy provided is only for small fund attempts, no guarantee of profit**

### 1. Binance perpetual arbitrage funding rate strategy
#### Perpetual contracts and funding rates
At the earliest time, there were only delivery contracts in the digital currency contracts. Later, BitMEX introduced perpetual contracts innovatively, which were very popular and now almost all mainstream exchanges support perpetual contracts.

The further away the delivery date is, and the more volatile the price will be, the more the contract price will deviate from the spot price, but on the delivery date, it will be settled at the spot price, so the price will always return. Unlike delivery contracts with timed delivery, perpetual contracts can always be held and they require a mechanism to ensure that the contract price and the spot price are consistent, which is the funding rate mechanism. If the price is bullish for a period of time, there are many people who going long, which will result in the perpetual price higher than the spot, at this time, the funding rate is generally positive, that is, the going long side has to pay fees to the going short side according to the position, the greater the deviation of the marketis, the higher the rate will be, making the spread tends to decrease. Going long the trading perpetual contracts is equivalent to borrowing money to add leverage, and there is a cost of using the funds, so most of the time, it is a positive rate of 0.01%. The funding rate is charged every 8 hours, so the perpetual price tends to be very close to the spot.

#### Analysis of arbitrage returns
The funding rate is positive most of the time. If you go short the perpetual contract, go long the spot, and hold it for a long time, theoretically, you can obtain a positive funding rate return for a long time regardless of the increase or decrease of the currency price. Now we will analyze the feasibility in detail.

The funding rate history is provided by Binance: https://www.binance.com/cn/futures/funding-history/1
The average rates for the near-term (March 2021) currencies are:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6yhuwgxrttsowlrd8rj.png)

It can be seen that the average rate of multiple currencies is above 0.15% (due to the recent bull market, the rate is high, but it is difficult to continue). According to the latest yield, the daily yield will be 0.15% * 3=0.45%, and the annualized rate will be 164% without compound interest. Considering the spots hedging, double leverage of futures, and the loss of opening positions, premium, closing positions and other adverse factors, the annualization should be 100%. Rollback is almost negligible. In the non bull market, the annualized interest rate is about 20%.

#### Risk analysis and avoidance
- Negative rate

The lowest rate can be -0.75%. If it happens once, the loss is equivalent to 75 times the returns of 0.01% rate. Although the currency of the average rate has been filtered, it is inevitable that there will be an unexpected market. In addition to avoiding new currency and demon currency, the most important solution is decentralized hedging. If you hedge more than 30 currencies at a time, the loss of one currency will account for a small part only. In addition, in this case, it is necessary to close the position in advance, but due to the handling charges and closing position costs, it is not allowed to close the position at a negative rate. Generally, it can be avoided by closing the position at a rate below - 0.2%. Generally, when the rate is negative, the perpetual price is lower than the spot price, and the negative premium makes it possible to make profits after deducting the handling fees.

- Change in premium
Generally, a positive rate represents a premium for perpetuity on spot. If the premium is large, it may earn a certain premium return. Of course, the strategy has been holding positions for a long time, so it will not take this part of profit. Attention should be paid to not open a position against a high negative premium. Of course, in the long run, the problem of premium change can be ignored.

- Contract liquidation risk
Because of decentralized hedging, this part of the risk is much smaller. Take the perpetual leverage as an example, unless the overall price increases by 50%, there will be the possibility of liquidations. And because of the spot hedging, there will be no loss at this time. As long as the position is closed and transfer the fund, or the margin can be increased at any time. The higher the perpetual leverage is, the higher the funding utilization rate will be, and the greater the risk of contract liquidation.

- Long-term bear market
Bull market rates are mostly positive, and the average rate in many currencies exceeds 0.02%, occasionally, there is a high rate. If the market turns into a long-term bear market, the average rate will decrease, and the probability of large negative rates will increase, which will reduce returns.

#### Specific strategy ideas
1. The currency can be automatically filtered or manually specified. You can refer to the historical funding rate. Transactions can only be conducted when the threshold value is exceeded.
2. Obtain the current rate, if it exceeds the set threshold, start to place an order for hedging futures and spots at the same time to fix a certain value.
3. If the price of a single currency has increased too much, the strategy can close the position automatically to avoid excessive perpetual risk.
4. If the rate of a currency is too low, it is necessary to close the position to avoid the charged rate.
5. Since there is no requirement on the opening position speed, iceberg entrustment is used for opening and closing positions to reduce impact.

#### Summary
The overall risk of the rate arbitrage strategy is low, the capital capacity is large, so it is relatively stable, and the profit is not high. So it's suitable for low risk arbitrageurs. If there are idle funds in the exchange, you can consider running this strategy. Currently, only the Binance exchange is supported, and more exchanges will be considered in the future.

### 2. Spot grid strategy (supporting all spot exchanges)

#### Strategic principles

Reference article: https://www.fmz.com/digest-topic/5944

If one day the price of Bitcoin will be the same as it is now, what strategies will you take to gain profits? It's easy to think of a way to sell when it increases, buy when it decreases, and earn the price difference when the price returns again. How to implement it? How much do you need to sell if it increases? If you sell too early, you will lose. If you buy too early, you will earn less. The grid strategy is suitable for this situation.

The grid strategy is to buy and sell at a fixed price. You can set multiple groups of buying and selling intervals, such as 8000-8500, 8500-9000. The strategy will buy 0.1 coin at 8000 yuan, sell 0.1 coin at 8500 yuan, continue to sell 0.1 coin at 9000 yuan, and buy 0.1 coin at 8500 yuan. Note that the price of one end of the grid will only be ordered to the price of the other end after the transaction is completed at one end of the range. In this way, the strategy always buys at a low price and sells at a high price. It is also noted that the currencies bought and sold are the same. In this way, when the price returns to the initial price, the currency of the strategy remains unchanged, but the money increases.

The strategy grid is divided into isochromatic grid and proportional grid. The grid price difference of the former one is fixed. If the lower limit and upper limit of the price range are set to 10000-20000 respectively, and the number of grids is set to 5, then the price difference is (20000-10000)/(5-1)=2500. The grids are 10000-12500, 12500-15000, 15000 - 17500, 17500-20000 respectively. If the price is 14500 when the strategy starts, the buying order of 10000, 12500 and the selling order of 17500, 20000 will be placed respectively. An order at the other end of the grid will be placed when any price is closed. The lower the price of isochromatic grid orders is, the higher the profit margin will be. The profit margin of the first group of 10000-12500 is 25%, and that of the last group of 17500-20000 is 14.3%.

The principle of proportional grid is similar to that of isochromatic grid, except that each group of grids has the same profit margin and different price differentials. The lower limit and upper limit of the same price range are set to 10000-20000 respectively, the number of grids is set to 5, and the grids are 10000-11892.07, 11892.07-14142.13, 14142.13-16817.92, 16817.92-20000 respectively. So the profit margin of each group of grids is 18.9%.

The isochromatic grid calculation is simple and clear, and the proportional profit margin is consistent. In fact, the operation effect is similar. If you are interested, you can backtest and observe the difference.

#### Market and risk applicable to the strategy

The grid strategy is not a risk-free strategy. Choosing the grid represents that you think the market will remain volatile, and the price will return no matter whether it increases or decreases. If the grid strategy is abandoned, because the price increases or decreases too much, the actual loss will occur. Grid strategy is not suitable for unilateral increasing or decreasing market, and the calculation of floating profit and loss will result in temporary loss.

The grid strategy can be used not only for buying and selling repeatedly for profits in volatile markets, but also for stopping profits or adding positions. If you want to clear Bitcoin positions at above 40000, you can set the upper limit of the grid to 40000, and calculate the investment. If it increases above 40000, the grid stops running, which completes the closing position operation, and also obtains profit that fluctuates during the period. Similarly, it can be used to add positions and fish bottoms gradually.

#### Description

1. The strategy can be backtested directly. It is recommended to determine the appropriate parameters according to the service charge, trading pairs.
2. Total capital = the funds required by the buying order + the total value of currency required by the selling order.
3. The strategy needs to set the order in advance. If the fund or currency is insufficient, the strategy will prompt to buy or sell.
4. The grid strategy needs to be operated for a long time, and there will also be long-term floating losses, which cannot make steady profits.
5. The grid cannot be set too densely, and it needs to cover the service charges.
6. The lower limit and upper limit of the price range should be increased appropriately, otherwise it will be easy to exceed.

### 3. Binance perpetual contract grid strategy
#### Perpetual grid strategy principle
Trading on the USDT-based perpetual contract of Binance futures, compared with the spot grid, you can go short without holding currency, and use USDT to trade and account for the profits, which can be leveraged. Therefore, compared to the spot grid strategy, the perpetual grid is more convenient and simple, but of course, it also increases the risk of liquidation. The grid strategy does not guarantee returns and it is only suitable for oscillating markets. Binance officials also provide grid trading tools, there are not too many differences.

The principle of the specific grid strategy is the same as the spot grid, refer to the library article: https://www.fmz.com/digest-topic/5944.

The strategy requires setting two main parameters: the grid trading value and the grid spacing ratio. If the spacing ratio is set to 0.01 and the trading value is set to 500, then the trading currency price will go short 500 USDT for every 1% increase, and go long for every 1% decrease. The grid strategy needs to obtain profits relying on oscillation, if the price returns to the initial price in the future, it will cash out all the grid profit. If it's out of the independent market obviously, such as increasing 100% 1 day, the grid will have a significant floating loss, and if the trading value is too large, it will have the risk of liquidation. Also, trading pairs need to be active in order to trade frequently and increase profits.

#### Strategy risks
1. Risk of liquidation, futures have leverage, and the grid strategy is to add positions against the trend, if the position is too large, it is likely to have a liquidation;
2. API errors, if the return position delay or data errors, will lead to strategy exceptions;
3. Rate loss, this kind of risk is not large, generally, increasing is positive rate, going short will obtain rate gains.

### 4. Binance perpetual high-frequency strategy
#### Strategy principle
Refer to this article for details: https://www.fmz.com/bbs-topic/9750

Obtain the recent transaction trades, depth and current position, judge the trend according to the trades, and determine the opening amount according to the trading volume. If the trend is upward, open a long position order, and close the long position at the same time. If you hold short positions at this time, close all positions first. It is the same to judge the downward trend.

The idea of high-frequency strategy is very consistent. My strategy this time draws on the idea of high-frequency strategy in 2014 and OKCoin leeks-reaper strategy that I have disclosed previously. The source code of both strategies can be found on FMZ. If you understand both of these strategies thoroughly, high-frequency trading will be no secret to you.

- [Simple Bitcoin high-frequency strategy robot in 2014](https://www.fmz.com/strategy/1088)
- [Transplant OKCoin leek harvester](https://www.fmz.com/strategy/34388)

#### Strategic risks
There are risks when opening positions, but the advantage of high-frequency trading is that the number of transactions is very large. One loss can be quickly covered by 10 more transactions, and the withdrawal is very small when the cycle is extended. The larger the position is, the greater the risk will be. Therefore, it is not allowed to add positions indefinitely. There must be a certain negative feedback mechanism. When there are many positions, it is necessary to increase the closing position and reduce the opening position, so as to ensure that the time for holding positions is short. If there is a position, there will be a big loss if the trend is just reversed. Therefore, the strategy has designed a judgment on the direction to ensure that the position is opened on the side of the trend when the trend is big surge or big plunge, further reducing the risk at the cost of frequent small losses when the short-term trend is not clear.

The trading volume of the strategy is large, and it is very sensitive to the handling fees. It is better to have a commission account with negative handling fees, otherwise it is difficult to make profits. Of course, you can test the strategy with a small fund.

The strategy is picky about trading pairs. It needs to be active in trading. There is a price difference in the opening market. Most trading pairs are inappropriate. It can be arranged according to the increase. If the trading pair has a large increase and the transaction is frequent, the real bot test can be considered. If there is no profit, the robot needs to be closed in time to avoid losses.

From: https://blog.mathquant.com/2022/12/19/recent-fmz-official-charging-strategy-introduction.html