alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.59k stars 375 forks source link

ConnectionError: ERR#0015: error 429, try again later #467

Closed Ashabat1 closed 2 years ago

Ashabat1 commented 2 years ago

I keep getting the following message: ConnectionError: ERR#0015: error 429, try again later.

alvarobartt commented 2 years ago

Hi @Ashabat1, could you please provide me with more information about it? Like the investpy function that you are calling, the parameters, etc., and also some other information if possible like the region you are sending the requests from. As the HTTP 429 error code states that you may have exceeded the limitations of the Investing.com and, so on, you have been blocked from it 😩

Ashabat1 commented 2 years ago

Thank you for the quick response.
Function: investpy.get_stock_historical_data Parameter: South Africa Exchanges companies Country: South Africa

What are exactly the limitations? Is it the number of requests?

alvarobartt commented 2 years ago

Thanks for your response, I'm not getting that error, anyway, I'll try to run some stress tests in order to estimate a little bit better which are the limitations of Investing.com, so that I can give you at least a number of supported requests per hour or something similar!

In the meantime, you could try using a different IP to see whether that works or not, so as to clearly spot that the issue with Investing.com is the rate limitation.

Ashabat1 commented 2 years ago

I have done some tests. I fix it by setting up the time.sleep(10) between the calls. Thank you @alvarobartt

arielmeragelman commented 2 years ago

I have done some tests. I fix it by setting up the time.sleep(10) between the calls. Thank you @alvarobartt

Could you please tell us how much time you have to wait until get again the response from the api Did it work from the same IP? Im having the same issue Thanks

ymyke commented 2 years ago

I had the same issue. Using a VPN to change my IP address helps to "start clean" again.

In my case, waiting 2'' after each request prevents running in to the issue.

See this also: https://github.com/alvarobartt/investpy/issues/149

ghost commented 2 years ago

I am getting the same error

start_date = '1993-01-01'
end_date = '2020-01-01'

# convert to date objects 
start_date = dt.datetime.strptime(start_date, '%Y-%m-%d').date()
end_date   = dt.datetime.strptime(end_date, '%Y-%m-%d').date()

# set correct date format for investpy library 
start_date = start_date.strftime("%d/%m/%Y") 
end_date = end_date.strftime("%d/%m/%Y")

investpy.get_fund_historical_data(fund= 'Baillie Gifford American Fund B Accumulation',
                                       country   = 'united kingdom',
                                       from_date = start_date,
                                       to_date   = end_date)
arielmeragelman commented 2 years ago

After 2 days It start working again, so I sugest to run que api with time.sleep to avoid get your ip banned, I dont have enought information to say how often you can run it

ghost commented 2 years ago

I have done some tests. I fix it by setting up the time.sleep(10) between the calls. Thank you @alvarobartt

Can you please put a minimum working example so others can see how you used the sleep function to fix this?

alvarobartt commented 2 years ago

@msh855 Should look something similar to:

import investpy
from time import sleep

for _ in range(10):
    _ = investpy.get_stock_historical_data(stock="AAPL", country="United States", from_date="01/01/2010", to_date="01/01/2021")
    sleep(5)