from pandas_datareader import data, wb
import pandas as pd
import numpy as np
import datetime
%matplotlib inline
start = datetime.datetime(2000, 1, 1)
end = datetime.datetime(2020, 12, 31)
# Honeywell
HON = data.DataReader("HON", 'yahoo', start, end)
# Cisco
CSCO = data.DataReader("CSCO", 'yahoo', start, end)
# Thermo Fisher
TMO = data.DataReader("TMO", 'yahoo', start, end)
# Oracle
ORCL = data.DataReader("ORCL", 'yahoo', start, end)
# Netflix
NFLX = data.DataReader("NFLX", 'yahoo', start, end)
# Pfizer
PFE = data.DataReader("PFE", 'yahoo', start, end)
# Disney
DIS = data.DataReader("DIS", 'yahoo', start, end)
# Visa
V = data.DataReader("V", 'yahoo', start, end)
# Facebook
FB = data.DataReader("FB", 'yahoo', start, end)
# Adobe
ADBE = data.DataReader("ADBE", 'yahoo', start, end)
# Accenture
ACN = data.DataReader("ACN", 'yahoo', start, end)
# McDonald's
MCD = data.DataReader("MCD", 'yahoo', start, end)
# Intel
INTC = data.DataReader("INTC", 'yahoo', start, end)
df = data.DataReader(['HON', 'CSCO', 'TMO', 'ORCL', 'NFLX', 'PFE', 'DIS', 'V', 'FB', 'ADBE', 'ACN', 'MCD', 'INTC'],'yahoo', start, end)
tickers = ['HON', 'CSCO', 'TMO', 'ORCL', 'NFLX', 'PFE', 'DIS', 'V', 'FB', 'ADBE', 'ACN', 'MCD', 'INTC']
company_stocks = pd.concat([HON, CSCO, TMO, ORCL, NFLX, PFE, DIS, V, FB, ADBE, ACN, MCD, INTC],axis=1,keys=tickers)
company_stocks.columns.names = ['Company Name','Stock Info']
returns = pd.DataFrame()
for tick in tickers:
returns[tick+' Return'] = company_stocks[tick]['Close'].pct_change()
logar = pd.DataFrame()
for tick in tickers:
logar = np.log(1+company_stocks.pct_change())
company_stocks.xs(key='Close',axis=1,level='Stock Info').min()
company_stocks.xs(key='Close',axis=1,level='Stock Info').max()
returns.std()
returns['2019-01-01':'2019-12-31'].std()
returns['2020-01-01':'2020-12-31'].std()
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
%matplotlib inline
import plotly
import cufflinks as cf
cf.go_offline()
company_stocks.xs(key='Close',axis=1,level='Stock Info').iplot()
logar = pd.DataFrame()
for tick in tickers:
logar = np.log(1+company_stocks.pct_change())
logar.xs(key='Close',axis=1,level='Stock Info').iplot()
heatmap = company_stocks.xs(key='Close', axis=1, level='Stock Info').corr()
heatmap
HON['Close']['2020-06-01':'2020-12-31'].ta_plot(study='sma',periods=[14],title='Simple Moving Averages',color='red')
HON['Close']['2020-06-01':'2020-12-31'].ta_plot(study='boll',color='red')
HON[['Open', 'High', 'Low', 'Close']]['2020-09-01':'2020-12-31'].iplot(kind='candle')