Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exchange.fetchConvertTradeHistory - no data if the period is longer than about half a year - on binance #22289

Open
egabosh opened this issue Apr 26, 2024 · 5 comments · May be fixed by #22315

Comments

@egabosh
Copy link

egabosh commented Apr 26, 2024

Operating System

Debian 12

Programming Languages

Python

CCXT Version

4.3.8

Description

If I enter a period longer than half a year, e.g. 8 months, I get no data back. Here as an example 2023-01-01 to 2023-12-31.

CCXT Version: 4.3.8

fetch Request: binance GET https://api.binance.com/sapi/v1/convert/tradeFlow?timestamp=1714140060828&startTime=1672527600000&endTime=1703977200000&limit=200&recvWindow=10000&signature=3394f0782a6fc6b1992a216c8916f7be1196d25c222291aa558f13f4a30ee994 RequestHeaders: {'X-MBX-APIKEY': 'VGN6q6EvYsLAuuEgzC1Ng64K88eFy40WxbpAuRJeqAuzEiA5tNqDz7dNa13Pa7kB', 'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} RequestBody: None

fetch Response: binance GET https://api.binance.com/sapi/v1/convert/tradeFlow?timestamp=1714140060828&startTime=1672527600000&endTime=1703977200000&limit=200&recvWindow=10000&signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXX 200 ResponseHeaders: {'Content-Type': 'application/json', 'Content-Length': '90', 'Connection': 'keep-alive', 'Date': 'Fri, 26 Apr 2024 14:01:00 GMT', 'Server': 'nginx', 'X-SAPI-USED-UID-WEIGHT-1M': '3000', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 XXXXXXXXXXXXXXXXXXXXX.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA56-P4', 'X-Amz-Cf-Id': 'XXXXXXXXXXXXXXXXXXXXXXXXXX'} ResponseBody: {"list":[],"startTime":1701385200000,"endTime":1703977200000,"limit":200,"moreData":false}
[]

Code

exchange.verbose = True
print('CCXT Version:', ccxt.__version__)
print(exchange.fetchConvertTradeHistory(limit=200, since=1672527600000, params={'until': 1703977200000}))
@sc0Vu
Copy link
Contributor

sc0Vu commented Apr 27, 2024

@egabosh based on the documentation (https://binance-docs.github.io/apidocs/spot/en/#get-convert-trade-history-user_data), the max interval between start time and end time should be 30 days. The timestamp looks normal if I use 30 days interval:

request
https://api.binance.com/sapi/v1/convert/tradeFlow?startTime=1672527600000&endTime=1675119600000&limit=200

response
{"list":[],"startTime":1672527600000,"endTime":1675119600000,"limit":200,"moreData":false}

Let us know if you have other issues.

@egabosh
Copy link
Author

egabosh commented Apr 27, 2024

Thanks for the quick reply.

However, this behavior probably varies from exchange to exchange. Is there a way to query this beforehand using a CCXT method or similar?

Or does it make sense to add an error message via CCXT if more than 30 days are queried?

@egabosh
Copy link
Author

egabosh commented Apr 27, 2024

Perhaps it would also be a great feature if CCXT automatically split in several queries for periods longer than the 30-day limit and then summarized the results.

@sc0Vu
Copy link
Contributor

sc0Vu commented Apr 28, 2024

@egabosh the behavior would change acorss different exchanges.

I think that would be great if we validate interval and throw error. I'll open a PR for this!

For the split query, it's not unified behavior like pagination, maybe you can implement this on top of ccxt.

@egabosh
Copy link
Author

egabosh commented Apr 29, 2024

In order to implement this in addition to ccxt, I need an information about the limit of the respective exchange from somewhere.
For an application that should work for all exchanges, it would be optimal if CCXT could provide this information. Is there a possibility?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants