Home > Technical Reference > Workflow Automation > PreDeal Check

PreDeal Check

Introduction

The typical Vector Risk workflow is an end-of-day risk calculation with reports displayed and exported from the Vector Risk GUI.

A second potential workflow is the intra-day calculation of PFE or xVA credit exposure on a trade or trades to enable pre-deal checks. This type of workflow requires a fast return trip from the trading system which is possible through Vector Risk’s secure web services.

We will assume on-boarding of the customer has been completed and there is an environment set up in Vector Risk to accept data for a particular customer (this environment might already be doing end of day portfolio risk calculations for the customer).

The end-to-end process for a pre-deal check then involves the following steps:



Initiating the pre-deal check

The ashx call has five input parameters: q, e, d, g, and datafile. When calling the service with curl, each of these inputs will be preceeded by a -F flag.


Input Parameter Details
q=predeal
Setting the “q” flag (short for query) to “predeal” tells DailyProcess.ashx that we are initiating a pre-deal check.
e=org.env.level The “e” flag specifies the exact workflow environment. An environment has three components. For example “ABCBank.xVA.Production” means:
Organisation=ABCBank
Environment=xVA
Level=Production
d=date  (yyyy-MM-dd) This is the calculation date for the workflow. An environment contains workflows for multiple dates and this parameter selects the correct one.
g=guid  (or any unique identifier) This flag contains the unique identifier (supplied by the caller) for this pre-deal check. This could be a guid, but it is advisable to supply something easier to work with.

An example identifier might be: TimeStamp + product + SourceID

This has the advantage of being readable and ordered in the GUI views in the order the pre-deal checks were made.
datafile=@name This parameter is a string containing the trade data. The @ in front of it tells the system that it is actually a file being sent. The system will save the file into a temporary location on the server.

Typically the csv format is the easiest to map to. The system will convert the file from csv into Vector Risk objects on loading into the system. Once loaded, the data can be viewed in the GUI in an xml tree format.

Note:
When loading csv data the command includes the parameter:  type=text/csv.
If loading xml data, the command would instead use:  type=text/xml.


Monitoring progress

Use the asmx web service “GetStatus” in DailyProcess.asmx to monitor progress of tasks in a workflow. Our interest here is to be alerted when the pre-deal check is complete so we can retrieve results.


Input Parameter Details
Soap Header The body of the soap envelope contains a GetStatus object with three input parameters: environment, date and statusToGet.

Eg: In the example below:
environment should be configured as org.env.level
date should have the format yyyy-MM-dd.
statusToGet = all

<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:web='http://boundaryrider.com.au/webservices/'>
   <soapenv:Header/>
   <soapenv:Body>
      <web:GetStatus>
         <web:environmentName>$environment</web:environmentName>
         <web:environmentDate>$date</web:environmentDate>
         <web:statusToGet>all</web:statusToGet>
      </web:GetStatus>
   </soapenv:Body>
</soapenv:Envelope>

Soap call The soap call specifies:
soap_url
userpass (username and password separated by “:”)
Content-Type = text/xml
charset = utf-8
soapaction (GetStatus) 
soapheader (above)

Curl example:
curl.exe -s `
"https://workflow.ch.vectorrisk.com/DailyProcess.asmx" `
 -u $userpass `
 -H 'Content-Type: text/xml; charset=utf-8' 
 -H 'SOAPAction: http://boundaryrider.com.au/webservices/GetStatus' `
 -d $soapheader 

Response object The response is a list of objects (one per task) containing details of each task in the workflow. We are generally most interested in the “Status” field.

The Status may be one of the following:
Pending
InProgress
Success
Failure
Locked

The user (or calling system) can now poll the web service in a loop (sleeping for some seconds between each poll) until the pre-deal task status is successful. 

Note: When the next pre-deal check is initiated the PreDealCheck task status is reset to “Pending” so the GetStatus loop can start polling all over again. The system supports multiple simultaneous pre-deal requests to the same environment.


Retrieving Results (asmx)

