Detailed Explanation of Equilibrium & Grid Strategies
Tags: startegy, trading, cryptocurrency, fmzquant
Published: 2024-06-19 09:06:34

If the price of Bitcoin is going to be the same as it is today, what strategy will you take to make profits? It is easy to think of a way to sell when the price rises, and buy when it falls, and earn the price difference in the middle when the price recovers. How to implement it? How much do you need to sell if it goes up? If you sell too early, you will obviously lose money. Similarly, if you buy too early, you will make less profit. Both the equilibrium strategy and the grid strategy are designed to solve this problem, they are also very similar, and this article will introduce these two strategies in details.

## Strategy Introduction
The principle of the equilibrium strategy is very simple. The strategy only holds a fixed proportion of a currency (we can also call it coin, and we will call it coin in the following content), such as 50%. When the value of the coin exceeds 50%, it will be sold. Otherwise, the value of the coin held will always remain around 50%. If the price of the coin keeps rising, it will continue to be sold, but always hold a certain amount of coin and it will not be sold out. If the currency price first rises and then falls back to the initial price, the currency amount and money will increase due to the selling at high prices and buying at low prices in the strategy.

The grid strategy is to buy and sell at a fixed price, in which you can set multiple trading ranges, such as 8000-8500, 8500-9000. The strategy will buy 0.1 coin at 8,000 USD, and sell 0.1 coin when the price rises to 8,500; when the price continues to rise to 9,000 USD, sell 0.1 coin; then buy 0.1 coin when it falls back to 8,500 USD. Note that only when trades are made on one side in a range, the grid will pend the price of the other side. In this way, the strategy always buys at low prices and sells at high prices, and also notice that the currencies bought and sold are the same, so that when the price returns to the initial price, the currencies in the strategy are unchanged, but the money has increased.

The two strategies perform in a very similar way, but also very different. The equilibrium strategy always has funds to buy and sell, and the grid strategy has a certain range. If the range is exceeded, you may not be able to continue to buy, or you may have sold all the coins.

## How to Measure Profit
Before evaluating the strategy, we need to formulate the criteria for profit evaluation. Most people's view of return is absolute profit, that is, profit = current total funds - initial total funds. However, under the circumstance that the currencies are initially held, this method cannot show the profits brought by the active behavior of the strategy.

For example, the initial account has a balance of 10,000 USD, with 1 coin at a price of 8,000 USD, so the total funds = 10,000+1*8000=18,000 USD. After running the strategy for a period of time, the current account has a balance of 2000 USD, 2 coins at the price of 9000 USD, so the total funds = 2000+2*9000=20000 USD, with an absolute profit=20000-18000=2000 USD. However, one coin was already held in the initial account. Even if the strategy is not run, there will eventually be a profit of 1,000 USD, so the profit brought by the strategy is only 1,000 USD. This calculation method is floating profit calculation, namely floating profit = current balance + current currency*current price - (initial balance + initial currency*current price).

Next, let's look at the backtest results of these two strategies.

## Equilibrium Staretgy Backtest
The equilibrium strategy requires two parameters, namely holding value ratio and the adjustment ratio. The holding value ratio is set to 0.5 here, that is, half of the money and half of the currencies are held all the time; the adjustment ratio is set to 0.01, that is, when the value ratio of currencies exceeds 51% due to the rise in the currency price, sell 1% of the currencies, and the same is true for a drop. The backtest time is within the past year, the backtest currency symbol is Binance trading pair BTC_USDT, and the handling fee is 0.1%.

Backtest result:

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

Profit curve:

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

As Bitcoin's price has been volatile over the past year, the strategy has earned steady profits.

## Grid Strategy Backtest
The parameters required by the grid strategy are relatively complex, and parameters, such as the upper and lower limits of the grid, the grid type, the number of grids, and the invested funds, need to be set. When the strategy is launched, the currency price is 8,000 USD. Here, the upper and lower limits of the grid are set to be plus or minus 3,000 USD. The total number of grids is 21, and all funds are invested. The parameters here are as follows:

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

Backtest result:

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

Profit curve:

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

## Comparing equilibrium & Grid
From the view of the floating profit chart, the results of the two strategies are relatively similar. In the case of long-term sideways price of Bitcoin, both have obtained stable profits, and both have experienced drawdowns at the same time. After all, the principles of these strategies are very similar, and they all sell when rise and buy when fall. Due to the different parameters, it is difficult to directly compare the two strategies. In terms of profit/trading volume, the grid strategy is 18.6 and the balance strategy is 22.7. The equilibrium strategy performs more efficiently.

However, the equilibrium strategy is relatively inflexible. In order to increase the trading volume, except more frequent adjustments, we can only increase the investment of the total funds. The grid strategy has higher requirements for settings. If you choose a small range for the upper and lower limits of price fluctuations, the funds per grid will be large, and the trading volume will be enlarged. If the price is always within the range, the profit will be very high; of course, there is a danger that the price will exceed the set range. The equilibrium strategy is that it always has funds to buy coins and always have coins to sell, which is equivalent to a grid that cannot be broken.

For novices, the equilibrium strategy is highly recommended. The operation is simple. You only need to set a parameter with ratio, and you can run it even without thinking. Those who have certain experience can choose the grid strategy, and decide the upper and lower limits of fluctuations and the funds per grid, so as to improve the funding rate and seek for the maximum return.

The equilibrium strategy can choose to balance multiple currencies at the same time, and there are many variants of the grid strategy, such as proportional grid, infinite grid, etc. That will not be discussed in detail here, and I will leave it to you to study.

## Source Code
There are many public equilibrium strategies on FMZ platform, and recently I have written another version, with simple parameters, very easy to understand, which is the strategy used in the article.
Source code address: https://www.fmz.com/strategy/214943
Sure, there are other equilibrium strategies on FMZ: https://www.fmz.com/square/s:tag:平衡/1
Also, I recommend the version from master Zero: https://www.fmz.com/strategy/345

There are also many grid strategies on FMZ: https://www.fmz.com/square/s:tag:网格/1
The grid strategy used in the article will not be disclosed temporarily, and here I recommend the teaching version from Xiaoxiaomeng: https://www.fmz.com/strategy/113144

From: https://www.fmz.com/digest-topic/9294