Credit/Risk : Real Time Calculations in Open Components

Credit/Risk : Real Time Calculations in Open Components

By Yuntao Yi



Open Components (OC) has redesigned the scripting of Credit/Risk real time calculations in a clean, object oriented way. The structure for Deal scripts and Update scripts is more cohesive compared to the old AVS/OPENJVS scripts. With the advantages of Open Components, customized credit/risk scripts can be developed a lot faster than before, especially in complicated scenarios with criteria that needs overriding. However, there are still issues in OC V14 which haven’t been fixed at the time of writing, which will be discussed shortly.


In AVS/OPENJVS, the deal script and update script manipulate the argt and returnt tables. It is possible to use the same plugin for both the deal and update scripts, but we have to check which mode the script is running in (quick check, batch or update) and apply different logic to run simulations, etc. In OC, the deal script and update script are implemented in different methods of the same interface. This groups the deal and update script of the credit/risk definition into the same class. The update script is modelled in a method called aggregateLineExposures. The method has access to all the deal exposures hitting that exposure line. The deal script is modelled in createDealCache and calcDealExposure methods. The createDealCache method is normally used to run simulation results and is called only once, whereas calcDealExposure is called once per transaction.


One of the biggest advantages of OC is the flexibility and ease of overriding criteria. One Deal can hit multiple exposure lines by creating multiple DealExposure objects, and facility criteria, in credit/risk terms, can be overridden by setting field values. For example: A definition has External LE, Toolset, and Currency defined as facility criteria. This can be retrieved via a line of code as below:

Field[] fields = definition.getCriteriaFields(transaction);

This will return an array of three fields: External LE, Toolset, and Currency


We want to override the criteria for the deal so that it adds $1000 exposure on line ‘HSBC LE’, ‘FX’, ‘USD’, regardless the default value of the deal (The default criteria on the deal might be ‘ICBC LE’, ‘Cash’, ‘XAU’). We just need the following code:

fields[0].setValue(“HSBC LE “);

fields[1].setValue(“FX “);


DealExposure dealExposure1 = definition.createDealExposure(1000.0, transaction, fields);

However if we want the deal to hit multiple exposure lines, we need to return multiple DealExposure objects. i.e. create multiple objects as per the code above and return them in an array.

return new
DealExposure[]{dealExposure1, dealExposure2, dealExposure3};


Although OC is very powerful, there are bugs in V14 which have not been fixed at the point of writing (October 2015), which should be noted during implementation.

  1. The getClientData method is normally called inside aggregateLineExposures in the update script and will cause memory issues. Surprisingly, it will only cause issues when there are multiple definitions running at the same time. Possible symptoms can be script engines suddenly crashing or exposures from different definitions get picked up by the update code. There are potential workarounds but the correct one depends on the configuration of credit/risk.
  2. When running full simulation results (using the Simulation object rather than Reval) for FX Swaps, the system can crash occasionally (depending on the scenario). Workarounds do exist, but involve setting Reval parameters and using OpenJVS APIs inside OC code.

There is a big push from the vendor to use Open Components as the new coding standard, and we look forward to seeing reported bugs fixed in the next release.

Have your say:

You Must Be A Member To Read This Article

We regularly publish great content from our experts advising you on how to maximise the efficiency of your trading software and business intelligence suites.  Become a member today to access them all, for free.

Download PDF version

This field is for validation purposes and should be left unchanged.