Resources

SAS Products

SAS Risk Dimensions - Stressing Variables in a Scenario Analysis



Objective

Set Up Your Environment

Define Your Portfolio

Register Market Data

Define Valuation Methods and Instrument Types

Specify the Analysis and Create the Project

Run the Project

View Results

Example Code (ZIP file)



Objective

Stress testing enables you to assess how a portfolio performs under adverse market conditions. You can stress test a portfolio using scenario analysis in SAS Risk Dimensions. In such scenarios, you can stress relevant variables:

In this example, you perform stress testing on a portfolio that contains shares in two stocks. You define a scenario in which TechCompanyís stock price drops and you reduce your holding in TechCompany.



Set Up Your Environment

First, set up the library for analysis and the name of the SAS Risk Dimensions environment. Use the directory C:\users\sasdemo\RD_Examples.

libname RDExamp "C:\users\sasdemo\RD_Examples";
%let test_env = stressholding;

In this code, you use the SAS Macro Language facility to create the macro variable Test_Env. You assign the value stressholding to the variable Test_Env.

Using macro variables in this way enables you to change the physical location of the target library and the environment name in just two lines of code. The macro does not directly affect calculations. You can assign the library to any path as long as you have Write access to the referenced directory.

Next, create a new SAS Risk Dimensions environment called stressholding in the RDExamp library.

proc risk;
   env new=RDExamp.&test_env;
   env save;
run;



Define Your Portfolio

Next, describe the assets in your portfolio and register the portfolio data in the environment.

data RDExamp.instdata;
  input insttype $12. instid $8. holding;
  datalines;
TechCompany instid1 1000000
BankCompany instid2 1000000
;

proc risk;
  env open=RDExamp.&test_env;
  instdata Instruments file=RDExamp.instdata format=simple;
  env save;
run;



Register Market Data

Next, provide current risk factor values and the scenario data set. The scenario data set specifies the holding stress and the stressed TechCompany price. Register the current market data and the scenario data in the environment.

data RDExamp.mktdata;
  TEC=15;
  BNK=30;
run;

data RDExamp.scendata;
  length _cvalue_ $ 20;
  input _type_ $ _name_ $ _value_ _ctype_ $ _cvalue_ $;
  datalines;
absolute holding -500000 insttype TechCompany
value    TEC      10     none     none
run;

proc risk;
   env open=RDExamp.&test_env;
   declare riskfactors=(TEC num var, BNK num var);
   marketdata Market file=RDExamp.mktdata  type=current;
   marketdata TechCoScenario file=RDExamp.scendata type=scenarioanalysis;
   env save;
run;



Define Valuation Methods and Instrument Types

Create pricing methods using the COMPILE procedure, and pull them into the environment. Tell the RISK procedure which pricing methods to use for each of the instrument types through assignment in the INSTRUMENT statement. Specify the instrument variables needed for pricing; InstType and InstID do not need to be specified because they are included by default.

proc compile env=RDExamp.&test_env outlib=RDExamp.&test_env;
  method Tech_Price kind=price;
    _value_ = TEC;
  endmethod;
  method Bank_Price kind=price;
    _value_ = BNK;
  endmethod;
run;

proc risk;
  env open=RDExamp.&test_env;
  instrument TechCompany methods=(Price Tech_Price) variables = (holding);
  instrument BankCompany methods=(Price Bank_Price) variables = (holding);
  env save;
run;

When you stress an instrumentís holding, you ask how the value of your portfolio would be different had you bought or sold the instrument. When holding changes are combined with stressed risk factor values, you must capture a two-fold effect. First, you need to capture the effect of the change in the risk factor value; second you must incorporate the holding effect.



Specify the Analysis and Create the Project

Set up a project to compute the Mark-to-Market (MtM) value of your portfolio given the current market. Create a scenario analysis to value the portfolio under the stressed conditions. Build a project to run the analysis.

proc risk;
  env open=RDExamp.&test_env;
  sources InstDataSource (Instruments);
  read sources=InstDataSource out=Portfolio;
  crossclass InstTypeCC (Insttype);

  scenario TechCompanyScen
     data = TechCoScenario
     label = "TechCompany Share Price Decrease";

  project Project
     analysis=(TechCompanyScen)
     portfolio=Portfolio
     crossclass=InstTypeCC
     data=( Market )
     rundate = '07JAN2013'd;
env save;
run;



Run the Project

Run the project, putting output files in the StressHolding_Output subdirectory of the environment directory.

proc risk;
    env open=RDExamp.&test_env;
    runproject Project
    out= StressHolding_Output
    options=(outall);
  env save;
run;



View Results

Now explore the results using the SAS Risk Dimensions UI. From here, you can view data sets and perform analysis with JMP. For more information, see the SAS Risk Dimensions: Userís Guide.

It is helpful to set up library references to the output directories before working with the results. Open the Scen data set.

Scen Data Set

Scen Data Set

Notice the Value (the Portfolio Value for Market State), which tells you the value of the portfolio and subportfolios under the stressed conditions. Compare these values to BaseCaseValue (the Base Case MtM values).

If you take the difference in the stressed value versus the base case value for the TechCompany subportfolio, you see that the difference is -$10M. However, the profit/loss (P/L) is only -$2.5M. Of the $10M change in value, $7.5M is attributed to the sale of TEC shares prior to the drop in TEC price (500,000 shares sold at $15/share). This amount is shown as the HoldingAdjustment.

The rest of the loss is attributed to the change in value of the remaining shares (500,000 shares remaining multiplied by the $5/share loss). This is shown as the PL Value. Note that the P/L of BankCompany is 0. Neither perturbation affected the bank stock.

You can also view data sets and perform analyses with JMP. For example, here is a JMP plot comparing the stressed value of the TEC subportfolio to the base case value of the TechCompany subportfolio.

JMP Plot

JMP Plot


Back to Examples index page