Skip to main content

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

ParameterTypeComments
idstringMessage ID
topicstringTopic name
creationTimenumberData created timestamp (ms)
dataarrayObject
> categorystringProduct type
  • Unified account: spot, linear, inverse, option
  • Classic account: spot, linear, inverse.
> symbolstringSymbol name
> isLeveragestringWhether to borrow. Unified spot only. 0: false, 1: true. . Classic spot is not supported, always 0
> orderIdstringOrder ID
> orderLinkIdstringUser customized order ID
> sidestringSide. Buy,Sell
> orderPricestringOrder price. Classic spot is not supported
> orderQtystringOrder qty. Classic spot is not supported
> leavesQtystringThe remaining qty not executed. Classic spot is not supported
> createTypestringOrder create type
  • UTA: Only for category=linear or inverse
  • Classic: always ""
  • Spot, Option do not have this key
  • > orderTypestringOrder type. Market,Limit. Classic spot is not supported
    > stopOrderTypestringStop order type. If the order is not stop order, any type is not returned. Classic spot is not supported
    > execFeestringExecuted trading fee. You can get spot fee currency instruction here Classic spot is not supported
    > execIdstringExecution ID
    > execPricestringExecution price
    > execQtystringExecution qty
    > execTypestringExecuted type. Classic spot is not supported
    > execValuestringExecuted order value. Classic spot is not supported
    > execTimestringExecuted timestamp(ms)
    > isMakerbooleanIs maker order. true: maker, false: taker
    > feeRatestringTrading fee rate. Classic spot is not supported
    > tradeIvstringImplied volatility. Valid for option
    > markIvstringImplied volatility of mark price. Valid for option
    > markPricestringThe mark price of the symbol when executing. Valid for option
    > indexPricestringThe index price of the symbol when executing. Valid for option
    > underlyingPricestringThe underlying price of the symbol when executing. Valid for option
    > blockTradeIdstringParadigm block trade ID
    > closedSizestringClosed position size
    > seqlongCross sequence, used to associate each fill and each position update
    • The seq will be the same when conclude multiple transactions at the same time
    • Different symbols may have the same seq, please use seq + symbol to check unique

    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",
    "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
    }
    ]
    }