Created
June 27, 2020 14:47
-
-
Save rpkyle/b69a4c70bb35b53c1902587a7c3e52dc to your computer and use it in GitHub Desktop.
Dash for Python Stock Ticker Sample App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | |
external_stylesheets=['https://codepen.io/chriddyp/pen/bWLwgP.css']) | |
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, | |
'yahoo', | |
dt(2017, 1, 1), | |
dt.now() | |
) | |
return { | |
'data': [{ | |
'x': df.index, | |
'y': df.Close | |
}], | |
'layout': {'margin': {'l': 40, 'r': 0, 't': 20, 'b': 30}} | |
} | |
if __name__ == '__main__': | |
app.run_server() |
Nice! Thanks!
Good job!!
Awesome.
Good job!
Good job! ありがとうございます。
F# version here: https://gist.github.com/kMutagene/b1af6e4d388dbd04a47a1014ad450593
Python 3.8 says "No module named 'pandas_datareader'"
ありがとうございます。
I just wanted to know... Can i grab the data from the SharePoint List.
Please share if someone knows about it.
@abenvie pip3 install pandas-datareader
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
R version: https://gist.github.com/rpkyle/e01e67b1b395291f65b7a584ebe6a93a
Julia version: https://gist.github.com/rpkyle/cedf2b34043362d303ed677f139c8375
F# version: https://gist.github.com/kMutagene/b1af6e4d388dbd04a47a1014ad450593