Order
Subscribe to the order stream to see changes to your orders in real-time.
All-In-One Topic: order
Categorised Topic: order.spot
, order.linear
, order.inverse
, order.option
info
- All-In-One topic and Categorised topic cannot be in the same subscription request
- All-In-One topic: Allow you to listen to all categories (spot, linear, inverse, option) websocket updates
- Categorised Topic: Allow you to listen only to specific category websocket updates
Response Parameters
Parameter | Type | Comments |
---|---|---|
id | string | Message ID |
topic | string | Topic name |
creationTime | number | Data created timestamp (ms) |
data | array | Object |
> category | string | Product type |
> orderId | string | Order ID |
> orderLinkId | string | User customised order ID |
> isLeverage | string | Whether to borrow. Unified spot only. 0 : false, 1 : trueClassic spot is not supported, always 0 |
> blockTradeId | string | Block trade ID |
> symbol | string | Symbol name |
> price | string | Order price |
> qty | string | Order qty |
> side | string | Side. Buy ,Sell |
> positionIdx | integer | Position index. Used to identify positions in different position modes |
> orderStatus | string | Order status |
> createType | string | Order create type |
> cancelType | string | Cancel type |
> rejectReason | string | Reject reason. Classic spot is not supported |
> avgPrice | string | Average filled price "" for those orders without avg price, and also for those classic account orders have partilly filled but cancelled at the end"" |
> leavesQty | string | The remaining qty not executed. Classic spot is not supported |
> leavesValue | string | The remaining value not executed. Classic spot is not supported |
> cumExecQty | string | Cumulative executed order qty |
> cumExecValue | string | Cumulative executed order value |
> cumExecFee | string | Cumulative executed trading fee.
|
> closedPnl | string | Closed profit and loss for each close position order. The figure is the same as "closedPnl" from Get Closed PnL |
> feeCurrency | string | Trading fee currency for Spot only. Please understand Spot trading fee currency here |
> timeInForce | string | Time in force |
> orderType | string | Order type. Market ,Limit . For TP/SL order, it means the order type after triggered |
> stopOrderType | string | Stop order type |
> ocoTriggerBy | string | The trigger type of Spot OCO order.OcoTriggerByUnknown , OcoTriggerByTp , OcoTriggerBySl . Classic spot is not supported |
> orderIv | string | Implied volatility |
> marketUnit | string | The unit for qty when create Spot market orders for UTA account. baseCoin , quoteCoin |
> triggerPrice | string | Trigger price. If stopOrderType =TrailingStop, it is activate price. Otherwise, it is trigger price |
> takeProfit | string | Take profit price |
> stopLoss | string | Stop loss price |
> tpslMode | string | TP/SL mode, Full : entire position for TP/SL. Partial : partial position tp/sl. Spot does not have this field, and Option returns always "" |
> tpLimitPrice | string | The limit order price when take profit price is triggered |
> slLimitPrice | string | The limit order price when stop loss price is triggered |
> tpTriggerBy | string | The price type to trigger take profit |
> slTriggerBy | string | The price type to trigger stop loss |
> triggerDirection | integer | Trigger direction. 1 : rise, 2 : fall |
> triggerBy | string | The price type of trigger price |
> lastPriceOnCreated | string | Last price when place the order |
> reduceOnly | boolean | Reduce only. true means reduce position size |
> closeOnTrigger | boolean | Close on trigger. What is a close on trigger order? |
> placeType | string | Place type, option used. iv , price |
> smpType | string | SMP execution type |
> smpGroup | integer | Smp group ID. If the UID has no group, it is 0 by default |
> smpOrderId | string | The counterparty's orderID which triggers this SMP execution |
> createdTime | string | Order created timestamp (ms) |
> updatedTime | string | Order updated timestamp (ms) |
Subscribe Example
{
"op": "subscribe",
"args": [
"order"
]
}
from pybit.unified_trading import WebSocket
from time import sleep
ws = WebSocket(
testnet=True,
channel_type="private",
api_key="XXXXX",
api_secret="XXXXX",
)
def handle_message(message):
print(message)
ws.order_stream(callback=handle_message)
while True:
sleep(1)
Stream Example
{
"id": "5923240c6880ab-c59f-420b-9adb-3639adc9dd90",
"topic": "order",
"creationTime": 1672364262474,
"data": [
{
"symbol": "ETH-30DEC22-1400-C",
"orderId": "5cf98598-39a7-459e-97bf-76ca765ee020",
"side": "Sell",
"orderType": "Market",
"cancelType": "UNKNOWN",
"price": "72.5",
"qty": "1",
"orderIv": "",
"timeInForce": "IOC",
"orderStatus": "Filled",
"orderLinkId": "",
"lastPriceOnCreated": "",
"reduceOnly": false,
"leavesQty": "",
"leavesValue": "",
"cumExecQty": "1",
"cumExecValue": "75",
"avgPrice": "75",
"blockTradeId": "",
"positionIdx": 0,
"cumExecFee": "0.358635",
"closedPnl": "0",
"createdTime": "1672364262444",
"updatedTime": "1672364262457",
"rejectReason": "EC_NoError",
"stopOrderType": "",
"tpslMode": "",
"triggerPrice": "",
"takeProfit": "",
"stopLoss": "",
"tpTriggerBy": "",
"slTriggerBy": "",
"tpLimitPrice": "",
"slLimitPrice": "",
"triggerDirection": 0,
"triggerBy": "",
"closeOnTrigger": false,
"category": "option",
"placeType": "price",
"smpType": "None",
"smpGroup": 0,
"smpOrderId": "",
"feeCurrency": ""
}
]
}