简体中文
NAV
console python

Introduction

Welcome to the official documentation for the Bybit APIs and Websocket! Here you can find details on how to access all of our endpoints, their respective expected outputs, and possible errors you may encounter.

If you encounter an issue you need help with, have a suggestions for us, or just want to have a chat with fellow developers then please head on over to our API Telegram chat!

Bybit API Resources

Changelog

2020-09-15

REST API

2020-08-19

REST API

2020-07-07

REST API

2020-06-22

REST API

2020-05-21

REST API

2020-04-29

REST API

2020-04-27

REST API

2020-04-17

REST API

2020-04-14

REST API

2020-03-31

REST API

2020-03-26

REST API

2020-03-16

REST API

2020-03-09

REST API

2020-03-02

Websocket API

2020-02-26

REST API

2020-02-10

REST API

2019-12-27

REST API

2019-12-18

REST API

Websocket API

2019-12-13

REST API

2019-12-02

REST API

2019-11-19

REST API

2019-11-07

REST API

2019-11-04

REST API

Websocket API

2019-10-22

REST API

Websocket API

Authentication

All requests made to private endpoints must be authenticated. Requests made to public endpoints do not require the additional parameters needed for authentication.

Parameters for Authenticated Endpoints

The following parameters must be used for authentication:

Additionally, we offer the recv_window, which indicates for how long an HTTP request is valid. This should be sent in milliseconds. Default value: 5000. It used to prevent replay attacks.

A smaller recv_window is more secure, but your request may fail if the transmission time is greater than your recv_window.

Please ensure that your timestamp is synced with our server time. You can use the Server Time endpoint.

Constructing the Request

An example for adjusting leverage

param_str = "api_key=B2Rou0PLPpGqcU0Vu2&leverage=100&symbol=BTCUSD&timestamp=1542434791747"

# api_key=B2Rou0PLPpGqcU0Vu2&
# leverage=100&
# symbol=BTCUSD&
# timestamp=1542434791747

Note how the parameters are ordered in alphabetical order, with api_key first followed by leverage, then symbol, then timestamp.

1. Concatenate all the public parameters in the query string format. The parameters must be ordered in alphabetical order. This will be used to generate the sign.

2. Sign the parameters string.

Different requests need different message formats. Message format for GET requests:

GET /user/leverage?api_key=B2Rou0PLPpGqcU0Vu2&timestamp=1542434791000&sign=670e3e4aa32b243f2dedf1dafcec2fd17a440e71b05681550416507de591d908 HTTP/1.1
Host: api-testnet.bybit.com

Message format for POST requests:

POST /user/leverage/save HTTP/1.1
Host: api-testnet.bybit.com
Content-Type: application/json

{
    "api_key": "B2Rou0PLPpGqcU0Vu2",
    "leverage": 100,
    "symbol": "BTCUSD",
    "timestamp": 1542434791000,
    "sign": "670e3e4aa32b243f2dedf1dafcec2fd17a440e71b05681550416507de591d908"
}

3. Append the signature at the end of the parameters string, and send the HTTP request. Please note that the format for messages is different depending on whether you are sending a GET or POST request.

Market Data Endpoints

The following market data endpoints do not require authentication.

Orderbook

Request Example

curl https://api.bybit.com/v2/public/orderBook/L2?symbol=BTCUSD
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_orderbook(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,                              // return code
    "ret_msg": "OK",                            // error message
    "ext_code": "",                             // additional error code
    "ext_info": "",                             // additional error info
    "result": [
        {
            "symbol": "BTCUSD",                 // symbol
            "price": "9487",                    // price
            "size": 336241,                     // size (in USD contracts)
            "side": "Buy"                       // side
        },
        {
            "symbol": "BTCUSD",                 // symbol
            "price": "9487.5",                  // price
            "size": 522147,                     // size (in USD contracts)
            "side": "Sell"                      // side
        }
    ],
    "time_now": "1567108756.834357"             // UTC timestamp
}

Get the orderbook.

HTTP Request

GET /v2/public/orderBook/L2

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
symbol string Symbol
price string Order price
size integer Symbol contracts
side string Side

Query Kline

Request Example

curl https://api.bybit.com/v2/public/kline/list?symbol=BTCUSD&interval=1&limit=2&from=1581231260
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Kline.Kline_get(symbol="BTCUSD", interval="m", **{'from':1}).result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": [{
        "symbol": "BTCUSD",
        "interval": "1",
        "open_time": 1581231300,
        "open": "10112.5",
        "high": "10112.5",
        "low": "10112",
        "close": "10112",
        "volume": "75981",
        "turnover": "7.51394369"
    }, {
        "symbol": "BTCUSD",
        "interval": "1",
        "open_time": 1581231360,
        "open": "10112",
        "high": "10112.5",
        "low": "10112",
        "close": "10112",
        "volume": "24616",
        "turnover": "2.4343353100000003"
    }],
    "time_now": "1581928016.558522"
}

Get kline.

HTTP Request

GET /v2/public/kline/list

Request Parameters

parameter required type comments
symbol true string Symbol
interval true string Data refresh interval. Enum : 1 3 5 15 30 60 120 240 360 720 "D" "M" "W" "Y"
from true integer From timestamp in seconds
limit false integer Limit for data size per page, max size is 200. Default as showing 200 pieces of data per page

Response Parameters

parameter type comments
symbol string Symbol
interval string Data refresh interval. Enum : 1 3 5 15 30 60 120 240 360 720 "D" "M" "W" "Y"
open_time integer Starting time
open string Starting price
high string Maximum price
low string Minimum price
close string Closing price
volume string Trading volume
turnover string Transaction amount

Latest Information for Symbol

Request Example

curl https://api.bybit.com/v2/public/tickers
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_symbolInfo().result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": [
        {
            "symbol": "BTCUSD",
            "bid_price": "7230",
            "ask_price": "7230.5",
            "last_price": "7230.00",
            "last_tick_direction": "ZeroMinusTick",
            "prev_price_24h": "7163.00",
            "price_24h_pcnt": "0.009353",
            "high_price_24h": "7267.50",
            "low_price_24h": "7067.00",
            "prev_price_1h": "7209.50",
            "price_1h_pcnt": "0.002843",
            "mark_price": "7230.31",
            "index_price": "7230.14",
            "open_interest": 117860186,
            "open_value": "16157.26",
            "total_turnover": "3412874.21",
            "turnover_24h": "10864.63",
            "total_volume": 28291403954,
            "volume_24h": 78053288,
            "funding_rate": "0.0001",
            "predicted_funding_rate": "0.0001",
            "next_funding_time": "2019-12-28T00:00:00Z",
            "countdown_hour": 2
        }
    ],
    "time_now": "1577484619.817968"
}

Get the latest information for symbol.

HTTP Request

GET /v2/public/tickers

Request Parameters

parameter required type comments
symbol false string Symbol

Response Parameters

parameter type comments
symbol string Symbol
bid_price string Purchase price of the first order
ask_price string Selling price of the first order
last_price string Latest transaction price
last_tick_direction string Tick Direction
prev_price_24h string Price of 24 hours ago
price_24h_pcnt string Percentage change of market price relative to 24h
high_price_24h string The highest price in the last 24 hours
low_price_24h string Lowest price in the last 24 hours
prev_price_1h string Hourly market price an hour ago
price_1h_pcnt string Percentage change of market price relative to 1 hour ago
mark_price string Mark price
index_price string Index_price
open_interest number Open interest
open_value string Open position value
total_turnover string Total turnover
turnover_24h string Turnover for 24H
total_volume number Total volume
volume_24h number Trading volume in the last 24 hours
funding_rate string Funding rate
predicted_funding_rate string Predicted funding rate
next_funding_time string Next settlement time of capital cost
countdown_hour number Countdown of settlement capital cost

Public Trading Records

Request Example

curl https://api.bybit.com/v2/public/trading-records?symbol=BTCUSD
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_trading_records(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,                                   // error code 0 means success
    "ret_msg": "OK",                                 // error message
    "ext_code": "",
    "ext_info": "",
    "result": [
        {
            "id": 7724919,                                   // ID
            "symbol": "BTCUSD",                             // contract type
            "price": 9499.5,                                // execution price
            "qty": 9500,                                    // execution quantity
            "side": "Buy",                                  // side
            "time": "2019-11-19T08:03:04.077Z"              // UTC time
        }
    ],
    "time_now": "1567109419.049271"
}

Get recent trades. You can find a complete history of trades on Bybit here.

HTTP Request

GET /v2/public/trading-records

Request Parameters

parameter required type comments
symbol true string Symbol
from false int From ID. Default: return latest data
limit false int Limit for data size, max size is 1000. Default size is 500

Response Parameters

parameter type comments
id number Latest data ID
symbol string Symbol
price number Execution price
qty number Order quantity in USD
side string Side
time string UTC time

Query Symbol

Request Example

curl https://api.bybit.com/v2/public/symbols
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Symbol.Symbol_get().result())

Response Example

{
  "ret_code": 0,
  "ret_msg": "OK",
  "ext_code": "",
  "ext_info": "",
  "result": [
    {
      "name": "BTCUSD",
      "base_currency": "BTC",
      "quote_currency": "USD",
      "price_scale": 2,
      "taker_fee": "0.00075",
      "maker_fee": "-0.00025",
      "leverage_filter": {
        "min_leverage": 1,
        "max_leverage": 100,
        "leverage_step": "0.01"
      },
      "price_filter": {
        "min_price": "0.5",
        "max_price": "999999.5",
        "tick_size": "0.5"
      },
      "lot_size_filter": {
        "max_trading_qty": 1000000,
        "min_trading_qty": 1,
        "qty_step": 1
      }
    },
    {
      "name": "ETHUSD",
      "base_currency": "ETH",
      "quote_currency": "USD",
      "price_scale": 2,
      "taker_fee": "0.00075",
      "maker_fee": "-0.00025",
      "leverage_filter": {
        "min_leverage": 1,
        "max_leverage": 50,
        "leverage_step": "0.01"
      },
      "price_filter": {
        "min_price": "0.05",
        "max_price": "99999.95",
        "tick_size": "0.05"
      },
      "lot_size_filter": {
        "max_trading_qty": 1000000,
        "min_trading_qty": 1,
        "qty_step": 1
      }
    },
    {
      "name": "EOSUSD",
      "base_currency": "EOS",
      "quote_currency": "USD",
      "price_scale": 3,
      "taker_fee": "0.00075",
      "maker_fee": "-0.00025",
      "leverage_filter": {
        "min_leverage": 1,
        "max_leverage": 50,
        "leverage_step": "0.01"
      },
      "price_filter": {
        "min_price": "0.001",
        "max_price": "1999.999",
        "tick_size": "0.001"
      },
      "lot_size_filter": {
        "max_trading_qty": 1000000,
        "min_trading_qty": 1,
        "qty_step": 1
      }
    },
    {
      "name": "XRPUSD",
      "base_currency": "XRP",
      "quote_currency": "USD",
      "price_scale": 4,
      "taker_fee": "0.00075",
      "maker_fee": "-0.00025",
      "leverage_filter": {
        "min_leverage": 1,
        "max_leverage": 50,
        "leverage_step": "0.01"
      },
      "price_filter": {
        "min_price": "0.0001",
        "max_price": "199.9999",
        "tick_size": "0.0001"
      },
      "lot_size_filter": {
        "max_trading_qty": 1000000,
        "min_trading_qty": 1,
        "qty_step": 1
      }
    }
  ],
  "time_now": "1581411225.414179"
}

Get symbol info.

HTTP Request

GET /v2/public/symbols

Request Parameters

parameter required type comments

Response Parameters

parameter type comments
name string Symbol name
base_currency string Base currency
quote_currency string Quote currency
price_scale number Price scale
taker_fee string Taker fee
maker_fee string Maker fee
leverage_filter > min_leverage number Min leverage
leverage_filter > max_leverage number Max leverage
leverage_filter > leverage_step string Leverage step
price_filter > min_price string Min price
price_filter > max_price string Max price
price_filter > tick_size string Tick size
lot_size_filter > max_trading_qty number Max trading quantity
lot_size_filter > min_trading_qty number Min trading quantity
lot_size_filter > qty_step number Qty step

Liquidated Orders

Request Example

curl https://api.bybit.com/v2/public/liq-records?symbol=BTCUSD
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_liqRecords(symbol="BTCUSD").result())

Response Example

{
    "ret_code":0,
    "ret_msg":"OK",
    "ext_code":"",
    "ext_info":"",
    "result":[
        {
            "id":2369683,
            "qty":155,
            "side":"Buy",
            "time":1590030126798,
            "symbol":"BTCUSD",
            "price":9444
        }
    ],
    "time_now":"1590068362.493540"
}

Retrieve the liquidated orders, The query range is the last seven days of data.

HTTP Request

GET /v2/public/liq-records

Request Parameters

parameter required type comments
symbol true string Symbol
from false integer From ID. Default: return latest data
limit false integer Limit for data size, max size is 1000. Default size is 500
start_time false integer Start timestamp point for result, in milliseconds
end_time false integer End timestamp point for result, in milliseconds

Response Parameters

parameter type comments
id number Latest data ID
qty number Order quantity in USD
side string Liquidated order's side
time number Millisecond timestamp
symbol string Symbol
price number Execution price

Query Mark Price Kline

Request Example

curl "https://api.bybit.com/v2/public/mark-price-kline?symbol=BTCUSD&interval=1&limit=2&from=1581231260"

Request Example

import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Kline.Kline_markPrice(symbol="BTCUSD", interval="m", **{'from':1581231260}, limit=2).result())

Response Example


{
    "ret_code":0,
    "ret_msg":"OK",
    "ext_code":"",
    "ext_info":"",
    "result":[
        {
            "id":2,
            "symbol":"BTCUSD",
            "period":"1",
            "start_at":1582231260,
            "open":100,
            "high":120,
            "low":88,
            "close":115
        }
    ],
    "time_now":"1591263582.601795"
}

Query mark price kline (like Query Kline but for mark price).

HTTP Request

GET /v2/public/mark-price-kline

Request Parameters

parameter required type comments
symbol true string Symbol
interval true string Data refresh interval. Enum : 1 3 5 15 30 60 120 240 360 720 "D" "M" "W" "Y"
from true integer From timestamp in seconds
limit false integer Limit for data size, max size is 200. Default as showing 200 pieces of data

Response Parameters

parameter type comments
symbol string Symbol
period string Data recording period. 5min, 15min, 30min, 1h, 4h, 1d
start_at integer Start timestamp point for result, in seconds
open integer Starting price
high integer Maximum price
low integer Minimum price
close integer Closing price

Advanced Data

Open Interest

Request Example

curl https://api.bybit.com/v2/public/open-interest?symbol=BTCUSD&period=5min
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_openInterest(symbol="BTCUSD", period="5min").result())

Response Example

{
    "ret_code":0,
    "ret_msg":"OK",
    "ext_code":"",
    "ext_info":"",
    "result":[
        {
            "open_interest":371491978,
            "timestamp":1597658100,
            "symbol":"BTCUSD"
        },
        {
            "open_interest":370696076,
            "timestamp":1597657800,
            "symbol":"BTCUSD"
        }
    ],
    "time_now":"1597658304.938839"
}

Gets the total amount of unsettled contracts. In other words, the total number of contracts held in open positions.

HTTP Request

GET /v2/public/open-interest

Request Parameters

parameter required type comments
symbol true string Symbol
period true string Data recording period. 5min, 15min, 30min, 1h, 4h, 1d
limit false int Limit for data size per page, max size is 200. Default as showing 50 pieces of data per page

Response Parameters

parameter type comments
open_interest number Number of contracts in open interest
timestamp number Timestamp
symbol string Symbol

Latest Big Deal

Request Example

curl https://api.bybit.com/v2/public/big-deal?symbol=BTCUSD
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_bigDeal(symbol="BTCUSD").result())

Response Example

{
    "ret_code":0,
    "ret_msg":"OK",
    "ext_code":"",
    "ext_info":"",
    "result":[
        {
            "symbol":"BTCUSD",
            "side":"Sell",
            "timestamp":1597623362,
            "value":1242368
        },
        {
            "symbol":"BTCUSD",
            "side":"Buy",
            "timestamp":1597623363,
            "value":1242368
        }
    ],
    "time_now":"1597658434.219859"
}

Obtain filled orders worth more than 500,000 USD within the last 24h.

HTTP Request

GET /v2/public/big-deal

Request Parameters

parameter required type comments
symbol true string Symbol
limit false int Limit for data size per page, max size is 1000. Default as showing 500 pieces of data per page

Response Parameters

parameter type comments
symbol string Symbol
side string Side
timestamp number Timestamp
value number Value of the order

Long-Short Ratio

Request Example

curl https://api.bybit.com/v2/public/account-ratio?symbol=BTCUSD&period=5min
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Market.Market_accountRatio(symbol="BTCUSD" "period"="5min").result())

Response Example

{
    "ret_code":0,
    "ret_msg":"OK",
    "ext_code":"",
    "ext_info":"",
    "result":[
        {
            "symbol":"BTCUSD",
            "buy_ratio":0.6538,
            "sell_ratio":0.3462,
            "timestamp":1597659000
        },
        {
            "symbol":"BTCUSD",
            "buy_ratio":0.6533,
            "sell_ratio":0.3467,
            "timestamp":1597658700
        }
    ],
    "time_now":"1597659230.743313"
}

Gets the Bybit user accounts' long-short ratio.

HTTP Request

GET /v2/public/account-ratio

Request Parameters

parameter required type comments
symbol true string Symbol
period true string Data recording period. 5min, 15min, 30min, 1h, 4h, 1d
limit false int Limit for data size per page, max size is 500. Default as showing 50 pieces of data per page

Response Parameters

parameter type comments
symbol string Symbol
buy_ratio number Long position ratio
sell_ratio number Short position ratio
timestamp number Timestamp

Account Data Endpoints

The following account data endpoints require authentication.

Active Orders

Place Active Order

Request Example

curl https://api.bybit.com/v2/private/order/create \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","side"="Buy","symbol"="BTCUSD","order_type":"Market","qty":10,"time_in_force":"GoodTillCancel","timestamp":{timestamp},"sign":"{sign}"}'

import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Order.Order_new(side="Buy",symbol="BTCUSD",order_type="Limit",qty=1,price=8300,time_in_force="GoodTillCancel").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "user_id": 1,
        "order_id": "335fd977-e5a5-4781-b6d0-c772d5bfb95b",
        "symbol": "BTCUSD",
        "side": "Buy",
        "order_type": "Limit",
        "price": 8800,
        "qty": 1,
        "time_in_force": "GoodTillCancel",
        "order_status": "Created",
        "last_exec_time": 0,
        "last_exec_price": 0,
        "leaves_qty": 1,
        "cum_exec_qty": 0,
        "cum_exec_value": 0,
        "cum_exec_fee": 0,
        "reject_reason": "",
        "order_link_id": "",
        "created_at": "2019-11-30T11:03:43.452Z",
        "updated_at": "2019-11-30T11:03:43.455Z"
    },
    "time_now": "1575111823.458705",
    "rate_limit_status": 98,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Market price active order: A traditional market price order which will be filled at the best available price. price is not required for this type of order.

Limit price active order: You can set an execution price for your order. Only when the last traded price reaches the order price will the system will fill your order.

Take profit/Stop loss: You may only set a TP/SL conditional order upon opening the position. Once you hold a position, any new active order requests which contain TP/SL data will be accepted but the TP/SL data will be ignored. tp_trigger_by/sl_trigger_by default to LastPrice. Passing values to the take_profit or stop_loss parameters in this endpoint will create conditional orders managed by the system, which will be be automatically cancelled if the position is closed.

Order quantity: This parameter indicates the quantity of perpetual contracts you want to buy or sell. All USD markets have a contract size of 1 USD. See more

Order price: If it is a conditional order, this parameter is required. When there is no position, the long commission price should be 10% higher than the market price and less than 1 million. If there are positions, they need to be better than strong parity. For the minimum unit of price increase or decrease, please refer to the price_filter field in the Query Symbols endpoint. This must modulo by 0.5 (20 and 21.5 are accepted, but 16.1 or 16.15 are not).

Custom order ID: You may customise order IDs for active orders. We will link it to the system order ID, and return the unique system order ID to you after the active order is created successfully. You may use this order ID or your custom order ID to cancel your active order. The customised order ID should be unique, with a maximum length of 36 characters.

Each account can hold up to 500 active orders yet to be filled entirely simultaneously. This is per instrument, so it's possible to have, for example, 300 active orders on the BTCUSD instrument and 280 active orders on the ETHUSD instrument. And order with parameter reduce_only or closeOnTrigger is unlimited.

HTTP Request

POST /v2/private/order/create

Request Parameters

parameter required type comments
side true string Side
symbol true string Symbol
order_type true string Active order type
qty true integer Order quantity in USD
price false number Order price
time_in_force true string Time in force
take_profit false number Take profit price, only take effect upon opening the position
stop_loss false number Stop loss price, only take effect upon opening the position
reduce_only false bool What is a reduce-only order? True means your position can only reduce in size if this order is triggered
close_on_trigger false bool What is a close on trigger order? For a closing order. It can only reduce your position, not increase it. If the account has insufficient available balance when the closing order is triggered, then other active orders of similar contracts will be cancelled or reduced. It can be used to ensure your stop loss reduces your position regardless of current available margin.
order_link_id false string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.

Response Parameters

parameter type comments
user_id number UserID
order_id string Your active order ID. The unique order ID returned to you when the corresponding active order was created
symbol string Symbol
side string Side
order_type string Order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
order_status string Order status
last_exec_time string Last execution time
last_exec_price string Last execution price
leaves_qty number Number of unfilled contracts from the order's size
cum_exec_qty number Cumulative qty of trading
cum_exec_value number Cumulative value of trading
cum_exec_fee number Cumulative trading fees
reject_reason string The reason the order was rejected
order_link_id string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.
created_at string Creation time
updated_at string Update time

Get Active Order

Request Example

curl "https://api.bybit.com/open-api/order/list?api_key={api_key}&timestamp={timestamp}&sign={sign}&symbol=BTCUSD"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Order.Order_getOrders().result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "current_page": 1,
        "last_page": 6,
        "data": [
            {
                "user_id": 1,
                "symbol": "BTCUSD",
                "side": "Sell",
                "order_type": "Market",
                "price": 7074,
                "qty": 2,
                "time_in_force": "ImmediateOrCancel",
                "order_status": "Filled",
                "ext_fields": {
                    "close_on_trigger": true,
                    "orig_order_type": "BLimit",
                    "prior_x_req_price": 5898.5,
                    "op_from": "pc",
                    "remark": "127.0.0.1",
                    "o_req_num": -34799032763,
                    "xreq_type": "x_create"
                },
                "last_exec_time": "1577448481.696421",
                "last_exec_price": 7070.5,
                "leaves_qty": 0,
                "leaves_value": 0,
                "cum_exec_qty": 2,
                "cum_exec_value": 0.00028283,
                "cum_exec_fee": 0.00002,
                "reject_reason": "NoError",
                "order_link_id": "",
                "created_at": "2019-12-27T12:08:01.000Z",
                "updated_at": "2019-12-27T12:08:01.000Z",
                "order_id": "f185806b-b801-40ff-adec-52289370ed62"
            }
        ]
    },
    "ext_info": null,
    "time_now": "1577448922.437871",
    "rate_limit_status": 98,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Get my active order list.

Cause order creation/cancellation is asynchronous, sometimes there is a data delay in this endpoint. You can get real-time order info in Query Active Order (real-time) endpoint.

HTTP Request

GET /open-api/order/list

Request Parameters

parameter required type comments
order_id false string Order ID
order_link_id false string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.
symbol false string Symbol. Default BTCUSD
order false string Sort orders by creation date
page false integer Page. By default, gets first page of data
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page
order_status false string Query your orders for all statuses if 'order_status' is empty. If you want to query orders with specific statuses, you can pass the order_status split by ','.

Response Parameters

parameter type comments
user_id number UserID
symbol string Symbol
side string Side
order_type string Order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
order_status string Order status
ext_fields>close_on_trigger bool What is a close on trigger order? For a closing order. It can only reduce your position, not increase it. If the account has insufficient available balance when the closing order is triggered, then other active orders of similar contracts will be cancelled or reduced. It can be used to ensure your stop loss reduces your position regardless of current available margin.
ext_fields>orig_order_type string Original special order type
ext_fields>prior_x_req_price number Expected match price
ext_fields>op_from string Source of the request
ext_fields>remark string Remark
ext_fields>o_req_num number Used to correlate request & response
ext_fields>xreq_type string Request type
last_exec_time string Last execution time
last_exec_price number Last execution price
leaves_qty number Number of unfilled contracts from the order's size
leaves_value number The estimated value corresponding to the number of remaining orders
cum_exec_qty number Cumulative qty of trading
cum_exec_value number Cumulative value of trading
cum_exec_fee number Cumulative trading fees
reject_reason string The reason the order was rejected
order_link_id string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.
created_at string Creation time
order_id string Order ID

Cancel Active Order

Request Example

curl https://api.bybit.com/v2/private/order/cancel \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","order_id":"","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Order.Order_cancel(symbol="BTCUSD", order_id="").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "user_id": 1,
        "order_id": "3bd1844f-f3c0-4e10-8c25-10fea03763f6",
        "symbol": "BTCUSD",
        "side": "Buy",
        "order_type": "Limit",
        "price": 8800,
        "qty": 1,
        "time_in_force": "GoodTillCancel",
        "order_status": "New",
        "last_exec_time": 0,
        "last_exec_price": 0,
        "leaves_qty": 1,
        "cum_exec_qty": 0,
        "cum_exec_value": 0,
        "cum_exec_fee": 0,
        "reject_reason": "",
        "order_link_id": "",
        "created_at": "2019-11-30T11:17:18.396Z",
        "updated_at": "2019-11-30T11:18:01.811Z"
    },
    "time_now": "1575112681.814760",
    "rate_limit_status": 98,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Either order_id or order_link_id are required for cancelling active orders. order_id - this unique 36 characters order ID was returned to you when the active order was created successfully.

You may cancel active orders that are unfilled or partially filled. Fully filled orders cannot be cancelled.

HTTP Request

POST /v2/private/order/cancel

Request Parameters

parameter required type comments
symbol true string Symbol
order_id false string Order ID. Required if not passing order_link_id
order_link_id false string Agency customized order ID. Required if not passing order_id

Response Parameters

parameter type comments
user_id number UserID
order_id string Order ID
symbol string Symbol
side string Side
order_type string Order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
order_status string Order status
last_exec_time string Last execution time
last_exec_price string Last execution price
leaves_qty number Number of unfilled contracts from the order's size
cum_exec_qty number Cumulative qty of trading
cum_exec_value number Cumulative value of trading
cum_exec_fee number Cumulative trading fees
reject_reason string The reason the order was rejected
order_link_id string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.
created_at string Creation time
updated_at string Update time

Cancel All Active Orders

Request Example

