-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAAPLprice.py
More file actions
24 lines (19 loc) · 735 Bytes
/
AAPLprice.py
File metadata and controls
24 lines (19 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pandas as pd
import yfinance
import plotly
import plotly.graph_objs as go
from plotly.offline import *
# To initiate ploty to run offline
init_notebook_mode(connected=True)
apple = yfinance.Ticker('AAPL')
df = apple.history(period='ytd').reset_index()
data = []
data.append(go.Candlestick(x=df['Date'], open=df['Open'],
high=df['High'], low=df['Low'],
close=df['Close']))
layout = {'title':{'text':'Year-to-Date Apple Stock Price','x':0.5},
'xaxis':{'title':'Date','rangeslider':{'visible':False}},
'yaxis':{'title':'Price ($)'},
'hovermode':False}
fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(fig, filename='apple_candlestick.html')