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:

Spread = ( Upper Price Lower Price ) Number of Grids

In our example:

  • Lower Price: 2.00 USDT
  • Upper Price: 7.00 USDT
  • Number of Grids: 5

Spread = ( 7.00 2.00 ) 5 = 1.00 USDT

Table presents Lower and Upper prices with Spread for each grid:
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:

2.00 + 3.00 + 4.00 + 5.00 + 6.00 = 20.00  USDT

Since our Investment is 100.00 USDT, Amount per Grid is:

1.00 BTC × 100.00 20.00 = 5.00  BTC per grid

The general formula to calculate Amount per Grid is:

Amount per Grid = Investment / ( Lower Price Grid [ 1 ] + Lower Price Grid [ 2 ] + + Lower Price Grid [ n ] )

In our example:

Amount per Grid = 100.00 ( 2.00 + 3.00 + 4.00 + 5.00 + 6.00 ) = 5.00  BTC

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:

Investment per Grid [ n ] = Amount per Grid × Lower Price Grid [ n ]

In our example:

Using the calculated Amount per Grid of 5.00 BTC, the investments for each grid are as follows:

Investment per Grid [ 1 ] = 5.00 × 2.00 = 10.00  USDT Investment per Grid [ 2 ] = 5.00 × 3.00 = 15.00  USDT Investment per Grid [ 3 ] = 5.00 × 4.00 = 20.00  USDT Investment per Grid [ 4 ] = 5.00 × 5.00 = 25.00  USDT Investment per Grid [ 5 ] = 5.00 × 6.00 = 30.00  USDT

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.

Initial Distribution = ( Distribution of Quote Asset ) + ( Distribution of Base Asset )

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:

Base Asset Grid [ n ] = Amount per Grid × ( 1 fee )

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.

Quote Asset Grid [ 1 ] = 10.00  USDT Base Asset Grid [ 1 ] = 0.00  BTC

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.

Quote Asset Grid [ 2 ] = 15.00  USDT Base Asset Grid [ 2 ] = 0.00  BTC

For Grid[3]: Lower price of this grid is equal to Entry Price, so the buy order was executed.

Quote Asset Grid [ 3 ] = 20.00 5 × 4.00 = 0.00  USDT Base Asset Grid [ 3 ] = 5.00 × ( 1 0.001 ) = 4.995  BTC

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].

Quote Asset Grid [ 4 ] = 25.00 5.00 × 4.00 = 5.00  USDT Base Asset Grid [ 4 ] = 5.00 × ( 1 0.001 ) = 4.995  BTC

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].

Quote Asset Grid [ 5 ] = 30.00 5.00 × 4.00 = 10.00  USDT Base Asset Grid [ 5 ] = 5.00 × ( 1 0.001 ) = 4.995  BTC

Therefore,

Initial Distribution = ( 10.00  USDT + 15.00  USDT + 5.00  USDT + 10.00  USDT ) + ( 4.995  BTC + 4.995  BTC + 4.995  BTC ) = 40.00  USDT + 14.985  BTC

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:

Profit per Grid = Amount per Grid × Upper Price Amount per Grid × Lower price

However, trading fees impact the final profit. The accurate formula, taking fees into account, is:

Profit per Grid [ n ] = Amount per Grid × ( 1 Fee ) × Upper Price [ n ] × ( 1 Fee ) Amount per Grid × Lower Price [ n ]

The ratio of Profit per Grid to Investment per Grid can be calculated as:

Profit per Grid [ n ] , % = Profit per Grid [ n ] Investment per Grid [ n ] × 100 %

In our example:

Profit per Grid [ 1 ] = 5.00 × ( 1 0.001 ) × 3.00 × ( 1 0.001 ) 5.00 × 2.00 = 4.970015  USDT Profit per Grid [ 2 ] = 5.00 × ( 1 0.001 ) × 4.00 × ( 1 0.001 ) 5.00 × 3.00 = 4.960020  USDT Profit per Grid [ 3 ] = 5.00 × ( 1 0.001 ) × 5.00 × ( 1 0.001 ) 5.00 × 4.00 = 4.950025  USDT Profit per Grid [ 4 ] = 5.00 × ( 1 0.001 ) × 6.00 × ( 1 0.001 ) 5.00 × 5.00 = 4.940030  USDT Profit per Grid [ 5 ] = 5.00 × ( 1 0.001 ) × 7.00 × ( 1 0.001 ) 5.00 × 6.00 = 4.930035  USDT

Therefore, Profits per Grid,% are the following:

Profit per Grid [ 1 ] , % = 4.970015 10.00 × 100 % = 49.7002 % Profit per Grid [ 2 ] , % = 4.960020 15.00 × 100 % = 33.0668 % Profit per Grid [ 3 ] , % = 4.950025 20.00 × 100 % = 24.7501 % Profit per Grid [ 4 ] , % = 4.940030 25.00 × 100 % = 19.7601 % Profit per Grid [ 5 ] , % = 4.930035 30.00 × 100 % = 16.4335 %

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.

    Quote Asset Grid [ 2 ] = 15.00 5.00 × 3.00 = 0.00  USDT Base Asset Grid [ 2 ] = 5.00 × ( 1 0.001 ) = 4.995  BTC

  • 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.

    Base Asset Grid [ 2 ] = 4.995 4.995 = 0.00  BTC Quote Asset Grid [ 2 ] = 4.995 × 4.00 × ( 1 0.001 ) = 19.96  USDT

  • 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.

    Base Asset Grid [ 3 ] = 4.995 4.995 = 0.00  BTC Quote Asset Grid [ 3 ] = 4.995 × 5.00 × ( 1 0.001 ) = 24.95  USDT

  • 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.

    Base Asset Grid [ 4 ] = 4.995 4.995 = 0.00  BTC Quote Asset Grid [ 4 ] = 4.995 × 6.00 × ( 1 0.001 ) = 29.94  USDT + 5.00  USDT

  • 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"):

Final Distribution = ( Distribution of Quote Asset ) + ( Distribution of Base Asset )

In our example:

Final Distribution = ( 10.00  USDT + 19.96  USDT + 24.95  USDT + 29.94  USDT + 5.00  USDT + 10.00  USDT ) + 4.995  BTC = 99.85  USDT + 4.995  BTC

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:

Balance = Quote Asset Grid [ n ] + Base Asset Grid [ n ] × Last Price × ( 1 - fee )

In our example:

Last Price is 6.00 USDT.

Balance = ( 10.00 + 19.96 + 24.95 + 29.94 + 5.00 + 10.00 ) + 4.995 × 6.00 × ( 1 0.001 ) = 129.79  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:

Total PnL = Balance - Investment

In our example:

Investment is 100.00 USDT.

Total PnL = 129.79 100.00 = 29.79  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:

Annualized Return = ( Total PnL Investment × 365 Runtime ) × 100 %

In our example:

Date Range:
From January 1, 2024
To May 31, 2024

So, the Runtime = 151 days.

Annualized Return = ( 29.79 100 × 365 151 ) × 100 % = 72.01 %

11. Grid Profit

Grid Profit is the sum of Profit per Grid for each of the Matched Trades.

Grid Profit = Profit per Grid  ( 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].

Grid Profit = Profit per Grid [ 2 ] + Profit per Grid [ 3 ] + Profit per Grid [ 4 ] = 4.960020 + 4.950025 + 4.940030 = 14.850075  USDT

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:

Floating PnL = Total PnL Grid Profit

In our example:

Floating PnL = 29.79 14.850075 = 14.939925  USDT