MFM 714: Project Instructions Part 1
Due Midnight, March 11, 2021
Implement a CreditMetrics style of portfolio simulation in python that will be full of
incomplete “stubs” as described below. During the rest of the term, we will continually
replace components with better models/parameters/functionality. The intent is to first
build a working framework that takes the input and makes output, then populate the rest
of the code later.
However, your code must include full documentation within it. Everything must be
well-document with comments. In addition, the code must be stable enough that the
marker can just load it in and run it successfully.
The software is intended to produce risk measures such as standard deviation, VAR
and conditional tail expectation for the class portfolio. The time horizon for the simula-
tion will be ONE YEAR.
The structure of the software:
Step 1) Arrange for the input of the following 5 files describing the make-up of the
portfolio and the financial markets:
i) A data file of names, ratings, and industries for the bond issuers
ii) A data file for the instruments containing the instrument fields described in part A
iii) A file containing a table of yields by term and by rating available on Avenue. An
Excel version 1 of this data is provided.
iv) A file containing a transition matrix of probabilities. An Excel version 1 of this data
v) A correlation matrix with companies corresponding to the file of names ( as in (i)
above). For now, create such a data file yourself with “1” down the main diagonal, and
0.36 everywhere else. Use scipy.linalg.cholesky to perform a Cholesky decomposition to
create a matrix of factors that you will take as input to your code.
Step 2) Use the notional amounts times the market prices/100 to determine the re-
ported market value of the portfolio in millions of dollars. For the CDS’s, we will be using
the theoretical swap price. But for now, they will be worth zero initially.
Step 3) Create a routine that produces a matrix of possible prices for each instrument
for each possible credit rating one year from now. For now, for bonds, fill in the price for
every performing rating (performing means not in default) as the theoretical price from
the input file. In event of default, the bond price is to be the expected recovery value.
For the CDS, for now, leave it as zero value if the company is performing, but make it
worth the notional times the recovery value in event of default.
Step 4) Create a subroutine to generate N scenarios for the possible ratings of the
named companies at the end of the year, where N is set to 2000. For now, just have all
2000 scenarios simply show the exact same rating that the companies started with. We’ll
code this subroutine properly later. NOTE: you may find it preferrable to work with a
numerical rating system, so that 1=AAA, 2=AA+, and so on.
Step 5) Create a subroutine to go through each of the N scenarios. Compute the
value of the portfolio in each scenario by summing the value of the instruments. This
will be the notional value of the instrument, times (1/100) of the price of the instrument
looked up from the table created in step 3, using the company’s rating for that scenario
as generated in step 4. Record the portfolio value and the change in portfolio value for
Step 6) Create a subroutine to take the 2000 scenarios for the change in portfolio
value and compute:
- average change in value
- standard deviation of change in value
- 95th percentile VAR
- 99th percentile VAR
- 98th percentile CVAR
Report the two initial portfolio value calculations from step 1, as well as the above statis-