Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 1

News Headline API: How do I get results only showing headlines where the RIC is mentioned (don't want to see results where RIC is mentioned only in the article)?

Using Python API, I use the code below but this will give results where the RIC is either mentioned in the headline or mentioned in the article. I only need the results that will show the RIC on the headlines.


import numpy as np

import eikon as ek

import datetime as dt


ek.set_app_key('XXX')


query = [Instrument,'and',language,'and,documentType']

start_dt = dt.datetime(2021, 1, 1)

end_dt = dt.datetime(2021, 6, 30)

headlines = ek.get_news_headlines(query, raw_output = False, date_from=start_dt, date_to=end_dt, count = 100)

#headlines

#headlines.to_csv('VZ.csv')

headlines

eikonpythonpython apinews-filter
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.

Hello @CVSS ,

Your API key was removed from the question,

-AHS

Hello @CVSS,

<this is a private comment>

Apologies for not being more clear, you API key was removed from the public forum post for security purposes.

1 Answer

· Write an Answer
Upvotes
Accepted
32.2k 40 11 20

Hello @CVSS ,

You could select only the headlines that contain the RICs from the headline results detaframe, for example:

query2 = 'R:C.N IN ENGLISH'

Instrument,'and',language

start_dt = dt.datetime(2021, 1, 1)

end_dt = dt.datetime(2021, 6, 30)

headlines = ek.get_news_headlines(query2, raw_output = False, date_from=start_dt, date_to=end_dt, count = 100)

headlines

Then next you could:

headlines[headlines['text'].str.contains('C.N')]

Is this what you are looking for?

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.

Yes, perfect. Thanks!

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.