text_plain_output_1.png
from pandas_datareader import data

import math

ibm = data.DataReader('IBM', 'yahoo', start='1/1/2000')

time_elapsed = (ibm.index[-1] - ibm.index[0]).days

price_ratio = ibm['Adj Close'][-1] / ibm['Adj Close'][1]
inverse_number_of_years = 365.0 / time_elapsed
cagr = price_ratio ** inverse_number_of_years - 1

vol = ibm['Adj Close'].pct_change().std()

number_of_trading_days = 252
vol = vol * math.sqrt(number_of_trading_days)

print('cagr (mean returns) : ', str(round(cagr, 4)))
print('vol (standard deviation of return : )', str(round(vol, 4)))