6%let rgf_tgt_ticket = ${globals.ticket};
9%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
12%let cycle_id = ${context.cycle.key};
15%let analysis_run_id = ${context.analysisRun.key};
18%let config_set_id = ${params.CONFIGSETID};
21%let portfolio_key = ${params.PORTFOLIO.key};
24%let counterparty_key = ${params.MARKETMODEL.params.COUNTERPARTY.key};
27%let mitigant_key = ${params.MARKETMODEL.params.MITIGATION.key};
30%let collateral_key = ${params.MARKETMODEL.params.COLLATERAL.key};
33%let econsimulation_key = ${params.MARKETMODEL.params.ECONSIMULATION.key};
36%let ia_data_key = ${params.IADATA.key};
38%let modelIn_dataMap_key = ${params.MODELINPUTMAP.key};
41%let modelOut_dataMap_key = ${params.MODELOUTPUTMAP.key};
44%let model_run_key = ${params.MARKETMODEL.rels(
"context").modelRun.key};
47%let keep_mip_cube_flg = ${params.KEEPMIPCUBE};
50%let lasr_load_method = ${params.LASRLOADMETHOD};
53%let reload_key_list = ${params.RELOADKEYLIST};
55%let reload_key_list = %sysfunc(prxchange(s/\W+/ /i, -1, %superq(reload_key_list)));
58%let log_level = ${params.LOGLEVEL};
61%let max_wait = ${params.MAXWAIT};
64%let scenario_key = ${params.SCENARIO.key};
69%include
"&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_id./init.sas" / lrecl = 32000 source2;
72%irm_set_logging_options();
75%let jobflow_category = Analytics;
76%let jobflow_type = %lowcase(irm&solutionId._shortterm_market_risk);
77%let instance_date = %sysfunc(date(), yymmddp10.);
78%let instance_time = %sysfunc(prxchange(s/(\d+):(\d+):(\d+)/$1h$2m$3s/i, -1, %sysfunc(time(), tod8.)));
79%let instanceName = Market Risk Analysis &instance_date._&instance_time.;
80%let instanceDesc = Market Risk Analysis;
83%let reload_lasr_flg = %irmc_process_lasr_load_method(&lasr_load_method.);
91 config_name =
"RMC_FA_ID"; config_value =
"&rmc_fa_id."; output;
92 config_name =
"CYCLE_ID"; config_value =
"&cycle_id."; output;
93 config_name =
"ANALYSIS_RUN_ID"; config_value =
"&analysis_run_id."; output;
94 config_name =
"ANALYSIS_TYPE"; config_value =
"SCR"; output;
95 config_name =
"MAX_WAIT"; config_value =
"&max_wait."; output;
96 config_name =
"LOG_LEVEL"; config_value =
"&log_level."; output;
97 config_name =
"RELOAD_LASR_FLG"; config_value =
"&reload_lasr_flg."; output;
98 config_name =
"RELOAD_KEY_LIST"; config_value =
"&reload_key_list."; output;
99 config_name =
"TGT_TICKET"; config_value =
"&rgf_tgt_ticket."; output;
103data work.credit_risk_config;
108 config_name =
"CREDIT_MODEL_RUN_KEY"; config_value =
"&model_run_key."; output;
109 config_name =
"PORTFOLIO_KEY"; config_value =
"&portfolio_key."; output;
110 config_name =
"COUNTERPARTY_KEY"; config_value =
"&counterparty_key."; output;
111 config_name =
"MITIGANT_KEY"; config_value =
"&mitigant_key."; output;
112 config_name =
"COLLATERAL_KEY"; config_value =
"&collateral_key."; output;
113 config_name =
"ECONSIMULATION_KEY"; config_value =
"&econsimulation_key."; output;
114 config_name =
"IA_DATA"; config_value =
"&ia_data_key."; output;
115 config_name =
"MODELIN_DATAMAP_KEY"; config_value =
"&modelIn_dataMap_key."; output;
116 config_name =
"MODELOUT_DATAMAP_KEY"; config_value =
"&modelOut_dataMap_key."; output;
117 config_name =
"KEEP_MIP_CUBE_FLG"; config_value =
"&keep_mip_cube_flg."; output;
129%let dim_points_ar_cycle=;
130%macro find_dim_points(ar_cycle_dim_pts=dim_points_ar_cycle);
132%
if(%sysevalf(%superq(cycle_id) ne,
boolean)) %then %
do;
135 %let httpSuccess = 0;
136 %let responseStatus =;
137 %irm_rest_get_rgf_cycle(host = &rgf_protocol.:
138 , server = &rgf_service.
139 , solution = &rgf_solution.
141 , tgt_ticket = &rgf_tgt_ticket.
143 , outds = _tmp_cycle_info_
144 , outVarTicket = ticket
145 , outSuccess = httpSuccess
146 , outResponseStatus = responseStatus
150 %
if(not &httpSuccess. or not %rsk_dsexist(_tmp_cycle_info_)) %then
155 set _tmp_cycle_info_;
156 if not missing(dimensionalPoints) then
157 call symputx(
"dim_points_parent", dimensionalPoints,
"L");
158 if not missing(SolutionCreatedIn) then
159 call symputx(
"solution_created_in", solutionCreatedIn,
"L");
162%
else %
if(%sysevalf(%superq(analysis_run_id) ne,
boolean)) %then %
do;
165 %let httpSuccess = 0;
166 %let responseStatus =;
167 %irm_rest_get_rgf_analysis_run(host = &rgf_protocol.:
168 , server = &rgf_service.
169 , solution = &rgf_solution.
171 , tgt_ticket = &rgf_tgt_ticket.
173 , outds = _tmp_analysis_run_info_
174 , outVarTicket = ticket
175 , outSuccess = httpSuccess
176 , outResponseStatus = responseStatus
180 %
if(not &httpSuccess. or not %rsk_dsexist(_tmp_analysis_run_info_)) %then
185 set _tmp_analysis_run_info_;
186 if not missing(dimensionalPoints) then
187 call symputx(
"dim_points_parent", dimensionalPoints,
"L");
188 if not missing(SolutionCreatedIn) then
189 call symputx(
"solution_created_in", solutionCreatedIn,
"L");
194%
if(%sysevalf(%superq(dim_points_parent) ne,
boolean)) %then %
do;
195 %let dim_points_ar_cycle=;
197 %let httpSuccess = 0;
198 %let responseStatus =;
199 %irmc_get_dim_point_from_groovy(query_type = sameLocationReplaceSolutionsSharedWith
200 , dimensional_points = %quote(&dim_points_parent.)
201 , perspective_id = ICAAP
202 , outVar = dim_points_ar_cycle
203 , host = &rgf_protocol.:
204 , server = &rgf_service.
205 , solution = &rgf_solution.
207 , tgt_ticket = &rgf_tgt_ticket.
208 , outVarTicket = ticket
209 , outSuccess = httpSuccess
210 , outResponseStatus = responseStatus
221%irm_rest_get_rgf_bep(host = &rgf_protocol.:
223 , tgt_ticket = &rgf_tgt_ticket.
224 , filter = filter=eq(name,%27__market__empty__bep__%27)
225 , outds = bep_summary
226 , outds_details = bep_details
227 , outVarTicket = ticket
228 , outSuccess = httpSuccess
229 , outResponseStatus = responseStatus
235%
if &httpSuccess.=1 and %rsk_attrn(bep_summary, NLOBS) gt 0 %then %
do;
237 set bep_summary(obs=1);
238 call symputx(
"bep_key", key,
"L");
250%let responseStatus = ;
252%irm_rgf_retrieve_analysis_data(key = &portfolio_key.
253 , libref = &dr_libref
254 , outds = work.mkt_credit_portfolio_0
255 , outds_partition_list = work.mkt_portfolio_part_list
256 , out_type = deferred
257 , outds_dataInfo = work.portfolio_dataInfo
258 , outds_dataDef = work.portfolio_dataDef
259 , host = &rgf_protocol.:
260 , server = &rgf_service.
261 , solution = &rgf_solution.
263 , tgt_ticket = &rgf_tgt_ticket.
264 , outVarTicket = ticket
265 , outSuccess = httpSuccess
266 , outResponseStatus = responseStatus
273 set portfolio_dataDef;
274 call symputx(
"schemaName", schemaName,
"L");
275 call symputx(
"schemaVersion", schemaVersion,
"L");
280%
if &bep_key. = -99999 %then %
do;
282 %let httpSuccess = 0;
283 %let responseStatus =;
284 %irm_rest_create_rgf_seg_scheme(host = &rgf_protocol.:
286 , server = &rgf_service.
287 , tgt_ticket = &rgf_tgt_ticket.
288 , name = __market__by__entity__
289 , description = Created in batch. It provides a segmentation scheme on ENTITY_ID
for the market risk analysis in the
short term.
290 , dimensional_points = %quote(&dim_points_ar_cycle.)
291 , segmentVariables = entity_id
292 , schemaName = &schemaName.
293 , schemaVersion = &schemaVersion.
294 , outds = M_segmentation_scheme
295 , outVarTicket = ticket
296 , outSuccess = httpSuccess
297 , outResponseStatus = responseStatus
305%irm_rest_get_rgf_alloc_scheme(host = &rgf_protocol.:
307 , tgt_ticket = &rgf_tgt_ticket.
308 , filter = filter=eq(name,%27__market__model__alloc__%27)
309 , outds = alloc_scheme
310 , outds_details = allocation_details
311 , outVarTicket = ticket
312 , outSuccess = httpSuccess
313 , outResponseStatus = responseStatus
319%
if &httpSuccess.=1 and %rsk_attrn(alloc_scheme, NLOBS) gt 0 %then %
do;
321 set alloc_scheme(obs=1);
322 call symputx(
"allocKey", key,
"L");
326%
if &allocKey. = -99999 %then %
do;
328 data modelParameters;
329 length name $ 32 value $ 512;
330 name =
"PORTFOLIOHISTORYDATA";
331 value =
"'&portfolio_key.'";
332 task =
"Model Based Allocation";
338 %irm_rest_create_rgf_alloc_scheme(host = &rgf_protocol.:
340 , server = &rgf_service.
341 , perspective = icaap
342 , tgt_ticket = &rgf_tgt_ticket.
343 , name = __market__model__alloc__
344 , description = Created in batch. It provides an allocation scheme
for the market risk analysis in the
short term.
345 , segSchemeFilter = contains(name,
'__market__by__entity__')
347 , modelFilter = and(eq(runTypeCd,%27ALL%27),eq(typeCd,%27MKT%27))
348 , param_table_name = modelParameters
349 , dimensional_points = %quote(&dim_points_ar_cycle.)
351 , outVarTicket = ticket
352 , outSuccess = httpSuccess
353 , outResponseStatus = httpResponseStatus
359 call symputx(
"allocKey", key,
"L");
368filename bep_json temp;
372 %let temp=
"planningDataKey": &portfolio_key.,;
373 JSON = %unquote(%str(%
'&temp%'));
375 %let temp=
"allocationSchemeKey":&allocKey.,;
376 JSON = %unquote(%str(%
'&temp%'));
378 %let temp=
"bepShortName":
"emptyBEP",;
379 JSON = %unquote(%str(%
'&temp%'));
381 %let temp=
"interval":
"YEAR",;
382 JSON = %unquote(%str(%
'&temp%'));
384 %let temp=
"intervalCount": 0,;
385 JSON = %unquote(%str(%
'&temp%'));
387 %let temp=
"solutionCreatedIn":
"ICAAP",;
388 JSON = %unquote(%str(%
'&temp%'));
390 %let temp=%bquote(
"BEPDetails":
"{\"limit\":1,\"count\":1,\"start\":0,\"EXPOSURE_DELTA_MULTIPLIER\":{\"bepData\":{\"start\":0,\"limit\":1,\"count\":1,\"items\":[{\"entity_id\":\"SASBank_1\",\"EXPOSURE_DELTA_MULTIPLIER\":0,\"changeType\":\"rel_add\",\"key\":\"key0\"}]},\"cellOverrides\":{}},\"items\":[{}]}",);
391 JSON = %unquote(%str(%
'&temp%'));
393 %let temp=%bquote(
"planDataSegsAndTargets":
"{\"count\":0,\"limit\":0,\"items\":[]}",);
394 JSON = %unquote(%str(%
'&temp%'));
396 %let temp=%bquote(
"allocationFlg":
true,);
397 JSON = %unquote(%str(%
'&temp%'));
399 %let temp=%bquote(
"bepType":
"PORTFOLIO",);
400 JSON = %unquote(%str(%
'&temp%'));
402 %let temp=%bquote(
"segmentationVars":
"[{\"filterable\":\"Y\",\"partition_flg\":\"Y\",\"attributable\":\"N\",\"format\":\"\",\"mandatory_segmentation\":\"N\",\"label\":\"Entity ID\",\"type\":\"Char\",\"classification\":\"N\",\"size\":32,\"informat\":\"\",\"primary_key_flg\":\"\",\"name\":\"ENTITY_ID\",\"projection\":\"N\",\"key\":8,\"config_readOnly\":\"not_config_param_readOnly\"}]",);
403 JSON = %unquote(%str(%
'&temp%'));
405 %let temp=%bquote(
"targetVariables":
"[\"EXPOSURE_DELTA_MULTIPLIER\"]",);
406 JSON = %unquote(%str(%
'&temp%'));
408 %let temp=%bquote(
"lastSelectedTargetVariable":
"EXPOSURE_DELTA_MULTIPLIER");
409 JSON = %unquote(%str(%
'&temp%'));
414%macro create_object_instance( collectionName =
416 , runFinalize =
false
421 , dimensional_points =
428 length value $ 32000 type $ 32;
430 value =
"{""sourceSystemCd"": ""%upcase(&srcSystCode.)"", ""name"":""&objName."", ""description"":""&objDesc.""";
434 %
if(%sysevalf(%superq(dimensional_points) ne,
boolean)) %then %
do;
435 value =
", ""dimensionalPoints"": &dimensional_points.";
440 value =
" , ""customFields"": {";
444 value =
"&custFieldsFile.";
454 %irm_append_many(file=_body,append=appends,overwrite=Y);
457 %let responseHeader=;
463 %irm_rest_request(url = &rgf_protocol.:
465 , server = &rgf_service.
466 , tgt_ticket = &rgf_tgt_ticket.
467 , headerIn = Accept:application/json
469 , parser = sas.risk.irm.rgf_rest_parser.rmcRestDataDefinition
472 , outVarTicket = ticket
473 , outSuccess = success
474 , outResponseStatus = responseHeader
483 call symputX(
'new_key',key);
486 %
if (%qupcase(&runFinalize.) eq TRUE) %then %
do;
488 filename payload temp;
490 %irm_rest_request(url = &rgf_protocol.:
492 , server = &rgf_service.
493 , tgt_ticket = &rgf_tgt_ticket.
494 , headerIn = Accept:application/json
495 , body = %str({
"SCREENID":
"CustomObject&custObjNum."})
499 , outVarTicket = ticket
500 , outSuccess = success
501 , outResponseStatus = responseHeader
504 %irm_rest_request(url = &rgf_protocol.:
506 , server = &rgf_service.
507 , tgt_ticket = &rgf_tgt_ticket.
508 , headerIn = Accept:application/json
513 , outVarTicket = ticket
514 , outSuccess = success
515 , outResponseStatus = responseHeader
520%mend create_object_instance;
522%
if &bep_key. = -99999 %then %
do;
524 %create_object_instance( collectionName = businessEvolutionPlans
528 , srcSystCode = &rgf_solution.
529 , objName = __market__empty__bep__
530 , objDesc = Created in Batch. It provides an empty BEP
for the market risk analysis in the
short term.
531 , dimensional_points = %quote(&dim_points_ar_cycle.)
532 , custFieldsFile = bep_json
541 call symputX(
'bep_key',key);
546%irm_rest_create_rgf_link_inst( host = &rgf_protocol.:
547 , server = &rgf_service.
548 , solution = &rgf_solution.
550 , tgt_ticket = &rgf_tgt_ticket.
551 , link_type = analysisRun_busEvolution
552 , business_object1 = &analysis_run_id.
553 , business_object2 = &bep_key.
554 , outds = _tmp_link_instance_
565%let BEP_1 = &bep_key.;
566%let BEP_1_MRS_CNT = 1;
567%let BEP_1_MRS_1 = &scenario_key.;
570data bep_x_mrs_config;
571 length BEP_KEY MRS_KEY 8.;
572 keep BEP_KEY MRS_KEY;
573 bep_cnt = symgetn(
"BEP_CNT");
575 bep_key = symgetn(cats(
"BEP_", n));
576 mrs_cnt = symgetn(cats(
"BEP_", n,
"_MRS_CNT"));
577 if mrs_cnt <= 0 then
do;
578 put
"ERROR: No Master Risk Scenarios have been assigned to Business Evolution Plan Id " bep_key;
579 call symput(
"httpSuccess", 0);
583 mrs_key = symgetn(cats(
"BEP_", n,
"_MRS_", i));
589%macro check_httpSuccess;
590 %
if &httpSuccess. ne 1 %then %
do;
593%mend check_httpSuccess;
598%let jobflow_status = Unknown;
600%irm_rest_create_jobflow_instance(instance_name = &instanceName.
601 , description = &instanceDesc.
602 , entityId = &entity_id.
603 , entityRoleKey = &entity_role_key.
604 , category = &jobflow_category.
605 , jobflowFile = &jobflow_type.
606 , baseDate = &irm_base_dt.
607 , configSetId = &config_set_id.
608 , federatedAreaID = &irm_fa_id.
609 , sourceFederatedAreaId = &irm_fa_id.
610 , src_param_tables = work.run_option work.credit_risk_config
611 , tgt_param_tables = &solutionLibrefPrefix._CFG.RUN_OPTION &solutionLibrefPrefix._CFG.CREDIT_RISK_CONFIG
612 , src_upload_tables = work.bep_x_mrs_config
613 , tgt_upload_tables = &solutionLibrefPrefix._CFG.BEP_X_MRS_CONFIG
617 , maxWait = &max_wait.
618 , host = &irm_protocol.:
620 , tgt_ticket = &rgf_tgt_ticket.
621 , outvar = instanceKey
622 , outVarStatus = jobflow_status
626%irmc_update_ctrl_table(cycle_id = &cycle_id.
627 , analysis_run_id = &analysis_run_id.
628 , dr_libref = &dr_libref.
630 , entry_id = &instanceKey.
631 , entry_name = &instanceName.