Last active
April 20, 2020 10:38
-
-
Save databyjp/81d296e37feb57da82c84a7373dc6cfa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def get_bezos_data(): | |
amzn_data = get_stock_data(tiingo_token).json() | |
amzn_df = pd.DataFrame(amzn_data) | |
amzn_df = amzn_df.assign(bezos_year=(amzn_df.close - amzn_df.iloc[0].close) * 498 * 10**6 * 0.112) | |
return amzn_df | |
app.layout = dbc.Container([ | |
html.Div([ | |
dcc.Graph( | |
id='bezos-worth-graph', | |
config={"displayModeBar": False} | |
), | |
dcc.Interval( | |
id='bezos-graph-interval', | |
interval=60 * 60 * 1000, # in milliseconds | |
n_intervals=0 | |
) | |
]), | |
]) | |
@app.callback(Output('bezos-worth-graph', 'figure'), | |
[Input('bezos-graph-interval', 'n_intervals')]) | |
def update_graph(n): | |
amzn_df = get_bezos_data() | |
fig = px.scatter(amzn_df, x='date', y='bezos_year', template='ggplot2', title="Jeff Bezos' 2020 net worth gains", | |
labels={'close': 'Change to Net Worth (USD)', 'date': 'Date', 'bezos_year': 'YTD gains'}) | |
fig.update_traces(mode='lines+markers') | |
fig.update_xaxes(rangebreaks=[dict(bounds=["sat", "mon"])]) # hide weekends | |
return fig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment