Websockets listener - trade to order matching

Hi,

I have setup a client such that;

  1. It places orders when certain market conditions are met.
  2. I have a websocket listener setup listening to either aggregated trades or non aggregated trades.

I cannot see how to match the client Order ID/Order ID to the aggregated/non aggregated trades.
e.g. trades come in over websockets like this;

{
“e”: “aggTrade”, // Event type
“E”: 123456789, // Event time
“s”: “BTCUSDT”, // Symbol
“a”: 5933014, // Aggregate trade ID
“p”: “0.001”, // Price
“q”: “100”, // Quantity
“f”: 100, // First trade ID
“l”: 105, // Last trade ID
“T”: 123456785, // Trade time
“m”: true, // Is the buyer the market maker?
}

How can I map this to the new order I placed? The aim here is to be able to determine when my order has been executed without polling the binance backend.

Thanks much,

Graham

Can anybody help me out.

Hi Graham,

Use the User Data stream instead of the Aggregated Trade market stream for order changes.

https://binance-docs.github.io/apidocs/spot/en/#payload-order-update