finnhub-python
finnhub-python copied to clipboard
Time out?
New to Finnhub. I am running the following simple code and getting an error message. What is causing this?
CODE import finnhub import time import datetime import pandas as pd
Setup client finnhub_client = finnhub.Client(api_key="XXXXXXXXXXXXX")
Stock candles res = finnhub_client.stock_candles('AAPL', 'D', 1590988249, 1591852249) print(res)
ERROR MESSAGE
Traceback (most recent call last):
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen retries = retries.increment( File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/util/retry.py", line 403, in increment raise six.reraise(type(error), error, _stacktrace) File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise raise value File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen httplib_response = self._make_request( File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 428, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout) File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 335, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='finnhub.io', port=443): Read timed out. (read timeout=10)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "timeout-test.py", line 11, in
I have same issue, finnhub_client.aggregate_indicator fails half of the time
I have the same issue with pattern_recognition. Is there no way to increase the timeout value?
@enoch-prince , @jasonpolstein , @dejoski Just ran into the same issues. If you go into the Client class file (called client.py, in VSCode you can hold control and click on the Client class declaration wherever it is in your code to move to where that class is defined), change the DEFAULT_TIMEOUT value. Increased mine to 120 seconds. So far no issues.
EDIT: So now instead of a read timeout, I'm running into a 504: Gateway time-out from the API. Seems that Finnhub may not be able to keep up with API requests.... I've reached out to their support to identify the issues and see if they are working on something like scaling solutions.
Great service in theory but I may be moving onto different API until Finnhub can resolve these issues.
I am still having the issues mentioned above. Has there been no fix for this?