hitbtc-com / hitbtc-api

HitBTC API
GNU Lesser General Public License v3.0
322 stars 152 forks source link

'code': 20008, 'message': 'Duplicate clientOrderId' on cancelOrder #242

Closed alexanderborsch closed 3 years ago

alexanderborsch commented 4 years ago

Getting this error for a few months now: {'method': 'cancelOrder', 'params': {'clientOrderId': '1234567890123456789'}, 'id': 1590123456789} {'jsonrpc': '2.0', 'error': {'code': 20008, 'message': 'Duplicate clientOrderId', 'description': 'ClientOrderId must be unique during trading session'}, 'id': 1590123456789} Obviously the ID is not unique as I'm trying to cancel an existing order.

hitbtc-com commented 4 years ago

For the cancel Order request, you can't get a duplicate error message, looks like that you have got a response for different requests with the same id. Seem that you use a timestamp in ms as the id for your purpose. better to use atomic increase counter for this, if this is not available then guid can be a good choice

Do you use new endpoint wss://api.hitbtc.com/api/2/ws/trading ?

hitbtc-com commented 4 years ago

Anyway use the new endpoint, official documentation have to be updated soon. By code, do you use a Golang? If possible you can attach here this part of code?

alexander-hagen commented 4 years ago

Exactly. I'm pretty sure that the error comes in response to a cancelOrder request. For id use "int(10000 * time.time())" which increments every 100 microseconds and this is irrelevant as the error clearly says "Duplicate clientOrderId" not "Duplicate id". I use wss://api.hitbtc.com/api/2/ws as suggested here: https://api.hitbtc.com/#api-urls.

I have the same error: {"method":"cancelOrder","params":{"clientOrderId":"M-200531211307783-D-008"},"id":705}

Error caught (cancelOrder): {"code":20008,"message":"Duplicate clientOrderId","description":"ClientOrderId must be unique during trading session"} DEL: M-200531211307783-D-008

I actually get the same error on newOrder as well, for a clientOrderId that is 100% unique and hasn't been used before.

alexander-hagen commented 4 years ago

I have reduced clientOrderID to 20 characters and there's no duplicate clientOrderId errors anymore.