Use the asmx web service “RetrieveCalculationResults” in DailyProcess.asmx to retrieve the credit exposure results specific to this pre-deal check.

Input Parameter Details
Soap Header
The body of the soap envelope contains a RetrieveCalculationResults object with three input parameters: environment, date and taskName.

Eg: In the example below:
environment should be configured as org.env.level
date should have the format yyyy-MM-dd.
calculationDescription = unique identifier originally supplied in the “g” flag

<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:web='http://boundaryrider.com.au/webservices/'>
   <soapenv:Header/>
   <soapenv:Body>
      <web:RetrieveCalculationResults>
        <web:environmentName>$environment</web:environmentName>
        <web:environmentDate>$date</web:environmentDate>
        <web:taskName>PreDealCheck</web:taskName>
        <web:calculationDescription>$desc</web:calculationDescription>
        <web:fullResult>true</web:fullResult>
      </web:RetrieveCalculationResults>
   </soapenv:Body>
</soapenv:Envelope> 

Soap call The soap call specifies:
soap_url
userpass (username and password separated by “:”)
Content-Type = text/xml
charset = utf-8
soapaction (RetrieveCalculationResults) 
soapheader (above)

Curl example:
curl.exe -s `
"https://workflow.trunk.vectorrisk.com/DailyProcess.asmx" `
 -u $userpass `
 -H 'Content-Type: text/xml; charset=utf-8' 
 -H 'SOAPAction: http://boundaryrider.com.au/webservices/RetrieveCalculationResults' `
 -d  $soapheader

Response object The response is a string containing an object containing the maximum PFE and profile, or CVA/DVA depending on the configuration for the pre-deal check task. This configuration is maintained inside Vector Risk and viewable in the GUI.

A snippet of the result for a PFE pre-deal check looks like this:

<Exposure>
  <statistic>PFEMax</statistic>
  <type>Default</type>
  <term>0</term>
  <result>87304.68</result>
</Exposure>


Retrieving Results (ashx)

It is also possible to retrieve the pre-deal check results as a zip file. This is done in two steps:
  1. Use the asmx web service “GetZipReportUrl” to get access to the reports. This web service returns a temporary url for retrieving the reports (this URL times out after 5 minutes and is obfuscated by a GUID in the address).
  2. Pull down the file behind this URL. The file is a zip file containing all a csv report with the results for the pre-deal check in question. Unpack the zip file in a local directory to access the reports.

Input Parameter Details
Soap Header
The body of the soap envelope contains a GetZipReportUrl object with three input parameters: environment, date and taskName with ":guid" appended to the task name. The guid must be the one supplied in the original call for this pre-deal check.

Eg: In the example below:
environment should be configured as org.env.level
date should have the format yyyy-MM-dd.
taskName = PreDealCheck:guid


<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:web='http://boundaryrider.com.au/webservices/'>
   <soapenv:Header/>
   <soapenv:Body>
      <web:GetZipReportUrl>
         <web:environmentName>$environment</web:environmentName>
         <web:environmentDate>$date</web:environmentDate>
         <web:taskName>PreDealCheck:$guid</web:taskName>
      </web:GetZipReportUrl>
   </soapenv:Body>
</soapenv:Envelope> 

Soap call The soap call specifies:
soap_url
userpass (username and password separated by “:”)
Content-Type = text/xml
charset = utf-8
soapaction (GetZipReportUrl) 
soapheader (above)

Curl example:
curl.exe -s `
"https://workflow.ch.vectorrisk.com/DailyProcess.asmx" `
 -u $userpass `
 -H 'Content-Type: text/xml; charset=utf-8' 
 -H 'SOAPAction: 
     http://boundaryrider.com.au/webservices/GetZipReportUrl ' `
 -d $soapheader

Response object The response is a string containing the URL giving temporary access to the zip file on Azure blob storage containing the reports.


An example powershell command for getting a file from a URL and placing it in the current directory is:
Invoke-WebRequest -Uri $reportUrl -OutFile .\predeal_report.zip 

Note: The caller is able to choose the name of the file (in this example they chose the name "predeal_report.zip").



See also
Daily Process