Python代写:COMPG004 Market Risk Measures and Portfolio Theory

用Python进行数值分析,找出数据的相关性,分析风险点。

Description

The assignment has two parts: the first one is to calculate, using real information obtained from yahoo finance, value at risk and expected shortfall using two of the techniques presented during the lectures (closed form and historical simulation). This part is to be submitted in groups of four students. Details on the report are given below.
The second part consists in evaluating the solution proposed by another team of colleagues.
A guide on the aspects to be evaluated will be given in due time. This part is done individually.
Note: The process will be anonymous for both the submitting team and the assessing student.

Objectives

The goal of the first part is to reinforce your knowledge of risk measures techniques when applied in practice, and to increase your familiarity with Python.
The goal of the second part is to develop your ability to assess, in a fair way, work submitted by a colleague.

Deadlines

Each group should inform me via mail of their composition by December 1 2016. Students not included in any group will be automatically assigned one via Moodle.
For the first part, submit their work via Moodle.
Each member of a team having submitted a report, will receive the report of a colleague to be assessed. The assessment should be returned.

Exercises

  1. Download from the Yahoo Finance website http:finance.yahoo.com weekly information from 2002/06/01 to 2016/5/31. For the following tickers.
    [‘MSFT’,’AIG’,’T’, ‘XOM’,’AAPL’,’IBM’,’GPS’,’JPM’].
    Remember that we work with the ‘Adj Close’ column, since it has already been adjusted for splittings and dividend payments, as we need when dealing with historical data.
  2. Calculate the weekly loss increments for all the references (in the following I will called it P), the negative of increments for the logarithm of the price in the period (X), and the gross returns (R).
  3. Using only information from 2002/06/01 to 2007/5/31, estimate mean, variance-covariance matrix and correlation matrix for the gross return of the given assets.
  4. Using the previous estimates, find the portfolio composed of only the given assets with minimal variance. (Hint: See the lecture notes).
  5. Let us first focus on the closed form approximation based on a log-normal model. Let us check how Gaussian is the data for X. Plot a histogram, a QQ plot comparing to a normal distribution and perform a Shapiro-Wilks normality test on the risk-factor changes weighted according to the initial portfolio. Comment. (Hint: Check the functions histogram in Numpy and the functions shapiro and probplot in the scipy.stats).
  6. Define a function that has as inputs: the value of , a date (d), the value of the investment at that date (v) , a vector of portfolio weights (π), and the negative log normal increments X; and returns the closed form value at risk and expected shortfall shown during the lectures (using linearisation and normal approximation). The values of mean and variance should be estimated from the data using only the previous 261 weeks or 5 years before d.
  7. Define a function that has as inputs: the value of , a date (d), the value of the investment at that date (v) , a vector of portfolio weights (π), and the negative log normal increments X; and returns the historical simulation estimation for value at risk and expected shortfall shown during the lectures (using linearisation and normal approximation). The history to be used should be obtained using only the previous 261 weeks or 5 years before d.
  8. In the same plot, show the value at risk (99% level) estimated with the two methods for the portfolio defined on question 3, assuming your initial investment was 100 (million) dollars. The plot should show the weekly calculation for the period 2007/06/01 - 2011/05/31. What do you observe?
  9. Perform a coverage backtest on the two estimated value at risk using the mentioned period. State explicitly the type of test you will perform and the level of significance. Comment.
  10. In the same plot, show the expected shortfall calculated with the two methods, and the realised losses per week, for the period 2007/06/01 - 2011/05/31. What do you observe?
  11. (Bonus question) Perform a coverage backtest on the estimated expected shortfall using the previous period. Comment
  12. Repeat questions 8 and 9 but replacing 2007 by 2012 and 2011 by 2016 (keep fixed the portfolio of 3). Comment.

Report

The report consists on a PDF obtained from the python notebook where you have made your calculations. To generate the report, please go to: File - Download as - PDF via LATEX. You might be prompted to install pandoc.
Alternatively, use any of the available software to print to PDF the given file.
Submitting your work in pdf is important in order to ease the task for the assessment part.
Keep in mind to be as clear and as precise as possible.
Note: Please do not include your name in the report.