-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrydash-03.py
41 lines (35 loc) · 1.03 KB
/
trydash-03.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pandas_datareader.data as web
import datetime
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
app = dash.Dash()
app.layout = html.Div(children=[
html.Div(children='''
Symbol to graph:
'''),
dcc.Input(id='input', value='', type='text'),
html.Div(id='output-graph'),
])
@app.callback(
Output(component_id='output-graph', component_property='children'),
[Input(component_id='input', component_property='value')]
)
def update_value(input_data):
start = datetime.datetime(2015, 1, 1)
end = datetime.datetime.now()
df = web.DataReader(input_data, 'quandl', start, end)
return dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': df.index, 'y': df.Close, 'type': 'line', 'name': input_data},
],
'layout': {
'title': input_data
}
}
)
if __name__ == '__main__':
app.run_server(debug=True, host='0.0.0.0')