In [1]:
import pandas_datareader.data as web
import datetime
import matplotlib.pyplot as plt
In [2]:
start = datetime.datetime(2012, 1, 1)
end = datetime.datetime(2017, 12, 31)
In [3]:
f = web.DataReader('SNE', 'morningstar', start, end)
In [4]:
print(f.head())
In [5]:
f2 = web.DataReader(['SNE', 'AAPL'], 'morningstar', start, end)
In [6]:
print(type(f2.index))
print(f2.head())
print(f2.tail())
In [7]:
f2_u = f2.unstack(0)
print(f2_u.head())
In [8]:
print(f2_u['Close'].head())
In [9]:
f2_u['Close'].plot(title='SNE vs AAPL', grid=True)
# plt.show()
plt.savefig('data/dst/pandas_datareader_morningstar.png')
In [10]:
f2_u['Close', 'AAPL'] /= f2_u['Close'].loc[f2_u.index[0], 'AAPL']
f2_u['Close', 'SNE'] /= f2_u['Close'].loc[f2_u.index[0], 'SNE']
In [11]:
f2_u['Close'].plot(title='SNE vs AAPL', grid=True)
# plt.show()
plt.savefig('data/dst/pandas_datareader_morningstar_normalize.png')