curl https://api.bybit.com/v2/private/order/cancelAll \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Order.cancelAll(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,      
    "ret_msg": "OK",    
    "ext_code": "",     
    "ext_info": "",
    "result": [
        {
            "clOrdID": "89a38056-80f1-45b2-89d3-4d8e3a203a79",  
            "user_id": 1,                                  
            "symbol": "BTCUSD",                                
            "side": "Buy",                                      
            "order_type": "Limit",                              
            "price": "7693.5",                                  
            "qty": 1,                                           
            "time_in_force": "GoodTillCancel",                  
            "create_type": "CreateByUser",                     
            "cancel_type": "CancelByUser",                      
            "order_status": "",                                 
            "leaves_qty": 1,                                    
            "leaves_value": "0",                                
            "created_at": "2019-11-30T10:38:53.564428Z",        
            "updated_at": "2019-11-30T10:38:59.102589Z",        
            "cross_status": "PendingCancel",  // `PendingCancel` means the matching engine received the cancellation but there is no guarantee that the cancellation will be successful.
            "cross_seq": 387734027                              
        }
    ],
    "time_now": "1575110339.105675",
    "rate_limit_status": 98,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Cancel all active orders that are unfilled or partially filled. Fully filled orders cannot be cancelled.

HTTP Request

POST /v2/private/order/cancelAll

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
clOrdID string A unique order number of type UUID
user_id number UserID
symbol string Symbol
side string Side
order_type string Order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
create_type string Trigger scenario for single action
cancel_type string Trigger scenario for cancel operation
order_status string Order status
leaves_qty number Number of unfilled contracts from the order's size
leaves_value number The estimated value corresponding to the number of remaining orders
created_at string Creation time
updated_at string Update time
cross_status string The state of initiating a matchmaking request
cross_seq number Cross sequence (internal value)

Replace Active Order

Request Example

curl https://api.bybit.com/open-api/order/replace \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","order_id":"","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Order.Order_Replace(symbol="BTCUSD", order_id="").result())

Response Example

{
    "ret_code": 0,    //Error code,
    "ret_msg": "ok",  //Error message,
    "ext_code": "",
    "result": {
        "order_id": "efa44157-c355-4a98-b6d6-1d846a936b93"
    },
    "time_now": "1539778407.210858",    // UTC timestamp
    "rate_limit_status": 99, // The remaining number of accesses in one minute
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100             
}

Replace order can modify/amend your active orders.

p_r_qty and p_r_price are the modified price and quantity. If these two fields are not provided, nothing will be modified.

It is possible to modify only the qty or price of an order.

HTTP Request

POST /open-api/order/replace

Request Parameters

parameter required type comments
order_id true string Your active order ID. The unique order ID returned to you when the corresponding active order was created
symbol true string Symbol.
p_r_qty false int New order quantity. Do not pass this field if you don't want modify it
p_r_price false number New order price. Do not pass this field if you don't want modify it

Response Parameters

parameter type comments
order_id string Order ID

Query Active Order (real-time)

Request Example

curl "https://api.bybit.com/v2/private/order?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}order_id={order_id}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Order.query().result(symbol="BTCUSD", order_id=""))

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "user_id": 106958,
        "symbol": "BTCUSD",
        "side": "Buy",
        "order_type": "Limit",
        "price": "11756.5",
        "qty": 1,
        "time_in_force": "PostOnly",
        "order_status": "Filled",
        "ext_fields": {
            "o_req_num": -68948112492,
            "xreq_type": "x_create"
        },
        "last_exec_time": "1596304897.847944",
        "last_exec_price": "11756.5",
        "leaves_qty": 0,
        "leaves_value": "0",
        "cum_exec_qty": 1,
        "cum_exec_value": "0.00008505",
        "cum_exec_fee": "-0.00000002",
        "reject_reason": "",
        "cancel_type": "",
        "order_link_id": "",
        "created_at": "2020-08-01T18:00:26Z",
        "updated_at": "2020-08-01T18:01:37Z",
        "order_id": "e66b101a-ef3f-4647-83b5-28e0f38dcae0"
    },
    "time_now": "1597171013.867068",
    "rate_limit_status": 599,
    "rate_limit_reset_ms": 1597171013861,
    "rate_limit": 600
}

Query real-time active order information.

HTTP Request

GET /v2/private/order

Request Parameters

parameter required type comments
order_id false string Order ID. Required if not passing order_link_id
order_link_id false string Agency customized order ID. Required if not passing order_id
symbol true string Symbol

Response Parameters

parameter type comments
user_id number UserID
symbol string Symbol
side string Side
order_type string Order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
order_status string Order status
ext_fields json Extension field
leaves_qty number Number of unfilled contracts from the order's size
leaves_value number The estimated value corresponding to the number of remaining orders
cum_exec_qty number Cumulative qty of trading
cum_exec_value number Cumulative value of trading
cum_exec_fee order_link_id string
reject_reason string The reason the order was rejected
cancel_type string Trigger scenario for cancel operation
order_link_id string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.
created_at string Creation time
updated_at string Update time
order_id string Order ID

Conditional Orders

Place Conditional Order

Request Example

curl https://api.bybit.com/open-api/stop-order/create \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","order_type":"Limit","side":"Buy","symbol":"BTCUSD","qty":1,"price":8100,"base_price":8300,"stop_px":8150,"time_in_force":"GoodTillCancel","order_link_id":"cus_order_id_1","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Conditional.Conditional_new(order_type="Limit",side="Buy",symbol="BTCUSD",qty=1,price=8100,base_price=8300,stop_px=8150,time_in_force="GoodTillCancel", order_link_id="cus_order_id_1").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "user_id": 1,
        "symbol": "BTCUSD",
        "side": "Buy",
        "order_type": "Limit",
        "price": 8000,
        "qty": 1,
        "time_in_force": "GoodTillCancel",
        "stop_order_type": "Stop",
        "trigger_by": "LastPrice",
        "base_price": 7000,
        "order_status": "Untriggered",
        "ext_fields": {
            "stop_order_type": "Stop",
            "trigger_by": "LastPrice",
            "base_price": 7000,
            "expected_direction": "Rising",
            "trigger_price": 7500,
            "op_from": "api",
            "remark": "127.0.01",
            "o_req_num": 0
        },
        "leaves_qty": 1,
        "leaves_value": 0.00013333,
        "reject_reason": null,
        "cross_seq": -1,
        "created_at": "2019-12-27T12:48:24.000Z",
        "updated_at": "2019-12-27T12:48:24.000Z",
        "stop_px": 7500,
        "stop_order_id": "a85cd1c0-a9a4-49d3-a1bd-bab5ebe946d5"
    },
    "ext_info": null,
    "time_now": "1577450904.327654",
    "rate_limit_status": 99,
    "rate_limit_reset_ms": 1577450904335,
    "rate_limit": "100"
}

Market price conditional order: A traditional market price order, will be filled at the best available price. price is not required for this type of order.

Limit price conditional order: You can set an execution price for your order. Only when the last traded price reaches the order price will the system will fill your order.

Take profit/Stop loss: You may only set a take-profit/stop-loss conditional order upon opening the position. Once you hold a position, the take profit and stop loss information you sent when placing an order will no longer be valid.

Order quantity: This parameter indicates the quantity of perpetual contracts you want to buy or sell, currently Bybit only support order quantity in an integer.

Order price: If it is a condition order, this parameter is required. When there is no position, the long commission price should be 10% higher than the market price and less than 1 million. If there are positions, they need to be better than strong parity. For the minimum unit of price increase or decrease, please refer to the price_filter field in the Query Symbols endpoint.

Conditional order trigger price: You may set a trigger price for your conditional order. conditional order will not enter the order book until the last price hits the trigger price. When last price hits trigger price: 1) your limit conditional order will enter order book, and wait to be executed; 2) your market conditional order will be executed immediately at the best available market price.

Customize conditional order ID: You may customize order IDs for active orders. We will link it to the system order ID , and return the unique system order ID to you after the active order is created successfully. You may use this order ID to cancel your active order. The customized order ID is asked to be unique, with a maximum length of 36 characters.

HTTP Request

POST /open-api/stop-order/create

Request Parameters

parameter required type comments
side true string Side
symbol true string Symbol
order_type true string Conditional order type
qty true integer Order quantity in USD
price false number Execution price for conditional order. Required if you make limit price order
base_price true number It will be used to compare with the value of stop_px, to decide whether your conditional order will be triggered by crossing trigger price from upper side or lower side. Mainly used to identify the expected direction of the current conditional order.
stop_px true number Trigger price
time_in_force true string Time in force
trigger_by false string Trigger price type. Default LastPrice
close_on_trigger false bool What is a close on trigger order? For a closing order. It can only reduce your position, not increase it. If the account has insufficient available balance when the closing order is triggered, then other active orders of similar contracts will be cancelled or reduced. It can be used to ensure your stop loss reduces your position regardless of current available margin.
order_link_id false string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.

Response Parameters

parameter type comments
user_id number UserID
symbol string Symbol
side string Side
order_type string Active order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
ext_fields>stop_order_type string Conditional order type
ext_fields>trigger_by string Trigger price type
ext_fields>base_price number The current market price
ext_fields>order_status string Order status
ext_fields>stop_order_type string Conditional order type
ext_fields>expected_direction string Expected direction
ext_fields>trigger_price number If stop_order_type is TrailingProfit, this field is the trailing stop active price.
ext_fields>op_from string Source of the request
remark string Remark
o_req_num number Used to correlate request & response
leaves_qty number Number of unfilled contracts from the order's size
leaves_value number The estimated value corresponding to the number of remaining orders
reject_reason string The reason the order was rejected
cross_seq number Cross sequence (internal value)
created_at string Creation time
updated_at string Update time
stop_px number Trigger price
stop_order_id string Your conditional order ID. The unique order ID returned to you when the corresponding active order was created

Get Conditional Order

Request Example

curl "https://api.bybit.com/open-api/stop-order/list?api_key={api_key}&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Conditional.Conditional_getOrders().result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "current_page": 1,
        "last_page": 1,
        "data": [
            {
                "user_id": 1,
                "stop_order_status": "Untriggered",
                "symbol": "BTCUSD",
                "side": "Buy",
                "order_type": "Limit",
                "price": 8000,
                "qty": 1,
                "time_in_force": "GoodTillCancel",
                "stop_order_type": "Stop",
                "trigger_by": "LastPrice",
                "base_price": 7000,
                "order_link_id": "",
                "created_at": "2019-12-27T12:48:24.000Z",
                "updated_at": "2019-12-27T12:48:24.000Z",
                "stop_px": 7500,
                "stop_order_id": "a85cd1c0-a9a4-49d3-a1bd-bab5ebe946d5"
            },
            {
                "user_id": 1,
                "stop_order_status": "Untriggered",
                "symbol": "BTCUSD",
                "side": "Sell",
                "order_type": "Limit",
                "price": 999999,
                "qty": 1,
                "time_in_force": "PostOnly",
                "stop_order_type": "Stop",
                "trigger_by": "LastPrice",
                "base_price": 6910.5,
                "order_link_id": "",
                "created_at": "2019-12-17T12:13:20.000Z",
                "updated_at": "2019-12-17T12:13:20.000Z",
                "stop_px": 10000000000000,
                "stop_order_id": "dea89649-9492-459d-a8c4-c298b87b3d26"
            }
        ]
    },
    "ext_info": null,
    "time_now": "1577451658.755468",
    "rate_limit_status": 599,
    "rate_limit_reset_ms": 1577451658762,
    "rate_limit": 600
}

Get my conditional order list.

Cause order creation/cancellation is asynchronous, sometimes there is a data delay in this endpoint. You can get real-time order info in Query Conditional Order (real-time) endpoint.

HTTP Request

GET /open-api/stop-order/list

Request Parameters

parameter required type comments
stop_order_id false string Your conditional order ID. The unique order ID returned to you when the corresponding active order was created
order_link_id false string Customised order ID, maximum length at 36 characters, and order ID under the same agency has to be unique.
symbol false string Symbol. Default BTCUSD
stop_order_status false string Stop order status
order false string Sort orders by creation date
page false integer Page. By default, gets first page of data
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page

Response Parameters

parameter type comments
user_id number UserID
stop_order_status string Stop order status
symbol string Symbol
side string Side
order_type string Active order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
stop_order_type string Conditional order type
trigger_by string Trigger price type
base_price number The current market price
order_link_id string Customised order ID
created_at string Creation time
updated_at string Update time
stop_px number Trigger price
stop_order_id string Your conditional order ID. The unique order ID returned to you when the corresponding active order was created

Cancel Conditional Order

Request Example

curl https://api.bybit.com/open-api/stop-order/cancel \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","order_id":"","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Conditional.Conditional_cancel(symbol="BTCUSD", order_id="").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "user_id": 1,
        "stop_order_status": "Untriggered",
        "symbol": "BTCUSD",
        "side": "Buy",
        "order_type": "Limit",
        "price": 8000,
        "qty": 1,
        "time_in_force": "GoodTillCancel",
        "stop_order_type": "Stop",
        "trigger_by": "LastPrice",
        "base_price": 7000,
        "order_link_id": "",
        "created_at": "2019-12-27T13:10:18.000Z",
        "updated_at": "2019-12-27T13:10:18.000Z",
        "stop_px": 7500,
        "stop_order_id": "c1025629-e85b-4c26-b4f3-76e86ad9f8cb"
    },
    "ext_info": null,
    "time_now": "1577452218.567120",
    "rate_limit_status": 97,
    "rate_limit_reset_ms": 1577452218573,
    "rate_limit": "100"
}

You may cancel all untriggered conditional orders. Essentially, after a conditional order is triggered, it will become an active order. So, when a conditional order is triggered, cancellation has to be done through the active order endpoint for any unfilled or partially filled active order. As always, orders that have been fully filled cannot be cancelled.

HTTP Request

POST /open-api/stop-order/cancel

Request Parameters

parameter required type comments
symbol true string Symbol
stop_order_id false string Order ID. Required if not passing order_link_id
order_link_id false string Agency customized order ID. Required if not passing stop_order_id

Response Parameters

parameter type comments
user_id number UserID
stop_order_status string Stop order status
symbol string Symbol
side string Side
order_type string Active order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
stop_order_type string Conditional order type
trigger_by string Trigger price type. Default LastPrice
base_price number The current market price
order_link_id string Customised order ID
created_at string Creation time
updated_at string Update time
stop_px number Trigger price
stop_order_id string Your conditional order ID. The unique order ID returned to you when the corresponding active order was created

