News Headline API: How do I get results only showing headlines where the RIC is mentioned (don't wan

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

Best Answer

  • 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?

Answers