FAQ
Home
Support Center
FAQ
Trading Bots
Futures Grid Bot
What Is Long/Short Grid Trading?

What Is Long/Short Grid Trading?

2021-04-08 10:05
Tutorial
Order Logic
PnL Calculation
Tutorial

What is Futures grid trading?

Futures grid trading is a trading bot that automates the buying and selling of futures contracts. The bot is designed to place orders in the market at preset intervals within a configured price range. Futures grid trading is ideal for volatile and sideways markets when prices fluctuate in a given range. This technique attempts to make profits on small price changes.
For more details, please refer to What Is Futures Grid Trading.

What is long/short grid trading?

Long/short grid trading is a popular algorithmic trading strategy that enables users to trade with the market trend within a grid trading system using a trading bot. With this bot, traders can open an initial position (long or short) based on their analysis and simultaneously place buy-limit and sell-limit orders at predetermined intervals to capitalize on market volatility and ranging conditions.
For example, a trader could open an initial long position in BTCUSDT to express his bullish view on Bitcoin. He can set up the Grid Trading Bot to place buy orders at every 1,000 USDT below the market price of BTCUSDT, while also placing sell orders at every 1,000 USDT above the market price of BTCUSDT. This allows him to trade with the underlying trend within a grid trading system.
A critical difference between a long/short grid and a neutral grid is the initial opening position. For a long grid bot, users will have an initial long position opened. Conversely, an initial short position will be opened for a short grid bot.

How to set up a Futures Grid Trading Bot?

The grid trading bot systematically executes buy- and sell-limit orders based on the parameters you set. Here’s how you can set up your first long/short grid trading bot.
1. Log in to your Binance account and go to [Derivatives] - [Binance Futures Overview]. Click [Trading Bots] - [Futures Grid].
You can also access the Futures Grid Trading interface from the Binance Futures homepage by clicking [Trading Bots] - [Futures Grid].
If you’re using the Binance App, go to [Futures] - [USDⓈ-M Futures] or [COIN-M Futures]. Select a trading pair and tap [Grid] at the bottom left.
2. The first parameter you must select is the contract on which the trading bot will be deployed. In this example, we will be using the BTCUSDT perpetual contract.
3. Enter the parameters of your long/short grid trading bot on the grid trading panel. The key parameters that you must include are:
  • The upper and the lower boundaries of the price range;
  • The number of orders to be placed within the configured price range;
  • The width between each grid order;
  • Initial margin.
If the current market price exceeds the grid trading range, the Futures Grid Trading Bot will start without any position.
4. Assign the initial margin of the position. The system will calculate your initial margin value based on the number of grids, leverage, and price range you set. Note that the denser the grid, the greater the corresponding initial margin.
Please note that the notional value of each grid order must meet the minimum requirement. You can reduce the number of grids or increase the initial margin to ensure that each grid’s minimum notional value is met.
Insufficient Initial Margin Reminder
When the initial margin is lower than the minimum requirement, you will be notified to meet the minimum initial margin required to activate the grid trading bot.
Please ensure that your margin balance is higher than the maintenance margin to avoid liquidation.
5. Click [Create] to place your grid order.

Advanced Settings

Trigger Price
The grid trading bot also comes with enhanced functions that enable you to manage your positions and risk better. One of which is the trigger price. The trigger price is a predetermined price level at which the grid trading bot will be activated. This allows you to dictate when the system will be active when market conditions meet your criteria.
When a grid trade is triggered, the system divides the asset price range into several grid levels according to your parameters and sets pending orders for each price level. When the asset’s price falls, a buy order is executed, and a sell order is placed immediately at a high price. When the price rises, a buy order is placed directly at a lower price as soon as a sell order is executed. This bot sets you up to buy low and sell high, allowing you to profit in volatile market conditions.
Stop-Loss
Additionally, you can set a stop-loss for your grid positions. Once the asset’s price crosses below or above the stop loss range, your entire grid position will be closed. This feature protects your position from incurring outsized losses when the market behaves unfavorably.
To monitor trading activity, click the [Running] tab to find grid trading details.
To end the grid trading system, click [End].

