关键词 > MATLAB代写

Computational Finance – Quiz 1 Practice Questions

发布时间:2021-04-26

Vadim Elenev

Computational Finance

2021 Spring II


Computational Finance – Quiz 1 Practice Questions

The following practice problems are also posted as a PRACTICE Quiz 1 on Blackboard. When you complete these problems, I strongly encourage you to try submitting them on Blackboard so you can get familiar with how Blackboard handles exams in preparation for the actual in-class quiz, which will also be administered via Blackboard.

Note: these questions are deliberately more difficult than the questions on the quiz.


1. The attached stock_returns.csv file contains monthly stock returns on the 500 largest companies as of January 2011. The sample ranges from January 2011 to December 2020. First row contains tickers. First column contains dates.

a. Write a function called get_portfolio_vols() that takes in a T (months) x N (stocks) matrix of stock returns and outputs a 1 x N vector of portfolio volatilities such that the K’th element of the vector is the volatility of an equal-weighted portfolio of the first K stocks in the matrix.

b. Write a separate script file to test your function using data in stock_returns.csv. Compute portfolio volatilities for 200 different random draws of 100 stocks from the total sample of 500. To randomly generate M indices in the range of 1 to N, you can use MATLAB’s randperm() function:

indices = randperm(N,M);

Store your portfolio volatilities in a 200 x 100 matrix.

c. Plot the average portfolio volatility on the vertical axis and the number of assets in the portfolio on the horizontal axis. What does your graph suggest about the benefits of diversification?


2. The attached stock_returns.csv file contains monthly stock returns on the 500 largest companies as of January 2011. The sample ranges from January 2011 to December 2020. First row contains tickers. First column contains dates.

Use these data to evaluate a momentum investment strategy.

a. Suppose that every month starting in February 2011, you decide to allocate your portfolio equally to all “winners” i.e., stocks which had positive returns in the previous month because you believe that these stocks have momentum and thus will continue to do well. Report the name of the company, which is the most frequent winner. Compute the monthly returns on this strategy. Report the mean and standard deviation of these returns in percent with two digits after the decimal point.

b. Compute the return on an equal-weighted portfolio of all stocks over the same period. Report the mean and standard deviation of these returns in percent with two digits after the decimal point. How does the momentum strategy compare to the equal-weighted portfolio?

c. Make a scatter plot of momentum strategy returns (on the vertical axis) vs. equal-weighted portfolio returns (on the horizontal axis). Exclude the periods in which the equal-weighted return was at its minimum or maximum. Add a 45-degree line to the plot. Just looking at your graph, when does the momentum strategy seem to outperform the equal-weighted portfolio?


3. In your Corporate Finance class, you learned the concepts of Net Present Value (NPV) and Internal Rate of Return (IRR). While computing the NPV when you know discount rates is easy – just plug into the formula, computing the IRR is hard b/c you cannot analytically solve for the IRR (in other words, you cannot plug values into an equation). In this exercise, you will write a function that estimates the IRR of a project given its cash flows.

a. Write a function called get_irr() that takes two inputs – (a) a row vector of times at which the project generates cash flows, and (b) a vector of the corresponding cash flow amounts. Your function must return one output: the estimated IRR. The estimated IRR must be correct within 1 basis point (0.01%). Your function can assume that all IRRs will be between 0 and 50%.

Hint: in a systematic way, guess and check. Try many values for the IRR, calculate the NPV that those values imply, and then have MATLAB pick the one that produces the NPV closest to zero.

Note: the goal of this exercise is for you to find the IRR yourself. If you find built-in or otherwise available MATLAB functions that can solve for IRR, you can use them to check your result, but you cannot use them in your function.

b. Write a script file which computes and reports the IRR of a project with the following cash flows:

  Time (years)
  0
  1
  2
  3
  4
  5
  6
  7
  Cash Flow
  -100
  5
  8
  20
  35
  45
  50
  30

c. Change the initial investment to 120 and run the script again. How does an increase in the initial investment required to fund a project affect its return?