place_order
Execute trades on Bybit across spot, linear, and inverse markets. Place market or limit orders, set take profit/stop loss, and manage positions with category, symbol, side, order type, and quantity parameters.
Instructions
Execute order
Args:
category (str): Category
- spot: Spot trading
* Minimum order quantity: 0.000011 BTC (up to 6 decimal places)
* Minimum order amount: 5 USDT
* If buying at market price, qty should be input in USDT units (e.g., "10" = 10 USDT)
* If selling at market price, qty should be input in BTC units (e.g., "0.000100" = 0.0001 BTC)
* If placing a limit order, qty should be input in BTC units
* positionIdx is not used
- linear: Futures trading (USDT margin)
* positionIdx is required (1: Long, 2: Short)
- inverse: Futures trading (coin margin)
* positionIdx is required (1: Long, 2: Short)
symbol (str): Symbol (e.g., BTCUSDT)
side (str): Order direction (Buy, Sell)
orderType (str): Order type (Market, Limit)
qty (str): Order quantity
- Market Buy: qty should be input in USDT units (e.g., "10" = 10 USDT)
- Market Sell: qty should be input in BTC units (e.g., "0.000100" = 0.0001 BTC, up to 6 decimal places)
- Limit: qty should be input in BTC units (e.g., "0.000100" = 0.0001 BTC, up to 6 decimal places)
price (Optional[str]): Order price (for limit orders)
positionIdx (Optional[str]): Position index
- Required for futures (linear/inverse) trading
- "1": Long position
- "2": Short position
- Not used for spot trading
timeInForce (Optional[str]): Order validity period
- GTC: Good Till Cancel (default, for limit orders)
- IOC: Immediate or Cancel (market order)
- FOK: Fill or Kill
- PostOnly: Post Only
orderLinkId (Optional[str]): Order link ID (unique value)
isLeverage (Optional[int]): Use leverage (0: No, 1: Yes)
orderFilter (Optional[str]): Order filter
- Order: Regular order (default)
- tpslOrder: TP/SL order
- StopOrder: Stop order
triggerPrice (Optional[str]): Trigger price
triggerBy (Optional[str]): Trigger basis
orderIv (Optional[str]): Order volatility
takeProfit (Optional[str]): Take profit price
stopLoss (Optional[str]): Stop loss price
tpTriggerBy (Optional[str]): Take profit trigger basis
slTriggerBy (Optional[str]): Stop loss trigger basis
tpLimitPrice (Optional[str]): Take profit limit price
slLimitPrice (Optional[str]): Stop loss limit price
tpOrderType (Optional[str]): Take profit order type (Market, Limit)
slOrderType (Optional[str]): Stop loss order type (Market, Limit)
Returns:
Dict: Order result
Example:
# Spot trading (SPOT account balance required)
place_order("spot", "BTCUSDT", "Buy", "Market", "10") # Buy market price for 10 USDT
place_order("spot", "BTCUSDT", "Sell", "Market", "0.000100") # Sell market price for 0.0001 BTC
place_order("spot", "BTCUSDT", "Buy", "Limit", "0.000100", price="50000") # Buy limit order for 0.0001 BTC
# Spot trading - limit order + TP/SL
place_order("spot", "BTCUSDT", "Buy", "Limit", "0.000100", price="50000",
takeProfit="55000", stopLoss="45000", # TP/SL setting
tpOrderType="Market", slOrderType="Market") # Execute TP/SL as market order
# Futures trading
place_order("linear", "BTCUSDT", "Buy", "Market", "0.001", positionIdx="1") # Buy market price for long position
place_order("linear", "BTCUSDT", "Sell", "Market", "0.001", positionIdx="2") # Sell market price for short position
Notes:
1. Spot trading order quantity restrictions:
- Minimum order quantity: 0.000011 BTC
- Minimum order amount: 5 USDT
- BTC quantity is only allowed up to 6 decimal places (e.g., 0.000100 O, 0.0001234 X)
2. Pay attention to unit when buying/selling at market price:
- Buying: qty should be input in USDT units (e.g., "10" = 10 USDT)
- Selling: qty should be input in BTC units (e.g., "0.000100" = 0.0001 BTC)
3. Futures trading requires positionIdx:
- Long position: positionIdx="1"
- Short position: positionIdx="2"
4. positionIdx is not used for spot trading
Reference:
https://bybit-exchange.github.io/docs/v5/order/create-order
Input Schema
Name | Required | Description | Default |
---|---|---|---|
category | Yes | Category (spot, linear, inverse, etc.) | |
isLeverage | No | Use leverage (0: No, 1: Yes) | |
orderFilter | No | Order filter (Order, tpslOrder, StopOrder) | |
orderIv | No | Order volatility | |
orderLinkId | No | Order link ID | |
orderType | Yes | Order type (Market, Limit) | |
positionIdx | No | Position index (1: Long, 2: Short) | |
price | No | Order price (for limit orders) | |
qty | Yes | Order quantity | |
side | Yes | Order direction (Buy, Sell) | |
slLimitPrice | No | Stop loss limit price | |
slOrderType | No | Stop loss order type (Market, Limit) | |
slTriggerBy | No | Stop loss trigger basis | |
stopLoss | No | Stop loss price | |
symbol | Yes | Symbol (e.g., BTCUSDT) | |
takeProfit | No | Take profit price | |
timeInForce | No | Time in force (GTC, IOC, FOK, PostOnly) | |
tpLimitPrice | No | Take profit limit price | |
tpOrderType | No | Take profit order type (Market, Limit) | |
tpTriggerBy | No | Take profit trigger basis | |
triggerBy | No | Trigger basis | |
triggerPrice | No | Trigger price |
Input Schema (JSON Schema)
{
"properties": {
"category": {
"description": "Category (spot, linear, inverse, etc.)",
"title": "Category",
"type": "string"
},
"isLeverage": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Use leverage (0: No, 1: Yes)",
"title": "Isleverage"
},
"orderFilter": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Order filter (Order, tpslOrder, StopOrder)",
"title": "Orderfilter"
},
"orderIv": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Order volatility",
"title": "Orderiv"
},
"orderLinkId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Order link ID",
"title": "Orderlinkid"
},
"orderType": {
"description": "Order type (Market, Limit)",
"title": "Ordertype",
"type": "string"
},
"positionIdx": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Position index (1: Long, 2: Short)",
"title": "Positionidx"
},
"price": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Order price (for limit orders)",
"title": "Price"
},
"qty": {
"description": "Order quantity",
"title": "Qty",
"type": "string"
},
"side": {
"description": "Order direction (Buy, Sell)",
"title": "Side",
"type": "string"
},
"slLimitPrice": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Stop loss limit price",
"title": "Sllimitprice"
},
"slOrderType": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Stop loss order type (Market, Limit)",
"title": "Slordertype"
},
"slTriggerBy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Stop loss trigger basis",
"title": "Sltriggerby"
},
"stopLoss": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Stop loss price",
"title": "Stoploss"
},
"symbol": {
"description": "Symbol (e.g., BTCUSDT)",
"title": "Symbol",
"type": "string"
},
"takeProfit": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Take profit price",
"title": "Takeprofit"
},
"timeInForce": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Time in force (GTC, IOC, FOK, PostOnly)",
"title": "Timeinforce"
},
"tpLimitPrice": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Take profit limit price",
"title": "Tplimitprice"
},
"tpOrderType": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Take profit order type (Market, Limit)",
"title": "Tpordertype"
},
"tpTriggerBy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Take profit trigger basis",
"title": "Tptriggerby"
},
"triggerBy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Trigger basis",
"title": "Triggerby"
},
"triggerPrice": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Trigger price",
"title": "Triggerprice"
}
},
"required": [
"category",
"symbol",
"side",
"orderType",
"qty"
],
"title": "place_orderArguments",
"type": "object"
}