SDR Data via Microservices

  • SDR Prices can be retrieved directly from Clarus using very simple code
  • This allows our users to efficiently bring the data into any suitable environment
  • This means that SDR data is available via an API
  • This API is also simple to implement and simple to access.

As I said last time, I’m not a coder. Fortunately, our developers help me get around that weakness. Our new microservices architecture makes it as easy as possible for me to access our data in any way I want to.

SDR USSW10 Tape

Our first Microservice has allowed me to create my own unique SDR tapes – for example USSW10 is shown to the right.

But what is a microservice? Essentially, it is a specific application that does one thing, but does it simply. So it is a small application, but it means it is very easy to learn as well. I illustrate a classic example of this below – you now only need a “snippet” of code to retrieve the last traded price for an interest rate swap reported to the SDRs. That snippet goes something like this:

r = requests.post(fullRESTUrl, data=paramStr, headers=headers, auth=(apiKey, apiSecret))

The basic premise of the blog will follow my blog on using Python previously:

Some explanation of why I’m doing this will go here.

Some code goes here.

Arm yourself with an API Token

First things first. We don’t just give this stuff away – it’s protected using an APIsecret and an APIkey. This means that to access the microservice, you’ll need a Clarus token. This will authorise you to use our API. For testing purposes and to follow along with this blog, we are happy to supply you with a time-limited token. So please don’t hesitate to contact us or use your existing credentials to access the microservice directly.

Now, simply follow the steps below. And if you haven’t previously installed python (or pip), please refer to my previous blog.

1. Set up your python module

It soon becomes second nature. But to set up the right python environment, at the top of a new Python module, you need to include the packages we will be working with:

import json
import requests
import sys
import csv

2. Build the Microservices URL

All of the Clarus microservices are accessed via a RESTful API. This basically means that you send a sequence of parameters to a URL. We define the URL that we are going to send the parameters to in Python using the code below:

headers = {'Content-Type': 'application/json'}

## Manually edit and set key/secret here ##
apiKey = 'xxxxxxxxxxx'
apiSecret = 'xxxxxxxxxxxxxxxxx'

urlBase = 'http://api.clarusft.com'
restAPI = '/rest/v1/sdr/'
name = 'LastPrice'
fullRESTUrl = urlBase + restAPI + name + '.csv'

As you’ll probably notice, we are asking for ‘LastPrice’ from our ‘api.clarusft.com’ URL, and asking the microservice to return a ‘.csv’ file.

3. Build the parameters

This is all well and good, but we also need to send some parameters concerning which last price we are interested in. Surprise, surprise, we do this by defining some ‘Parameters’ using the following code:

params = {}
params['sef'] = 'On,Off'
params['source'] = 'DTCC,BBG,ICE'
params['ticker'] = 'USSW10'

paramStr = json.dumps(params)

Telling the microservice to;

  • Look at both On and Off SEF trades
  • Look for trades from all three SDRs – DTCC, Bloomberg (BBG) and ICE
  • The instrument we are interested in is the 10 year US Swap traded on market standard conventions – specifically a spot starting, semi-annual 30/360 fixed rate versus 3m Libor. Handily, Bloomberg supply their tickers for such instruments via the Open FIGI initiative. Therefore, we can just type in USSW10.

From a user’s perspective, I think that last part about the ticker is key. Leveraging the data augmentation that we do on the SDR data makes this microservice so much easier to use.

4. Send the parameters

This is where we have simplified things even further. Having now built the structure, it is a simple one line call to extract the data that we want:

r = requests.post(fullRESTUrl, data=paramStr, headers=headers, auth=(apiKey, apiSecret))

5. Get the results

As with all things Python, we can simply return the results within IDLE using print.

print (r.text)

And that is it

It should only take a short blog to describe a microservice – it does only one thing after all! In IDLE, you will see the following output:

SDRLastPrices Output
Output from our Python script

 

This simplicity is reflected in our official documentation for the microservice – 4 parameters with their values, and code examples in Python, Perl and R. That really is all that is necessary.

However, once you are familiar with the above, it also means that our other microservices become second nature to you. They tend to share common parameters, so it is a simple case of changing the URL address (from Prices to Volumes for example) and re-saving the Python script.

 

In Summary

We provide an elegant, short and simple solution to provide a clean SDR tape for any Bloomberg ticker.

It is simple to implement.

And simple to access.

Something the swaps markets are certainly in need of.

Finally, I wanted to create something visual, so I once again created a streaming chart via plotly. Enjoy the output below:

Streaming Chart Static grab
Static screen grab of USSW10 on Monday 1st August (a quiet day!)

Stay informed with our FREE newsletter, subscribe here.