How does "fromId" works with duplicate trades returned from /myTrades endpoint?

While fetching /myTrades, received multiple trades with same trade ID (for ETH / AUD pair). Worth noting that time is also identical.

    ┌─────────┬──────────┬─────────┬──────────────────────────┐
    │ (index) │ orderId  │   id    │           time           │
    ├─────────┼──────────┼─────────┼──────────────────────────┤
    │    0    │ 77079375 │ 2474695 │ 2021-08-10T00:05:36.145Z │
    │    1    │ 77073886 │ 2474695 │ 2021-08-10T00:05:36.145Z │
    └─────────┴──────────┴─────────┴──────────────────────────┘

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”?

Also found this thread that points that this should not be happening:

cc @tantialex

TradeId is unique per symbol.

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.

1 Like