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.
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
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.