After a career in Capital Markets enterprise software, I recently joined Clarus and other than their great blogs, my reason for joining is that I buy into the vision of cloud based technology as the future for our domain.
Micro-services delivering sophisticated analytical computation, easily consumed into a firms existing infrastructure, applications and Excel, will be how the Front and Middle office engages with new risk and regulatory requirements.
Clarus has a number of blogs on using Micro Services, see here.
All of these blogs seem to assume some familiarity with the programming languages C#,R, Python etc. If it requires programming how easy could it be for an Absolute Beginner programmer to use these micro services?
I am an Absolute Beginner programmer, and set myself the goal to:
- Install everything needed to connect to a Clarus Micro Service
- Write a program that uses the ISDA SIMM Margin micro service to get a “what if” margin estimation for a single standalone trade
- Write a program that uses ISDA SIMM Margin micro service that applies a “what If” incremental margin check to a counterparty where the counterparties exposures are documented in a ISDA CRIF format.
Firstly, I needed to select a programming language to use. Python, a language more and more prevalent in financial services, seemed like a good start.
How was I going to be able to get hold of python? One of our developers recommended that I use a tool called Anaconda as it “contains all the right packages and allows you to manage multiple python environments”- whatever that meant? You can download the full Anaconda package or you can download the Miniconda version (and select the packages that you want). I chose the full package which you can download from here.
Now how was I going to use python?
The best place to start seemed to be YouTube, so I watched the first two videos in a series for absolute beginners. (~20 mins in total viewing time).
Python Beginner Tutorial 1 (For Absolute Beginners)
Python Beginner Tutorial 2 (For Absolute Beginners)
After going through the checks in the video, I wanted to check if Clarus package was in the Anaconda download. In a dos command prompt I typed the command:
The Clarus package was not installed so I did the following from the command prompt
pip install clarus
To get to this python command prompt just do a search for the python executable from the search function on your PC/Laptop.
A subsequent “pip list” from the dos command prompt showed that the Clarus package was installed.
I also downloaded Notepad++ as a text editor v (from here).
Task 1 was completed. I could start programming.
To start task 2 I needed some sample python code.
I used the Clarus API Reference to find an example of using the ISDA SIMM margin method. I then simplified to make sure that I understood everything that was in the script. And the resuling script is below.
The api_key.txt and api_secret.txt are the login and password details that you can get from registering for the API from here.
You also need to save the file with the “.py” file extension to ensure that you can run it as a python script.
Running that file from a dos prompt resulted in the following output to the screen.
I was rather pleased with myself.
I had completed task 2.
The first thing for task 3 was to find a file in an ISDA SIM CRIF format, that would form the base set of my risk with each counterparty. I found an example based on the ISDA SIMM test cases with a reasonably diverse set of exposures. This file was saved as ISDA206.txt.
In the previous example I had written all the results to a screen. This time I wanted to write to a csv file, so I had to make some changes to my python script. (There was a bit trial and error here as I needed research how to get a python script to write to a csv file.)
I executed the script and was very pleased to see a new CVS file called “new_file.csv” was created. Opening this file I could see the following
|S I M M||A c c o u n t||W h a t I f||C h a n g e||M a r g i n|
|C 2 0 6||8 8 4 7 9 2 6 1||4 0 3 3 9 4 0||1 4 0 2 0 6 2||8 9 8 8 1 3 2 3|
|M a r g i n||8 8 4 7 9 2 6 1||4 0 3 3 9 4 0||1 4 0 2 0 6 2||8 9 8 8 1 3 2 3|
- Account = The base counterparties SIMM Margin (as in the file ISDA206.txt),
- WhatIf = The “what if” standalone margin charge (from a 10Y Pay Fixed 2% swap),
- Change = The change in the base portfolio’s SIMM margin because of the new trade
- Margin = Then new margin that includes the additional margin from the what if trade.
This matched the Charm GUI as seen below. (Note that Charm GUI also provides drill down explain these numbers).
Task 3 completed
So how easy was it?
Well I was rather surprised at how easy it was to do these three tasks, if any time was wasted it was due to the formatting of data to get into a CSV file in task 3.
So for developers and non-developers alike, it really is straight-forward and rewarding to learn to use the API and start doing productive tasks.
And for those of you that are time poor, the Clarus API Reference has a new sandbox, which after you register and login, allows you to execute and modify code from within a browser environment.
What more could you want?
Register here to request a login and give it a go.
Start your journey from monolithic applications to microservices.