question

Upvotes
Accepted
1 0 0 2

How to pull bond data from GOVSRCH using Codebook?

Hi, I would like to pull bond data from the GOVSRCH universe.


I have used the Codebook tutorial to pull Enterprise Value data from 3 universes as below:

df = rd.get_data(universe=['LSEG.L', 'VOD.L', 'GOOGL'], fields=['TR.EV','TR.EVToSales'])


From the filters, it seems that GOVSRCH like it is a universe on it's own. govsrch-universe.png

1678385061016.png

So when attempting to pull a specific bond's data, for example GOOGL, I have tried searching with the Preferred RIC:


df = rd.get_data( universe = 'GOVSRCH', fields = ['02079KAB3='], parameters = ['ISIN']

This results in the following error:

Failure sending request with <refinitiv.data.content.fundamental_and_reference.Definition object at 0x7f57140dd340 {universe='['GOVSRCH']', fields='['TR.RIC']', parameters='['Coupon']', row_headers='None'}>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/_fin_coder_layer/get_data.py", line 67, in get_adc_data
    response = definition.get_data()
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/content/fundamental_and_reference/_definition.py", line 224, in get_data
    response = super().get_data(session, on_response_filter)
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/content/_content_provider_layer.py", line 45, in get_data
    return super().get_data(session, on_response)
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/delivery/_data/_data_provider_layer.py", line 106, in get_data
    response = self._provider.get_data(
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/delivery/_data/_data_provider.py", line 74, in get_data
    request = self.request.create(session, *args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/content/fundamental_and_reference/_data_provider.py", line 171, in create
    body_parameters = self.get_body_parameters(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/content/fundamental_and_reference/_data_provider.py", line 194, in get_body_parameters
    kwargs = validate_correct_format_parameters(*_, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/refinitiv/data/content/fundamental_and_reference/_data_provider.py", line 113, in validate_correct_format_parameters
    raise ValueError(f"Arg parameters must be a dictionary")
ValueError: Arg parameters must be a dictionary

I also get a similar error when searching via the ISIN


How do I pull bond data using Codebook? Any assistance is greatly appreciated, thank you in advance.

python#technology#contentbondscodebook
1678385061016.png (44.7 KiB)
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
5.6k 18 2 7

Hi @oscar.guitet ,


Thank you for your question. You can't use GOVSRCH as universe in your request unfortunately.

Is all the fields you are after exist in your GOVSRCH output? If so, the best way I could think of is using Export query functionality of the Workspace:

screenshot-2023-03-09-at-230531.png

Then a new window appears and clicking on the Codebook field you will get a python query with search capabilities which will allow you returning the same values you see in GOVSRCH via an API call:

screenshot-2023-03-09-at-230544.png


In case you want other fields not available in GOVSRCH or you want time series data, we can retrieve the rics via search query and can request the fields/series via rd.get_data/rd.get_history function. Happy to help you on that if necessary.


Hope this was helpful. Please feel free to let me know should you have any further question.


Best regards,

Haykaz



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
1 0 0 2

Thank you very much for your response!


A follow-up if you don't mind:

Is there a way of searching the GOVSRCH environment for specific ISINs? I have an example export query below for ISIN US45766X2053. Is this a limitation of the license I am using? Thank you in advance.


df =rd.discovery.search(

view = rd.discovery.Views.GOV_CORP_INSTRUMENTS,

top = 100,

filter = "((DbType eq 'GOVT' or DbType eq 'CORP' or DbType eq 'AGNC' or DbType eq 'OMUN' or DbType eq 'OTHR') and IsActive eq true and (ISIN eq 'US45766X2053'))",

select = "RIC,EJVAssetID,DTSubjectName,BusinessEntity,PI,SearchAllCategoryv3,SearchAllCategoryv2,SearchAllCategory,DBSTicker,CouponRate,MaturityDate,IssueDate,ISIN,RCSCurrencyLeaf,RCSCountryLeaf,DbTypeDescription,InstrumentTypeDescription,RCSCouponTypeGenealogy,FaceIssuedUSD,RCSBondGradeLeaf"

)

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
17.9k 82 39 63

Hi @oscar.guitet

You provided an example query that looks correct. For example, this is the result when I applied your request:

1681245620870.png

It's unclear what limitation you ran into? Are you suggesting there is a limitation of not being able to specify the ISIN within the GOVSRCH app within the desktop? You can specify the ISIN.

Or did you not get a result when you tried to execute your code segment?


1681245620870.png (38.2 KiB)
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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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