gateio / gateapi-go

100 stars 32 forks source link

Page order is incorrect for public order (GET /spot/trades) request in v6.22.3 #26

Closed Algalish closed 2 years ago

Algalish commented 2 years ago

First of all - thank you @revilwang for adding support to requesting orders by time range in v6.22.3. It was a tricky task getting the correct ID of the old trade before.

So the problem is that when I make such a request with "from" and "to" and "page" I get pagination inverted. For example if from Date A to Date B there were 500 trades then I expect to get trades 1-100 with "page" = 1 , then 101-200 with 'page' = 2 etc. But I am getting trades 401-500 with "page" = 1 then 301-400 with 'page' = 2 , etc. So the pagination order is inverted. And its impossible to get the first trades right away because you have to know the maximum number of pages (since the order is inverted). P.S. And if I don't send the 'page' parameter at all I get the last 100 trades in that time interval.

I hope my explanation makes sense.

Algalish commented 2 years ago

I am also seeing this error when requesting old trades with 'from' and 'to' "message: for public trades older than 30 days, download from historical data instead"

Thats very strange since this is the historical data endpoint and there are no others right?

revilwang commented 2 years ago

Trade history by design is returned with newest first, so that you'll get the latest 100 trades if only currencyPair is provided. Other parameters will not change the sorting.

Order and trade history are limited to last 30 days using REST API. Older public data can be retrieved from here, which you can also find it from the developers link down below gate.io main page

Algalish commented 2 years ago

Trade history by design is returned with newest first, so that you'll get the latest 100 trades if only currencyPair is provided. Other parameters will not change the sorting.

Order and trade history are limited to last 30 days using REST API. Older public data can be retrieved from here, which you can also find it from the developers link down below gate.io main page

thx for reply! but do you think there will be a way to change the order from the 'from' to 'to' timestamps in the future? I mean it's called 'from' and 'to' but pages are returned beginning with 'to' and all the way to 'from' timestamps and thats kind of bizarre, don't you think?

revilwang commented 2 years ago

We think it another way. The default action is returning the latest 100 trades with newest in front. If adding more non-sorting-releated parameters leads to sorting change, it is API inconsistency.