Balance strategy and grid strategy
Tags: startegy, grid, balance, fmzquant
Published: 2024-06-19 01:25:02

If the price of Bitcoin one day in the future will be the same as it is now, what strategy will you adopt to gain profit? The easy way to think of is to sell if it rises, buy if it falls, and wait for the price to recover again, and then earn the intermediate price difference. How to implement it? How much do you need to sell when it rises? If you sell too early, you will obviously lose money. Similarly, buying too early will make less profit. Balance strategy and grid strategy are both to solve this problem, they are also very similar, this article will specifically introduce these two strategies.

## Brief introduction of strategy
The principle of the balance strategy is very simple. The strategy only holds a fixed proportion of the crypto currency, such as 50%. When the value of the crypto currency exceeds 50%, it will be sold. On the contrary, the value of the crypto currency held will be maintained at around 50%. If the price of the crypto currency continues to rise, it will continue to be sold, but always holding a certain crypto currency will not be sold out. If the price of the crypto currency first rises and then falls back to the starting price, the strategy of selling high and buying low will increase the crypto currency and fiat currency.

The grid strategy is to buy and sell at a fixed price, and you can set multiple groups of trading intervals, such as 8000-8500, 8500-9000. The strategy will buy 0.1 crypto currency at 8000 yuan, sell 0.1 crypto currency when it rises to 8500, continue to sell 0.1 crypto currency at 9000, and then buy 0.1 crypto currency when it falls to 8500. Note that the grid will only peg the price at the other end only when one end of a range is traded. In this way, the strategy always buys low and sells high. It is also noticed that the crypto currency bought and sold are the same, so that when the price returns to the initial price, the crypto currency of the strategy remain unchanged, but the fiat currency increases.

The performance of these two strategies is very close, but also very different. The balance strategy always has funds to buy and sell, and the grid strategy has a certain range. If it exceeds the range, you may not be able to continue to buy, or you may have sold all the crypto currency.

## How to measure profit
Before evaluating the strategy, we need to formulate the criteria for evaluating the profit. Most people's view of income is absolute income, that is, income = current total funds - initial total funds. But if the crypto currency is initially held, this method cannot show the profit of the active behavior of the strategy.

For example, the initial account has a balance of 10,000 yuan, 1 crypto currency, and a crypto currency price of 8,000, and total funds = 10,000 + 1 * 8000 = 18,000 yuan. After running the strategy for a period of time, the current account balance is 2000u, 2 crypto currency, the crypto currency price is 9000, and the total funds = 2000 + 2 * 9000 = 20,000 yuan. Absolute income = 20000 - 18000 = 2000 yuan. But the initial account already holds a crypto currency, even if the strategy is not run, there will be a return of 1,000 yuan in the end, so the profit from the strategy is only 1,000 yuan. This calculation method is floating income, floating income = current balance + current crypto currency * current price - (initial balance + initial crypto currency * current price).

Next we look at the backtest results of these two strategies.

## Backtesting of balance strategies
The balance strategy requires two parameters, the holding value ratio and the adjustment ratio. The holding value is set to 0.5 here, that is, to hold half of the money and half of the crypto currency, and the adjustment ratio is set to 0.01, that is, when the crypto currency price rises and the value of the crypto currency exceeds 51%, 1% of the crypto currency is sold, and the same goes for the decline. The backtest time is the past year, the backtest crypto currency is the Binance BTC_USDT trading pair, and the handling fee is 0.1%.

Backtest results:

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

Profit curve:

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

Since the price of Bitcoin has been volatile in the past year, the strategy has achieved stable returns.

## Grid strategy backtest
The parameters required by the grid strategy are relatively complicated, and it is necessary to set the upper and lower limits of the grid, the grid type, the number of grids, and the investment funds. When the strategy is launched, the crypto currency price is 8,000 yuan, here the upper and lower limits of the grid are set to plus or minus 3,000 yuan, 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/0pviqwm72u3p48yuih5m.png)

Backtest results:

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

Profit curve:

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

## Comparison of two strategies
From the perspective of the floating income chart, the results of the two strategies are relatively similar. In the case of long-term sideways trading in Bitcoin prices, both have obtained stable returns and both have retracements at the same time. After all, the principles of the strategy are very close. Due to the different parameters, it is difficult to directly compare the two strategies. From the perspective of income/trading volume, the grid strategy is 18.6 and the balance strategy is 22.7. The balance strategy is more efficient.

However, the balance strategy is relatively rigid. In order to increase the transaction volume, apart from more frequent adjustments, it can only increase the total capital investment. The grid strategy has higher requirements for settings. If you choose a small range of price fluctuations, the funds per grid will be large and the transaction volume will be enlarged. If the price is always within the range, the profit will be high, of course. Face the danger of prices exceeding the set range. The balance strategy always has fiat currency to buy and sell crypto currency, which is equivalent to a grid that cannot be broken.

For beginner, it is recommended the balance strategy, the operation is simple, only need to set a parameter of holding ratio, you can run without brain. Those with certain experience can choose the grid strategy, decide the upper and lower limits of fluctuation and the funds per grid by themselves, improve the utilization rate of funds, and seek the maximum benefit.

The balance strategy can choose to balance multiple currencies at the same time. There are also many variants of the grid strategy, such as proportional grids, infinite grids, etc., I will not elaborate on them here, and leave it to the reader to study.

## Strategy source code
There are a lot of Balance Strategy on our strategy square. I recently wrote a new version with simple parameters and easy to understand. This version is used in this article. Source address: https://www.fmz.com/strategy/214943. in addition, our platform also has other versions of balance strategy: https://www.fmz.com/square/s:tag:balance/1, and https://www.fmz.com/ strategy/345

Grid Strategy also has published a lot, https://www.fmz.com/square/s:tag:Grid/1. here is another one: https://www.fmz.com/strategy/113144.

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