Back to Community
portfolio volatility formula

Can someone please help me to understand this line for portfolio annualized volatility:

portfolio_std = np.sqrt(np.dot(weights.T, np.dot(cov_matrix, weights))) * np.sqrt(252)  

what i have understood:

  • in order to understand portfolio volatility one cannot just sum the volatility of each stock multiplyed by weigths because correlations between them has to be taken in consideration
  • portfolio standard deviation is equal to square root of portfolio variance so np.sqrt(ptf_variance)
  • in the covariance matrix i have the variance of each stock in the diagonal

what i have not understood:
the double matrix multiplication between the transpose of weigths and the covariance matrix
np.dot(weights.T, np.dot(cov_matrix, weights) what does it mean this double .dot and whay should it return the portfolio variance?