How to pull all available bonds listed on a particular exchange(NYSE) using Xbbg or blpapi Python?

667 Views Asked by At

I'm trying to pull all available bonds in an exchange(NYSE) from the Blomberg terminal via Python. I want to retrieve the various bond data fields like say(Option Adjusted Spread ,S&P Rating, Yield to Maturity, Sector). How can I be able to achieve this either using xbbg or blpapi? In both of them from their docs you need the ticker option that is what I don't know how to navigate given I intend on referencing an exchange or different exchanges.

I've looked at this answer How to pull out the list of active German government bonds using xbbg? but this is specific to local bonds. From the Bloomberg docs as well I'm not clearly seeing from the "//blp/instruments" endpoint instrumentListRequest option how this can be achieved. however I tried playing around with this by passing a sector as part of the query but clearly this is not right given it returns an empty results.

session.openService("//blp/instruments")
service = session.getService("//blp/instruments")
request = service.createRequest("instrumentListRequest")
request.set("query", "Corporate Bonds")
request.set("sector", "Corporate")
request.set("maxResults",10)

response = session.sendRequest(request)

any one whose had some experience with this?

1

There are 1 best solutions below

1
AKdemy On

To run something like SECF you will need you to use the instrumentListRequest you tried.

You can find all available info in the "services schema and references guide" on wapi. There are only 3 queries possible:

  • security lookup
  • curve lookup
  • government lookup

Only the security lookup makes sense for you. The following code snippet demonstrates how to make a Security Lookup Request, assumes that a Session already exists and that the “//blp/instruments” service has been successfully opened.

Service secfService = 
session.getService("//blp/instruments"); Request request = 
secfService.createRequest("instrumentListRequest");
request.asElement().setElement("query", "IBM"); 
request.asElement().setElement("yellowKeyFilter", 
"YK_FILTER_CORP"); 
request.asElement().setElement("languageOverride", 
"LANG_OVERRIDE_NONE"); 
request.asElement().setElement("maxResults", 10);
sendRequest(request, session);

It will be cumbersome to filter out relevant products and in cases like this, I think it will be easiest to either use a SRCH as suggested or directly BQL (where the help desk should be able to help) to obtain all filds and the entire universe of interest.

Certain tools (The FX toolkit, the curves toolkit for example) are simple better or only available in Excel.