| preface

Grid Trading Method is also known as Grid Trading strategy. To put it simply, the core of grid trading method is to set the value center and operate the investment target by using the mode of bottom position + stall position. When it goes down, buy it, when it goes up, sell it. Grid trading is also called fishnet trading strategy because it is a procedural behavior and uses market fluctuations to buy low and sell high within the grid range just like a fishing net. Grid trading method can reasonably control positions, avoid chasing up and killing down, with strong risk resistance.

In this paper, the grid trading strategy of BTC/USDT will be implemented based on Python, and the k-line data of Huobi obtained on 1Token will be used to carry out the back test on 1TokenQuant’s quantitative back test platform, and the results will also be visualized and analyzed. In addition, we use the multi-parameter space tuning function of 1TokenQuant to find the optimal parameter solution for this strategy.

| target selection

Since the grid trading method pursues constant market fluctuations, the more severe the market fluctuations, the higher the yield, so even if the price does not rise, but only fluctuates within a certain range, the grid trading method will obtain great benefits. According to the characteristics of the grid transaction law, will rise and fall, the amplitude of the mark is suitable for the grid law, so the greater the fluctuation of the K line currency is more suitable for the grid law. At the same time, based on the perspective of security, the first to choose high efficiency, good liquidity currency.

It’s better to be on mainstream currencies, not copycats, because copycats can go to zero at any time and fall indefinitely, whereas mainstream currencies don’t.

Buy in equal amount, can reduce cost to the greatest extent. For example, if you buy 10000 BTC at 4500 yuan and then go down to 3500 dollars, then buy 10000 BTC again, what is the unit cost? 4000 dollars? No, it’s 3937.5 yuan!

Do not do it in the futures market, because the futures market turnover is too large to equal the amount of buying. More importantly, grid trading is contrarian trading, and contrarian trading is taboo in leveraged markets.

| grid interval

Short-term interval: for example, a period of time, the market or a single currency has been in the box shock, can set the top of the box short-term position to sell the most high-grade, the bottom of the box to buy the lowest.

Long-term range: set the historical average lower position of the market or the valuation of a single currency as the lowest buying level; The high historical average setting of a broad or individual currency valuation is the highest selling point.

| grid gear

Here, taking the 5-file method as an example, two different file classification methods are introduced:

Average grading method: assuming that the interval is 10 yuan ~20 yuan, then the buying stalls are evenly distributed. Taking 15 yuan as the mid-range of reasonable valuation to build positions, 50% capital can be invested here, and the remaining 50% capital can be divided by 5 grades. When the grid threshold is triggered by a rise, sell 10% of the position, when the grid threshold is triggered by a fall, buy 10% of the position, constantly buy low sell high.

Note: this method is more suitable for shock market or short-term box operation and no specific rules when used, suitable for small funds.

Index division method: the price range of the former equal division grid is correct, but the equal division of the amount of money bought and sold each time is easy to cause that in a one-sided trend market, the amount of money bought and sold each time is too average, resulting in too early buying or selling. Although the security is very good, but easy to lead to a very low yield. The index method is to use an exponential function to guide the volume of buying and selling at each level. Below the valuation center, only buy, above the valuation center, only sell. At the same time, increase the amount of buying at the bottom, less buying and selling in the middle of the interval, and increase the amount of selling at the top of the interval to ensure bottom hunting and escape the top. It is suitable for unilateral trend markets and long-term markets to increase the overall yield.

Note: this method is suitable for ultra long – term bull – bear cycle, guide long – term or mid – line unilateral trend to build positions and sell.

Grid trades should be placed when valuations are reasonable and the long-term trend is upward. Position management is very important. The grid size can be set according to personal energy and capital allocation. The minimum is not less than 1%, and the maximum is not more than 5%.

It can be seen that grid trading is more of a position strategy. The purpose of a positioning strategy is not to improve returns (alpha), but to reduce risk (beta). It is investors who realize that the future is not completely predictable and there is always the possibility of failure no matter what forecasting means are used. Therefore, in order to protect capital, the return of a single transaction must be sacrificed to reduce the overall risk and achieve higher overall return. In the presence of compound interest, the scheme with a lower average but relatively stable rate of return is superior to the scheme with a higher average but relatively unstable rate of return.

| strategy implementation

| parameter tuning

1TokenQuant supports finding optimal solutions in the parameter space of policies directly online. In this case, we expect to find the optimal mesh interval, and for this purpose, we specify the following two parameters:

To use the tuning parameters, we need to change line 20 in the above policy to read:

Note: When using multi-parameter tuning, you need to filter out unnecessary combinations, such as mult1 greater than mult2.

We use the 5-minute K line data of Huobi BTC/USDT trading pair as an example, and the backtest period is from December 1, 2018 to December 31, 2018. The following table shows some of the results of the tuning back test:

Finally, we select the optimal set of parameters, namely mult1=2.0 and MULt2 =2.5, and run a complete backtest, obtaining the following results:

Details of some transactions are as follows:

| strategy is limited

It is important to note that grid trading strategies have underperformed in bull markets. Too low beta (risk) is necessarily at the expense of low alpha (return) due to the over-diversified positioning strategy and the subjective setting of the grid out of the price pattern. In addition, the trading rules are inflexible, and the blind rejection of chasing the rise and falling will lead to the missing of some buying and selling points that break through the support resistance. Although these buying and selling points are not advantageous, the wind ratio is very high in the early stage of the trend formation.

| summary

The core of grid trading method is mean regression, if the price does not regression, grid trading will fail. In the form of volatility, grid trading can continuously absorb low-price chips by selling high and buying low, and then sell them at the high of each volatility to obtain the benefits brought by volatility.