How to get news headlines for list of stocks at once using Python API?

For a one share I do :

ek.get_news_headlines(query='R:ALCLS.PA IN FRENCH', date_from='2018-11-05', date_to='2018-11-11', count=20)

How can I do for my all portfolio (BpiFrance)?

Best Answer

  • try using PF:portfolioname in your query -> ie. ek.get_news_headlines(query='PF:BpiFrance IN FRENCH', date_from='2018-11-05', date_to='2018-11-11', count=20)

Answers

  • @simone.dacosta thanks it worked. User asking any way they can add filters like they want only important news and not all news.

    Some kind of information which directly impact the compagny , no macro economics news

  • the news code for major news (not all news) is NEWS1 - so i would definitely suggest adding this, as well as a language filter. I would suggest adapting a news browser window in Eikon to the needs and then to copy the text over into the code.

    I have a news monitor (F9) on my Eikon desktop that has the following filters Topic:NEWS1 NOT R:AMZN.O NOT Topic:BRXT AND Language:LEN and I can simply paste that into my Jupyter notebook:

    ek.get_news_headlines(query='Topic:NEWS1 NOT R:AMZN.O NOT Topic:BRXT AND Language:LEN', count=20)

    Bringing your attention to the fact you can use things like Topic, RIC, Language etc.

    Good luck!

  • @simone.dacosta How can we do the same for lets say sp500 underlying stocks news headline? Thank you!

  • @feras.obeid

    When asking a new question, please always start a new thread. Old threads with accepted answers are not monitored by forum moderators. A post added to an old thread can easily me missed and not receive a response.

    To answer your question, if you'd like company news for all index constituents, you need to retrieve index constituents, transform the list of constituent RICs into a space separated string and use the latter as the news search expression. E.g.

    df, err = ek.get_data('0#.SPX','TR.RIC')
    instr = df['Instrument'].tolist()
    news_search_expr = ' '.join(instr)
    ek.get_news_headlines(news_search_expr)

    Alternatively you can use the index RIC as the news search expression, which retrieves the news headlines relevant to the index or the stock market the index represents.