question

Upvotes
Accepted
1 0 1 1

How to retrieve a history of yields for each day over the past month for all bonds with currency CHF and exchange SIX

Hello,

I'm trying to use the Python Refinitive Data Library via CodeBook in order to retrieve the history of yields for each day over the past month for each bond with currency CHF and exchange SIX.

As a first step I was trying to use the following query as an input to the `universe` parameter of the `get_data()` function:

rd.discovery.search(
    view = rd.discovery.Views.GOV_CORP_INSTRUMENTS,     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 (RCSCurrencyLeaf eq 'Swiss Franc' and SukukExchangeName xeq 'SIX SWISS EXCHANGE'))",     select = "ISIN" )

... but then the output of `get_data()` is empty, no matter which `fields`I select.

Could you point me in the right direction how to achieve this? Also, it's not entirely clear to me how to further parametrize the `get_data()` function in order to retrieve the historical yields.

Any help is very much appreciated. Thanks in advance!


python#technologypython apicodebookrefinitiv-data-libraries
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.

1 Answer

· Write an Answer
Upvotes
Accepted
7.3k 18 2 8

Hi @agnes.mallinger ,


Thank you for your question. I believe you are on the right direction. The only thing is to note rd.get_data or get_history (which I would advise using in your case) requires RIC universe as in put not the ISIN. So the first step is to modify your Search query to select RIC:

rics_df = rd.discovery.search(
    view = rd.discovery.Views.GOV_CORP_INSTRUMENTS,
    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 (RCSCurrencyLeaf eq 'Swiss Franc' and SukukExchangeName xeq 'SIX SWISS EXCHANGE'))",
    select = "ISIN, RIC"
)

Then you can retrieve the pics to a list and pass it to get_history function:

rics = rics_df['RIC'].to_list()
df = rd.get_history(rics)
df

screenshot-2023-05-31-at-175238.png

And from here you can modify the get_history function to request for a specific fields and dates.


Hope this helps.


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.

Hi Haykaz,

Thank you so much for your answer! This indeed does what I wanted. Just one follow-up question:

In the "Bond Search" explorer (available at this link), there is a field called "Yield to Maturity" which I cannot seem to find within the data retrieved vie `get_history()`. Therefore I wanted to ask, which of the available historical fields matches the "Yield to Maturity" (at any fixed point each day) the closest?

Thank you very much again!!

Hi @agnes.mallinger ,


Happy to hear that it worked for you. As for your follow up question, I am afraid I will not be able to provide much help as it is a content related query and we don't have the complete knowledge on the content. The best place to ask is our Helpdesk which can be reached via MyRefinitiv. Then the support team will contact you directly to assist with this.


Best regards,

Haykaz

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.