question

Upvotes
Accepted
9 1 1 3

Retrieve bond data from rd.discovery.search()

Hi! I am trying to download bond data by Refinitiv data API. Learnt from this post retrieve bond ISIN issued by a list of firm RICs - Forum | Refinitiv Developer Community, I write the code, which works well in the chat window in Notebook. However, I do not know how to export the results to excel. How I need to modify my code on this? Many thanks!

import pandas as pd
import refinitiv.data as rd

rd.open_session()

rd.discovery.search(
    view = rd.discovery.Views.GOV_CORP_INSTRUMENTS,
filter = "(DbType eq 'CORP' and RCSAssetCategory eq 'A:J' and DebtType ne 'SYKHYB' and DebtType ne 'SUK*' and IsConvertible eq false and ((IssuerOrgid eq '27965') and IsGreenBond eq false and (IssueDate ge 2013-01-01 and IssueDate le 2013-12-31)))",
select = "FirstAnnouncementDate,CouponRate,MaturityDate,IssueDate,ISIN,FaceIssuedUSD,RCSConvertibleLeaf,IsGreenBond,IssuerOrgid"
)
pythonrefinitiv-dataplatform-eikon#technologyapibonds
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 @jiayin.meng.20 ,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thank you,

AHS


Hi @jiayin.meng.20, Please note that the answer below was marked as 'Accepted'. Please do let us know if that is incorrect.

1 Answer

· Write an Answer
Upvote
Accepted
22.2k 59 14 21

Hi @jiayin.meng.20,

Once you have the results of the search in the Pandas dataframe, you can use the to_csv() method of dataframe to export this data into a CSV file. This file can be opened with Excel.

You can also use other modules like Excelwriter or openpyxl to manipulate and directly write excel workbook.

pd = rd.discovery.search(    view = rd.discovery.Views.GOV_CORP_INSTRUMENTS,
filter = "(DbType eq 'CORP' and RCSAssetCategory eq 'A:J' and DebtType ne 'SYKHYB' and DebtType ne 'SUK*' and IsConvertible eq false and ((IssuerOrgid eq '27965') and IsGreenBond eq false and (IssueDate ge 2013-01-01 and IssueDate le 2013-12-31)))",
select = "FirstAnnouncementDate,CouponRate,MaturityDate,IssueDate,ISIN,FaceIssuedUSD,RCSConvertibleLeaf,IsGreenBond,IssuerOrgid"
)

pd.to_csv('ExportedData.csv')

PS: You must have write permission in the directory where you are trying to export this into.

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.