'Plotly-Dash IEX Stock API error or any alternative?

I am on my way completing my course, capstone project is about creating stock ticker. I browse through documentation and said that IEX now need special Key. I tried it and it's not worked. I tried other source such as Tiingo, Yahoo, Morningstar, OECD, FRED and still not working.

Since I'm new in python or programming world, I do not understand what is wrong exactly here. I just wanna learn the basic first by following the course instruction. And this is happen. There is no error code here, just the output did not working. Here is the code:

import dash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output, State
import pandas_datareader.data as web
from datetime import datetime

app = dash.Dash()

app.layout = html.Div([
            html.H1('Stock Ticker Dashboard'),
            html.H3('Enter Stock Symbol:'),
            dcc.Input(id='my_stock_picker',
                     value='TSLA'),
            dcc.Graph(id='my_graph',
                     figure={'data':[
                         {'x':[1,2],'y':[3,1]}
                     ], 'layout':{'title':'Default Title'}})
])

@app.callback(Output('my_graph','figure'),
             [Input('my_stock_picker','value')])
def update_graph(stock_ticker):
    start = datetime(2017,1,1)
    end = datetime(2017,12,31)
    df = web.DataReader(stock_ticker,'iex',start,end) ######'iex' not wroking? Any alternative?
    fig = {'data':[{'x': df.index, 'y': df['close']}],
          'layout':{'title':stock_ticker}
          }
    return fig


Solution 1:[1]

You should add the api_key as one of the parameters to the web.DataReader call:

df = web.DataReader(stock_ticker, 'iex', start,end, api_key='<iex_api_key>')

The above code worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ezra Katz