SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_mip_cm_eba2020_template.sas
1
2
3
4
5
6
7/*BEGIN: INIZIALIZATION*/
8&computedmethod_name. = 0;
9AlreadyDefaultedBin=0;
10CALL PMXELEM(stresstest_coef, "DEFAULT_STATE_INDEX_CMatrix", 1, DEFAULT_STATE_INDEX_CMatrix, rc4);
11if rc4 NE 0 then do;
12 put "ERROR: Unable to parse the parameter DEFAULT_STATE_INDEX_CMatrix.";
13end;
14if CREDIT_STATE=DEFAULT_STATE_INDEX_CMatrix then do;
15 AlreadyDefaultedBin=1;
16end;
17STAGE2_Contribution = 0;
18STAGE3_Contribution = 0;
19/*END: INIZIALIZATION*/
20
21if AlreadyDefaultedBin NE 1 then do;
22 do t = 1 to &period_cnt.;
23
24 /*QUERY of the ADVERSE scenario*/
25 b_tr11=GET_QUERYVAL_SCEN('TR_11','Value',t,"&Scenario_base.");
26 b_tr12=GET_QUERYVAL_SCEN('TR_12','Value',t,"&Scenario_base.");
27 b_tr21=GET_QUERYVAL_SCEN('TR_21','Value',t,"&Scenario_base.");
28 b_tr22=GET_QUERYVAL_SCEN('TR_22','Value',t,"&Scenario_base.");
29 b_tr13=GET_QUERYVAL_SCEN('TR_13','Value',t,"&Scenario_base.");
30 b_tr23=GET_QUERYVAL_SCEN('TR_23','Value',t,"&Scenario_base.");
31 stage3_frc_base=GET_QUERYVAL_SCEN('STG3_FRC','Value',t,"&Scenario_base.");
32
33
34 /*QUERY of the BASE scenario*/
35 a_tr11=GET_QUERYVAL_SCEN('TR_11','Value',t,"&Scenario_adv.");
36 a_tr12=GET_QUERYVAL_SCEN('TR_12','Value',t,"&Scenario_adv.");
37 a_tr21=GET_QUERYVAL_SCEN('TR_21','Value',t,"&Scenario_adv.");
38 a_tr22=GET_QUERYVAL_SCEN('TR_22','Value',t,"&Scenario_adv.");
39 a_tr13=GET_QUERYVAL_SCEN('TR_13','Value',t,"&Scenario_adv.");
40 a_tr23=GET_QUERYVAL_SCEN('TR_23','Value',t,"&Scenario_adv.");
41 stage3_frc_adv=GET_QUERYVAL_SCEN('STG3_FRC','Value',t,"&Scenario_adv.");
42
43 /*Dynamic evaluation of the weights: 1,0 - 1,0 - ... - 1,0 - 5/6,1/6 - - 4/6,2/6 - ... - 1/6,5/6 - 0,1 - 0,1 - .... - 0,1*/
44 tk = max(t-&ft.,0);
45 w_adv = (max(6-tk,0))/6;
46 w_base = 1-w_adv;
47
48
49 /*------------------------------------------------------------------*/
50 /*BEGIN: Dynamic evaluation of the cumulative weighted default rates*/
51 /*------------------------------------------------------------------*/
52 if activationScenario="&Scenario_base." then do;
53 /*SPECIAL CASE.*/
54 /*If the instrument process being processed is a synthetic instrument active only only in base scenario,
55 then the logic for the evaluation of the EBA2020 is changed slightly. Specifically instead of considering the
56 the transition probability matrix evaluated under the adverse scenario, the transition probability matrix available under the base case is considered.
57 Potentially this will consider a bigger "alive" portion of the asset vs the alive portion available under stressing conditions. If this assumption does not
58 not apply for a specific instrument, then a customization might be required.*/
59 tmp11=b_tr11*( 0 + w_base*b_tr13 );
60 tmp21=b_tr21*( 0 + w_base*b_tr13 );
61 tmp12=b_tr12*( 0 + w_base*b_tr23 );
62 tmp22=b_tr22*( 0 + w_base*b_tr23 );
63 end;
64 else if activationScenario="&Scenario_adv." then do;
65 /*SPECIAL CASE.*/
66 /*If an instrument is available only in the adverse scenario, its contribution to the ECL will be lower than in the case
67 of an instrument available under both base and adverse scenarios.*/
68 tmp11=a_tr11*( w_adv*a_tr13 + 0 );
69 tmp21=a_tr21*( w_adv*a_tr13 + 0 );
70 tmp12=a_tr12*( w_adv*a_tr23 + 0 );
71 tmp22=a_tr22*( w_adv*a_tr23 + 0 );
72 end;
73 else do;
74 /*GENERAL CASE.*/
75 /*Notice that if an instrument is available only in the adverse scenario, its contribution to the ECL will be lower than in the case
76 of an instrument available under both base and adverse scenarios.*/
77 tmp11=a_tr11*( w_adv*a_tr13 + w_base*b_tr13 );
78 tmp21=a_tr21*( w_adv*a_tr13 + w_base*b_tr13 );
79 tmp12=a_tr12*( w_adv*a_tr23 + w_base*b_tr23 );
80 tmp22=a_tr22*( w_adv*a_tr23 + w_base*b_tr23 );
81 end;
82 /*----------------------------------------------------------------*/
83 /*END: Dynamic evaluation of the cumulative weighted default rates*/
84 /*----------------------------------------------------------------*/
85
86
87 /*Evaluation of the discount factor.*/
88 dsc_factor = 1.0 / (1+EFFECTIVE_INTEREST_RT)**t;
89
90 if t < (&ft.+1) then do;
91 if activationScenario="&Scenario_base." then do;
92 /*This case is only triggered by a synthetic instrument which is active only in the basecase scenario. This follows the same
93 approximating argument seen above.*/
94 STAGE3_Contribution = STAGE3_Contribution + stage3_frc_base*UNPAID_BALANCE_AMT*LGD*dsc_factor;
95 end;
96 else do;
97 STAGE3_Contribution = STAGE3_Contribution + stage3_frc_adv*UNPAID_BALANCE_AMT*LGD*dsc_factor;
98 end;
99 end;
100 else if t = (&ft.+1) then do;
101 STAGE1_Contribution = (tmp11+tmp21)*UNPAID_BALANCE_AMT*LGD*dsc_factor;
102 STAGE2_Contribution = (tmp12+tmp22)*UNPAID_BALANCE_AMT*LGD*dsc_factor;
103 prev_stg2 = (tmp12+tmp22);
104 end;
105 else if t > (&ft.+1) then do;
106 STAGE2_Contribution = STAGE2_Contribution + ((tmp12+tmp22)-prev_stg2)*UNPAID_BALANCE_AMT*LGD*dsc_factor;
107 prev_stg2 = (tmp12+tmp22);
108 end;
109
110 end;/*END do t = 1 to &period_cnt.;*/
111
112 &computedmethod_name. = STAGE1_Contribution + STAGE2_Contribution + STAGE3_Contribution;
113end;
114else do;/*BEGIN alternative path for AlreadyDefaultedBin = 1*/
115 &computedmethod_name. = UNPAID_BALANCE_AMT*LGD;
116end;