USDⓈ-M Futures Short Grid Example

Consider a short grid bot with a configured price range between 9,800 USDT to 10,200 USDT and a grid quantity of 4.
Assuming that the quantity of sell-limit orders at each price is 1, and the market price (the latest transaction price) is 10,010 USDT. The following scenario shows how a short grid trading bot will be activated.
PriceDirection
10,200 USDTSell
10,100 USDTSell
10,000 USDTSell
9,900 USDTSell
9,800 USDTSell
In this case, the lowest sell-limit order (9,800 USDT) is excluded, and the subsequent sell orders are placed upwards from 9,900 USDT to 10,200 USDT. If the initial position is transacted between the prices of 9,900 USDT and 10,000 USDT, the initial number of grid orders will be 2.
Since the current market price is 10,010 USDT, the sell orders at the prices of 9,900 USDT and 10,000 USDT will be filled as the initial position. Once the initial position is filled, a buy order will be placed at the next lower price. The grid limit orders will be updated as follows:
PriceDirection
10,200 USDTSell
10,100 USDTSell
10,000 USDT-
9,900 USDTBuy
9,800 USDTBuy
To summarize, for short grid trading bots, the first sell-limit order will trigger the initial short position. Simultaneously, the subsequent sell-limit orders will be populated in ascending order toward the highest boundary of your configured grid. Then, the buy-limit orders will be placed in the market once the initial short position is triggered, according to your bot’s parameters.
Similarly, long grid trading bots will be activated once the first buy-limit order is filled. Subsequently, all grid orders will be populated.

Long/Short Grid activations and immediate orders

How grid orders are set?

Common rules
  • When activating a grid strategy, the number of grid lines you configure determines the number of orders that will be placed across the price range.
  • For example, if you activate a grid strategy with 12 grids, 12 orders will be placed within the price range at equal intervals.
  • The space between the orders is calculated based on the overall price range set for the grid, the number of grid lines specified, and whether the arithmetic or geometric grid spacing is used.

How initial order placements in long/short grids differ from neutral grids?

Neutral grids spread orders evenly above and below the current market price when activated. This means the first order triggered will establish a new long or short position depending on price movement. If the price goes up, it will trigger a sell order, starting the grid with an initial short position. If it goes down, it will trigger a buy order, and the grid strategy will start with a long position.
Unlike neutral grids, Long grids initially place only buy orders above the current price when activated (T+0). This aims to immediately build a long position as high buy orders get filled near the last price at the time of grid activation. The filled buy orders are then replaced with sell orders (T+1).
Following the same logic, Short grids initially place only sell orders below the current price when activated to establish a short position. It aims to immediately build a short position as low sell orders get filled close to the last price at the time of grid activation (T+0). The filled sell orders are then replaced with buy orders (T+1).
  • Long orders above the last price will likely be executed upon activation at a price close to the last price, building up a long position size that is equal to the combined order sizes of the initially executed orders. (T+1)
  • The executed long orders will then be automatically replaced by sell orders, reflected in the grid preview.
  • Please note that the grid preview reflects the grid orders at T+1, not at T+0. You’ll see a combination of buy and sell orders in the grid preview on the candlestick chart, instead of the initial order set immediately post grid activation (corresponding to T+0).
The logic behind the initial order placement allows long grids to establish an initial long position by having buy limit orders filled close to the current market price. If an uptrend is anticipated, the long position built from these limit orders can then be sold at higher price levels within the grid range for profit.
Similarly, short grids establish an initial short position by having sell limit orders filled close to the current market price. If a downtrend is anticipated, this short position can then be bought back at lower prices within the grid range, allowing the short position to be closed at a more favorable price.

Example

You've set up a long grid on ETHUSDT:
  • ETHUSDT price: 1,650.70 USDT
  • Number of grid: 5 (arithmetic)
  • Initial investment: 100 USDT
  • Price range: 1620 - 1800 USDT
