question

Upvotes
Accepted
1 0 0 2

How can I get municipal instruments data with a list of cusip?

I have a list of cusip data about municipal bonds with around 50000 length, and I wanna get their historical rating with rd.discovery.search, but the followting code doesn't work.

What should I do?

cusip = ['18085PMP6', '613340Q27', '181012B','10141PAM5'
         ,'181059KB','181000LH1'] # The actual length is 500000
ratings = rd.discovery.search(
    view = rd.discovery.Views.MUNICIPAL_INSTRUMENTS,
    query = cusip,
    select = "CUSIP, Ratings"
)
pythonrefinitiv-dataplatform-eikon#technologyrefinitiv-data-platformbonds
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
27.8k 67 18 14

Hello @eikon11

Thank you for contacting us. According to the RD Library reference, the query parameter of the rd.discovery.search method supports string only, not an array.

search.png

However, the query string supports the boolean operator, so you can use the "A OR B OR C ..." query as follows:

cusip = ['18085PMP6', '613340Q27', '181012B','10141PAM5','181059KB','181000LH1'] # The actual length is 500000
ratings = rd.discovery.search(
    view = rd.discovery.Views.MUNICIPAL_INSTRUMENTS,
    query = ' OR '.join(cusip),
    select = "CUSIP, Ratings"
)
ratings

** Note**: You may need to split 50000 items to multiple lists and sends request multiple times instead of sending one request with 50000 items.

search-2.png I hope this helps.


search.png (49.2 KiB)
search-2.png (45.8 KiB)
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.