👉 Explore All My Excel Solutions: https://pythonandvba.com/solutions
𝗗𝗘𝗦𝗖𝗥𝗜𝗣𝗧𝗜𝗢𝗡
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
In this tutorial, I will show you, how to create a Candlestick Chart in Python by using the library called Plotly.
I will show you, how you can pull stock data for free using the pandas DataReader and to plot the stock information in Candlestick Chart.
__________________________________________________________
📝 SOURCE CODE:
import pandas_datareader as web
from datetime import datetime
import pandas as pd
import plotly.graph_objs as go
import plotly
import sys, os
os.chdir(sys.path[0])
Get Stock Data
start = datetime(2020,1,1)
end = datetime(2020,7,31)
stock ='TSLA'
df = web.DataReader(stock,'yahoo',start,end)
df = df.reset_index()
Create Candlestick
fig = go.Figure(data=[go.Candlestick(
x=df['Date'],
open=df['Open'],
high=df['High'],
low=df['Low'],
close=df['Adj Close']
)])
// Black Background and no gridlines
fig.update_layout(plot_bgcolor='rgb(0,0,0)',
xaxis = {'showgrid': False},
yaxis = {'showgrid': False})
Export Candlestick to HTML
plotly.offline.plot(fig, filename='Candlestick.html')
𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🔗 LinkedIn: / sven-bosau
📬 Contact: https://pythonandvba.com/contact
☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲?
If you want to support this channel, you can buy me a coffee here:
▶ https://pythonandvba.com/coffee-donation
In questa pagina del sito puoi guardare il video online 📈 How To Create A Candlestick Chart In Python Using Plotly | Tutorial [EASY] della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Coding Is Fun 19 settembre 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 12,237 volte e gli è piaciuto 193 spettatori. Buona visione!