-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtechstock.py
More file actions
57 lines (46 loc) · 1.21 KB
/
techstock.py
File metadata and controls
57 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import datetime
import plotly.offline as py
import plotly.graph_objs as go
import pandas_datareader as web
start = datetime.datetime(2014,1,1)
end = datetime.datetime(2018,1,1)
FB = web.DataReader('FB', 'yahoo', start,end)
TW = web.DataReader('TWTR', 'yahoo', start,end)
AAPL = web.DataReader('AAPL', 'yahoo', start,end)
trace = go.Ohlc(
x=FB.index[:],
open=FB['Open'],
high=FB['High'],
low=FB['Low'],
close=FB['Close'],
name='FB',
increasing=dict(line=dict(color='blue')),
decreasing=dict(line=dict(color='red')),
)
trace2 = go.Ohlc(
x=FB.index[:],
open=TW['Open'],
high=TW['High'],
low=TW['Low'],
close=TW['Close'],
name='TW',
increasing=dict(line=dict(color='yellow')),
decreasing=dict(line=dict(color='red')),
)
trace3 = go.Ohlc(
x=FB.index[:],
open=AAPL['Open'],
high=AAPL['High'],
low=AAPL['Low'],
close=AAPL['Close'],
name='AAPL',
increasing=dict(line=dict(color='green')),
decreasing=dict(line=dict(color='red')),
)
data = [trace, trace2, trace3]
layout = {
'title': 'Facebook vs Twitter vs Apple',
'yaxis': {'title': 'Price per stock'}
}
fig = dict(data=data, layout=layout)
py.plot(fig, filename='techstocks.html')