def risk_contribution(w, cov):
    '\n    Compute the contributions to risk of the constituents of a portfolio, given a set of portfolio weights and a covariance matrix\n    '
    total_portfolio_var = (portfolio_vol(w, cov) ** 2)
    marginal_contrib = (cov @ w)
    risk_contrib = (np.multiply(marginal_contrib, w.T) / total_portfolio_var)
    return risk_contrib
Compute the contributions to risk of the constituents of a portfolio, given a set of portfolio weights and a covariance matrix
def risk_contribution(w, cov):
    '\n    \n    '
    total_portfolio_var = (portfolio_vol(w, cov) ** 2)
    marginal_contrib = (cov @ w)
    risk_contrib = (np.multiply(marginal_contrib, w.T) / total_portfolio_var)
    return risk_contrib