Clarus Financial Technology

Microservices: A SIMM Sensitivities Calculator

Calling directly in the browser

To appreciate the ease with which the SIMM sensitivities function may be called, we call it directly in the browser without writing code!

This URL is enough to call the function and see its results.
https://api.clarusft.com/rest/v1/simm/sensitivity.html?trades=USSN015

To ease the exposition, we set the trades parameter to USSN015, the Bloomberg ticker for the USD 1×5 swaption. The SIMM sensitivities are shown below, although you will need to enter a username/password the first time (obtained by registering here).

SIMM sensitivities for a USD 1×5 Swaption

Trade Format

Financial Product Markup Language (FpML) is an XML standard widely used amongst capital market participants in the processing of OTC derivatives. The API can accept FpML descriptions of trades as well as several other formats including CSV trade list files. In the example below we will use a CCP trade list file, other formats would work in exactly the same way.

Calling from Python

To calculate the SIMM sensitivities for a CSV trade list, we cannot type the entire trade list into the URL, instead we will use Python to load the trade list from a file, assign the contents to the trades parameter and call the Clarus SIMM sensitivity function. Notice we do not need to specify the format explicitly, we just pass the data and the function can understand it, a simple and convenient approach for the caller!
The API will return a response object containing the results that can be dumped to a file or passed on in the program for further processing. The code snippet below shows the main steps.


my_csv_trade_list = open('/home/gary/clarus/IRSTR_Clarus_123_20170330.csv').read()

r = clarus.simm.sensitivity(trades=my_csv_trade_list)

print(r)
  

The results produced by this code is (truncating the right most columns for convenience);


RiskType         Qualifier    Bucket    Label1     Label2        Amount \
Risk_IRCurve           USD         1        2w    Libor3m         -2.56 
Risk_IRCurve           USD         1        3m    Libor3m        -37.49
Risk_IRCurve           USD         1        6m    Libor3m         -7.43
Risk_IRCurve           USD         1        1y    Libor3m      -5000.42
Risk_IRCurve           USD         1        2y    Libor3m        -18.61
Risk_IRCurve           USD         1        3y    Libor3m       -117.22
Risk_IRCurve           USD         1        5y    Libor3m      18678.81
Risk_IRCurve           USD         1       10y    Libor3m        9520.8
Risk_IRVol             USD         1        1y    Libor3m    1613200.99

A very similar approach works in other languages, such as R and Julia. Working examples are found at SIMM sensitivity API Documentation.

The complete code used in the example above is shown below. It relies on the Clarus python module (which utilises the popular Requests library). The key/secret can be obtained by registering here.


import clarus 

# Example of REST API call to Clarus Microservices #

# Manually edit and set key/secret here #
clarus.ApiConfig.api_key = ''
clarus.ApiConfig.api_secret = ''

my_csv_trade_list = open('/home/gary/clarus/IRSTR_Clarus_123_20170330.csv').read()
  
print(my_csv_trade_list)

r = clarus.simm.sensitivity(trades=my_csv_trade_list)

print(r)

# Now save results to create ISDA SIMM CRIF file #

f = open('/home/gary/clarus/CRIF.csv', 'wt')
f.write(r.text)
f.close()

13-Apr-2017
Updated full example code to create CRIF file rather than just printing the results.

Stay informed with our FREE newsletter, subscribe here.

Exit mobile version