Cancel All Conditional Orders

Request Example

curl https://api.bybit.com/v2/private/stop-order/cancelAll \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Conditional.Conditional_cancelAll(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": [
        {
            "clOrdID": "dea89649-9492-459d-a8c4-c298b87b3d26",
            "user_id": 1,
            "symbol": "BTCUSD",
            "side": "Sell",
            "order_type": "Limit",
            "price": "999999",
            "qty": 1,
            "time_in_force": "PostOnly",
            "create_type": "CreateByUser",
            "cancel_type": "CancelByUser",
            "order_status": "",
            "leaves_qty": 1,
            "leaves_value": "0",
            "created_at": "2019-12-17T12:13:20Z",
            "updated_at": "2019-12-27T13:56:33.793799Z",
            "cross_status": "Deactivated",
            "cross_seq": -1,
            "stop_order_type": "Stop",
            "trigger_by": "LastPrice",
            "base_price": "6910.5",
            "expected_direction": "Rising"
        },
        {
            "clOrdID": "a85cd1c0-a9a4-49d3-a1bd-bab5ebe946d5",
            "user_id": 1,
            "symbol": "BTCUSD",
            "side": "Buy",
            "order_type": "Limit",
            "price": "8000",
            "qty": 1,
            "time_in_force": "GoodTillCancel",
            "create_type": "CreateByStopOrder",
            "cancel_type": "CancelByUser",
            "order_status": "",
            "leaves_qty": 1,
            "leaves_value": "0",
            "created_at": "2019-12-27T12:48:24.339323Z",
            "updated_at": "2019-12-27T13:56:33.793802Z",
            "cross_status": "Deactivated",
            "cross_seq": -1,
            "stop_order_type": "Stop",
            "trigger_by": "LastPrice",
            "base_price": "7000",
            "expected_direction": "Rising"
        }
    ],
    "time_now": "1577454993.799912",
    "rate_limit_status": 90,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Cancel all untriggered conditional orders.

HTTP Request

POST /v2/private/stop-order/cancelAll

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
clOrdID string A unique order number of type UUID
user_id number UserID
symbol string Symbol
side string Side
order_type string Active order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
create_type string Trigger scenario for single action
cancel_type string Trigger scenario for cancel operation
order_status string Order status
leaves_qty number Number of unfilled contracts from the order's size
leaves_value number The estimated value corresponding to the number of remaining orders
created_at string Creation time
updated_at string Update time
cross_status string The state of initiating a matchmaking request
cross_seq number Cross sequence (internal value)
stop_order_type string Conditional order type
trigger_by string Trigger price type. Default LastPrice
base_price number The current market price
expected_direction string Expected direction

Replace Conditional Order

Request Example

curl https://api.bybit.com/open-api/stop-order/replace \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","stop_order_id":"","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Conditional.Conditional_replace(symbol="BTCUSD", stop_order_id="").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "stop_order_id": "378a1bbc-a93a-4e75-87f4-502ea754ba36"
    },
    "ext_info": null,
    "time_now": "1577475760.604942",
    "rate_limit_status": 96,
    "rate_limit_reset_ms": 1577475760612,
    "rate_limit": "100"
}

Replace conditional order can modify/amend your conditional orders.

order_id and symbol are required for identifying a conditional order.

p_r_qty, p_r_price and p_r_trigger_price can be set for your conditional order. If these fields are not provided, nothing will be modified.

HTTP Request

POST /open-api/stop-order/replace

Request Parameters

parameter required type comments
stop_order_id true string Your conditional order ID. The unique order ID returned to you when the corresponding active order was created
order_id true string Abandoned!! Your conditional order ID. The unique order ID returned to you when the corresponding active order was created
symbol true string Symbol.
p_r_qty false int New order quantity. Do not pass this field if you don't want modify it
p_r_price false number New order price. Do not pass this field if you don't want modify it
p_r_trigger_price false number New conditional order's trigger price, also known as stop_px. Do not pass this field if you don't want modify it

Response Parameters

parameter type comments
stop_order_id string Your conditional order ID. The unique order ID returned to you when the corresponding active order was created

Query Conditional Order (real-time)

Request Example

curl "https://api.bybit.com/v2/private/stop-order?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}order_id={order_id}&sign={sign}"

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "user_id": 1,
        "symbol": "BTCUSD",
        "side": "Buy",
        "order_type": "Limit",
        "price": "8000",
        "qty": 1,
        "time_in_force": "GoodTillCancel",
        "order_status": "Untriggered",
        "ext_fields": {},
        "leaves_qty": 1,
        "leaves_value": "0.00013333",
        "cum_exec_qty": 0,
        "cum_exec_value": null,
        "cum_exec_fee": null,
        "reject_reason": "",
        "order_link_id": "",
        "created_at": "2019-12-27T19:56:24.052194Z",
        "updated_at": "2019-12-27T19:56:24.052194Z",
        "order_id": "378a1bbc-a93a-4e75-87f4-502ea754ba36"
    },
    "time_now": "1577476584.386958",
    "rate_limit_status": 99,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Query real-time stop order information.

HTTP Request

GET /v2/private/stop-order

Request Parameters

parameter required type comments
symbol true string Symbol
stop_order_id false string Order ID. Required if not passing order_link_id
order_link_id false string Agency customized order ID. Required if not passing order_id

Response Parameters

parameter type comments
user_id number UserID
symbol string Symbol
side string Side
order_type string Active order type
price number Order price
qty number Order quantity in USD
time_in_force string Time in force
order_status string Order status
ext_fields json Extension field
leaves_qty number Number of unfilled contracts from the order's size
leaves_value number The estimated value corresponding to the number of remaining orders
cum_exec_qty number Cumulative qty of trading
cum_exec_value number Cumulative value of trading
cum_exec_fee number Cumulative trading fees
reject_reason string The reason the order was rejected
order_link_id string Customised order ID
created_at string Creation time
updated_at string Update time
order_id string Order ID

Position

My Position

Request Example

curl "https://api.bybit.com/v2/private/position/list?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Positions.Positions_myPosition(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "id": 27913,
        "user_id": 1,
        "risk_id": 1,
        "symbol": "BTCUSD",
        "side": "Buy",
        "size": 5,
        "position_value": "0.0006947",
        "entry_price": "7197.35137469",
        "auto_add_margin": 0,
        "leverage": "1",  //In Isolated Margin mode, the value is set by user. In Cross Margin mode, the value is the max leverage at current risk level
        "effective_leverage": "1", // Effective Leverage. In Isolated Margin mode, its value equals `leverage`; In Cross Margin mode, The formula to calculate:
effective_leverage = position size / mark_price / (wallet_balance + unrealised_pnl)
        "position_margin": "0.0006947",
        "liq_price": "3608",
        "bust_price": "3599",
        "occ_closing_fee": "0.00000105",
        "occ_funding_fee": "0",
        "take_profit": "0",
        "stop_loss": "0",
        "trailing_stop": "0",
        "position_status": "Normal",
        "deleverage_indicator": 4,
        "oc_calc_data": "{\"blq\":2,\"blv\":\"0.0002941\",\"slq\":0,\"bmp\":6800.408,\"smp\":0,\"fq\":-5,\"fc\":-0.00029477,\"bv2c\":1.00225,\"sv2c\":1.0007575}",
        "order_margin": "0.00029477",
        "wallet_balance": "0.03000227",
        "realised_pnl": "-0.00000126",
        "unrealised_pnl": 0,
        "cum_realised_pnl": "-0.00001306",
        "cross_seq": 444081383,
        "position_seq": 287141589,
        "created_at": "2019-10-19T17:04:55Z",
        "updated_at": "2019-12-27T20:25:45.158767Z"
    },
    "time_now": "1577480599.097287",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 120
}

Get my position list.

HTTP Request

GET /v2/private/position/list

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
id number PositionID
user_id number UserID
risk_id number Risk ID.
symbol string Symbol
side string Side
size number Position qty
position_value string Position value
entry_price string Average entry price
auto_add_margin number Whether to add margin automatically
leverage string In Isolated Margin mode, the value is set by user. In Cross Margin mode, the value is the max leverage at current risk level
effective_leverage string Effective leverage
position_margin string Position margin
liq_price string Liquidation price
bust_price string Bankruptcy price
occ_closing_fee string Position closing fee occupied (your opening fee + expected maximum closing fee)
occ_funding_fee string Pre-occupied funding fee: calculated from position qty and current funding fee
take_profit string Take profit price
stop_loss string Stop loss price
trailing_stop string Trailing stop
position_status string Position status: Normal, Liq, Adl
deleverage_indicator number Deleverage indicator level (1,2,3,4,5)
oc_calc_data string Pre-occupied calculate parameters. blq: total number of the long side unsettled orders; bmp: the lowest price of the long side; slq: total number of the short side unsettled orders; smp: the lowest price of the short side
order_margin string Pre-occupied order margin
wallet_balance string Wallet balance
realised_pnl string Today's realised pnl
unrealised_pnl number Today's unrealised pnl
cum_realised_pnl string Accumulated realised pnl (all-time total)
cross_seq number Cross sequence (internal value)
position_seq number Position sequence
created_at string The account creation time
updated_at string Update time

Change Margin

Request Example

curl https://api.bybit.com/position/change-position-margin \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD",margin:"10","timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Positions.Positions_changeMargin(symbol="BTCUSD", margin="10").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": 9.996e-05,
    "ext_info": null,
    "time_now": "1577480720.003444",
    "rate_limit_status": 74,
    "rate_limit_reset_ms": 1577480720011,
    "rate_limit": 75
}

Update margin.

HTTP Request

POST /position/change-position-margin

Request Parameters

parameter required type comments
symbol true string Symbol
margin true string margin

Response Parameters

parameter type comments
result number User margin

Set Trading-Stop

Request Example

curl https://api.bybit.com/open-api/position/trading-stop \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","stop_loss":7000,"timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Positions.Positions_tradingStop(symbol="BTCUSD",stop_loss="7000").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "id": 27913,
        "user_id": 1,
        "symbol": "BTCUSD",
        "side": "Buy",
        "size": 5,
        "position_value": 0.0006947,
        "entry_price": 7197.35137469,
        "risk_id": 1,
        "auto_add_margin": 0,
        "leverage": 6.95,
        "position_margin": 9.996e-05,
        "liq_price": 6320,
        "bust_price": 6292.5,
        "occ_closing_fee": 6e-07,
        "occ_funding_fee": 0,
        "take_profit": 0,
        "stop_loss": 7000,
        "trailing_stop": 0,
        "position_status": "Normal",
        "deleverage_indicator": 5,
        "oc_calc_data": "{\"blq\":2,\"blv\":\"0.0002941\",\"slq\":0,\"bmp\":6800.408,\"smp\":0,\"fq\":-5,\"fc\":-0.00004279,\"bv2c\":0.14549282,\"sv2c\":0.14527699}",
        "order_margin": 4.279e-05,
        "wallet_balance": 0.03000227,
        "realised_pnl": -1.26e-06,
        "cum_realised_pnl": -1.306e-05,
        "cum_commission": 0,
        "cross_seq": 444081383,
        "position_seq": 287176872,
        "created_at": "2019-10-19T17:04:55.000Z",
        "updated_at": "2019-12-27T21:17:27.000Z",
        "ext_fields": {
            "trailing_active":"9000",
            "sl_trigger_by": "LastPrice",
            "v": 221,
            "mm": 0
        }
    },
    "ext_info": null,
    "time_now": "1577481447.436689",
    "rate_limit_status": 73,
    "rate_limit_reset_ms": 1577481447443,
    "rate_limit": 75
}

Set take profit, stop loss, and trailing stop for your open position.

HTTP Request

POST /open-api/position/trading-stop

Request Parameters

parameter required type comments
symbol true string Symbol
take_profit false number Cannot be less than 0, 0 means cancel TP
stop_loss false number Cannot be less than 0, 0 means cancel SL
trailing_stop false number Cannot be less than 0, 0 means cancel TS
new_trailing_active false number Trailing stop trigger price. Trailing stops are triggered only when the price reaches the specified price. Trailing stops are triggered immediately by default.

Response Parameters

parameter type comments
id number PositionID
user_id number UserID
symbol string Symbol
side string Side
size number Position qty
position_value string Position value
entry_price string Average entry price
risk_id number Risk ID.
auto_add_margin number Whether to add margin automatically
leverage string In Isolated Margin mode, the value is set by user. In Cross Margin mode, the value is the max leverage at current risk level
position_margin string Position margin
liq_price string Liquidation price
bust_price string Bankruptcy price
occ_closing_fee string Position closing fee occupied (your opening fee + expected maximum closing fee)
occ_funding_fee string Pre-occupied funding fee: calculated from position qty and current funding fee
take_profit string Take profit price
stop_loss string Stop loss price
trailing_stop string Trailing stop
position_status string Position status: Normal, Liq, Adl
deleverage_indicator number Deleverage indicator level (1,2,3,4,5)
oc_calc_data string Pre-occupied calculate parameters. blq: total number of the long side unsettled orders; bmp: the lowest price of the long side; slq: total number of the short side unsettled orders; smp: the lowest price of the short side
order_margin string Pre-occupied order margin
wallet_balance string Wallet balance
realised_pnl string Today's realised pnl
cum_realised_pnl string Accumulated realised pnl (all-time total)
cum_commission number Accumulated commission
cross_seq number Cross sequence (internal value)
position_seq number Position sequence
created_at string Creation time
updated_at string Update time
ext_fields>trailing_active string Trailing stop active price
ext_fields>sl_trigger_by string Trigger price type

User Leverage

Request Example

curl "https://api.bybit.com/user/leverage?api_key={api_key}&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Positions.userLeverage())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "BTCUSD": {
            "leverage": 5
        },
        "EOSUSD": {
            "leverage": 1
        },
        "ETHUSD": {
            "leverage": 1
        },
        "XRPUSD": {
            "leverage": 10
        }
    },
    "ext_info": null,
    "time_now": "1577477752.346548",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1577477752355,
    "rate_limit": 120
}

Get user leverage.

HTTP Request

GET /user/leverage

Request Parameters

parameter required type comments

Response Parameters

parameter type comments
BTCUSD > leverage number BTCUSD leverage
EOSUSD > leverage number EOSUSD leverage
ETHUSD > leverage number ETHUSD leverage
XRPUSD > leverage number XRPUSD leverage

Set Leverage

Request Example

curl https://api.bybit.com/user/leverage/save \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","leverage":14,"timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Positions.Positions_saveLeverage(symbol="BTCUSD", leverage="14").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": 2,
    "ext_info": null,
    "time_now": "1577477968.175013",
    "rate_limit_status": 74,
    "rate_limit_reset_ms": 1577477968183,
    "rate_limit": 75
}

translation missing: en.account_para_setleverage

HTTP Request

POST /user/leverage/save

Request Parameters

parameter required type comments
symbol true string Symbol
leverage true number Leverage. 0 means Cross Margin mode - any other value means Isolated Margin mode

Response Parameters

parameter type comments
result number User leverage

User Trade Records

Request Example

curl "https://api.bybit.com/v2/private/execution/list?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Execution.Execution_getTrades(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "order_id": "Abandoned!!", // Abandoned!!
        "trade_list": [
            {
                "closed_size": 0, // The corresponding closing size of the closing order
                "cross_seq": 277136382,
                "exec_fee": "0.0000001",
                "exec_id": "256e5ef8-abfe-5772-971b-f944e15e0d68",
                "exec_price": "8178.5",
                "exec_qty": 1,
                "exec_time": "1571676941.70682",    //Abandoned!!
                "exec_type": "Trade", //Exec Type Enum
                "exec_value": "0.00012227",
                "fee_rate": "0.00075",
                "last_liquidity_ind": "RemovedLiquidity", //Liquidity Enum
                "leaves_qty": 0,
                "nth_fill": 2,
                "order_id": "7ad50cb1-9ad0-4f74-804b-d82a516e1029",
                "order_link_id": "",
                "order_price": "8178",
                "order_qty": 1,
                "order_type": "Market", //Order Type Enum
                "side": "Buy", //Side Enum
                "symbol": "BTCUSD", //Symbol Enum
                "user_id": 1,
                "trade_time_ms": 1577480599000
            }
        ]
    },
    "time_now": "1577483699.281488",
    "rate_limit_status": 118,
    "rate_limit_reset_ms": 1577483699244737,
    "rate_limit": 120
}

Get user's trading records. The results are ordered in ascending order (the first item is the oldest).

HTTP Request

GET /v2/private/execution/list

Request Parameters

parameter required type comments
order_id false string OrderID. If not provided, will return user's trading records
symbol true string Contract type. Required
start_time false int Start timestamp point for result, in milliseconds
page false integer Page. By default, gets first page of data
limit false integer Limit for data size per page, max size is 200. Default as showing 50 pieces of data per page
order false string Sort orders by creation date

Response Parameters

parameter type comments
closed_size number The corresponding closing size of the closing order
cross_seq number Cross sequence (internal value)
exec_fee string Transaction fee
exec_id string Transaction ID
exec_price number Transaction price
exec_qty number Transaction qty
exec_type string Exec Type Enum
exec_value string Transaction value
fee_rate string Maker or taker fee rate
last_liquidity_ind string Liquidity Enum
leaves_qty number Number of unfilled contracts from the order's size
nth_fill number The sequence of the transaction in this cross sequence data package
order_id string Order ID
order_link_id string Order link ID
order_price string Order price
order_qty string Order qty
order_type string Order Type Enum
side string Side
symbol string Symbol Enum
user_id number User ID
trade_time_ms number Transaction timestamp

Closed Profit and Loss

Request Example

curl "https://api.bybit.com/v2/private/trade/closed-pnl/list?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Execution.Execution_closed_pnl(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "current_page": 1,
        "data": [
            {
                "id": 9982,
                "user_id": 160320,
                "symbol": "BTCUSD",
                "order_id": "e976ac13-10e7-4883-a7ba-13b0e93659f1",
                "side": "Sell",
                "qty": 226,
                "order_price": 1600,
                "order_type": "Limit",
                "exec_type": "Trade",
                "closed_size": 113,
                "cum_entry_value": 0.07062500000000001,
                "avg_entry_price": 1600,
                "cum_exit_value": 0.066198,
                "avg_exit_price": 1707,
                "closed_pnl": 0.0043950000000000005,
                "fill_count": 1,
                "leverage": 100,
                "created_at": 1591155741
            }
        ]
    },
    "time_now": "1591173153.876047",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1591173153852,
    "rate_limit": 120
}

Get user's closed profit and loss records. The results are ordered in descending order (the first item is the latest).

HTTP Request

GET /v2/private/trade/closed-pnl/list

Request Parameters

parameter required type comments
symbol true string Symbol
start_time false int Start timestamp point for result, in seconds
end_time false int End timestamp point for result, in seconds
exec_type false string Execution type
page false integer Page. By default, gets first page of data. Maximum of 50 pages
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page.

Response Parameters

parameter type comments
id number PositionID
user_id number UserID
symbol string Symbol
order_id string Order ID
side string Side
qty number Order quantity in USD
order_price number Order price
order_type string Active order type
exec_type string Exec Type Enum
closed_size number The corresponding closing size of the closing order
cum_entry_value number Closed position value
avg_entry_price number Average entry price
cum_exit_value number Cumulative trading value of position closing orders
avg_exit_price number Average exit price
closed_pnl number Closed Profit and Loss
fill_count number Number of transactions
leverage number In Isolated Margin mode, the value is set by user. In Cross Margin mode, the value is the max leverage at current risk level
created_at number Creation time

Risk Limit

Get Risk Limit

Request Example

curl "https://api.bybit.com/open-api/wallet/risk-limit/list?api_key={api_key}&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Wallet.Wallet_getRiskLimit().result())

Response Example

{
  "ret_code": 0,
  "ret_msg": "ok",
  "ext_code": "",
  "result": [
    {
      "id": 1,
      "coin": "BTC",
      "limit": 150,
      "maintain_margin": "0.50",
      "starting_margin": "1.00",
      "section": [
        "1",
        "2",
        "3",
        "5",
        "10",
        "25",
        "50",
        "100"
      ],
      "is_lowest_risk": 1,
      "created_at": "2018-11-09T13:53:04.000Z",
      "updated_at": "2018-11-09T13:53:04.000Z"
    },
    {
      "id": 11,
      "coin": "ETH",
      "limit": 3000,
      "maintain_margin": "1.00",
      "starting_margin": "2.00",
      "section": [
        "1",
        "2",
        "3",
        "5",
        "15",
        "30",
        "40",
        "50"
      ],
      "is_lowest_risk": 1,
      "created_at": "2019-01-25T08:31:54.000Z",
      "updated_at": "2019-01-25T08:31:54.000Z"
    }
  ],
  "ext_info": null,
  "time_now": "1577587907.157396",
  "rate_limit_status": 99,
  "rate_limit_reset_ms": 1577587907162,
  "rate_limit": 100
}

Get risk limit.

HTTP Request

GET /open-api/wallet/risk-limit/list

Request Parameters

parameter required type comments

Response Parameters

parameter type comments
id number Risk ID.
coin string Coin type
limit number Risk limit
maintain_margin string Maintain margin
starting_margin string Starting margin
section string Section
is_lowest_risk number Is lowest risk. 0: Yes; 1: No
created_at string Creation time
updated_at string Update time

Set Risk Limit

Request Example

curl https://api.bybit.com/open-api/wallet/risk-limit \
-H "Content-Type: application/json" \
-d '{"api_key":"{api_key}","symbol":"BTCUSD","risk_id":2,"timestamp":{timestamp},"sign":"{sign}"}'
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Wallet.Wallet_setRiskLimit(symbol="BTCUSD", risk_id=2).result())

Response Example

{
  "ret_code": 0,
  "ret_msg": "ok",
  "ext_code": "",
  "result": {
    "position": {
      "id": 1,
      "user_id": 1,
      "symbol": "BTCUSD",
      "side": "None",
      "size": 0,
      "position_value": 0,
      "entry_price": 0,
      "risk_id": 2,
      "auto_add_margin": 0,
      "leverage": 1,
      "position_margin": 0,
      "liq_price": 0,
      "bust_price": 0,
      "occ_closing_fee": 0,
      "occ_funding_fee": 0,
      "take_profit": 0,
      "stop_loss": 0,
      "trailing_stop": 0,
      "position_status": "Normal",
      "deleverage_indicator": 0,
      "oc_calc_data": "{\"blq\":1,\"blv\":\"0.000125\",\"slq\":0,\"bmp\":8000,\"smp\":0,\"fc\":-0.00012529,\"bv2c\":1.00225,\"sv2c\":1.0007575}",
      "order_margin": 0.00012529,
      "wallet_balance": 1000,
      "realised_pnl": 0,
      "cum_realised_pnl": 0,
      "cum_commission": 0,
      "cross_seq": 4376,
      "position_seq": 13689,
      "created_at": "2019-08-13T06:51:29.000Z",
      "updated_at": "2019-12-29T03:11:08.000Z",
      "ext_fields": {
        "trailing_active": "9000",
        "v": 4
      }
    },
    "risk": {
      "id": 2,
      "coin": "BTC",
      "limit": 300,
      "maintain_margin": "1.00",
      "starting_margin": "1.50",
      "section": "[\"1\",\"2\",\"3\",\"5\",\"10\",\"25\",\"50\",\"66\"]",
      "is_lowest_risk": 0,
      "created_at": "2019-06-26T05:46:45.000Z",
      "updated_at": "2019-06-26T05:46:55.000Z"
    }
  },
  "ext_info": null,
  "time_now": "1577589068.435439",
  "rate_limit_status": 71,
  "rate_limit_reset_ms": 1577589068546,
  "rate_limit": 75
}

Set risk limit.

HTTP Request

POST /open-api/wallet/risk-limit

Request Parameters

parameter required type comments
symbol true string Symbol
risk_id true integer Risk ID.

Response Parameters

parameter type comments
position > id number PositionID
user_id number UserID
symbol string Symbol
side string Side
size number Position qty
position_value number Position value
entry_price number Average entry price
risk_id number Risk ID.
auto_add_margin number Whether to add margin automatically
leverage number In Isolated Margin mode, the value is set by user. In Cross Margin mode, the value is the max leverage at current risk level
position_margin number Position margin
liq_price number Liquidation price
bust_price number Bankruptcy price
occ_closing_fee number Position closing fee occupied (your opening fee + expected maximum closing fee)
occ_funding_fee number Pre-occupied funding fee: calculated from position qty and current funding fee
take_profit number Take profit price
stop_loss number Stop loss price
trailing_stop number Trailing stop
position_status string Position status: Normal, Liq, Adl
deleverage_indicator number Deleverage indicator level (1,2,3,4,5)
oc_calc_data string Pre-occupied calculate parameters. blq: total number of the long side unsettled orders; bmp: the lowest price of the long side; slq: total number of the short side unsettled orders; smp: the lowest price of the short side
order_margin number Pre-occupied order margin
wallet_balance number Wallet balance
realised_pnl number Today's realised pnl
cum_realised_pnl number Accumulated realised pnl (all-time total)
cum_commission number Accumulated commission
cross_seq number Cross sequence (internal value)
position_seq number Position sequence
created_at string Creation time
updated_at string Update time
ext_fields>trailing_active string Trailing stop active price
risk>id number Risk ID.
risk>coin string Coin type
risk>limit number Risk limit
risk>maintain_margin string Maintain margin
risk>starting_margin string Starting margin
risk>section string Section
risk>is_lowest_risk number Is lowest risk. 0: Yes; 1: No
risk>created_at string Creation time
risk>updated_at string Update time

Funding

Get the Last Funding Rate

Request Example

curl "https://api.bybit.com/open-api/funding/prev-funding-rate?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Funding.Funding_prevRate(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "symbol": "BTCUSD",
        "funding_rate": "0.00010000",
        "funding_rate_timestamp": 1577433600
    },
    "ext_info": null,
    "time_now": "1577445586.446797",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1577445586454,
    "rate_limit": 120
}

The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.

HTTP Request

GET /open-api/funding/prev-funding-rate

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
symbol string Symbol
funding_rate string Funding rate
funding_rate_timestamp number Funding rate timestamp

My Last Funding Fee

Request Example

curl "https://api.bybit.com/open-api/funding/prev-funding?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Funding.Funding_myLastFee(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "symbol": "BTCUSD",
        "side": "Buy",  // Your position side at the time of settlement
        "size": 1,      // Your position size at the time of settlement
        "funding_rate": 0.0001,  // Funding rate for settlement. When the funding rate is positive, longs pay shorts. When it is negative, shorts pay longs.
        "exec_fee": 0.00000002,  // Funding fee.
        "exec_timestamp": 1575907200  // The time of funding settlement occurred, UTC timestamp
    },
    "ext_info": null,
    "time_now": "1577446900.717204",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1577446900724,
    "rate_limit": 120
}

Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval's fund fee settlement is based on the previous interval's fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 the next day.

HTTP Request

GET /open-api/funding/prev-funding

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
symbol string Symbol
side string Your position side at the time of settlement
size number Your position size at the time of settlement
funding_rate number Funding rate
exec_fee number Transaction fee
exec_timestamp number Transaction time

Predicted Funding Rate and My Funding Fee

Request Example

curl "https://api.bybit.com/open-api/funding/predicted-funding?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Funding.Funding_predicted(symbol="BTCUSD").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "predicted_funding_rate": 0.0001,
        "predicted_funding_fee": 0
    },
    "ext_info": null,
    "time_now": "1577447415.583259",
    "rate_limit_status": 118,
    "rate_limit_reset_ms": 1577447415590,
    "rate_limit": 120
}

Get predicted funding rate and my funding fee.

HTTP Request

GET /open-api/funding/predicted-funding

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
predicted_funding_rate number Predicted funding rate
predicted_funding_fee number Predicted funding fee

API Key Info

Request Example

curl "https://api.bybit.com/open-api/api-key?api_key={api_key}&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.APIkey.APIkey_info().result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": [
        {
            "api_key": "7GkMBBLTbGRfa0Nuh1",
            "type": "personal",
            "user_id": 1,
            "inviter_id": 3,
            "ips": [
                "*"
            ],
            "note": "scalping_bot",
            "permissions": [
                "Order",
                "Position"
            ],
            "created_at": "2019-10-28T13:22:39.000Z",
            "expired_at": "2020-01-28T13:22:39.000Z",
            "read_only": false
        }
    ],
    "ext_info": null,
    "time_now": "1577445138.790150",
    "rate_limit_status": 99,
    "rate_limit_reset_ms": 1577445138812,
    "rate_limit": 100
}

Get user's API key info.

HTTP Request

GET /open-api/api-key

Request Parameters

parameter required type comments

Response Parameters

parameter type comments
api_key string API key
type string Key type
user_id number User ID
inviter_id number Inviter ID
ips string IP
note string Note
permissions string ApiKey permission
created_at string Creation time
expired_at string Expire time
read_only bool ReadOnly

LCP Info

Request Example

curl "https://api.bybit.com/v2/private/account/lcp?api_key={api_key}&symbol=BTCUSD&timestamp={timestamp}&sign={sign}"

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": [
        {
            "date": "2020-04-27",
            "self_ratio": 1.1251,
            "platform_ratio": 0.001254,
            "score": 0.1459
        },
        {
            "date": "2020-04-26",
            "self_ratio": 1.1251,
            "platform_ratio": 0.001254,
            "score": 0.1459
        }
    ],
    "ext_info": null,
    "time_now": "1577445138.790150",
    "rate_limit_status": 99,
    "rate_limit_reset_ms": 1577445138812,
    "rate_limit": 100
}

Get user's LCP (data refreshes once an hour). Only supports inverse perpetual at present.

See Understanding Bybit's Liquidity System to learn more.

HTTP Request

GET /v2/private/account/lcp

Request Parameters

parameter required type comments
symbol true string Symbol

Response Parameters

parameter type comments
date string Date
self_ratio number Personal effective ratio
platform_ratio number Platform effective ratio
score number Liquidity contribution points

Wallet Data Endpoints

The following wallet data endpoints require authentication.

Get Wallet Balance

Request Example

curl "https://api.bybit.com/v2/private/wallet/balance?api_key={api_key}&coin=BTC&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Wallet.Wallet_getBalance(coin="BTC").result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {
        "BTC": {
            "equity": 1002,                         //equity = wallet_balance + unrealised_pnl
            "available_balance": 999.99987471,      //available_balance
            //In Isolated Margin Mode:
            // available_balance = wallet_balance - (position_margin + occ_closing_fee + occ_funding_fee + order_margin)
            //In Cross Margin Mode:
              //if unrealised_pnl > 0:
              //available_balance = wallet_balance - (position_margin + occ_closing_fee + occ_funding_fee + order_margin);
              //if unrealised_pnl < 0:
              //available_balance = wallet_balance - (position_margin + occ_closing_fee + occ_funding_fee + order_margin) + unrealised_pnl
            "used_margin": 0.00012529,              //used_margin = wallet_balance - available_balance
            "order_margin": 0.00012529,             //Used margin by order
            "position_margin": 0,                   //position margin
            "occ_closing_fee": 0,                   //position closing fee
            "occ_funding_fee": 0,                   //funding fee
            "wallet_balance": 1000,                 //wallet balance. When in Cross Margin mod, the number minus your unclosed loss is your real wallet balance.
            "realised_pnl": 0,                      //daily realized profit and loss
            "unrealised_pnl": 2,                    //unrealised profit and loss
                //when side is sell:
                // unrealised_pnl = size * (1.0 / mark_price -  1.0 / entry_price)
                //when side is buy:
                // unrealised_pnl = size * (1.0 / entry_price -  1.0 / mark_price)
            "cum_realised_pnl": 0,                  //total relised profit and loss
            "given_cash": 0,                        //given_cash
            "service_cash": 0                       //service_cash
        }
    },
    "time_now": "1578284274.816029",
    "rate_limit_status": 98,
    "rate_limit_reset_ms": 1580885703683,
    "rate_limit": 100
}

Get wallet balance info.

HTTP Request

GET /v2/private/wallet/balance

Request Parameters

parameter required type comments
coin false string currency alias. Returns all wallet balances if not passed

Response Parameters

parameter type comments
equity number User equity
available_balance number Available balance = wallet balance - position margin
used_margin number Used margin
order_margin number Pre-occupied order margin
position_margin number Position margin
occ_closing_fee number Position closing fee occupied (your opening fee + expected maximum closing fee)
occ_funding_fee number Pre-occupied funding fee: calculated from position qty and current funding fee
wallet_balance number Wallet balance
realised_pnl number Today's realised pnl
unrealised_pnl number Today's unrealised pnl
cum_realised_pnl number Accumulated realised pnl (all-time total)
given_cash number Experience gold
service_cash number Service cash is used for user's service charge

Wallet Fund Records

Request Example

curl "https://api.bybit.com/open-api/wallet/fund/records?api_key={api_key}&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Wallet.Wallet_getRecords().result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "ok",
    "ext_code": "",
    "result": {
        "data": [
            {
                "id": 235853,
                "user_id": 1,
                "coin": "BTC",
                "wallet_id": 27913,
                "type": "Realized P&L",
                "amount": "0.00000023",
                "tx_id": "",
                "address": "BTCUSD",
                "wallet_balance": "0.03000353",
                "exec_time": "2019-12-10T00:00:29.000Z",
                "cross_seq": 0
            },
            {
                "id": 234467,
                "user_id": 1,
                "coin": "BTC",
                "wallet_id": 27913,
                "type": "Realized P&L",
                "amount": "-0.00000006",
                "tx_id": "",
                "address": "BTCUSD",
                "wallet_balance": "0.03000330",
                "exec_time": "2019-12-09T00:00:25.000Z",
                "cross_seq": 0
            }
        ]
    },
    "ext_info": null,
    "time_now": "1577481867.115552",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1577481867122,
    "rate_limit": 120
}

Get wallet fund records. This endpoint also shows exchanges from the Asset Exchange, where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.

HTTP Request

GET /open-api/wallet/fund/records

Request Parameters

parameter required type comments
start_date false string Start point for result
end_date false string End point for result
currency false string Currency type
coin false string currency alias
wallet_fund_type false string Wallet fund type
page false integer Page. By default, gets first page of data
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page

Response Parameters

parameter type comments
user_id number UserID
coin string Coin type
type string Fund type
amount string Fund amount
tx_id string Transaction hash ID
address string Address
wallet_balance string Wallet balance
exec_timestamp string Transaction time
cross_seq number Cross sequence (internal value)

Withdraw Records

Request Example

curl "https://api.bybit.com/open-api/wallet/withdraw/list?api_key={api_key}&timestamp={timestamp}&sign={sign}"
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Wallet.Wallet_withdraw().result())

Response Example

{
  "ret_code": 0,
  "ret_msg": "ok",
  "ext_code": "",
  "result": {
      "data": [{
          "id": 137,                                        
          "user_id": 1,                                     
          "coin": "XRP",  //Coin Enum                                    
          "status": "Pending" //Withdraw Status Enum
          "amount": "20.00000000",
          "fee": "0.25000000",
          "address": "rH7H595XYEVTEHU2FySYsWnmfACBnZS9zM",
          "tx_id": "",
          "submited_at": "2019-06-11T02:20:24.000Z",
          "updated_at": "2019-06-11T02:20:24.000Z"
      }]
      "current_page": 1,
      "last_page": 1
  },
  "ext_info": null,
  "time_now": "1577482295.125488",
  "rate_limit_status": 119,
  "rate_limit_reset_ms": 1577482295132,
  "rate_limit": 120
}

Get withdrawal records.

HTTP Request

GET /open-api/wallet/withdraw/list

Request Parameters

parameter required type comments
start_date false string Start point for result
end_date false string End point for result
coin false string Currency type
status false string Withdraw Status Enum
page false integer Page. By default, gets first page of data
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page

Response Parameters

parameter type comments
user_id number UserID
coin string Coin type
status string Withdraw Status Enum
amount string Fund amount
fee string Maker or taker fee rate
address string Address
tx_id string Transaction hash ID
submited_at string Submit time
updated_at string Update time

Asset Exchange Records

Request Example

curl "https://api.bybit.com/v2/private/exchange-order/list?api_key={api_key}&timestamp={timestamp}&sign={sign}"

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": [
        {
            "id": 31,
            "exchange_rate": 40.57202774,
            "from_coin": "BTC",
            "to_coin": "ETH",
            "to_amount": 4.05720277,
            "from_fee": 0.0005,
            "from_amount": 0.1,
            "created_at": "2020-06-15 03:32:52"
        },
        {
            "id": 30,
            "exchange_rate": 39.92359901,
            "from_coin": "BTC",
            "to_coin": "ETH",
            "to_amount": 39.923599,
            "from_fee": 0.0005,
            "from_amount": 1,
            "created_at": "2020-06-12 08:27:51"
        }
    ],
    "time_now": "1592554785.486414",
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1592554785484,
    "rate_limit": 120
}

Get asset exchange records.

HTTP Request

GET /v2/private/exchange-order/list

Request Parameters

parameter required type comments
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page
from false integer Start ID. By default, returns the latest IDs
direction false string Search direction. Prev: searches in ascending order from start ID, Next: searches in descending order from start ID. Defaults to Next

Response Parameters

parameter type comments
from_coin string Exchange from coin
from_amount number Exchange from amount
to_coin string Exchange to coin
to_amount number Exchange to amount
exchange_rate number Exchange exchange rate
from_fee number Exchange fee in `from_coin` unit
created_at string Exchange time

API Data Endpoints

The following API data endpoints do not require authentication.

Server Time

Request Example

curl https://api-testnet.bybit.com/v2/public/time
import bybit
client = bybit.bybit(test=True, api_key="api_key", api_secret="api_secret")
print(client.Common.Common_get().result())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {},
    "time_now": "1577444332.192859"
}

Get Bybit server time.

HTTP Request

GET /v2/public/time

Request Parameters

parameter required type comments

Announcement

Request Example

curl https://api.bybit.com/v2/public/announcement

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": [
        {
            "id": 2,
            "title": "2019-12-02 RELEASE",
            "link": "https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/CHANGELOG.md",
            "summary": "<p>New `cancel all` endpoint is here now!</p><p>Additionally, we strongly recommend that you use the new released place and cancel active V2 endpoints, which are more stable and efficient.The old ones are deprecated (although still working for the time be",
            "created_at": "2019-12-02T11:33:42Z"
        }
    ],
    "time_now": "1577444818.227082"
}

Get Bybit OpenAPI announcements in the last 30 days in reverse order.

HTTP Request

GET /v2/public/announcement

Request Parameters

parameter required type comments

API Rate Limits

IP Rate Limit

Bybit has different IP frequency limits for GET and POST method:

Understanding Your Request Rate Limit

Bybit makes frequency limits based on the rolling time window per minute and UID, and each symbol is independent. Every request to the API returns the fields shown in the code panel:

"rate_limit_status": 119,
"rate_limit_reset_ms": 1572114055663,
"rate_limit": 120

Rate Limits For All Private Endpoints

limit path consume
100/min open-api/order/create 1 / request
open-api/order/cancel 1 / request
open-api/stop-order/create 1 / request
open-api/stop-order/cancel 1 / request
open-api/order/replace 1 / request
open-api/stop-order/replace 1 / request
v2/private/order/create 1 / request
v2/private/order/cancel 1 / request
v2/private/order/cancelAll 10 / request
v2/private/stop-order/cancelAll 10 / request
600/min open-api/order/list 1 / request
open-api/stop-order/list 1 / request
v2/private/order 1 / request
120/min v2/private/execution/list 1 / request
75/min user/leverage/save 1 / request
position/change-position-margin 1 / request
position/trading-stop 1 / request
120/min position/list 1 / request
user/leverage1 / request
v2/private/position/list1 / request
v2/private/wallet/balance1 / request
120/min open-api/funding/prev-funding-rate 1 / request
open-api/funding/prev-funding 1 / request
open-api/funding/predicted-funding 1 / request
120/min open-api/wallet/fund/records 1 / request
open-api/wallet/withdraw/list 1 / request
600/min open-api/api-key 1 / request

Order Limits

The number of orders per instrument that can be held entirely simultaneously:

How to Raise Your API Limit

Understanding Bybit's Liquidity System

Bybit uses an Order Fill Ratio (OFR) and Liquidity Contribution Points (LCP) to measure customers' contribution to our executable liquidity.

The LCP and OFR of different symbols are calculated separately.

Order Fill Ratio (OFR) Threshold

If you place more than 2000 orders per day on Bybit, please maintain your 7-day OFR above a Minimum OFR threshold, or Bybit may reduce your API request frequency limit.

Order Fill Ratio (OFR)

Order Fill Ratio Example
User A:
Orders Filled = 2
Orders Submitted to Bybit = 8
QFR = 2/8 = 25%

User B:
Orders Filled = 1
Orders Submitted to Bybit = 1
QFR = 1/1 = 100%

Minimum OFR Threshold

7-day OFR must be kept above 0.1%.

API Request Frequency Limits

Your API request frequency limit is based on your min Liquidity Contribution Points (LCP) of 7 days.

LCP Order Frequency Limit
20-100 800 times per minute
10-20 600 times per minute
5-10 400 times per minute
2-5 200 times per minute
<2 100 times per minute
Liquidity Contribution Points (LCP)

Explanation
Effective Price Range

Effective Price Range Example
BTC best bid = 10000
BTC best ask = 10001
Effective Price Range: [(10000 + 10001) / 2 - 3* 0.5, (10000 + 10001) / 2 + 3* 0.5] = [9999,10002]

POU

Bybit calculates your amount of orders within effective price range / amount of all your orders in orderbook, and then performs a 1-Day Time-Weighted-Average over the series of seconds rates.

amount of User C's orders within effective price range = 8000
amount of all User C's orders = 2000 + 8000 = 10000
POU = 8000 / 10000 = 0.8

POA

Bybit calculates your amount of orders within effective price range / amount of all orders within effective price range in orderbook, and then performs a 1-Day Time-Weighted-Average over the series of seconds rates.

POA example

User C only has 8000 contracts within effective price range, while Bybit have 200000 contracts within effective price range in orderbook.

amount of User C's orders within effective price range = 8000
amount of all orders within effective price range = 200000
POA = 8000 / 200000 = 0.04

WebSocket Data

Authentication

Authentication methods:

First method: Apply for authentication when establishing a connection.

var api_key = "";
var secret = "";
// A UNIX timestamp after which the request become invalid. This is to prevent replay attacks.
// unit:millisecond
var expires = time.now()+1000;

// Signature
var signature = hex(HMAC_SHA256(secret, 'GET/realtime' + expires));

// Parameters string
var param = "api_key={api_key}&expires={expires}&signature={signature}";

// Establishing connection
var ws = new WebSocket("wsurl?param");

Second method: Apply for authentication after establishing a connection through auth request.

var ws = new WebSocket("wsurl")
// Signature is the same for both methods of authentication
ws.send('{"op":"auth","args":["{api_key}","{expires}","{signature}"]}');

Base endpoints:

There are two methods of authentication, as shown in the code panel to the right.

How to Send the Heartbeat Packet

How to Send

ws.send('{"op":"ping"}');

Response Example

{
    "success": true, // Whether ping is successful
    "ret_msg": "pong",
    "conn_id": "036e5d21-804c-4447-a92d-b65a44d00700",// current connection id
    "request": {
        "op": "ping",
        "args": null
    }
}

How to Subscribe to Topics

Understanding Websocket Filters

How to subscribe with a filter

// Subscribing to the trade data for ETHBTC
ws.send('{"op":"subscribe","args":["trade.ETHBTC"]}')

How to subscribe with multiple filters

// Example: Subscribing to the trade data for BTCUSD and XRPUSD
ws.send('{"op":"subscribe","args":["trade.BTCUSD|XRPUSD"]}')

How to subscribe without filters

// Example: Subscribing to the trade data for all symbols
ws.send('{"op": "subscribe", "args": ["trade.*"]}')

After establishing the connection, one can subscribe to a new topic by sending a JSON request. The specific formats are as follows:

ws.send('{"op": "subscribe", "args": ["topic.filter"]}');

The topic indicates the data you would like to receive whilst the filter parses for the specific data you desire - for example, the symbol. The topic is mandatory but the filter is optional.

To subscribe to more than one topic, simply list multiple topics out, like so:

ws.send('{"op": "subscribe", "args": ["topic.filter", "topic.filter"]}');

It is possible to use multiple filters for the same topic by splitting them with a pipe (|) - of course, these filters must all be applicable to the selected topic.

Finally, to subscribe to the topic without filters please use the * wildcard.

Intervals

Some topics are pushed at intervals. If the args contain a millisecond param, such as 100ms, this topic is pushed at intervals. Otherwise, it is pushed constantly.

Understanding the Subscription Response

Subscription Response

{
   "success": true, // Whether subscription is successful
   "ret_msg": "",   // Successful subscription: "", otherwise it shows error message
   "conn_id":"e0e10eee-4eff-4d21-881e-a0c55c25e2da",// current connection id
   "request": {     // Request to your subscription
       "op": "subscribe",
       "args": [
           "kline.BTCUSD.1m"
       ]
   }
}

Every subscription will have a response.

Public Topics

orderBookL2_25

How to Subscribe

ws.send('{"op": "subscribe", "args": ["orderBookL2_25.BTCUSD"]}');
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=None, api_secret=None)
ws.subscribe_orderBookL2(symbol="BTCUSD")
while True:
    data = ws.get_data("orderBookL2_25.BTCUSD")
    if data:
        print(data)

Snapshot Response Example - format of the first response

{
     "topic": "orderBookL2_25.BTCUSD",
     "type": "snapshot",
     "data": [
        {
            "price": "2999.00",
            "symbol": "BTCUSD",
            "id": 29990000,
            "side": "Buy",
            "size": 9
        },
        {
            "price": "3001.00",
            "symbol": "BTCUSD",
            "id": 30010000,
            "side": "Sell",
            "size": 10
        }
     ],
     "cross_seq": 11518,
     "timestamp_e6": 1555647164875373
}

Delta Response Example - format of the responses following the snapshot response

{
     "topic": "orderBookL2_25.BTCUSD",
     "type": "delta",
     "data": {
          "delete": [
             {
                   "price": "3001.00",
                   "symbol": "BTCUSD",
                   "id": 30010000,
                   "side": "Sell"
             }
          ],
          "update": [
             {
                   "price": "2999.00",
                   "symbol": "BTCUSD",
                   "id": 29990000,
                   "side": "Buy",
                   "size": 8
             }
          ],
          "insert": [
             {
                   "price": "2998.00",
                   "symbol": "BTCUSD",
                   "id": 29980000,
                   "side": "Buy",
                   "size": 8
             }
          ],
          "transactTimeE6": 0
     },
     "cross_seq": 11519,
     "timestamp_e6": 1555647221331673
}

Fetches the orderbook with a depth of 25 orders per side.

After the subscription response, the first response will be the snapshot response. This shows the entire orderbook. The data is ordered by price, starting with the lowest buys and ending with the highest sells.

Following this, all responses are in the delta format, which represents updates to the orderbook relative to the last response.

Response Parameters

parameter type comments
price string Order price
symbol string Symbol
side string Side
size number Position qty

orderBookL2_200

How to Subscribe

ws.send('{"op": "subscribe", "args": ["orderBook_200.100ms.BTCUSD"]}');

Snapshot Response Example - format of the first response

{
     "topic": "orderBook_200.100ms.BTCUSD",
     "type": "snapshot",
     "data": [
        {
            "price": "2999.00",
            "symbol": "BTCUSD",
            "id": 29990000,
            "side": "Buy",
            "size": 9
        },
        {
            "price": "3001.00",
            "symbol": "BTCUSD",
            "id": 30010000,
            "side": "Sell",
            "size": 10
        }
     ],
     "cross_seq": 11518,
     "timestamp_e6": 1555647164875373
}

Delta Response Example - format of the responses following the snapshot response

{
     "topic": "orderBook_200.100ms.BTCUSD",
     "type": "delta",
     "data": {
          "delete": [
             {
                   "price": "3001.00",
                   "symbol": "BTCUSD",
                   "id": 30010000,
                   "side": "Sell"
             }
          ],
          "update": [
             {
                   "price": "2999.00",
                   "symbol": "BTCUSD",
                   "id": 29990000,
                   "side": "Buy",
                   "size": 8
             }
          ],
          "insert": [
             {
                   "price": "2998.00",
                   "symbol": "BTCUSD",
                   "id": 29980000,
                   "side": "Buy",
                   "size": 8
             }
          ],
          "transactTimeE6": 0
     },
     "cross_seq": 11519,
     "timestamp_e6": 1555647221331673
}

Fetches the orderbook with a depth of 200 orders per side.

After the subscription response, the first response will be the snapshot response. This shows the entire orderbook. The data is ordered by price, starting with the lowest buys and ending with the highest sells.

Following this, all responses are in the delta format, which represents updates to the orderbook relative to the last response.

Response Parameters

parameter type comments
price string Order price
symbol string Symbol
side string Side
size number Position qty

trade

How to Subscribe

ws.send('{"op": "subscribe", "args": ["trade"]}')
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=None, api_secret=None)
ws.subscribe_trade()
while True:
    data = ws.get_data("trade.BTCUSD")
    if data:
        print(data)

Response Example - format of all responses

{
    "topic": "trade.BTCUSD",
    "data": [
        {
            "timestamp": "2020-01-12T16:59:59.000Z",
            "trade_time_ms": 1582793344685, // trade time in millisecond
            "symbol": "BTCUSD",
            "side": "Sell",
            "size": 328,
            "price": 8098,
            "tick_direction": "MinusTick",
            "trade_id": "00c706e1-ba52-5bb0-98d0-bf694bdc69f7",
            "cross_seq": 1052816407
        }
    ]
}

Get real-time trading information.

Response Parameters

parameter type comments
time string UTC time
trade_time_ms number Millisecond timestamp
symbol string Symbol
side string Side
size number Position qty
price number Order price
tick_direction string Direction of price change
trade_id string Trade ID
cross_seq number Cross sequence (internal value)

insurance

How to Subscribe

ws.send('{"op": "subscribe", "args": ["insurance"]}')
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=None, api_secret=None)
ws.subscribe_insurance()
while True:
    data = ws.get_data("insurance.BTC")
    if data:
        print(data)

Response Example - format of all responses

{
    "topic": "insurance.BTC",
    "data": [
        {
            "currency": "BTC",
            "timestamp": "2020-01-11T20:00:00Z",
            "wallet_balance": 98786916569
        }
    ]
}

Get the daily insurance fund update.

Response Parameters

parameter type comments
currency string Currency type
timestamp string UTC time
wallet_balance number Wallet balance

instrument_info

How to Subscribe

ws.send('{"op": "subscribe", "args": ["instrument_info.100ms.BTCUSD"]}')
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=None, api_secret=None)
ws.subscribe_instrument_info(symbol="BTCUSD")
while True:
    data = ws.get_data("instrument_info.100ms.BTCUSD")
    if data:
        print(data)

Snapshot Response Example - format of the first response

{
    "topic": "instrument_info.100ms.BTCUSD",
    "type": "snapshot",
    "data": {
        "id": 1,
        "symbol": "BTCUSD",                           //instrument name
        "last_price_e4": 81165000,                    //the latest price
        "last_tick_direction": "ZeroPlusTick",        //the direction of last tick:PlusTick,ZeroPlusTick,MinusTick,ZeroMinusTick
        "prev_price_24h_e4": 81585000,                //the price of prev 24h
        "price_24h_pcnt_e6": -5148,                   //the current last price percentage change from prev 24h price
        "high_price_24h_e4": 82900000,                //the highest price of prev 24h
        "low_price_24h_e4": 79655000,                 //the lowest price of prev 24h
        "prev_price_1h_e4": 81395000,                 //the price of prev 1h
        "price_1h_pcnt_e6": -2825,                    //the current last price percentage change from prev 1h price
        "mark_price_e4": 81178500,                    //mark price
        "index_price_e4": 81172800,                   //index price
        "open_interest": 154418471,                   //open interest quantity - Attention, the update is not immediate - slowest update is 1 minute
        "open_value_e8": 1997561103030,               //open value quantity - Attention, the update is not immediate - the slowest update is 1 minute
        "total_turnover_e8": 2029370141961401,        //total turnover
        "turnover_24h_e8": 9072939873591,             //24h turnover
        "total_volume": 175654418740,                 //total volume
        "volume_24h": 735865248,                      //24h volume
        "funding_rate_e6": 100,                       //funding rate
        "predicted_funding_rate_e6": 100,             //predicted funding rate
        "cross_seq": 1053192577,                      //sequence
        "created_at": "2018-11-14T16:33:26Z",         
        "updated_at": "2020-01-12T18:25:16Z",         
        "next_funding_time": "2020-01-13T00:00:00Z",  //next funding time
                                                      //the rest time to settle funding fee
        "countdown_hour": 6                           //the remaining time to settle the funding fee
    },
    "cross_seq": 1053192634,
    "timestamp_e6": 1578853524091081                  //the timestamp when this information was produced
}

Delta Response Example - format of the responses following the snapshot response

{
    "topic": "instrument_info.100ms.BTCUSD",
    "type": "delta",
    "data": {
        "delete": [],
        "update": [
            {
                "id": 1,
                "symbol": "BTCUSD",
                "prev_price_24h_e4": 81565000,
                "price_24h_pcnt_e6": -4904,
                "open_value_e8": 2000479681106,
                "total_turnover_e8": 2029370495672976,
                "turnover_24h_e8": 9066215468687,
                "volume_24h": 735316391,
                "cross_seq": 1053192657,
                "created_at": "2018-11-14T16:33:26Z",
                "updated_at": "2020-01-12T18:25:25Z"
            }
        ],
        "insert": []
    },
    "cross_seq": 1053192657,
    "timestamp_e6": 1578853525691123
}

Get latest information for symbol.

Response Parameters

parameter type comments
symbol string Symbol
last_price_e4 integer Latest transaction price 10^4
last_tick_direction string Tick Direction
prev_price_24h_e4 integer Price of 24 hours ago * 10^4
price_24h_pcnt_e6 integer Percentage change of market price relative to 24h * 10^4
high_price_24h_e4 integer The highest price in the last 24 hours * 10^4
low_price_24h_e4 integer Lowest price in the last 24 hours * 10^4
prev_price_1h_e4 integer Hourly market price an hour ago * 10^4
price_1h_pcnt_e6 integer Percentage change of market price relative to 1 hour ago * 10^6
mark_price_e4 integer Mark price * 10^4
index_price_e4 integer Index_price * 10^4
open_interest integer Open interest. The update is not immediate - slowest update is 1 minute
open_value_e8 integer Open position value * 10^8. The update is not immediate - slowest update is 1 minute
total_turnover_e8 integer Total turnover * 10^8
turnover_24h_e8 integer Turnover for 24H * 10^8
total_volume integer Total volume
volume_24h integer Trading volume in the last 24 hours
predicted_funding_rate_e6 integer Predicted funding rate *10^6
cross_seq integer Cross sequence (internal value)
created_at string Creation time
updated_at string Update time
next_funding_time string Next settlement time of capital cost
countdown_hour integer Countdown of settlement capital cost

