Skip to main content

Validate Grid Input

Validate futures grid bot input parameters and return allowable ranges. Use before creating a futures grid bot to ensure parameters are within valid bounds.

info
  • When to call:
    Always call this endpoint before Create Futures Grid Bot.

  • check_code:
    FGRID_CHECK_CODE_SUCCESS = all parameters are valid. Any other value identifies the specific parameter that is out of range.

  • Rate limit:
    10 requests per second per UID.

HTTP Request

POST/v5/fgridbot/validate

Request Parameters

ParameterRequiredTypeComments
symboltruestringTrading pair symbol, uppercase only (e.g. BTCUSDT)
cell_numbertrueintegerNumber of grid levels, minimum 2
min_pricetruestringLower price bound of the grid range (decimal string)
max_pricetruestringUpper price bound of the grid range (decimal string)
leveragetruestringPosition leverage, must be >= 1 (e.g. "5")
grid_typetrueintegerGrid spacing type: 1 Arithmetic, 2 Geometric
grid_modetrueintegerStrategy direction: 1 Neutral, 2 Long, 3 Short
stop_loss_pricefalsestringStop-loss trigger price (decimal string). Used when tp_sl_type includes price-based SL
take_profit_pricefalsestringTake-profit trigger price (decimal string). Used when tp_sl_type includes price-based TP
tp_sl_typefalseintegerTP/SL trigger mode: 1 Both %, 2 Both price, 3 TP price+SL %, 4 TP %+SL price
entry_pricefalsestringEntry trigger price for delayed activation (decimal string)
stop_loss_perfalsestringStop-loss as percentage (e.g. "10" means 10%). Used when tp_sl_type includes percentage-based SL
take_profit_perfalsestringTake-profit as percentage (e.g. "20" means 20%). Used when tp_sl_type includes percentage-based TP
trailing_stop_perfalsestringTrailing stop callback as percentage (e.g. "5" means 5%)
init_marginfalsestringInitial margin amount in quote currency (decimal string)
move_up_pricefalsestringMove-up price for grid shifting
move_down_pricefalsestringMove-down price for grid shifting

Response Parameters

ParameterTypeComments
status_codeinteger0 = success, non-zero = error
debug_msgstringDebug message (testnet only)
check_codestringValidation result. FGRID_CHECK_CODE_SUCCESS = OK. See check code table below
investmentobjectAcceptable investment amount range (from / to, decimal strings in quote currency)
profitobjectAcceptable per-grid profit rate range as percentage (from / to)
cell_numberobjectAcceptable grid count range (from / to)
min_priceobjectAcceptable lower price bound range (from / to)
max_priceobjectAcceptable upper price bound range (from / to)
leverageobjectAcceptable leverage range (from / to)
stop_lossobjectAcceptable stop-loss percentage range (from / to)
take_profitobjectAcceptable take-profit percentage range (from / to)
take_profit_priceobjectAcceptable take-profit price range (from / to)
stop_loss_priceobjectAcceptable stop-loss price range (from / to)
entry_priceobjectAcceptable entry price range (from / to)
trailing_stop_perobjectAcceptable trailing stop percentage range (from / to)
long_liq_pricestringEstimated liquidation price for long direction
short_liq_pricestringEstimated liquidation price for short direction
move_up_priceobjectAcceptable move-up price range (from / to)
move_down_priceobjectAcceptable move-down price range (from / to)
cell_gtv0_perstringExtra grid count allowance for VIP users (percentage relative to non-VIP)

Check Code Values (selected)

check_codeDescription
FGRID_CHECK_CODE_SUCCESSOK — no error
FGRID_CHECK_CODE_LOW_PRICE_TOO_LOWMin price too low
FGRID_CHECK_CODE_LOW_PRICE_TOO_HIGHMin price too high
FGRID_CHECK_CODE_HIGH_PRICE_TOO_LOWMax price too low
FGRID_CHECK_CODE_HIGH_PRICE_TOO_HIGHMax price too high
FGRID_CHECK_CODE_GRID_NO_TOO_LOWGrid count too low (min 2)
FGRID_CHECK_CODE_GRID_NO_TOO_HIGHGrid count too high
FGRID_CHECK_CODE_INVESTMENT_TOO_LOWInvestment too low
FGRID_CHECK_CODE_INVESTMENT_TOO_HIGHInvestment too high
FGRID_CHECK_CODE_LEVERAGE_TOO_LOWLeverage too low (min 1)
FGRID_CHECK_CODE_LEVERAGE_TOO_HIGHLeverage too high
FGRID_CHECK_CODE_TP_TOO_LOWTake-profit ratio too low
FGRID_CHECK_CODE_TP_TOO_HIGHTake-profit ratio too high
FGRID_CHECK_CODE_SL_TOO_LOWStop-loss ratio too low
FGRID_CHECK_CODE_SL_TOO_HIGHStop-loss ratio too high
FGRID_CHECK_CODE_SL_CAUSE_LIQUIDATIONStop-loss would cause liquidation
FGRID_CHECK_CODE_RISK_LIMITCannot set leverage due to risk limit
FGRID_CHECK_CODE_OI_POS_LIMITOpen interest position limit exceeded
FGRID_CHECK_CODE_SYMBOL_NOT_EXISTSSymbol does not exist
FGRID_CHECK_CODE_USER_BANNEDUser banned
FGRID_CHECK_CODE_INVALID_TRAILING_STOP_PERCENTInvalid trailing stop percentage

Request Example

POST /v5/fgridbot/validate HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1672211928338
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"symbol": "BTCUSDT",
"grid_mode": 2,
"min_price": "230000",
"max_price": "800000",
"cell_number": 88,
"leverage": "6",
"grid_type": 2
}

Response Example

{
"retCode": 0,
"retMsg": "success",
"result": {
"status_code": 200,
"debug_msg": "",
"investment": {
"from": "7900.3349",
"to": "26748800"
},
"profit": {
"from": "8.1959",
"to": "8.1959"
},
"cell_number": {
"from": "3",
"to": "1562"
},
"min_price": {
"from": "56930.2",
"to": "1997760.4"
},
"max_price": {
"from": "479430.7",
"to": "1999999.8"
},
"leverage": {
"from": "1",
"to": "50"
},
"stop_loss": {
"from": "0",
"to": "100"
},
"take_profit": {
"from": "0",
"to": "500"
},
"check_code": "FGRID_CHECK_CODE_UNSPECIFIED",
"take_profit_price": {
"from": "800000",
"to": "1999999.8"
},
"stop_loss_price": {
"from": "56930.2",
"to": "230000"
},
"entry_price": {
"from": "142325.4",
"to": "479162.1"
},
"cell_gtv0_per": "71.88",
"trailing_stop_per": {
"from": "0.05",
"to": "0.99"
},
"long_liq_price": "",
"short_liq_price": "",
"move_up_price": {
"from": "811412.8",
"to": "1999999.8"
},
"move_down_price": {
"from": "0.1",
"to": "226764.9"
}
},
"retExtInfo": {},
"time": 1774508649318
}