In [17]:
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import pandas_datareader.data as web
import datetime
In [20]:
prices = web.DataReader(['CVX','XOM','BP'], 'yahoo', start=datetime.datetime(2010,1,1),
end=datetime.datetime(2013,1,1))['Adj Close']
prices.head()
Out[20]:
In [21]:
volume = web.DataReader(['CVX','XOM','BP'], 'yahoo', start=datetime.datetime(2010,1,1),
end=datetime.datetime(2013,1,1))['Volume']
volume.head()
Out[21]:
In [22]:
returns = prices.pct_change()
returns.head()
Out[22]:
In [33]:
corr = returns.corr
In [34]:
%matplotlib inline
prices.plot()
Out[34]:
In [35]:
# plotting correlation
import seaborn as sns
import matplotlib.pyplot as plt
In [36]:
sns.corrplot(returns, annot=False, diag_names=False)
Out[36]: