Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit



MF 703:  Programming for Mathematical Finance

Fall 2021

 

Problem set # 6

 

Ticker

Description

XLB

Materials

XLE

Energy

XLF

Financials

XLI

Industrials

XLK

Technology

XLP

Consumer Staples

XLU

Utilities

XLV

Healthcare

XLY

Consumer Discretionary

 

1.  Covariance Matrix Decomposition:

 

(a)  Download historical price data from January 1st 2010 until today for the sector ETFs

in the table above. Clean the data for splits and any other anomalies.

(b)  Calculate the covariance matrix of daily returns for the sector ETFs.

(c)  Perform an eigenvalue decomposition of the covariance matrix.  Plot the eigenvalues in order from largest to smallest. How many eigenvalues are positive? How many are negative?  How many are zero?  If any are negative, is this a problem?  How many do you think are statistically significant?

(d)  Generate a random matrix of the same size as your covariance matrix, where each element has a standard normal distribution.

(e)  Perform an eigenvalue decomposition of this random matrix. Plot the eigenevalues in

order from largest to smallest.  Comment on the differences and similarities between the structure of the eigenvalues in this matrix and your historical covariance matrix.

2.  Portfolio Optimization:

Recall that an unconstrained optimal portfolio can be found using the following formula:

max wT R - awT Cw                                                           (1)

w

The constant a indicates the amount of our risk aversion. Assume you are an investor with a risk aversion coefficient of 1.


(a)  Calculate the historical annualized returns for each sector ETFs.

(b) Using the annualized returns as expected returns and the covariance matrix obtained

above, calculate the weights of the unconstrained mean-variance optimal portfolio.

(c)  Create a new set of expected returns equal to the historical annualized return (µ) plus a random component, that is:

E [r] = µ + σ * Z                                                    (2)

where σ is the volatility of the random component and Z is a standard normal random variable.

Using σ = 0.005, σ = 0.01, σ = 0.05 and σ = 0.1 calculate the unconstrained mean- variance optimal portfolio using the adjusted expected returns and the covariance ma- trix. Comment on the stability of your portolio weights to changes in expected returns.

(d)  Consider a regularized covariance matrix that is a blend of the historical covariance matrix and a diagonal matrix with each asset’s variance along the diagonals, that is:

 = δΣdiag + (1 - δ)Σfull                                                                (3)

 

where δ is the weight of the diagonal matrix and (1 - δ) is the weight of the historical covariance matrix.

(e)  Set δ  =  1 and perform and eigenvalue decomposition of the regularized covariance

matrix. What is the rank of the regularized covariance matrix now?

(f)  Try different values of δ between 0 and 1 and perform eigenvalue decomposition on

the regularized covariance matrix. How many eigenvalues are positive? How many are zero?

(g)  Repeat the exercise in (2.c) with the regularized covariance matrix for a few values of

δ. Compare the stability of your portfolio weights to what you got with the historical covariance matrix.

NOTE: All code for completing these exercises should be completed either in Python or C++ and should be written generically.  You may end up using this code on future assignments so I encourage you to code thoughtfully.