Coinigy / api

Coinigy API Examples
162 stars 65 forks source link

Potential order_id issue #28

Open madsmao opened 6 years ago

madsmao commented 6 years ago

I'm pulling order history via the API, and saving it in a MongoDB collection, because I need history for more than the past 200 orders. I assumed that order_id was unique, so I could simply pull the freshest data from your API and insert them into my MongoDB collection (with a unique index on order_id) ignoring duplicates. However, I noticed a weird issue with ZCL/BTC on Cryptopia yesterday (have not seen it with any other markets so far) where a small subset of historical buy orders would suddenly show up multiple times with different values for order_id, but everything else appears to be identical. Is it possible that order_id is not unique as I assumed?

madsmao commented 6 years ago

Digging a bit deeper, it seems that this is happening only to a particular buy order that was filled by two separate sales. The first part of the order is repeated 5 times, and the 2nd part of the order (that filled the remaining buy amount) is now repeated 36 times. All repeats have been assigned a new order_id, but they are clearly the same order in every other aspect. As I see no other meaningful way to filter out duplicates than assuming a unique order_id (multiple orders with the same amount and timestamp is theoretically possible), I really can't see a good way of handling this issue.

madsmao commented 6 years ago

The problem seems to be isolated to Cryptopia (I have history for Bittrex, Binance, and Bitfinex as well), and it doesn't seem to be only isolated to buy orders that were filled by multiple sell orders. It seems to randomly affect only buy orders, and I have spotted it on ETN/BTC, ORME/BTC, and ZCL/BTC, which are the only markets on Cryptopia I have any recent trade history on.

On the first invocation of the API, when I first populate my empty MongoDB collection with data, there doesn't appear to be any duplicates at all, but then subsequent invocations of the API will eventually create these duplicates, where only the order_id differs.