How would be able to retrieve “next” trade when trade ID is not unique? Wondering what data model is behind trade and what attributes make trade “unique”?
In theory, one trade should appear in two orders across the exchange. One on the maker order, and the other on the taker order.
The scenario mentioned above is most likely the result of two of your orders matching with each other. Could you confirm if the two orders are in opposing directions (one BUY & one SELL)?
If this is the case, the system is working as intended.
Yes it does look like it - the trades are on opposite side.
TradeId is unique per symbol.
If this is the case, the system is working as intended.
Sounds like, indeed, trade is unique for the symbol and unique entity appears on both side of the trade.
The original question is still valid then, given each returned record is, potentially, “half” of the trade
How would be able to retrieve “next” trade when trade ID is not unique across returned entries?
This could cause an issue in a case (albeit, rare) where say requesting 50 records that end with one side of the trade. Then, for next request the fromId would be incremented and miss the second side of the trade.
How would be able to retrieve “next” trade when trade ID is not unique across returned entries?
Take note of the orderId of the last trade of the page, iterate the page including the last tradeId, and exclude any trade with matching tradeId and orderId as the previous noted trade.
Since the maximum number of trades sharing a common tradeId is two, this will solve your issue assuming your limit is greater than 2.