For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
11 3 3 9

Method to pull all Corporate Bonds in country using Python

Is there a way to pull all corporate bonds in a given country with a Python script? I haven't been able to find any method on this forum. The script would ideally interact with the Eikon data API and pull the list directly from Eikon.

Currently, I can extract a list of bonds, but this involves downloading an excel file and pulling in the values from that excel file. Another problem with this method is the Excel file export is limited to 1000 bonds and extracting all the necessary bonds would require several exports.

Any help is appreciated.

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonbonds
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
18k 21 12 20

Hi @cchen01

You can try using RDP Lib(Python).

You have to install it first:

pip install refinitiv.dataplatform


Then import it to your codebook or python code, you can use the same appkey with eikon data api:

import refinitiv.dataplatform as rdp
rdp.open_desktop_session('a_valid_appkey')


And call it:

filterStr = "DerivedCategory eq 'BOND' and Country eq 'TH'"
srchfields = "Country, RIC, FullName, CommonName,CompanyName, SeniorityType, NativeIdentifier, DerivedCategory, OriginalIssueCurrency, ParentIndustrySector, CouponCurrency, CouponTypeDescription"
GroupSize = 10000 #max at 10000

data = rdp.search(view=rdp.SearchViews.GovCorpInstruments, filter=filterStr, top=GroupSize, select=srchfields)
data


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

You can add several filter to the "filterStr" sample such as:

ahs.jpg (186.6 KiB)

I am running into issues with the installation of refinitiv.dataplatform. After running pip install and receiving the "Successfully installed refinitiv.dataplatform-1.0.0a8.post2" message and attempting to import the module, I receive the following error:

ImportError: DLL load failed: The specified module could not be found.

Additional Warning Messages:

WARNING: Ignoring invalid distribution -yzmq (c:\programdata\anaconda3\lib\site-packages)

WARNING: Ignoring invalid distribution -penpyxl (c:\programdata\anaconda3\lib\site-packages)

Any insight into why this error may be occurring? I copied the pip install and import statements from the reply above.

Thanks,

Hi @cchen01,

Can you include your specific code segment that results in this error. I just tried it within the Jupyter environment with no issues.

ImportError Traceback (most recent call last) <ipython-input-1-c3185ee3f92b> in <module>

2 import numpy as np

3 import eikon as ek

----> 4 import refinitiv.dataplatform as rdp

5 rdp.open_desktop_session("eikon_api_appkey")


It seems like there is an issue with the installation of the module. The module is installed successfully because the requirements are all satisfied, but the error still occurs. I've also attempted un-installing and re-installing the module too, but that is unsuccessful too.

Show more comments
Upvotes
12.1k 59 39 61

Hi @cchen01,

I would suggest you review the Search article on the developer community to better understand the capability of what you can do with Search, such as some tips and tricks to get the most out of the service. In addition, I would also suggest you review the Debt Structure Analysis article as it utilizes Search to retrieve a list of Corporate bonds. For example, to retrieve a list of active bonds that have not matured within a country, you can try this:

df = rdp.Search.search(
    # The 'view' represents a specific domain of content we wish to 
    # search across.  
    view = rdp.SearchViews.GovCorpInstruments,
    
    # The 'filter' parameter is a powerful, criteria-based, syntax 
    # that allows us to filter for specific results.
    #
    # Disclaimer: The following expression includes bonds that are 
    #             in 'default'.  If you choose to ignore these from 
    #             your result set, simply modify the expression 
    #             below as follows:
    #
    #             "..not(AssetStatus in ('MAT' 'DEF'))"
    #
    filter = "IsActive eq true and RCSIssuerCountryLeaf xeq 'United States' \
              and ISIN ne null and MaturityDate ne null and \
              not(AssetStatus in ('MAT')) and EOMAmountOutstanding ne null \
              and CouponRate ne null and NextCallDate ne null",

    # Define the upper limit of rows within our result set.  This is a 
    # system imposed maximum value.
    top = 10000,

    # The 'select' parameter determines the fields of interest in our 
    # output.  The logic below takes our list of properties defined and 
    # creates the appropriate comma-separated list of properties required 
    # by the service.
    select = "ISIN, DBSTicker, IssueDate, Currency, FaceIssuedTotal, \
              EOMAmountOutstanding, NextCallDate, CouponRate, MaturityDate, \
              CdsSeniorityEquivalentDescription"
)

If you noticed, I put in place a number of filters. This you will need to discover as you go through your journey of searching out content. The Search article talks about how to manage large data sets. Because you are interested in bonds issued for a whole country, expect the results to be in the hundreds of thousands. However, many of those bonds may contain details that are not relevant and should not be in your result set. This you will need to fine-tune based on your specific requirements.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.