Step-by-Step Grid Trading Example
(Conservative Approach to Investment allocation)
This article provides a basic demonstration of how Spot Grid Trading works using an example with simplified, hypothetical data. The goal is to explain every stage of the process, starting from configuring the Grid Trading Strategy to calculating final profits. By the end, readers will have a clear understanding of the mechanics behind Grid Trading and its potential outcomes.
Legend
For this example, we demonstrate a grid trading strategy using the BTC/USDT trading pair.
Let’s assume the price of BTC is hypothetical and measured in units of dollars per 1.00 BTC. This will make the explanation clearer and easier to follow.
All activities described in the example occurred in the past, specifically between January 1, 2024, and May 31, 2024.
Example Setup
The following parameters of Grid Trading were chosen for this example:
- Date Range:
From — January 1, 2024;
To — May 31, 2024 - Price Range: 2.00-7.00 USDT
- Grid Mode: Arithmetic
- Number of Grids: 5
- Investment: 100.00 USDT
Price Movements (Fluctuations) within Date Range:
- January 1, 2024: 4.00 USDT
- February 1, 2024: 3.00 USDT
- March 1, 2024: 4.00 USDT
- April 1, 2024: 5.00 USDT
- May 1, 2024: 6.00 USDT
- May 31, 2024: 6.00 USDT (end of the defined period)
On January 1, 2024, the price of BTC was 4.00 USDT — this is our Entry Price.
On May 31, 2024, the price of BTC was 6.00 USDT — this is our Last Price.
Additional Parameters:
- All dates and times are in UTC, with price changes occurring at precisely 00:00:00 on the respective day.
- Trading fee: 0.1% per transaction.
Detailed Explanation and Example Calculation
1. Spread & Grids Lower and Upper prices
In Arithmetic Mode, the difference between the Upper and Lower prices of each grid is constant. This difference is called Spread and it is calculated using the formula:
In our example:
- Lower Price: 2.00 USDT
- Upper Price: 7.00 USDT
- Number of Grids: 5
Grid # | Lower Price USDT |
Upper Price USDT |
Spread USDT |
---|---|---|---|
1 | 2.00 | 3.00 | 1.00 |
2 | 3.00 | 4.00 | 1.00 |
3 | 4.00 | 5.00 | 1.00 |
4 | 5.00 | 6.00 | 1.00 |
5 | 6.00 | 7.00 | 1.00 |
2. Amount per Grid
As it was mentioned in the Definitions, in Arithmetic Mode Investment is distributed in such a way to allocate equal amounts of the Base Asset to each grid.
Let's consider that the goal is to allocate 1.00 BTC per grid. For our example with 5 grids this means a total of 5.00 BTC is needed.
The next step in determining the Amount per Grid is to calculate the total amount of the Quote Asset required to allocate 1.00 BTC to each grid. This calculation is based on the Lower Price of the grid.
The total Quote Asset required per grid is:
- 2.00 USDT to buy 1.00 BTC for Grid[1];
- 3.00 USDT to buy 1.00 BTC for Grid[2];
- 4.00 USDT to buy 1.00 BTC for Grid[3];
- 5.00 USDT to buy 1.00 BTC for Grid[4];
- 6.00 USDT to buy 1.00 BTC for Grid[5].
So to get 5.00 BTC and distribute 1.00 BTC per grid we need:
Since our Investment is 100.00 USDT, Amount per Grid is:
The general formula to calculate Amount per Grid is:
In our example:
Grid # | Lower Price USDT |
Upper Price USDT |
Amount per Grid BTC |
---|---|---|---|
1 | 2.00 | 3.00 | 5.00 |
2 | 3.00 | 4.00 | 5.00 |
3 | 4.00 | 5.00 | 5.00 |
4 | 5.00 | 6.00 | 5.00 |
5 | 6.00 | 7.00 | 5.00 |
3. Investment per Grid
Investment per Grid represents the portion of Investment allocated to purchase the specified Amount per Grid based on the Lower Price of each grid. It is expressed in the Quote Asset.
The formula to calculate Investment per Grid is:
In our example:
Using the calculated Amount per Grid of 5.00 BTC, the investments for each grid are as follows:
Grid # | Lower Price USDT |
Upper Price USDT |
Amount per Grid BTC |
Investment USDT |
---|---|---|---|---|
1 | 2.00 | 3.00 | 5.00 | 10.00 |
2 | 3.00 | 4.00 | 5.00 | 15.00 |
3 | 4.00 | 5.00 | 5.00 | 20.00 |
4 | 5.00 | 6.00 | 5.00 | 25.00 |
5 | 6.00 | 7.00 | 5.00 | 30.00 |
4. Initial Distribution
The Initial Distribution represents the total allocation of the Quote Asset and Base Asset across all grids immediately after the Grid Trading is initialized and initially placed orders are executed.
While Grid Trading Strategy is initializing, orders to buy the Amount per Grid for each grid are placing at the Lower Price of the corresponding grid or based on the Entry Price according to the following conditions:
- if Lower Price Grid[n] >= Entry Price, the order is set and executed immediately at the Entry Price.
- if Lower Price Grid[n] < Entry Price, the order remains open.
For executed orders, trading fees reduce the final amount of the Base Asset allocated to the grid.
Therefore, formula to calculate the Base Asset for each grid considering trading fees is:
In our example:
Entry Price is 4.00 USDT.
For Grid[1]: Lower price of this grid is lower than Entry Price, so the buy order remained open. Investment per Grid[1] 10.00 USDT was retained.
For Grid[2]: Lower price of this grid is lower than Entry Price, so the buy order remained open. Investment per Grid[2] 15.00 USDT was retained.
For Grid[3]: Lower price of this grid is equal to Entry Price, so the buy order was executed.
For Grid[4]: Lower price of this grid is higher than Entry Price, so the buy order was executed. However, not all invested amount was required since the order was executed at the price of 4.00 USDT instead of 5.00 USDT. So we retained 5.00 USDT from Investment per Grid[4].
For Grid[5]: Lower price of this grid is higher than Entry Price, so the buy order was executed. Same as for Grid 4, not all invested amount was used, order was executed at the price of 4.00 USDT instead of 6.00 USDT. So we retained 10.00 USDT from Investment per Grid[5].
Therefore,
Grid # | Lower Price USDT |
Upper Price USDT |
Amount per Grid BTC |
Investment USDT |
USDT | BTC |
---|---|---|---|---|---|---|
1 | 2.00 | 3.00 | 5.00 | 10.00 | 10.00 | 0.000 |
2 | 3.00 | 4.00 | 5.00 | 15.00 | 15.00 | 0.000 |
3 | 4.00 | 5.00 | 5.00 | 20.00 | 0.00 | 4.995 |
4 | 5.00 | 6.00 | 5.00 | 25.00 | 5.00 | 4.995 |
5 | 6.00 | 7.00 | 5.00 | 30.00 | 10.00 | 4.995 |
5. Profit per Grid
Profit is generated within a grid when both BUY and SELL (or SELL and BUY) orders are executed. The Profit per Grid represents the earnings from these trades within a specific grid.
The base formula for calculating the profit in a grid is:
However, trading fees impact the final profit. The accurate formula, taking fees into account, is:
The ratio of Profit per Grid to Investment per Grid can be calculated as:
In our example:
Therefore, Profits per Grid,% are the following:
Grid # | Lower Price USDT |
Upper Price USDT |
Investment USDT |
Profit per Grid USDT |
Profit per Grid, % |
---|---|---|---|---|---|
1 | 2.00 | 3.00 | 10.00 | 4.970015 | 49.7002 |
2 | 3.00 | 4.00 | 15.00 | 4.960020 | 33.0668 |
3 | 4.00 | 5.00 | 20.00 | 4.950025 | 24.7501 |
4 | 5.00 | 6.00 | 25.00 | 4.940030 | 19.7601 |
5 | 6.00 | 7.00 | 30.00 | 4.930035 | 16.4335 |
6. Grid Trading Strategy algorithm execution
At this stage, the Grid Trading Strategy has been initialized. Amount per Grid and Investment per Grid have been calculated. Additionally, we have defined our Initial Distribution across the grid, and the expected Profit per Grid has also been calculated based on our example.
Then, according to the legend, the following events took place:
- February 1, 2024: BTC price dropped to 3.00 USDT per BTC, a buy order was executed for Grid[2] and 4.995 BTC was bought. A sell order for 4.995 BTC at a price of 4.00 USDT was opened.
- March 1, 2024: BTC price rebounded to 4.00 USDT per BTC, a sell order was executed for Grid[2] and 4.995 BTC was sold. A buy order for 5.00 BTC at a price of 3.00 USDT was opened.
- April 1, 2024: BTC price increased to 5.00 USDT per BTC, a sell order was executed for Grid[3] and 4.995 BTC was sold. A buy order for 5.00 BTC at a price of 4.00 USDT was opened.
- May 1, 2024: BTC price increased further to 6.00 USDT per BTC, a sell order was executed for Grid[4] and 4.995 BTC was sold. Reserved 5.00 USDT that wasn’t used during trading operations was retained. A buy order for 5.00 BTC at a price of 5.00 USDT was opened.
- May 31, 2024: BTC remained at 6.00 USDT per BTC, Grid Trading Strategy was finalized.
Now, let’s get the results of our strategy and compute the final financial outcomes.
7. Final Distribution
The Final Distribution represents the total allocation of the Quote Asset and Base Asset across all grids at the time when the Grid Trading Strategy is finalized. This is determined at the end date ("To"):
In our example:
Grid # | Lower Price USDT |
Upper Price USDT |
Amount per Grid BTC |
Investment USDT |
USDT | BTC |
---|---|---|---|---|---|---|
1 | 2.00 | 3.00 | 5.00 | 10.00 | 10.00 | 0.00 |
2 | 3.00 | 4.00 | 5.00 | 15.00 | 19.96 | 0.00 |
3 | 4.00 | 5.00 | 5.00 | 20.00 | 24.95 | 0.00 |
4 | 5.00 | 6.00 | 5.00 | 25.00 | 29.94 + 5.00 | 0.00 |
5 | 6.00 | 7.00 | 5.00 | 30.00 | 0.00 + 10.00 | 4.995 |
8. Balance
The total value of all assets at the moment when the Grid Trading Strategy ends is Balance. It is expressed in the Quote Asset.
Balance is calculated based on the Last Price of the Base Asset including trading fee deduction. The formula to calculate Balance is:
In our example:
Last Price is 6.00 USDT.
9. Total PnL
Total Profit and Loss (Total PnL) represents the overall financial result of the Grid Trading within the Date Range.
It is calculated using the following formula:
In our example:
Investment is 100.00 USDT.
10. Annualized Return
Annualized Return is a metric used to understand the return on investment over the one year. It is useful for comparing performance when the Date Range spans less than or more than a full year.
This metric is expressed as a percentage and calculated using the following formula:
In our example:
Date Range:
From January 1, 2024
To May 31, 2024
So, the Runtime = 151 days.
11. Grid Profit
Grid Profit is the sum of Profit per Grid for each of the Matched Trades.
In our example:
Based on the legend, Profit per Grid was earned only in Grid[2], Grid[3] and Grid[4].
12. Floating PnL
Floating Profit and Loss (Floating PnL) represents the change in the Base Asset’s market price when Grid Trading was initialized and when it was closed, excluding Grid Profit.
This metric is expressed in the Quote Asset and is calculated using the following formula:
In our example: