Place Order
This endpoint supports to create the order for Spot, Margin trading, USDT perpetual, USDC perpetual, USDC futures, Inverse Futures and Options.
Supported order type (
Market order:orderType
):
Limit order:orderType
=Limit, it is necessary to specify order qty and price.orderType
=Market, execute at the best price in the Bybit market until the transaction is completed. When selecting a market order, the "price" can be empty. In the futures trading system, in order to protect the serious slippage of the market order, the Bybit trading system will convert the market order into a limit order for matching. will be cancelled. The slippage threshold refers to the percentage that the order price deviates from the latest transaction price. The current threshold is set to 3% for BTC contracts and 5% for other contracts.Supported timeInForce strategy:
GTC
IOC
FOK
PostOnly
: If the order would be filled immediately when submitted, it will be cancelled. The purpose of this is to protect your order during the submission process. If the matching system cannot entrust the order to the order book due to price changes on the market, it will be cancelled. For the PostOnly order type, the quantity that can be submitted in a single order is more than other types of orders, please refer to the parameterlotSizeFilter > postOnlyMaxOrderQty
in the instruments-info endpoint.How to create conditional order:
When submitting an order, iftriggerPrice
is set, the order will be automatically converted into a conditional order. In addition, the conditional order does not occupy the margin. If the margin is insufficient after the conditional order is triggered, the order will be cancelled.Take profit / Stop loss: You can set TP/SL while placing orders. Besides, you could modify the position's TP/SL.
Order quantity: The quantity of perpetual contracts you are going to buy/sell. For the order quantity, Bybit only supports positive number at present.
Order price: Place a limit order, this parameter is required. If you have position, the price should be higher than the liquidation price. For the minimum unit of the price change, please refer to the
priceFilter
>tickSize
field in the instruments-info endpoint.orderLinkId: You can customize the active order ID. We can link this ID to the order ID in the system. Once the active order is successfully created, we will send the unique order ID in the system to you. Then, you can use this order ID to cancel active orders, and if both orderId and orderLinkId are entered in the parameter input, Bybit will prioritize the orderId to process the corresponding order. Meanwhile, your customized order ID should be no longer than 36 characters and should be unique.
Open orders up limit:
Perps & Futures:
a) Each account can hold a maximum of 500 active orders simultaneously per symbol.
b) conditional orders: each account can hold a maximum of 10 active orders simultaneously per symbol.
Spot: 500 orders in total, including a maximum of 30 open TP/SL orders, a maximum of 30 open conditional orders for each symbol per account
Option: a maximum of 50 open orders per accountRate limit:
Please refer to rate limit table. If you need to raise the rate limit, please contact your client manager or submit an application via hereRisk control limit notice:
Bybit will monitor on your API requests. When the total number of orders of a single user (aggregated the number of orders across main account and sub-accounts) within a day (UTC 0 - UTC 24) exceeds a certain upper limit, the platform will reserve the right to remind, warn, and impose necessary restrictions. Customers who use API default to acceptance of these terms and have the obligation to cooperate with adjustments.
Spot supports TP/SL order, Conditional order, however, the system logic is different between classic account and Unified account
classic account: When the stop order is created, you will get an order ID. After it is triggered, you will get a new order ID
Unified account: When the stop order is created, you will get an order ID. After it is triggered, the order ID will not be changed
HTTP Request
POST /v5/order/create
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type |
symbol | true | string | Symbol name, like BTCUSDT , uppercase only |
isLeverage | false | integer | Whether to borrow. Unified account Spot trading only.0 (default): false, spot trading1 : true, margin trading, make sure you turn on margin trading, and set the relevant currency as collateral |
side | true | string | Buy , Sell |
orderType | true | string | Market , Limit |
qty | true | string | Order quantity
|
marketUnit | false | string | Select the unit for qty when create Spot market orders for UTA accountbaseCoin : for example, buy BTCUSDT, then "qty" unit is BTCquoteCoin : for example, sell BTCUSDT, then "qty" unit is USDT |
price | false | string | Order price
|
triggerDirection | false | integer | Conditional order param. Used to identify the expected direction of the conditional order.
linear & inverse |
orderFilter | false | string | If it is not passed, Order by default.
spot only |
triggerPrice | false | string |
|
triggerBy | false | string | Trigger price type, Conditional order param for Perps & Futures. LastPrice IndexPrice MarkPrice linear & inverse |
orderIv | false | string | Implied volatility. option only. Pass the real value, e.g for 10%, 0.1 should be passed. orderIv has a higher priority when price is passed as well |
timeInForce | false | string | Time in force
|
positionIdx | false | integer | Used to identify positions in different position modes. Under hedge-mode, this param is required
|
orderLinkId | false | string | User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. Futures & Perps: orderLinkId rules:
option orderLinkId rules: |
takeProfit | false | string | Take profit price |
stopLoss | false | string | Stop loss price |
tpTriggerBy | false | string | The price type to trigger take profit. MarkPrice , IndexPrice , default: LastPrice . Valid for linear & inverse |
slTriggerBy | false | string | The price type to trigger stop loss. MarkPrice , IndexPrice , default: LastPrice . Valid for linear & inverse |
reduceOnly | false | boolean | What is a reduce-only order? true means your position can only reduce in size if this order is triggered.
linear , inverse & option |
closeOnTrigger | false | boolean | 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. Valid for linear & inverse |
smpType | false | string | Smp execution type. What is SMP? |
mmp | false | boolean | Market maker protection. option only. true means set the order as a market maker protection order. What is mmp? |
tpslMode | false | string | TP/SL mode
linear & inverse |
tpLimitPrice | false | string | The limit order price when take profit price is triggered
|
slLimitPrice | false | string | The limit order price when stop loss price is triggered
|
tpOrderType | false | string | The order type when take profit is triggered
|
slOrderType | false | string | The order type when stop loss is triggered
|
Response Parameters
Parameter | Type | Comments |
---|---|---|
orderId | string | Order ID |
orderLinkId | string | User customised order ID |
The ack of create order request indicates that the request is successfully accepted. Please use websocket order stream to confirm the order status
Request Example
- HTTP
- Python
- Go
- Java
- .Net
- Node.js
POST /v5/order/create HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672211928338
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
// Spot Limit order with market tp sl
{"category": "spot","symbol": "BTCUSDT","side": "Buy","orderType": "Limit","qty": "0.01","price": "28000","timeInForce": "PostOnly","takeProfit": "35000","stopLoss": "27000","tpOrderType": "Market","slOrderType": "Market"}
// Spot Limit order with limit tp sl
{"category": "spot","symbol": "BTCUSDT","side": "Buy","orderType": "Limit","qty": "0.01","price": "28000","timeInForce": "PostOnly","takeProfit": "35000","stopLoss": "27000","tpLimitPrice": "36000","slLimitPrice": "27500","tpOrderType": "Limit","slOrderType": "Limit"}
// Spot PostOnly normal order
{"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"0.1","price":"15600","timeInForce":"PostOnly","orderLinkId":"spot-test-01","isLeverage":0,"orderFilter":"Order"}
// Spot TP/SL order
{"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"0.1","price":"15600","triggerPrice": "15000", "timeInForce":"Limit","orderLinkId":"spot-test-02","isLeverage":0,"orderFilter":"tpslOrder"}
// Spot margin normal order (UTA)
{"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"0.1","price":"15600","timeInForce":"Limit","orderLinkId":"spot-test-limit","isLeverage":1,"orderFilter":"Order"}
// Spot Market Buy order, qty is quote currency
{"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Market","qty":"200","timeInForce":"IOC","orderLinkId":"spot-test-04","isLeverage":0,"orderFilter":"Order"}
// USDT Perp open long position (one-way mode)
{"category":"linear","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"1","price":"25000","timeInForce":"GTC","positionIdx":0,"orderLinkId":"usdt-test-01","reduceOnly":false,"takeProfit":"28000","stopLoss":"20000","tpslMode":"Partial","tpOrderType":"Limit","slOrderType":"Limit","tpLimitPrice":"27500","slLimitPrice":"20500"}
// USDT Perp close long position (one-way mode)
{"category": "linear", "symbol": "BTCUSDT", "side": "Sell", "orderType": "Limit", "qty": "1", "price": "30000", "timeInForce": "GTC", "positionIdx": 0, "orderLinkId": "usdt-test-02", "reduceOnly": true}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.place_order(
category="spot",
symbol="BTCUSDT",
side="Buy",
orderType="Limit",
qty="0.1",
price="15600",
timeInForce="PostOnly",
orderLinkId="spot-test-postonly",
isLeverage=0,
orderFilter="Order",
))
import (
"context"
"fmt"
bybit "https://github.com/bybit-exchange/bybit.go.api")
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{
"category": "linear",
"symbol": "BTCUSDT",
"side": "Buy",
"positionIdx": 0,
"orderType": "Limit",
"qty": "0.001",
"price": "10000",
"timeInForce": "GTC",
}
client.NewUtaBybitServiceWithParams(params).PlaceOrder(context.Background())
import com.bybit.api.client.restApi.BybitApiAsyncTradeRestClient;
import com.bybit.api.client.domain.ProductType;
import com.bybit.api.client.domain.TradeOrderType;
import com.bybit.api.client.domain.trade.PositionIdx;
import com.bybit.api.client.domain.trade.Side;
import com.bybit.api.client.domain.trade.TimeInForce;
import com.bybit.api.client.domain.trade.TradeOrderRequest;
import com.bybit.api.client.service.BybitApiClientFactory;
import java.util.Map;
BybitApiClientFactory factory = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET");
BybitApiAsyncTradeRestClient client = factory.newAsyncTradeRestClient();
Map<String, Object> order =Map.of(
"category", "option",
"symbol", "BTC-29DEC23-10000-P",
"side", "Buy",
"orderType", "Limit",
"orderIv", "0.1",
"qty", "0.1",
"price", "5",
"orderLinkId", "test_orderLinkId_1"
);
client.createOrder(order, System.out::println);
using bybit.net.api.ApiServiceImp;
using bybit.net.api.Models.Trade;
BybitTradeService tradeService = new(apiKey: "xxxxxxxxxxxxxx", apiSecret: "xxxxxxxxxxxxxxxxxxxxx");
var orderInfo = await tradeService.PlaceOrder(category: Category.LINEAR, symbol: "BLZUSDT", side: Side.BUY, orderType: OrderType.MARKET, qty: "15", timeInForce: TimeInForce.GTC);
Console.WriteLine(orderInfo);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.submitOrder({
category: 'spot',
symbol: 'BTCUSDT',
side: 'Buy',
orderType: 'Market',
qty: '0.1',
price: '15600',
timeInForce: 'PostOnly',
orderLinkId: 'spot-test-postonly',
isLeverage: 0,
orderFilter: 'Order',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"orderId": "1321003749386327552",
"orderLinkId": "spot-test-postonly"
},
"retExtInfo": {},
"time": 1672211918471
}