JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.02k stars 420 forks source link

GetOrdersAsync doesn't return filled quantity #1306

Closed tr5x closed 6 months ago

tr5x commented 9 months ago

Hi!

I recently started using method GetOrdersAsync and found that for a filled order QuanityFilled is 0 but LastFilledQuantity contains correct data. Binance API has completely different field for this - executedQty. I couldn't find any info on LastFilledQuantity and decided to ask here if it's a bug? Will LastFilledQuantity always have correct filled quantity and can be used to get filled quantity for both filled and partially filled orders?

Thanks a lot!

JKorf commented 9 months ago

QuantityFilled is mapped to executedQty, so that seems correct. LastFilledQuantity is not a property of the order class, so not sure what you're referring to there

tr5x commented 9 months ago

Hi, thanks for your prompt response.

I logged the result of GetOrdersAsync, as you can see it's filled, but QuantityFilled returned as 0. However there is a property called LastFilledQuantity which returns the correct filled quantity. Is it expected behavior? Should I just use LastFilledQuantity for both filled and partially filled orders? Thanks!

{
    "Symbol": "TRBUSDT",
    "Pair": null,
    "Id": 15337250984,
    "ClientOrderId": "cjZcj8TURVJxYUDhcpwLxj",
    "Price": 50.389,
    "AvgPrice": 50.389,
    "QuantityFilled": 0,
    "QuoteQuantityFilled": 5.0389,
    "BaseQuantityFilled": null,
    "LastFilledQuantity": 0.1,
    "Quantity": 0.1,
    "ReduceOnly": false,
    "ClosePosition": false,
    "Side": 1,
    "Status": 2,
    "StopPrice": 0,
    "TimeInForce": 0,
    "OriginalType": 0,
    "Type": 0,
    "ActivatePrice": null,
    "CallbackRate": null,
    "UpdateTime": "2023-10-12T06:15:54.016Z",
    "CreateTime": "2023-10-12T06:15:46.035Z",
    "WorkingType": 1,
    "PositionSide": 2,
    "PriceProtect": false
}
JKorf commented 6 months ago

Sorry for the late response. I'm guessing this is because you placed the order with quoteQuantity specified instead of quantity. So the API then returns the QuoteQuantityFilled instead of the QuantityFilled field. LastFilledQuantity only refers to the last trade, so that might not always be usable

tr5x commented 6 months ago

Thanks for your response. No, I never use quoteQuantity, only quantity, so there must be some mistake. I would really appreciate if you could have a look at the implementation. Thanks!

JKorf commented 6 months ago

Oh I'm sorry, I thought the json you posted was how you received it from the server, but I'm guessing it's the response data model serialized to json again. Could you see if you can also retrieve the original json? You can use the OutputOriginalData client option for it