gateio / gateapi-python

243 stars 90 forks source link

Is there any API that provides the total buy, total sell, total transaction, and total earning statistical report? #141

Open akashc-25 opened 1 year ago

akashc-25 commented 1 year ago

Hello,

I am looking for the total buy, total sell, total transaction, and total earning statistical report. For that, I referred to the gate.io developer API documentation, but I couldn't find out the above things from any APIs. So can you please help me? Is there any API that provides me with all these things?

Thank you.

akashc-25 commented 1 year ago

Can anyone please help me with my previous question?

revilwang commented 1 year ago

Can you give a more detailed explanation about your requirement. If you can find such data in a web page, please provide a screenshot.

akashc-25 commented 1 year ago

There is no data on the gate.io web page, What I want is if the user buys 1 crypto with 10 qty and another crypto with 20 qty then in total buy will be 30 because a user has bought two cryptos with different qty and the same as for sell. Total earnings means, how much has the user won by investing the amount in different crypto.

revilwang commented 1 year ago

You can list a user's trades with GET /spot/my_trades, then calculate the data by yourself. There are no such APIs on statistical reports.

akashc-25 commented 1 year ago

Okay, I go through the above API information, but I have one doubt: how can I find the total earnings? I mean, on which key would I consider calculating the total earnings?

revilwang commented 1 year ago

By earnings, I think you need to first define they should be calculated. If you have the rules, then you can do the calculation yourself. API only provides basic user accounts, trading history, etc. How you use these data depends mainly on your own logic.

akashc-25 commented 1 year ago

Okay, When I call the GET /spot/my_trades API without passing any query params it returns the record between "2022-11-09 14:02:39" and "2022-11-08 18:18:41" but it should return all the records. When I pass timestamp "1664821800" in query params which is equal to "2022-10-04 00:00:00", it returns every record between "2022-10-07 14:59:12" and "2022-10-04 17:57:32" but it should return all the records. I also try the different query parameters along with the time stamp but nothing changed. So can you please guide how can I get all records or which parameters I should pass to get all the records?

revilwang commented 1 year ago

Which field exactly do you mean by timestamp ? If no parameters are provided, the latest 100 trades returns. To list your records, specify both from, to, and set the limit to 1000 at most. If your time range is too broad, the number of records must exceed 1000 which you need to use page to retrieve paginated results.

akashc-25 commented 1 year ago

When I pass nothing in query params it returns only 4-5 records not all the records and I have less than 1000 records. I also passed the from, to, and limit in query params but it saying an invalid time range. Here is the example of what I'm passing: from=1664562600&to=1668364200&limit=1000

Please correct me if I am passing something invalid.

revilwang commented 1 year ago

Please provide your full request with your user id and send them to dev@gate.io so we can perform a detailed check.

revilwang commented 1 year ago

Hi, email is received. There is a mistake with my previous comment(which I've edited to cross out). The default behavior is based on time range. If no parameters are provided, only recent 7 days' records are returned. If only from or to is provided, the results will be in 7 days since from or until to.

You can specify both from and to to use a broader time range, but the range cannot exceed 30 days, which is why your from=1664562600&to=1668364200&limit=1000 request gets an error.

To fulfill your requirements, you need to retrieve your records by specify from and to within 30 days with limit set to 1000(if the number of records >= limit, increase page), then iterate the time range.

akashc-25 commented 1 year ago

Yes, I checked, and it's working. But I received an error while calling "/spot/my_trades" saying that currency_pair is required, but in the documentation, it is mentioned that required = false.

I am using the Python SDK to call the API.

revilwang commented 1 year ago

SDK still set the currency_pair as required to achieve compatibility. You can set the parameter, but set its value to an empty string ''