Execution
Subscribe to the execution stream to see your executions in real-time.
tip
You may have multiple executions for one order in a single message.
All-In-One Topic: execution
Categorised Topic: execution.spot
, execution.linear
, execution.inverse
, execution.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 |
> symbol | string | Symbol name |
> isLeverage | string | Whether to borrow. Unified spot only. 0 : false, 1 : trueClassic spot is not supported, always 0 |
> orderId | string | Order ID |
> orderLinkId | string | User customized order ID |
> side | string | Side. Buy ,Sell |
> orderPrice | string | Order price. Classic spot is not supported |
> orderQty | string | Order qty. Classic spot is not supported |
> leavesQty | string | The remaining qty not executed. Classic spot is not supported |
> createType | string | Order create type "" |
> orderType | string | Order type. Market ,Limit . Classic spot is not supported |
> stopOrderType | string | Stop order type. If the order is not stop order, any type is not returned. Classic spot is not supported |
> execFee | string | Executed trading fee. You can get spot fee currency instruction here Classic spot is not supported |
> execId | string | Execution ID |
> execPrice | string | Execution price |
> execQty | string | Execution qty |
> execPnl | string | Profit and Loss for each close position execution. The value keeps consistent with the field "cashFlow" in the Get Transaction Log |
> execType | string | Executed type. Classic spot is not supported |
> execValue | string | Executed order value. Classic spot is not supported |
> execTime | string | Executed timestamp(ms) |
> isMaker | boolean | Is maker order. true : maker, false : taker |
> feeRate | string | Trading fee rate. Classic spot is not supported |
> tradeIv | string | Implied volatility. valid for option |
> markIv | string | Implied volatility of mark price. valid for option |
> markPrice | string | The mark price of the symbol when executing. valid for option |
> indexPrice | string | The index price of the symbol when executing. valid for option |
> underlyingPrice | string | The underlying price of the symbol when executing. valid for option |
> blockTradeId | string | Paradigm block trade ID |
> closedSize | string | Closed position size |
> seq | long | Cross sequence, used to associate each fill and each position update
|
Subscribe Example
{
"op": "subscribe",
"args": [
"execution"
]
}
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.execution_stream(callback=handle_message)
while True:
sleep(1)
Stream Example
{
"id": "592324803b2785-26fa-4214-9963-bdd4727f07be",
"topic": "execution",
"creationTime": 1672364174455,
"data": [
{
"category": "linear",
"symbol": "XRPUSDT",
"execFee": "0.005061",
"execId": "7e2ae69c-4edf-5800-a352-893d52b446aa",
"execPrice": "0.3374",
"execQty": "25",
"execType": "Trade",
"execValue": "8.435",
"execValue": "0",
"isMaker": false,
"feeRate": "0.0006",
"tradeIv": "",
"markIv": "",
"blockTradeId": "",
"markPrice": "0.3391",
"indexPrice": "",
"underlyingPrice": "",
"leavesQty": "0",
"orderId": "f6e324ff-99c2-4e89-9739-3086e47f9381",
"orderLinkId": "",
"orderPrice": "0.3207",
"orderQty": "25",
"orderType": "Market",
"stopOrderType": "UNKNOWN",
"side": "Sell",
"execTime": "1672364174443",
"isLeverage": "0",
"closedSize": "",
"seq": 4688002127
}
]
}