klineV2

How to Subscribe

ws.send('{"op":"subscribe","args":["klineV2.1.BTCUSD"]}')

Response Example - format of all responses

{
    "topic": "klineV2.1.BTCUSD",                //topic name
    "data": [{
        "start": 1572425640,                    //start time of the candle
        "end": 1572425700,                      //end time of the candle
        "open": 9200,                           //open price
        "close": 9202.5,                        //close price
        "high": 9202.5,                         //max price
        "low": 9196,                            //min price
        "volume": 81790,                        //volume
        "turnover": 8.889247899999999,          //turnover
        "confirm": False,                       //snapshot flag
        "cross_seq": 297503466,                 
        "timestamp": 1572425676958323           //cross time
    }],
    "timestamp_e6": 1572425677047994            //server time
}

Currently supported intervals:

Response Parameters

parameter type comments
start integer Start timestamp point for result, in seconds
end integer End timestamp point for result, in seconds
open number Starting price
close number Closing price
high number Maximum price
low number Minimum price
volume number Trading volume
turnover number Transaction amount
confirm bool Is confirm
cross_seq integer Cross sequence (internal value)
timestamp integer End timestamp point for result, in seconds

Private Topics

position

How to Subscribe

ws.send('{"op": "subscribe", "args": ["position"]}')
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=api_key, api_secret=api_secret)
ws.subscribe_position()
while True:
    data = ws.get_data("position")
    if data:
        print(data)

Response Example - format of all responses

{
   "topic": "position",
   "action": "update",
   "data": [
       {
           "user_id":  1,                            // user ID
           "symbol": "BTCUSD",                       // the contract for this position
           "size": 11,                               // the current position amount
           "side": "Sell",                           // side
           "position_value": "0.00159252",           // positional value
           "entry_price": "6907.291588174717",       // entry price
           "liq_price": "7100.234",                  // liquidation price
           "bust_price": "7088.1234",                // bankruptcy price
           "leverage": "1",                           // leverage
           "order_margin":  "1",                      // order margin
           "position_margin":  "1",                   // position margin
           "available_balance":  "2",                 // available balance
           "take_profit": "0",                        // take profit price           
           "tp_trigger_by":  "LastPrice",             // take profit trigger price, eg: LastPrice, IndexPrice. Conditional order only
           "stop_loss": "0",                          // stop loss price
           "sl_trigger_by":  "",                     // stop loss trigger price, eg: LastPrice, IndexPrice. Conditional order only
           "realised_pnl":  "0.10",               // realised PNL
           "trailing_stop": "0",                  // trailing stop points
           "trailing_active": "0",                // trailing stop trigger price
           "wallet_balance":  "4.12",             // wallet balance
           "risk_id":  1,                       
           "occ_closing_fee":  "0.1",             // position closing
           "occ_funding_fee":  "0.1",             // funding fee
           "auto_add_margin": 0,                  // auto margin replenishment switch
           "cum_realised_pnl":  "0.12",           // Total realized profit and loss
           "position_status": "Normal",           // status of position (Normal: normal Liq: in the process of liquidation Adl: in the process of Auto-Deleveraging)
                        // Auto margin replenishment enabled (0: no 1: yes)
           "position_seq": 14                     // position version number
       }
   ]
}

Get my position list.

Response Parameters

parameter type comments
user_id number UserID
symbol string Symbol
side string Side
size number Position qty
position_value string Position value
entry_price string Average entry price
liq_price string Liquidation price
bust_price string Bankruptcy price
leverage string In Isolated Margin mode, the value is set by user. In Cross Margin mode, the value is the max leverage at current risk level
order_margin string Pre-occupied order margin
position_margin string Position margin
available_balance string Available balance = wallet balance - position margin
take_profit string Take profit price
tp_trigger_by string Trigger price type. Default LastPrice
stop_loss string Stop loss price
sl_trigger_by string Trigger price type. Default LastPrice
realised_pnl string Today's realised pnl
trailing_stop string Trailing stop
trailing_active string Trailing stop active price
wallet_balance string Wallet balance
risk_id number Risk ID.
occ_closing_fee string Position closing fee occupied (your opening fee + expected maximum closing fee)
occ_funding_fee string Pre-occupied funding fee: calculated from position qty and current funding fee
auto_add_margin number Whether to add margin automatically
cum_realised_pnl string Accumulated realised pnl (all-time total)
position_status string Position status: Normal, Liq, Adl
position_seq number Position sequence

execution

How to Subscribe

ws.send('{"op": "subscribe", "args": ["execution"]}')
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=api_key, api_secret=api_secret)
ws.subscribe_execution()
while True:
    data = ws.get_data("execution")
    if data:
        print(data)

Response Example - format of all responses

{
    "topic": "execution",
    "data": [
        {
            "symbol": "BTCUSD",
            "side": "Buy",
            "order_id": "xxxxxxxx-xxxx-xxxx-9a8f-4a973eb5c418",
            "exec_id": "xxxxxxxx-xxxx-xxxx-8b66-c3d2fcd352f6",
            "order_link_id": "",
            "price": "8300",
            "order_qty": 1,
            "exec_type": "Trade",
            "exec_qty": 1,
            "exec_fee": "0.00000009",
            "leaves_qty": 0,
            "is_maker": false,
            "trade_time": "2020-01-14T14:07:23.629Z" // trade time
        }
    ]
}

Get user's trading records. The results are ordered in ascending order (the first item is the oldest).

Response Parameters

parameter type comments
symbol string Symbol
side string Side
order_id string Order ID
exec_id string Transaction ID
order_link_id string Order link ID
price string Transaction price
order_qty number Order qty
exec_type string Exec Type Enum
exec_qty number Transaction qty
exec_fee string Transaction fee
leaves_qty number Number of unfilled contracts from the order's size
is_maker bool Is maker
trade_time string Transaction timestamp

order

How to Subscribe

ws.send('{"op": "subscribe", "args": ["order"]}')
from BybitWebsocket import BybitWebsocket
ws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
                    api_key=api_key, api_secret=api_secret)
ws.subscribe_order()
while True:
    data = ws.get_data("order")
    if data:
        print(data)

Response Example - format of all responses

{
    "topic": "order",
    "data": [
        {
            "order_id": "xxxxxxxx-xxxx-xxxx-9a8f-4a973eb5c418",
            "order_link_id": "",
            "symbol": "BTCUSD",
            "side": "Sell",
            "order_type": "Market",
            "price": "8579.5",
            "qty": 1,
            "time_in_force": "ImmediateOrCancel",
            "create_type": "CreateByClosing",
            "cancel_type": "",
            "order_status": "Filled",
            "leaves_qty": 0,
            "cum_exec_qty": 1,
            "cum_exec_value": "0.00011655",
            "cum_exec_fee": "0.00000009",
            "timestamp": "2020-01-14T14:09:31.778Z",
            "take_profit": "0",
            "stop_loss": "0",
            "trailing_stop": "0",
            "trailing_active": "0",
            "last_exec_price": "8580"
        }
    ]
}

Response Parameters

parameter type comments
order_id string Order ID
order_link_id string Order link ID
symbol string Symbol
side string Side
order_type string Conditional order type
price string Order price
qty number Transaction qty
time_in_force string Time in force
create_type string Trigger scenario for single action
cancel_type string Trigger scenario for cancel operation
order_status string Order status
leaves_qty number Number of unfilled contracts from the order's size
cum_exec_qty number Cumulative qty of trading
cum_exec_value string Cumulative value of trading
cum_exec_fee string Cumulative trading fees
timestamp string Commission time
take_profit string Take profit price
stop_loss string Stop loss price
trailing_stop string Trailing stop
trailing_active string Trailing stop active price
last_exec_price string Last execution price

stop_order

How to Subscribe

ws.send('{"op": "subscribe", "args": ["stop_order"]}')

Response Example - format of all responses

{
    "topic": "stop_order",
    "data": [
        {
            "order_id": "xxxxxxxx-xxxx-xxxx-98fb-335aaa6c613b",
            "order_link_id": "",
            "user_id": 1,
            "symbol": "BTCUSD",
            "side": "Buy",
            "order_type": "Limit",
            "price": "8584.5",
            "qty": 1,
            "time_in_force": "ImmediateOrCancel",
            "create_type": "CreateByStopOrder",
            "cancel_type": "",
            "order_status": "Untriggered", //Stop Order Status
            "stop_order_type": "Stop",
            "trigger_by": "LastPrice",
            "trigger_price": "8584.5", //If stop_order_type is TrailingProfit, this field is the trailing stop active price.
            "timestamp": "2020-01-14T14:11:22.062Z"
        }
    ]
}

Response Parameters

parameter type comments
order_id string Order ID
order_link_id string Order link ID
user_id number UserID
symbol string Symbol Enum
order_type string Order Type Enum
side string Side
price string Order price
qty number Order quantity in USD
time_in_force string Time in force
create_type string Trigger scenario for single action
cancel_type string Trigger scenario for cancel operation
order_status string Order status
stop_order_type string Conditional order type
trigger_by string Trigger price type. Default LastPrice
trigger_price string If stop_order_type is TrailingProfit, this field is the trailing stop active price.
timestamp string UTC time

Archive Data

Historical Market Data

You can get Bybit's historical market data here.

ENUMs Definitions

This is a list of valid options (and rules) for the different parameters when sending a request to the API.

Side (side)

Symbol (symbol)

Currency (currency/coin)

Wallet fund type (wallet_fund_type)

Withdraw status (status)

Order type (order_type)

Quantity (qty)

Price (price)

Time in force (time_in_force)

Trigger price type (trigger_by)

Order (order)

This is for sorting orders/trades in a specified direction.

Order status (order_status)

Filter fetched orders by their order statuses. To filter by multiple statuses, separate with a comma like so: Filled,New

Stop order status (stop_order_status)

Cancel type (cancel_type)

Create type (create_type)

Exec type (exec_type)

Liquidity type (last_liquidity_ind)

Tick direction type (tick_direction)

It indicates the fluctuation of price, which is up or down relative to the last transaction

Errors

The Bybit API uses the following HTTP Codes and Error Codes:

HTTP Code Meaning
200 Request valid -- Your request is valid
403 Forbidden -- You request too many times
404 Request path not found
Error Code Meaning
10001 parameter error
10002 request expired, check your timestamp and recv_window
10001 parameter error
10002 request expired, check your timestamp and recv_window
10003 Invalid apikey
10004 invalid sign
10005 permission denied for current apikey
10006 too many requests
10007 api_key not found in your request parameters
10010 request ip mismatch
10017 request path not found or request method is invalid
20001 Order not exists
20003 missing parameter side
20004 invalid parameter side
20005 missing parameter symbol
20006 invalid parameter symbol
20007 missing parameter order_type
20008 invalid parameter order_type
20009 missing parameter qty
20010 qty must be greater than 0
20011 qty must be an integer
20012 qty must be greater than zero and less than 1 million
20013 missing parameter price
20014 price must be greater than 0
20015 missing parameter time_in_force
20016 invalid value for parameter time_in_force
20017 missing parameter order_id
20018 invalid date format
20019 missing parameter stop_px
20020 missing parameter base_price
20021 missing parameter stop_order_id
20022 missing parameter leverage
20023 leverage must be a number
20031 leverage must be greater than zero
20070 missing parameter margin
20071 margin must be greater than zero
20084 order_id or order_link_id is required
30001 order_link_id is repeated
30003 qty must be more than the minimum allowed
30004 qty must be less than the maximum allowed
30005 price exceeds maximum allowed
30007 price exceeds minimum allowed
30008 invalid order_type
30009 no position found
30010 insufficient wallet balance
30011 operation not allowed as position is undergoing liquidation
30012 operation not allowed as position is undergoing ADL
30013 position is in liq or adl status
30014 invalid closing order, qty should not greater than size
30015 invalid closing order, side should be opposite
30016 TS and SL must be cancelled first while closing position
30017 estimated fill price cannot be lower than current Buy liq_price
30018 estimated fill price cannot be higher than current Sell liq_price
30019 cannot attach TP/SL params for non-zero position when placing non-opening position order
30020 position already has TP/SL params
30021 cannot afford estimated position_margin
30022 estimated buy liq_price cannot be higher than current mark_price
30023 estimated sell liq_price cannot be lower than current mark_price
30024 cannot set TP/SL/TS for zero-position
30025 trigger price should bigger than 10% of last price
30026 price too high
30027 price set for Take profit should be higher than Last Traded Price
30028 price set for Stop loss should be between Liquidation price and Last Traded Price
30029 price set for Stop loss should be between Last Traded Price and Liquidation price
30030 price set for Take profit should be lower than Last Traded Price
30031 insufficient available balance for order cost
30032 order has been filled or cancelled
30033 The number of stop orders exceeds maximum limit allowed
30034 no order found
30035 too fast to cancel
30036 the expected position value after order execution exceeds the current risk limit
30037 order already cancelled
30041 no position found
30042 insufficient wallet balance
30043 operation not allowed as position is undergoing liquidation
30044 operation not allowed as position is undergoing AD
30045 operation not allowed as position is not normal status
30049 insufficient available balance
30050 any adjustments made will trigger immediate liquidation
30051 due to risk limit, cannot adjust leverage
30052 leverage can not less than 1
30054 position margin is invalid
30057 requested quantity of contracts exceeds risk limit
30063 reduce-only rule not satisfied
30067 insufficient available balance
30068 exit value must be positive
33004 apikey already expired
34026 the limit is no change