Dynamic Grid Trading Strategy: From Zero Expectation To Market Outperformance
Dynamic Grid Trading Strategy: From Zero Expectation To Market Outperformance
Outperformance
Cryptocurrencies are digital assets secured by cryp- Assume there are n grids, resulting in n + 1 grid
tography, operating on decentralized blockchain levels. Given that the grid intervals have equal
networks. In recent years, the use of cryptocur- ratios, let the grid size be k. The current grid level
rencies for transactions has significantly increased. is represented in black, while the other grid levels
As of August 17, 2024, the daily trading volume are shown in gray (as Figure 1). Starting the grid at
of Bitcoin had reached approximately $37 billion. price P , if there are m gray grid levels above and
Furthermore, compared to traditional stock mar- n − m gray grid levels below the current price, the
kets, cryptocurrencies exhibit substantial volatility. corresponding grid levels are outlined in Table 1
above.
To capitalize on this volatility, many traders em-
ploy grid trading strategies in their transactions. If we invest M USDT in total, the instant starting
We began by proposing mathematical hypotheses the grid, we spend M ∗ m n USDT to buy cryptocur-
n−m
and conducting proofs, which informed the design rency and leave M ∗ n as USDT.
of our strategy based on the traditional grid trading
1.1.2 Algorithm
model. Following this, we developed a backtesting
system to assess its effectiveness through program- After initiating the grid strategy, a transaction is
ming. triggered only when the price crosses a gray grid
level. If the price rises and crosses the Gthi gray
1.1 Traditional Grid Trading Strategy grid level, counted from the upper limit, we will sell
1
Gi of the cryptocurrency we currently hold. The
We will provide a brief introduction to the spot original black grid level is then marked gray, and
grid trading strategy applied in our research. The the crossed gray level is marked black. Conversely,
grid type used in this study is the geometric grid, if the price falls and crosses the Gth
j gray grid level,
which places orders at price intervals that adjust
counted from the lower limit, we will spend G1j
proportionally. This method enables a more effi-
of the USDT we hold to purchase cryptocurrency.
cient capture of market movements across different
Similarly, the original black level is marked gray,
levels of volatility.
and the crossed gray level is marked black. This
* Equal contribution. dynamic adjustment of grid levels ensures that the
†
Corresponding author: [email protected] strategy continually adapts to market movements
1
without manual intervention. 2.2 Claim 2: Zero Expected Value
We assume that the price either increases or de-
1.1.3 Termination creases by k with equal probability (50-50), which
Once the price exceeds the upper limit or falls be- is a reasonable hypothesis for a basic investor
low the lower limit of the grid, the strategy ter- model. Additionally, we do not consider trans-
minates. According to the algorithm’s logic, if action fees and assume that all cryptocurrency is
the price surpasses the upper limit, we will retain sold if the price falls below our grid. Under these
the original USDT invested, the additional USDT conditions, we can assert that the expected value
earned from grid trading, and no cryptocurrency. of a grid trading strategy with grid size k and a
Conversely, if the price drops below the lower limit, finite number of grid levels is zero. The proof is as
all the USDT initially invested will be converted follows:
into cryptocurrency, and we will still retain the 2.2.1 Required Number of Arbitrage Times
bonus USDT earned from grid trading.
To determine when a grid trading strategy has a pos-
itive expected value, consider investing M USDT
1.2 Data Resources in the grid strategy with n grids, resulting in n + 1
We obtained the spot data from Binance using the grid levels. Since this is a spot grid trading strategy,
API: https://api.binance.com/api/v3/klines. The if the price rises linearly and surpasses the highest
data spans from January 2021 to July 2024, with a grid level, we can earn Pu USDT, where
time interval of 1 minute, representing the highest n
2
frequency candlestick data available. Given this MX
Pu = i (1)
interval, we assume that the grid strategy executes n
i=1
no more than one transaction per minute. Addition-
ally, we account for transaction fees, applying a fee Conversely, if the price falls linearly and drops
of 0.0008, which corresponds to the Level 1 maker below the lowest grid level, we incur a loss of Ll
fee on OKX. USDT, where
n
2
−1
2 Observations M n 2 X
Ll = [( ) + i] (2)
n 2
i=1
In the initial phase of our research, we identified
several market patterns and conditions that guided Thus, without accounting for profits from arbitrage,
the development of a series of hypotheses and math- the expected value of the grid strategy is E(G)
ematical derivations. These insights inspired the USDT.
design of a novel grid trading strategy.
1 M n2 n
E(G) = ∗ (Pu − Ll ) = − ( − ) (3)
2 n 8 4
2.1 Claim 1: Infinite Resources
In Figure 1, we use n = 6 for demonstration.
The first claim posits that if we have infinite capi- Since the grid strategy realizes profits before the
tal and time, the grid trading strategy is inherently price reaches the upper limit and buys more when
profitable. With unlimited funds, the strategy can the price falls, it results in a negative expected
capitalize on every price movement, as orders are value if the price moves linearly. According to
consistently placed at regular intervals above and the derivation above, if the strategy can achieve
2
below the current price. This guarantees continu- more than n8 − n4 arbitrage opportunities, it will
ous buying at low prices and selling at higher ones, yield a positive arbitrage value.
profiting from each market fluctuation. Infinite cap-
ital allows the strategy to endure even the most 2.2.2 Expected Value of Grid Trading
challenging market conditions without depleting To calculate the expected value of transactions exe-
funds. Similarly, infinite time ensures the ability cuted by a grid strategy, given that the probability
to wait out any downturns or periods of stagnation, of the price rising or falling by k is equal, we can re-
eventually profiting as the price moves. Therefore, frame the problem as follows: What is the expected
with infinite resources, the grid trading strategy number of coin tosses required to achieve either n2
would always yield positive returns over time. more heads than tails or n2 more tails than heads?
2
Em = E0 − m2 . We will prove this conjecture
using mathematical induction.
Base Case :
If m = 1, 2
E1 = E0 − 1
E2 = E0 − 4
The base case holds for m = 1, 2.
Inductive Hypothesis :
Suppose the result holds for m = k, k + 1, k ∈ N
Ek = E0 − k 2
Ek+1 = E0 − (k + 1)2
Inductive Step
For m = k + 2
Ek+2 = 2Ek+1 − Ek − 2
3
2
We obtain a result of n8 − n4 , which matches the Algorithm 1 DGT Strategy
required number of arbitrage opportunities. There- 1: Set Strategy Parameters: grid sizes, levels,
fore, we can conclude that the expected value of a transaction fee
grid strategy is zero under our assumptions. 2: Define Grid Calculation: Compute grid lev-
els around start price
E(grid strategy) = 0 (6) 3: Prepare Results Storage: Initialize empty list
for results
3 Dynamic Grid-Based Trading Strategy 4: for each combination of grid parameters do
5: Initialize variables: wallet, input money,
Based on our observations, we have found that a
grid count setup
grid strategy with infinite capital and time can gen-
6: for each price data point do
erate a positive return, while a grid strategy that
7: if price moves up then
stops once the price exceeds its boundaries cannot.
8: Execute sell if crossing grid level
The key difference is that the former continues to
9: else if price moves down then
capitalize on arbitrage opportunities, whereas the
10: Execute buy if crossing grid level
latter does not. Therefore, even though we lack in-
11: end if
finite capital, it is unwise to stop the strategy when
12: if price exceeds grid limitaries then
the price surpasses our upper or lower limits. This
13: Calculate profit, Reset grid
reasoning is straightforward, as the fundamental
14: Update wallet
concept of grid trading is to buy more when the
15: end if
price falls. Selling all cryptocurrency when the
16: end for
price drops below the grid contradicts this core
17: Calculate final performance metrics
principle. Building on these insights, we developed
18: end for
a novel approach, the Dynamic Grid-based Trad-
ing (DGT) strategy, which continues to operate
regardless of price movements.
two major cryptocurrencies, BTC and ETH, over
3.1 DGT Algorithm the backtesting period from January 2021 to July
We selected two mainstream cryptocurrencies, Bit- 2024.
coin and Ethereum, as the assets for backtesting The grid size represents the ratio of each step in
our strategy. As previously mentioned, we utilized the geometric grid, while grid numbers half refers
1-minute candlestick data for the testing. The algo- to the number of grids established above and below
rithm for our DGT strategy is outlined as follows: the central price when the grid is activated.
The strategy resets the grid whenever the price From Figure 3 and 4, we can derive the fol-
breaks above the upper limit or falls below the lowing conclusions: First, the IRR of our strategy
lower limit, with the current price becoming the remains consistently positive throughout the back-
new center. If the price breaks above the upper testing period, reaching as high as 60-70%. This
limit, the initial capital is fully recovered and rein- strong performance is largely due to the significant
vested in the next grid. Conversely, if the price rise in cryptocurrency prices in recent years, which
falls below the lower limit, the strategy holds the is highly favorable for spot grid trading. Moreover,
cryptocurrency, using the arbitrage profits gained ETH demonstrates a higher IRR than BTC, likely
as the principal for the new grid. because ETH’s smaller market volume leads to
The wallet tracks the cumulative profits earned greater price volatility, which benefits grid trading.
from grid arbitrage, while input money represents Finally, a small grid size results in lower profits due
the total invested capital. These variables are up- to the high proportion of transaction fees within the
dated each time the grid is reset. arbitrage profit. Conversely, a large grid size and
grid numbers half lead to poor IRR performance, as
3.2 Backtesting Results the infrequent activation of the grid results in lower
We used Python to construct the entire backtesting cryptocurrency holdings. Therefore, optimizing the
framework. Figure 3 and 4 illustrate the perfor- balance between grid size and grid numbers half
mance of the DGT in terms of annualized return is crucial for maximizing profits while minimizing
(IRR) across various parameter combinations for costs and maintaining an active trading frequency.
4
Figure 3: DGT strategy performance of BTC Figure 5: DGT strategy performance of ETH
Figure 4: DGT strategy performance compared with Figure 6: DGT strategy performance compared with
buy-and-hold on BTC buy-and-hold on ETH
5
Figure 7: Traditional grid trading strategy on BTC & ETH
(represented by the blue line), the IRR fluctuates at ing that the DGT strategy outperforms both the
a consistent level, aligning with our earlier calcula- buy and hold strategy and the grid trading strategy.
tion that the expected value of the grid strategy is In the future, we will attempt to use mathematical
zero. Next, after considering fees (represented by theory to derive the probability of profit and the
the red line), as with the DGT strategy results, we expected returns of the DGT strategy.
observe that a smaller grid size experiences lower
volatility but is more susceptible to transaction fees, Acknowledgments
while a larger grid size exhibits higher volatility due
We would like to extend our heartfelt gratitude
to greater differences in arbitrage levels. Finally,
to Yu-Chen Hung from the Department of Eco-
it’s clear that the DGT strategy outperforms the tra-
nomics at National Taiwan University (NTU) and
ditional grid trading strategy, even when applied to
Po-Chung Hsieh from the Department of Electrical
a grid with predefined cryptocurrency price bound-
Engineering at NTU for their valuable insights and
aries. This is expected, as the DGT strategy allows
thoughtful discussions. Their contributions have
for the reinvestment of profits and more efficient
been a great source of inspiration and have signif-
use of capital. Interestingly, we found that many
icantly influenced the successful outcomes of our
users employ a strategy known as the "sky and
research.
land" grid strategy on exchanges, which is similar
to the traditional grid trading strategy discussed
here. References
5 Conclusions and Future Work Agatino Luigi di Stallo Francesco Rundo,
Francesca Trenta and Sebastiano Battiato. 2019.
Grid trading has become a widely used trading Grid trading system robot (gtsbot): A novel math-
ematical algorithm for trading fx market. Applied
technique in recent years. However, our research Sciences, 9(9):1796.
reveals that without any insight into market trends,
the expected value of grid trading is effectively zero. Ruixin Jia. 2022. The feasibility of grid trading ap-
This means that investors face a high risk of losing proach for bitcoin based on backtesting. In Proceed-
ings of the 4th International Conference on Economic
money after taking transaction fees into consider- Management and Model Engineering, ICEMME
ation. To address this, we developed a modified 2022, November 18-20, 2022, Nanjing, China.
version of the grid trading strategy, known as the
DGT strategy. While it may seem like a blend of Sirapop Kamrat, Napasorn Suesangiamsakul, and
Rangsipan Marukatat. 2018. Technical analysis for
the buy-and-hold strategy and the traditional grid cryptocurrency trading on mobile phones. In The
trading strategy, the DGT strategy has significantly 2018 Technology Innovation Management and Engi-
outperformed both from 2021 to July 2024. We neering Science International Conference (TIMES-
hope that our research provides valuable insights iCON2018), pages 1–4.
for those considering grid trading strategies in the
Jia Xu, Kun Hu, Guang Yang, Jian Zhang, and Jianxing
cryptocurrency market. Ye. 2019. Using machine learning for cryptocurrency
In this paper, we demonstrated through backtest- trading. In 2019 IEEE International Conference on
6
Industrial Cyber Physical Systems (ICPS), pages 647–
652.
A Code Availability
The code used in this paper is available on GitHub
at the following link: Source codes.