ECE478 Financial Signal Processing

Problem Set II: Portfolio Analysis

Data

Our primary source of data in this experiment will be S&P 500, USD LIBOR rate (which

we will take as the risk-free rate), and stock data you can get from online sources such as

Yahoo Önance.

Select 5 stocks that you expect to have some correlation, e.g., from a common sector. [Make

sure these companies have been publicly traded since 2000]

Take data over the period 2000 through 2018. We will keep data over each year separate.

For purposes of computing the risk-free return, take the average LIBOR over the calendar

year. Note that the deÖnition of the daily return is the annual return (i.e., for a one year

time horizon) divided by 360; this is the daycount conversion for interest rates, not stocks!

If you look at monthly returns, then divide by 12.

Pull daily date for S&P500 and your 5 stocks. Use the adjusted closing price. This compensates for e§ects such as dividend payments.

Compute the daily log returns.

Compute the monthly log returns by comparing the Örst (trading) day of a month to the

Örst (trading) day of the prior month.

For the Örst day (month) of a calendar year, use the Önal day (month) of the previous

calendar year. (E.g., you will need some data from 1999 to do this for the year 2000).

In what follows, you can use ìcannedîroutines to compute mean vectors, covariance matrices,

and linear algebra operations such as eigenanalysis. However, the rest you should build up

yourself. Donít use higher level economic/Önancial functions.

There are potentially many graphs generated. You have to decide how to organize things

intelligently. I also want to see comments, especially when data doesnít seem to match

theory.

Analysis

Write code to take the daily data over a period of one calendar year. Consider a portfolio

comprised of your 5 stocks plus the risk-free return derived from USD LIBOR.

1

When you do this, there may be years when the standard theory fails because the USD

LIBOR is too high. Even if it is close to the assumed threshold, though technically below

the level, results can look weird. Have your code identify those conditions, as an exception.

If the exception occurs, then just pick an artiÖcial but convenient value for the risk-free

return, just to push through the theory. But you should clearly indicate when that happens.

You should perform the following operations for several years (no, not for EVERY year).

1. Compute the mean vector m and covariance matrix C for the stocks.

2. Compute the weight vectors of the MVP and Market portfolios ( ~wMV P , ~wM, respectively), and the respective points (MV P ; MV P ) and (M; M).

3. Generate the points on the e¢ cient frontier. Graph it, and also place markers at the

MVP and market portfolio points. Also superimpose a graph of the CAPM.

4. Identify the portion of the e¢ cient frontier that involves no short selling at all, and

highlight it with a di§erent color.

5. Look at the MVP and Market Portfolio weight vectors. Some of them may be negative.

If this is the case, zero those terms out, and adjust the other weights (rescale them)

to sum to 1. We can take this as an approximation to the optimal solution subject to

the constraint of no short-selling. Place markers for these ìmodiÖedîMVP and MP

points.

6. Pick two stocks out of 5 and compute the MP for just this pair. Compute the correlation

coe¢ cient between this portfolio and the MP (for the full set of 5 stocks), the , the

systematic risk and diversiÖable risk.

7. Now study the covariance matrix C:

(a) Compute the eigenvalues, and show that are all positive.

(b) Find the condition number, max=min. This is one way to quantify how numerically ìunstableîmanipulating C is, e.g., how close to nonsingular it is (the larger

this is, the worse for us).

(c) Graph the eigenvalues on a log scale in descending order.

8. Now we look at the S&P 500. Compute its (; ) and place a marker for it on the

above graph, to compare it to the other portfolios you have been looking at.

9. Compare the S&P500 with the MP for the full 5 stocks, and the MP for just the 2

stock subset you took, and also for the ímodiÖed” MP in which you removed any short

selling. . In particular, do one of these dominate some of the others? Compute the

correlation coe¢ cient between the S&P500 and these others.

2