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