Question:
What are the methods to get the executed price after placing a MARKET order by using /api/v3/order
endpoint ?
The executed price can be consulted in different scenarios:
- A - During New Order via REST API (POST /api/v3/order)
In this request’s response, you’ll find a section named “fills”
:
"fills": [
{
"price": "4000.00000000", // Filled Price
"qty": "1.00000000",
"commission": "4.00000000",
"commissionAsset": "USDT"
},
…
{
"price": "3998.00000000", // Filled Price
"qty": "2.00000000",
"commission": "7.99600000",
"commissionAsset": "USDT"
}
One MARKET price can have several trades and the average executed price can be calculated by doing:
sum(prices)/#trades = (4000.00000000+3998.00000000)/2 = 3999 (USDT)
- B - During New Order via Websocket (User Data Stream)
As one MARKET order can have several trades, you can receive several executionReport
events, look for the "L"
field:
"L": "20.00000000" // Filled Price
- C: During Query Order (GET /api/v3/order)
After sending this request with symbol, orderId/clientOrderId, you’ll receive the following example:
{
"symbol": "BTCUSDT",
"orderId": 6489937,
"orderListId": -1,
"clientOrderId": "my_order_id_1",
"price": "0.00000000",
"origQty": "0.01000000",
"executedQty": "0.01000000",
"cummulativeQuoteQty": "457.02230000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"stopPrice": "0.00000000",
"icebergQty": "0.00000000",
"time": 1629389900927,
"updateTime": 1629389900927,
"isWorking": true,
"origQuoteOrderQty": "0.00000000"
}
The average price can be obtained by doing:
cummulativeQuoteQty/executedQty = 457.02230000/0.01000000 = 45702.23 (USDT)
1 Like