본문 바로가기
트레이딩/암호화폐

bybit . API V5 . 웹소켓 Order , Execution . 내 주문 처리 정보 실시간 수신

by i.got.it 2023. 10. 26.

 

내 주문 체결 정보 실시간 수신 

- 내 주문의 접수, 거부, 체결 , 취소,  수정 이벤트 실시간  수신. 

- 비교 : 구버전에서는 Execution 에도 OrderStatus 정보 제공되었으나, V5 에서는 Order 로만 OrderStatus 정보 제공됨. 

 

 

 

 

 

Order . subscribe 구문. 

 




{
    "op": "subscribe",
    "args": [
        "order"
    ]
}

args 에 order 기록하면 내가 주문한 종목이 현물, 선물, 인버스, 옵션 모두 실시간 수신 가능. 

그룹별로 요청 하려면  order.spot , order.linear, order.inverse, order.option 기록. 

 

 

Order 실시간 수신데이터 형식. 



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

 

데이터 항목 

 

Parameter Type Comments
     
id string Message ID
topic string Topic name
creationTime number Data created timestamp (ms)
data array Object
> category string Product type
  • Unified account: spot, linear, inverse, option
  • Classic account: spot, linear, inverse.
> orderId string Order ID
> orderLinkId string User customised order ID
> isLeverage string Whether to borrow. Unified spot only. 0: false, 1: true. . Classic 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
cancelType string Cancel type
rejectReason string Reject reason. Classic spot is not supported
> avgPrice string Average filled price. If unfilled, it is ""
  • For normal account USDT Perp and Inverse derivatives trades, if a partially filled order, and the final orderStatus is Cancelled, then avgPrice is "0"
  • For Classic spot is not supported, it is always ""
> 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. For normal spot, it is the execution fee per single fill
> 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
> orderIv string Implied volatility
> 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)

 

orderStaus 상세 

 

orderStatus

  • Created order has been accepted by the system but not yet put through the matching engine
  • New order has been placed successfully
  • Rejected
  • PartiallyFilled
  • PartiallyFilledCanceled Only spot has this order status
  • Filled
  • Cancelled In derivatives, orders with this status may have an executed qty
  • Untriggered
  • Triggered
  • Deactivated
  • Active order has been triggered and the new active order has been successfully placed. Is the final state of a successful conditional order

 

 

 

 

 

 

Execution . subscribe 구문 



{
    "op": "subscribe",
    "args": [
        "execution"
    ]
}

 

 args 에 executiuon 기록하면 내가 주문한 종목이 현물, 선물, 인버스, 옵션 모두 실시간 수신 가능. 

그룹별로 요청 하려면  execution.spot , execution.linearexecution.inverseexecution.option 기록. 

 

 

VC++ 코드 구현예.



/*
2023.10.26. api v5  
subscribe 구문. 
{
    "op": "subscribe",
    "args": [
        "execution" 
    ]
}
args에 기록가능한 것.
전종목그룹 요청시 : execution
그룹별 요청시: execution.spot , execution.linear, execution.inverse, execution.option
인자 : Symbol* 종목 1개단위로 요청안되므로 사용하지 않음. 
*/
int CCyWebSocketBybit_Spot::Subscribe_Execution_MyOrder(CCyD_CyFinSymbol::Symbol* p_symbol, int sub_unsub)
{
    std::string str_data;
    if (sub_unsub == 1) {
        str_data = "{\"op\": \"subscribe\", \"args\": [ \"execution.spot\"]}";

        if (0 < m_CCyWebSocket_Secure.send_websocket(str_data)) { // 구독성공. 
            Regi_Symbol(p_symbol, 1);
        }

    }
    else if (sub_unsub == 0) {
        str_data = "{\"op\": \"unsubscribe\", \"args\": [ \"execution.spot\"],\"req_id\":\"customised_id\"}";

        if (m_CCyWebSocket_Secure.send_websocket(str_data)) { // 구독해지 성공. 
            Regi_Symbol(p_symbol, 0);
        }

    }
    else {
        return -1;
    }


    return 1;

}

 

 

Execution 실시간 수신데이터 형식. 


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

 

Execution 데이터 항목 

 

 

Parameter Type Comments
     
id string Message ID
topic string Topic name
creationTime number Data created timestamp (ms)
data array Object
category string Product type
  • Unified account: spot, linear, inverse, option
  • Classic account: spot, linear, inverse.
> symbol string Symbol name
> isLeverage string Whether to borrow. Unified spot only. 0: false, 1: true. . Classic 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
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
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
  • 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

 

 

 

연관 

 

bybit api 페이지 

 

Bybit | Bybit API

Powerful APIs for Developers

www.bybit.com

 

 

상위정리

 

 

bybit api v5 . 활용방법 정리

bybit API v5 . 서버 주소 bybit. API V5. 서버 주소 정리. 암호화폐 거래소 bybit 의 API V5 서버 주소 bybit 전종목 Rest 서버 - Rest 서버는 전 종목 동일 주소. 실거래 서버 시험용 서버 Rest 서버 주소 https://api.

igotit.tistory.com

 


첫 등록 : 2023.10.26

최종 수정 : 

단축 주소 : https://igotit.tistory.com/4952


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드         암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)         프랍 트레이더 온라인 지원가능. MT4,MT5