SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_model_precode_simBased.sas
1/*
2 The following SAS macro variables are available to the model at run time:
3 - ticket: SAS authentication service ticket (useful for performing operations that require authentication, i.e. interacting with REST services).
4 - rgf_protocol: Communication protocol (http/https) of the SAS Risk and Governance Framework web application
5 - rgf_host: Hostname of the SAS Risk and Governance Framework web application
6 - rgf_port: Port where the SAS Risk and Governance Framework web application is listening
7 - rgf_service: The service where the SAS Risk and Governance Framework web application is listening
8 - ds_in_portfolio: portfolio table
9 - ds_in_scenario: scenario table
10 - ds_in_counterparty: counterparty table (if used)
11 - ds_in_mitigant: credit risk mitigant table (if used)
12
13 The following libraries are pre assigned:
14 - mipport: MIP portfolio library
15 - mipcpty: MIP counterparty library
16 - mipmit: MIP credit risk mitigant library
17 - mipcf: MIP cashflow library
18 - mippmx: MIP parameter matrix library
19 - mippmx: MIP valueData library
20 - mipfunc: MIP functions library
21
22*/
23
24/*The model does not support pricing cubes unless the DISTRIBUTE_POSITIONS=YES.*/
25%let mipProcHpriskArguments = %bquote(distribute_positions = YES priceby = positions;);
26
27/* Cashflow data object key */
28%let cashflow_key = ${params.CASHFLOW.key};
29
30/*It determines which information should be extracted from the simstat tables (These are MIP output tables.)*/
31%let mipQueryFilter=simulationpart="ECONOMIC_CAPITAL" or simulationpart="COMPONENT_ECONOMIC_CAPITAL" or simulationpart="VALUEATRISK" or simulationpart="COMPONENT_VALUEATRISK" or simulationpart="EXPECTEDLOSS";
32
33/*In this model the mip horizon is always larger (+1) because the VAR and the EC variable are based on the PD for the coming period.*/
34%let mipHorizon=%eval(&maxForecastTime.+1);
35
36
37/* ******************************************** */
38
39/* Prepare RiskDataMaps parameters for the MIP execution
40Syntax: <Risk Data Object Name>:<Libname.Dataset> [, <Risk Data Object Name>:<Libname.Dataset>] */
41%let mipCashflows = EC_Cashflows : mipcf.cashflow_&base_dt_ymdn._&model_run_key.;
42
43
44
45/* Set logging options (based on the value of LOG_LEVEL macro variable) */
46%irm_set_logging_options();
47
48%macro st_model_prep();
49
50 %local
51 reporting_dt
52 _ecsim_
53 mipecsim
54 renameStmt
55 ;
56
57
58 %let renameStmt = %nrstr(
59 rename
60 cashflow_dt = valDate
61 cashflow_leg = valType
62 cashflow_amt = valAmount
63 ;
64 );
65
66 /*It register the cash-flow data set into MIP*/
67 %let httpSuccess = 0;
68 %let responseStatus =;
69 %irm_rgf_retrieve_analysis_data(key = &cashflow_key.
70 , libref = &dr_libref.
71 , outds = mipcf.cashflow_&base_dt_ymdn._&model_run_key.
72 , outds_partition_list = cashflow_partition_list
73 , out_type = data
74 , custom_code = %superq(renameStmt)
75 , outds_dataInfo = cashflow_dataInfo
76 , outds_dataDef = cashflow_dataDef
77 , host = &rgf_protocol.://&rgf_host.
78 , server = &rgf_service.
79 , solution = &rgf_solution.
80 , port = &rgf_port.
81 , tgt_ticket = &tgt_ticket.
82 , outVarTicket = ticket
83 , outSuccess = httpSuccess
84 , outResponseStatus = responseStatus
85 , restartLUA = Y
86 , clearCache = Y
87 );
88
89
90 /*It creates the cash-flow data set for the synthetic positions ("Front Book")*/
91 %let reporting_dt=%sysfunc(datepart(&BASE_DTTM.));
92 %irmc_cf_frontbook_generation( ds_in_frontbook = &ds_in_synth_position.
93 , ds_in_cf_config = ST_CFG.SYNTHETIC_TEMPLATE_CF_CONFIG
94 , ds_out = mipcf.frontbook_cf_&base_dt_ymdn._&model_run_key.
95 , balance_var = unpaid_balance_amt
96 , id_var = INSTID
97 , maturity_dt_var = maturity_dt
98 , reporting_dt = &reporting_dt.
99 , interval = ${params.MIPINTERVAL}
100 , debug = FALSE
101 );
102
103 /*It appends the cash-flow for the synthetic instruments to the cash-flow of the portfolio.*/
104 proc append
105 data=mipcf.frontbook_cf_&base_dt_ymdn._&model_run_key.
106 base=mipcf.cashflow_&base_dt_ymdn._&model_run_key.;
107 run;
108
109
110
111
112
113
114
115
116
117 /*
118 data _null_;
119 set sashelp.vlibnam(keep=libname path
120 where=(libname='MIPPORT'));
121 call symputx('wholepath',path,'l');
122 run;
123 libname _FRTBK_ "&wholepath.";
124 */
125
126 %if (%rsk_dsexist(_FRTBK_.short_position) and %rsk_attrn(_FRTBK_.short_position, nlobs) ne 0) %then %do;
127
128 /*It creates the cash-flow data set for the elimnated positions*/
129 %irmc_cf_eliminated_remap( ds_in_cf = mipcf.cashflow_&base_dt_ymdn._&model_run_key.
130 , ds_in_short_position = _FRTBK_.short_position
131 , working_libname = _FRTBK_
132 , ds_out = mipcf.elimnated_CF_&base_dt_ymdn._&model_run_key.
133 );
134
135 /*It appends the cash-flow for the eliminated positions to the cash-flow of the portfolio.*/
136 proc append
137 data=mipcf.elimnated_CF_&base_dt_ymdn._&model_run_key.(drop=ORIG_INSTID)
138 base=mipcf.cashflow_&base_dt_ymdn._&model_run_key.;
139 run;
140
141 %end;
142
143
144
145%mend;
146
147%st_model_prep();