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!


Best Answer

  • aramyan.h
    aramyan.h admin
    Answer ✓

    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

Answers