As this is a long grid made of 5 grids, the system will start by placing 5 buy limit orders upon grid confirmation to build an initial long position.
Given the range and ETHUSDT price at grid activation, 4 out of these 5 limit orders are placed above the last price at the time of grid activation (T+0).
This causes the 4 limit orders above current market price to be executed immediately, building up your initial long position.
Right after, the filled buy limit orders are automatically replaced by sell orders, which are in turn placed on the upper grid (T+1).
Pending grid trading bot orders
Grid trading bot orders preview on the candlestick chart
The initial long position size at T+1 is therefore composed by the number of grids above the current price, corresponding to the initial buy limit orders that have been executed.
Reflecting the 4 buy market orders, your initial position size will then be 4 * 0.027 ETH = 0.108 ETH, equivalent to 178.28 USDT as initial entry price of 1,650.72 USDT.

How to calculate long/short grid profit and loss?

The profit and loss calculation for a long/short grid trading bot considers both the total matched profits, the unmatched profit and loss, and the funding fees of the position. In this case, completed transactions are recorded as matched transactions, while partially completed transactions are recorded as unmatched transactions. A matched transaction means that every short position (or long position) in the grid trading bot is matched by a corresponding buy order (or sell order).
IndexDefinitionMethodology
Unmatched PnLThe profit and loss of unmatched grid transactionsUnmatched PnL = Total Profit - Matched Profit - Funding Fees
Total ProfitTotal matched profit and unmatched profit and loss since inceptionTotal Profit = Realized Profit + Unrealized PnL + Funding Fees
Yield Total return ROIROI = Total Profit / Initial Margin * 100%
Annualized Rate of Return Annualized total return APR
APR = ROI * Year / T
(T is the running time of the bot)

How to calculate the total profit of a grid trading bot?

You can use the realized profit, unrealized PnL, and the funding fees to calculate the total profit:
Total Profit = Net Realized Profit + Unrealized PnL + Funding Fees
Let’s use the USDⓈ-M Futures Grid as an example. Assume a positive Funding Rate of 0.01% for this pair.
1. Calculate the net realized profits
Net realized profit = gross realized profit - total fee expenses of all the completed orders of the grid trading bot
Notes:
  • Fees paid for each trade can be found in [Trade History].
  • You may check the net realized profit in the grid details page.
Total realized profit = 0.20596000 + 0.13932000 + 0.07268000 - 0.00642000 - (0.00123038 + 0.00122238 + 0.00121439 + 0.00321511 + 0.00321511 + 0.00321511 + 0.00321511 + 0.00482797 + 0.00483002 ) = 0.38535442
2. Calculate the unrealized PnL
Unrealized PnL is calculated based on the difference between the last price and the entry price of open positions. You can find your unrealized PnL and entry price under the [Positions and Orders] window.
3. Calculate the total profits
Total profits = Net Realized Profit + Unrealized PnL + Funding Fees
= 0.38535442 + 0.26 + 53.5 * 0.01%
= 0.65070442 USDT
4. Calculate the unmatched profits
Unmatched profits is the unrealized profit of filled grid orders that are not matched.
Unmatched PnL = Total Profit - Matched Profit - Funding Fee
= 0.65070442 USDT - 0.60454353 USDT - 53.5 * 0.01%
= 0.04081119 USDT

How are positions matched?

Positions are matched using the First-In-Last-Out (FILO) methodology. Under FILO, orders that are filled first will be matched last.
Example
Suppose a long grid trading bot is filled in the following order:
PriceDirectionSequence
10,200 USDTBuy1st
10,100 USDTBuy2nd
10,000 USDTBuy3rd
The corresponding sell orders to be matched will be in the following sequence:
PriceDirectionSequenceMatched Sequence
10,200 USDTBuy1st3rd
10,100 USDTBuy2nd2nd
10,000 USDTBuy3rd1st
The last buy order (10,000 USDT) will be matched with a corresponding sell order at 10,100 USDT, and the remaining buy orders will be matched at a higher selling price.