Search code examples
python-3.xpandasdataframedata-sciencestockquotes

Connecting to Iex API via Pandas Datareader (Python)


I try to connect to "iex" via the Pandas Datareader to retrieve some historical stock data. After searching around and trying several methods I came up with this code here:

from datetime import datetime
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader as pdr
import os


#How to get historical Stock data

symbols = "FB" #Stock Kürzel
start = datetime(2018, 9, 1)
end = datetime(2018, 10, 2)

DataframeStock = pdr.DataReader(symbols, data_source = "iex", start = start, end = end, api_key = "pk_1234")

print(DataframeStock)

As far as I can tell everything looks fine and like in the tutorials (for example here: https://pandas-datareader.readthedocs.io/en/latest/remote_data.html#remote-data-iex) (I registered on https://iexcloud.io/docs/api/ and Iam using my own public key). Unfortunately I get this error message:

SSLError: HTTPSConnectionPool(host='cloud.iexapis.com', port=443): Max retries exceeded with url: /stable/stock/market/batch?symbols=FB&types=chart&range=2y&token=pk_8dfc5c0ae37940e78a2a0037bed89d5b (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

It sound like I tried to often, but there shouldnt be to much of a restriction and overall I tried it less then 30 times and today stopped at 2 tries.

Also I cant find any Info that the API was changed recently (last time 2018 as far as I can tell) and the Code should be working with the current Version.


Solution

  • I think i found the answer to my issue. After change my OS and giving my Python IDE (Anconda/Spyder) full Administrative control it worked for me just fine. Another tip, always check if your source is currently still open or ristricted in some way. Happened to me with "morningstar". Happy trading :)