In [2]:
import pandas as pd
import pandas.io.data as web
import datetime
In [3]:
start = datetime.datetime(2016,1,1)
end = datetime.date.today()
In [4]:
google = web.DataReader("GOOGL", "yahoo", start, end)
In [5]:
type(google)
Out[5]:
In [6]:
google.head()
Out[6]:
In [7]:
import matplotlib.pyplot as plt
%matplotlib inline
%pylab inline
pylab.rcParams['figure.figsize'] = (15, 9)
In [8]:
google["Adj Close"].plot(grid = True)
Out[8]:
In [9]:
amazon = web.DataReader("AMZN", "yahoo", start, end)
facebook = web.DataReader("FB", "yahoo", start, end)
In [10]:
stocks = pd.DataFrame({"GOOGL": google["Adj Close"],
"AMZN": amazon["Adj Close"],
"FB": facebook["Adj Close"]})
In [11]:
stocks.head()
Out[11]:
In [12]:
stocks.plot(grid = True)
Out[12]:
In [13]:
stocks.plot(secondary_y = ["FB"], grid = True)
Out[13]:
In [14]:
stocks_return = stocks.apply(lambda x: x / x[0])
stocks_return.head()
Out[14]:
In [15]:
stocks_return.plot(grid = True).axhline(y = 1, color="black", lw=2)
Out[15]:
In [20]:
# BHARTIARTL.NS
airtel = web.DataReader("BHARTIARTL.NS", "yahoo", start, end)
In [21]:
airtel.head()
Out[21]:
In [ ]: