def portfolio_metrics(weights, avg_xs_returns, covariance_matrix):
    ' Compute basic portfolio metrics: return, stdv, sharpe ratio '
    portfolio_return = np.sum((weights * avg_xs_returns))
    portfolio_stdv = np.sqrt(np.dot(weights.T, np.dot(weights, covariance_matrix)))
    portfolio_sharpe = (portfolio_return / portfolio_stdv)
    tickers = covariance_matrix.columns
    metrics = {'return': portfolio_return, 'stdv': portfolio_stdv, 'sharpe': portfolio_sharpe, 'weights': weights}
    metrics.update(dict([(ticker, weight) for (ticker, weight) in zip(tickers, weights)]).items())
    return metrics
Compute basic portfolio metrics: return, stdv, sharpe ratio
def portfolio_metrics(weights, avg_xs_returns, covariance_matrix):
    '  '
    portfolio_return = np.sum((weights * avg_xs_returns))
    portfolio_stdv = np.sqrt(np.dot(weights.T, np.dot(weights, covariance_matrix)))
    portfolio_sharpe = (portfolio_return / portfolio_stdv)
    tickers = covariance_matrix.columns
    metrics = {'return': portfolio_return, 'stdv': portfolio_stdv, 'sharpe': portfolio_sharpe, 'weights': weights}
    metrics.update(dict([(ticker, weight) for (ticker, weight) in zip(tickers, weights)]).items())
    return metrics