How is exclude duplicate order execution by API?

My case is:

  1. ORDER request to API
  2. NO RESPONSE from API during request
  3. Catched trouble from (2)
  4. Retry ORDER request to API
  5. Good response of (4)

After some time I found that request (1) has gotten by API Binance and executed, So we hade duplicated executing of order.

How can I prevent this case/behavior?

Did anyone find a good solution so far ? Binance allowing same ClientOrderId on 2 orders is getting me unintended duplicated orders.

2 Likes

At #1, specify a unique ID to newClientOrderId
At #2, instead of relying on response, listen to user data stream and check the status of that order (use the ID you specified at #1 to identify the order)

Yes, I’m using unique ID to newClientOrderId and decied that market doesn’t allow 2 orders with same field. That’s not so :frowning:

Sorry :frowning:
It was hoped that the API would not allow me to create two orders with the same newClientOrderId

And I want to see someone else’s processing experience of handling this situation

As the document said “same newClientOrderId can be accepted only when the previous one is filled, otherwise the order will be rejected.”
Binance won’t reject the duplicate order if the previous one is filled. In the case of market order, which may filled in seconds, newClientOrderId won’t help much.

I’m wondering if there is a more effective way to avoid duplicate order. @MJW

Always rely on user data stream to confirm the status of the order you sent out. That’s the most effective way to avoid duplicate orders

hi, i just placed a market spot order, but it got executed twice.
i use node , and node-binance-api module for this. pls help me how to stop binance from duplicating my orders.

Please rephrase your language. I don’t understand what your problem of using client order id is