def annualised_sharpe(returns, N=252):
return np.sqrt(N) * returns.mean()/returns.std()
def equity_sharpe(ticker,start, end):
pdf = web.DataReader(ticker, 'quandl', start, end).sort_index()
pdf['daily_ret'] = pdf['Close'].pct_change()
pdf['excess_daily_ret'] = pdf['daily_ret'] - 0.05/252
return annualised_sharpe(pdf['excess_daily_ret'])