Skip to content

Instantly share code, notes, and snippets.

@rohithteja
Created March 11, 2022 14:39
Show Gist options
  • Save rohithteja/9ec75770c48a2ba61ff949829c5fa282 to your computer and use it in GitHub Desktop.
Save rohithteja/9ec75770c48a2ba61ff949829c5fa282 to your computer and use it in GitHub Desktop.
Daily trend line chart Plotly
# download daily crypto prices from Yahoo Finance
df = yf.download(tickers=f'{select_token}-{select_fiat}', period = '1d', interval = '1m')
# Plotly line chart
fig = go.Figure()
fig.add_scattergl(x=df.index, y=df.Close,
line={'color': 'green'},name='Up trend')
fig.add_scattergl(x=df.index, y=df.Close.where(df.Close <= df.Open[0]),
line={'color': 'red'},name='Down trend')
fig.add_hline(y=df.Open[0])
fig.update_layout(go.Layout(xaxis = {'showgrid': False},
yaxis = {'showgrid': False}),
title=f'{dic1[select_token]} Daily Trends in Comparison to Open Price',
yaxis_title=f'Price ({select_fiat})',template='plotly_dark',
xaxis_rangeslider_visible=False)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment