alvarobartt / investpy

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

No connection Error in get_stock_historical_data #462

Closed ajit1310 closed 2 years ago

ajit1310 commented 2 years ago

Hi, Not sure what this Error is about , can you please look into it .

File "C:\Python38\lib\site-packages\investpy\stocks.py", line 559, in get_stock_historical_data raise ConnectionError("ERR#0015: error " + str(req.status_code) + ", try again later.") ConnectionError: ERR#0015: error 429, try again later.

alvarobartt commented 2 years ago

Hi @ajit1310, thanks for reporting it, let me check!

alvarobartt commented 2 years ago

Soooo I've tried the following piece of code and it worked! :weary: So could you please provide me more information so as to be able to reproduce the exact same error that you ran into? Thanks!

import investpy

data = investpy.get_stock_historical_data(
    stock='aapl',
    country='united states',
    from_date='01/01/2020',
    to_date='01/01/2021'
)
systinvest commented 2 years ago

I am getting the same error... Exception has occurred: ConnectionError (note: full exception trace is shown but execution is paused at: ) ERR#0015: error 429, try again later.

I also get the error running the previously example code with AAPL.

In the web I found that #429 stands for "Too Many Requests", which is a bit odd in my case since I haven't used investpy quite a while. Could it be that some IP's get blocked by investing in case of 'too many' requests? How much is too much?

ugurilter commented 2 years ago

Hi @alvarobartt, i'm also having an error, but the code is 503 for me. I tried your example too and it doesn't work for me also.

$ python invest.py

Traceback (most recent call last): File "invest.py", line 3, in data = investpy.get_stock_historical_data( File "/home/prodigy/.local/lib/python3.8/site-packages/investpy/stocks.py", line 559, in get_stock_historical_data raise ConnectionError("ERR#0015: error " + str(req.status_code) + ", try again later.") ConnectionError: ERR#0015: error 503, try again later.

alvarobartt commented 2 years ago

Mmm so the error code that you provided @ugurilter is something affecting Investing.com as that's directly related to the API of Investing.com (something I cannot handle), so just wait a bit and it should be back working soon 😩 Sorry I cannot help you more!

alvarobartt commented 2 years ago

And I assume that @ajit1310 error was thrown because he/she sent way too many requests to Investing.com, which led to an IP-blacklisting by Investing.com which means that you'll need to wait some time until your IP is released to start sending requests again...

ajit1310 commented 2 years ago

alvarobartt , you seems to be correct , now it working for few stocks . then it throws error .

File "C:\Python38\lib\site-packages\investpy\stocks.py", line 559, in get_stock_historical_data raise ConnectionError("ERR#0015: error " + str(req.status_code) + ", try again later.") ConnectionError: ERR#0015: error 429, try again later.

alvarobartt commented 2 years ago

@ajit1310, maybe you can just include a timeout between the requests so that Investing.com doesn't blacklists your IP 😩

ajit1310 commented 2 years ago

getting same error. Traceback (most recent call last): File "C:\Python38\Lib\site-packages\investpy\temp1.py", line 3, in data = investpy.get_stock_historical_data( File "C:\Python38\lib\site-packages\investpy\stocks.py", line 559, in get_stock_historical_data raise ConnectionError("ERR#0015: error " + str(req.status_code) + ", try again later.") ConnectionError: ERR#0015: error 429, try again later.

Process finished with exit code 1

ajit1310 commented 2 years ago

it may be something to do with the headers and params .