stas-prokopiev / binance_historical_data

python PYPI package to dump all needed crypto historical data from binance just by 2 lines of code
MIT License
71 stars 25 forks source link

HTTPError: HTTP Error 451: #6

Closed waynelapierre closed 1 year ago

waynelapierre commented 1 year ago

I am getting the error message: HTTPError: HTTP Error 451: when running the examples in your package homepage.

miro-ka commented 1 year ago

I got the same issue when I tried to run it from colab, which IP is afaik on Binance Restricted Location list (US). Didn't get any message when I tried it locally (outside of US).

So I believe this isn't a bug

stas-prokopiev commented 1 year ago

Hi, Sorry for the super late response. Seems that the problem is that Binance forbids access from US IPs. Could you please provide the full error traceback so I could add a more understandable message for the users?

AdrianosBates commented 1 year ago

FYI I fixed this by simply changing the API URLS to their US versions in data_dumper.py:get_list_all_trading_pairs(). Like this: https://api.binance.com/api/v3/exchangeInfo -> https://api.binance.us/api/v3/exchangeInfo

stas-prokopiev commented 1 year ago

Hi, Thank you so much for your suggestion, I applied a fix for everyone. Now URL is selected according to the user's country location so now it should work seamlessly. The new version is published on PYPI.

AdrianosBates commented 1 year ago

Looking into this a bit further, this method may have unintended consequences. For example, unless the list of tickers is the same on Binance.US and Binance, there may be attempts to retrieve tickers that do not exist on Binance, or there may be tickers that exist on Binance that are inaccessible. There is also a distinction between historical data on Binance.US and Binance, so a disclaimer may be pertinent to remind users they are not actually accessing historical data from Binance.US. I don't have any suggestions for fixing these inconsistencies, but this is something to think about.

Thank you for updating the repo.

waynelapierre commented 7 months ago

There is also a distinction between historical data on Binance.US and Binance

Are you sure about this?

AdrianosBates commented 7 months ago

It's been a while since I've worked with this library, so I can't say for sure at this point. I've since opted to use the official Binance spot client for historical data. From what I remember I was comparing the two datasets and found discrepancies, but that could have been my error or just the very slight difference in when data is recorded from either exchange.

waynelapierre commented 7 months ago

use the official Binance spot client for historical data.

How? Is there any Python package for that?

AdrianosBates commented 7 months ago

https://github.com/binance/binance-connector-python I believe this is the official package for it, but do your own research/use at your own risk and all that. You have to change the baseurl when instantiating the Client class to the US link. Although it seems this library has been updated a lot since I used it so things may have changed.