-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-analysis.py
More file actions
executable file
·33 lines (24 loc) · 862 Bytes
/
Copy pathdata-analysis.py
File metadata and controls
executable file
·33 lines (24 loc) · 862 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
25
26
27
28
29
30
31
32
33
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
from matplotlib.finance import candlestick_ohlc
import matplotlib.dates as mdates
style.use('ggplot')
start = dt.datetime(2014, 1, 1)
end = dt.datetime(2016, 12, 31)
df = web.DataReader('TSLA', "google", start, end)
df.to_csv('TSLA.csv')
df = pd.read_csv('tsla.csv', parse_dates=True, index_col=0)
# df['High'].plot()
df[['High', 'Low']].plot()
# plt.show()
df['100ma'] = df['Close'].rolling(window=100,min_periods=0).mean()
ax1 = plt.subplot2grid((6,1), (0,0), rowspan=5, colspan=1)
ax2 = plt.subplot2grid((6,1), (5,0), rowspan=1, colspan=1,sharex=ax1)
ax1.plot(df.index, df['Close'])
ax1.plot(df.index, df['100ma'])
ax2.bar(df.index, df['Volume'])
plt.show()
# print(df.head())