How to retrieve a bond's rating at the date of the issue using the codebook?

Client has a list of ISINs in an excel file and would like to get the Bond Rating on Issue Date of each bond.

 

Each bond has different Issue Dates so we have an excel formula for each individual bond as:

 

=@RDP.Data($A3,"TR.GR.RatingDate;TR.GR.RatingSourceDescription;TR.GR.Rating","Frq=NA SDate=#1 RH=IN",,RDP.Data($A3,"TR.FiIssueDate"))

 

where cell A3 contains the ISIN.

 

Is it possible to create a python code that will loop the process of getting the rating on bond's issue date then append the result in a table until the last ISIN on the list?

 

Here is an excel file with a list of bond ISINs, see attached.

 

Here is the python code sample for the excel formula above:

 

import refinitiv.data as rd
rd.open_session()

 

Issue_Date_1 = rd.get_data(
    universe = ISIN,
    fields = ['TR.FiIssueDate']
)

 

ISIN = "USP78625EA73"
Issue_Date = Issue_Date_1['Issue Date'].tolist()

 

 

Rating = rd.get_data(
    universe = ISIN,
    fields = [
        'TR.GR.RatingDate',
        'TR.GR.RatingSourceDescription',
        'TR.GR.Rating'
    ],
    parameters = {
        'SDate': Issue_Date
    }
)

 

Rating

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @MarkTheodore.Martin

    Thank you for reaching out to us.

    Yes, the sample code looks like this:

    df_list = []
    ISIN = ["US71654QCZ37","USP78625EA73","US71654QDE98","US200447AH32"]
    
    Issue_Date_1 = ld.get_data(
        universe = ISIN,
        fields = ['TR.FiIssueDate']
    )
    
    for index, row in Issue_Date_1.iterrows():
        Rating = ld.get_data(
            universe = row["Instrument"],
            fields = [
                'TR.GR.RatingDate',
                'TR.GR.RatingSourceDescription',
                'TR.GR.Rating'
            ],
            parameters = {
                'SDate': row["Issue Date"].strftime("%Y-%m-%d")
            }
        )
        df_list.append(Rating)
    
    pd.concat(df_list)