Lesson 3 of 15
N-Asset Covariance Matrix
N-Asset Covariance Matrix
For a portfolio of N assets, the full variance-covariance structure is captured in an N×N covariance matrix Σ.
The (i, j) entry of Σ is the sample covariance between asset i and asset j:
Note: when i = j this reduces to the variance of asset i.
Portfolio Variance
Given weights vector w and covariance matrix Σ, portfolio variance is:
Your Task
Implement:
cov_matrix(returns_list)— takes a list of return series (each a list of T returns), returns an N×N covariance matrix as a list of lists (sample covariance, divide by T−1)portfolio_variance_n(weights, cov)— computes wᵀ Σ w given a weights list and a covariance matrix (list of lists)
Python runtime loading...
Loading...
Click "Run" to execute your code.