The Introduction of Grid Trading
Definition
Grid trading is a type of quantitative trading strategy. This trading bot automates buying and selling on spot trading. It is designed to place orders in the market at preset intervals within a configured price range.
Grid trading is when orders are placed above and below a set price, creating a grid of orders at incrementally increasing and decreasing prices. In this way, it constructs a trading grid.
Fees
The fee rate of the spot order executed by the spot strategy bot. Maker & Taker are both 0.1%
Create Schema
There are two ways to create a grid strategy. One is to create it manually: set the grid parameters according to your own judgment on the volatile market; the other is to generate a grid with one click through the AI intelligent algorithm. The AI intelligent algorithm will combine the recent market and The backtest data gives dynamic grid strategy parameters.
Lowest Price
The grid strategy will not execute orders below the lowest price of the grid.
When the trigger price is set, it cannot exceed 400% of the trigger price; when the trigger price is not set, it cannot exceed 400% of the current price.
Highest Price
The grid strategy will not execute orders above the highest price of the grid.
Grid Type
Arithmetic mode (The difference between the prices of every two adjacent orders is equal, the price difference = (highest price — lowest price) / grid quantity, such as 100/140/180/220 USDT)
Geometric mode(The ratio of the prices of every two adjacent tiers of pending orders is equal, price ratio = (highest price / lowest price) ^ (1/grid number) , such as 10/20/40/80 USDT)
Number of Grids
The number of adjacent pending order ranges between the grid high and low.
The precision is 0, limited to [2,200], and the net rate of return per grid cannot be less than or equal to 0.
For example, the parameters with the highest price of 100U, the lowest price of 1600U, a proportional grid, and a grid of 4 are correspondingly divided into 4 grids of 100–200, 200–400, 400–800, and 800–1600.
Investment Amount
The amount of funds the user expects to invest in the grid strategy, the investment amount of grid trading will be isolated from the spot account as an independent position, and the order will be placed according to the established strategy. The actual amount of funds used to create the grid depends on market conditions and may not equal the amount entered by the user.
Trigger Price
After the trigger price is set, the grid strategy will not start running immediately after the strategy is successfully created. The grid will only start running when the latest transaction price of the benchmark currency crosses the strategy trigger price. Users please make sure that when the grid strategy is triggered, the spot account has enough investment funds available.
For example, when the strategy is created, the transaction price is 2333, and the strategy trigger price is set to 2000, then the strategy will start to run when the latest transaction price is less than or equal to 2000; similarly, when the strategy trigger price is set to 3000, then when the latest transaction price The strategy will only start running when it is greater than or equal to 3000.
Take Profit Price
When the latest transaction price of the benchmark currency rises to this price, the strategy is automatically terminated and all benchmark currencies in the current strategy are sold at the market price.
The take profit price is greater than the highest price, and cannot be less than the current price. When the trigger price is set when the grid is initially created, the take profit price cannot be less than the trigger price.
Stop Loss Price
When the latest transaction price of the benchmark currency falls to this price, the strategy will automatically terminate and all benchmark currencies in the current strategy will be sold at the market price.
The stop loss price is less than the minimum price, and cannot be greater than the current price. When the trigger price is set when the grid is initially created, the take profit price cannot be greater than the trigger price.
Follow Settings
Whether to allow others to view the benefits of this strategy and follow them according to this strategy. The follower position will be liquidated when it is terminated, and the total profit of the position will be deducted according to the set ratio and transferred to the account of the strategy sponsor.
Strategy Run
By way of example, the strategy operation rules are simulated, and the grid parameters are as follows:
Trading pair: BTC/USDT
Price when creating the strategy: 29600 USDT
Lowest price: 21000 USDT
Highest price: 43000 USDT
Grid Type: Uniform
Number of grids: 22
Investment amount: 3300U
Strategy trigger price: 32500 USDT
Take Profit Price: 56000 USDT
Stop Loss Price: 18000 USDT
Follow Settings: Do not allow others to follow
The first stage: the policy is successfully created, and the state is to be triggered.
The strategy will not be triggered until the price of BTC/USDT reaches 32500 USDT. Strategies with no trigger price set skip phase one.
The second stage: The strategy is triggered, and a pending order is initially opened.
When the price of BTC/USDT reaches (or exceeds) 32,500 USDT, the strategy is triggered, and the system will lock the expected investment amount in the currency account. The system will calculate the prices of all pending orders in the grid (21000/22000/23000…40000/41000/42000 respectively) according to the strategy parameters, and then place a buy order at these prices. If the market depth is good, the price will be at 32500 All the above buy orders will be filled, and the grid strategy will place sell orders at one level higher than the price of the traded buy orders. At this time, 34000/35000/36000/37000/38000/39000/40000/41000/42000/43000 prices are all pending sell orders, 21000/22000/23000/24000/25000/26000/27000/28000/31000/20000 All prices are pending buy orders.
After completing the position opening operation, the remaining unfrozen investment funds in the strategy (not used by the strategy order) will be unlocked, and the expected investment amount — the unlocked part is equal to the actual investment amount.
The third stage: strategy operation, position covering and arbitrage.
If the price of BTC/USDT falls below 32000, the buy order will be filled at this position (Buy at a low price), and the program will automatically place a sell order at the position of 33000 (the small grid of 32000–33000 corresponds to the upper position), and the number of sell orders is a single grid buy volume. If the price of BTC/USDT rises above 33000, the sell order will be filled ( Sell at a high price), and the program will automatically place a buy order at the position of 32000 (the small grid of 32000–33000 corresponds to the lower position), and the number of buy orders is a single grid buy volume. Only after the pending order at the current level is completely filled, the system will place an order in the opposite direction at the corresponding position. When the price of BTC/USDT does not break through the highest price and lowest price of the strategy, by placing orders and transactions cyclically with market fluctuations, you can continue to earn volatile returns in the volatile market. If the price of BTC/USDT continues to fall below 21,000, the system will no longer carry out buy-to-cover operations. Similarly, after the price continues to rise above 43,000, the system will no longer carry out sell arbitrage operations.
The price currency income generated by arbitrage cannot be used until the strategy is terminated, it is locked in the strategy position, and it is only used to pay the pending order fee.
The fourth stage: Policy Termination.
If the price of BTC/USDT falls below 18000, the strategy will start stop loss and terminate. At this time, after the system cancels the pending order information of the strategic position, it will sell all the benchmark coins held in the strategic position at the market price, after that, all the price coins in the position will be unlocked.. The price coin is unlocked. In the same way, if the price of BTC/USDT exceeds 56000, the strategy will start the take profit termination. At this time, after the system cancels the pending order information of the strategy position, it will sell all the remaining benchmark coins in the strategy position at the market price. After that, all the price coins in the position will be unlocked.
There is also a situation where the user manually terminates the strategy. At this time, if the user chooses to sell all the benchmark coins and then terminate the strategy, the system will withdraw the pending order information of the strategy position and sell all the benchmark coins held in the strategy position at the market price. Unlock all the price coins in the position; if the user does not choose to sell all the base coins and then terminate the strategy, the system will unlock all the price coins and base coins in the position after withdrawing the pending order information of the strategic position.
In the case of a follow-up strategy in which the total revenue is profit, the system will transfer part of the revenue with the total revenue as profit to the currency account of the strategy sponsor
Actual Investment
The actual investment amount, the amount of assets actually used after the grid strategy position is created, and the unit of price currency.
Total Revenue
The total revenue since the grid strategy runs, and the revenue is converted into price currency units. Total Return = Grid Profit + Floating P&L
Yield = Total Return / Actual Investment Amount * 100%
Annualized Rate of Return
Annualized rate of return = total return / actual investment amount * 365 * 24 * 60 * 60 / number of seconds the strategy has been running * 100%
Floating Profit And Loss
The fluctuation in value caused by the rise and fall of the base currency of the current trading pair. It is the change of the latest price of the benchmark currency for the current trading pair relative to the average buying price.
Total floating profit and loss = Σ sell order floating profit and loss + Σ buy order floating profit and loss
Sell order floating profit and loss = remaining trading currency quantity * latest price + invoicing currency quantity obtained from the selling part — invoicing currency quantity consumed by the matching buy order
Buy order floating profit and loss = transaction quantity * (last price — average transaction price)
When the grid strategy is running, the price of the currency pair is the latest price of the base currency; when the grid strategy is terminated, the price of the currency pair is the price of the benchmark currency when the grid is terminated.
Floating profit and loss ratio = floating profit and loss / actual investment amount * 100%
Grid Profit
The realized profit generated by grid trading is the sum of the profits generated by the traded sell orders paired with the buy orders.
Grid Profit = Σ Paired Profit
The buy orders in the grid strategy are commissioned one by one from the lowest price upwards. The traded buy orders are in a stack structure. After arbitrage, each traded sell order is matched with a traded buy order at the top of the stack, and then the matching profit is calculated.
Matching Profit = Sell Order Volume — Buy Order Volume
Buy order turnover = transaction quantity * transaction price + buy order handling fee
Sell order turnover = trade quantity * trade price — sell order handling fee
Grid Profit Rate = Grid Profit / Actual Investment Amount * 100%
Net Yield of Per Grid
Net yield of per grid refers to the profit percentage after matching buy and sell orders for each grid. After the equal difference/proportion mode is determined, the net rate of return per grid can be calculated from the highest price, the lowest price, the number of grids, and the grid transaction fee. Net yield per grid must be greater than 0.
For the Arithmetic mode, the net rate of return per grid is an interval, the minimum net rate of return per grid is generated by the topmost grid, and the maximum net rate of return per grid is generated by the bottom grid.
Single Grid Buy Volume
Single grid buying volume refers to the buying volume of pending orders for each grid at different price levels during the grid operation.