Sample code for stocks charts

I got few questions if anyone can answer. I have seen interactive charts for stocks. What would I need to test one of those sample codes such as this one?

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html

from pandas_datareader import data as web
from datetime import datetime as dt

app = dash.Dash(‘Hello World’)

app.layout = html.Div([
dcc.Dropdown(
id=‘my-dropdown’,
options=[
{‘label’: ‘Coke’, ‘value’: ‘COKE’},
{‘label’: ‘Tesla’, ‘value’: ‘TSLA’},
{‘label’: ‘Apple’, ‘value’: ‘AAPL’}
],
value=‘COKE’
),
dcc.Graph(id=‘my-graph’)
], style={‘width’: ‘500’})

@app.callback(Output(‘my-graph’, ‘figure’), [Input(‘my-dropdown’, ‘value’)])
def update_graph(selected_dropdown_value):
df = web.DataReader(
selected_dropdown_value,
‘google’,
dt(2017, 1, 1),
dt.now()
)
return {
‘data’: [{
‘x’: df.index,
‘y’: df.Close
}],
‘layout’: {‘margin’: {‘l’: 40, ‘r’: 0, ‘t’: 20, ‘b’: 30}}
}

app.css.append_css({‘external_url’: ‘https://codepen.io/chriddyp/pen/bWLwgP.css’})

if name == ‘main’:
app.run_server()

When I run it on Rodeo IDE, it shows the following error:

ModuleNotFoundError: No module named ‘dash_renderer’

Thanks in advance.

Hi @syracusepro,

I guess you do not have dash_renderer library. Please install dash_renderer:

  pip install dash-renderer==0.12.1

Maybe you do not have other libraries required. Please confirm you have already installed all libraries you need for Dash app.

See here: https://dash.plot.ly/installation