Specify the Analysis and Create the Project
This example demonstrates how to stress instrument and counterparty variables the same way that you can stress risk factor variables. Stresses can be defined as relative changes, absolute changes, or value changes.
This example demonstrates this capability in the context of credit risk (See "Assessing Credit Risk"). You stress the instrument variables' contract price and interest rate. Here interest rate is an instrument variable rather than a risk factor. You also stress the counterparty variable loss given default (LGD).
First, set up the library for analysis and the name of the SAS Risk Dimensions environment. Use the directory C:\users\sasdemo\RD_Examples. You can assign the libref to any path as long as you have Write access to that directory.
libname RDExamp "C:\users\sasdemo\RD_Examples";In this code, you use the SAS Macro Language Facility to create the macro variable test_env. You assign the value instscen to the variable test_env. Using macro variables in this way gives you the flexibility to change the physical location of the target library and environment name in just two lines of code.
Next, create a new SAS Risk Dimensions environment assigned the name instscen in the library RDExamp.
Next, define the assets in your portfolio and provide information about the counterparty. The following code creates a data set called instdata that stores information about the forward agreement in your portfolio. It specifies the characteristics of the instrument:
FwdContract instid1 CounterPartyA cptyid1 01JUL2014 0.02 TechCompany 20 1000 |
The following code creates the data set cptydata that stores information about the counterparty including the counterparty's current credit rating, which is BBB.
MidGrade_Cpty cptyid1 CounterPartyA BBB 0.20 |
The following code registers the instrument data and counterparty data in the environment. It also defines the output variable creditloss, the value of which is computed in the pricing method.
Next, define current risk factor values and create the scenario data sets for the instrument and counterparty variable stresses.
The code below identifies the risk factors that affect the value of your portfolio and the credit worthiness of the counterparty. It registers the market data in the environment. It also defines the instrument and counterparty stresses as scenarios. The stresses can be specified as scenario data sets or can be specified using the changes option in the SCENARIO statement. You do both in this example. When you specify an instrument or counterparty stress, the stress is applied to all instruments or counterparties.
Next, create both a scoring method and a pricing method. The scoring method is used to calculate probability of default and loss given default based on the current credit rating of the counterparty. The outputs of the scoring method are then used in the pricing method to calculate the output variable creditloss. Create methods using the COMPILE procedure, which is similar to and supports the functionality and syntax of the FCMP procedure. For more information, see the SAS Risk Dimensions and SAS High-Performance Risk: Procedures Guide.
method Fwd_Contract kind=price;
Use the COUNTERPARTY statement to assign the scoring method to the counterparty type MidGrade_Cpty. Identify the counterparty variables needed for scoring by specifying the variables option. Use the INSTRUMENT statement to assign the pricing method to the instrument type FwdContract and to identify the instrument variables needed for pricing.
Set up a project to calculate the portfolio mark-to-market (MtM) value and to calculate the portfolio value under the stress scenarios. The following code creates a portfolio file from the instrument data set and identifies the cross classifications for portfolio aggregation. The scenarios are specified in the analysis option of the PROJECT statement. MtM is calculated by default. Note that you do not specify a run date, so the base case date is today and horizon one is the following business day.
Run the project, putting output files in the InstScen subdirectory of the environment.
Next, analyze your results. You can perform analysis on SAS data sets output from the project.
The following figure shows the Scen data set. This data set contains the output variable values for each of the scenarios and for the base case.