How to get news historical news headlines for specific companies for more than 2 years in Codebook?

Options

Hello Team,

Client is using Codebook and has asked the below query.

I need to know how to get news historical news headlines for specific companies. The following script only gets me 2 years worth of headlines. I need a much longer history to backtest my sentiment analysis.

import refinitiv.data as rd

from refinitiv.data.content import news

from IPython.display import HTML

import pandas as pd

import numpy as np

from datetime import datetime,timedelta

import time

import warnings

warnings.filterwarnings("ignore")

dNow = datetime.now().date()

maxenddate = dNow - timedelta(days=3650) #upto months=15

compNews = pd.DataFrame()

riclist = ['MSFT.O'] # can also use Peers, Customers, Suppliers, Monitor, Portfolio to build universe

for ric in riclist:

try:

cHeadlines = rd.news.get_headlines("R:" + ric + " AND Language:LEN AND Source:RTRS", start= str(dNow),

end = str(maxenddate), count = 10000000)

cHeadlines['cRIC'] = ric

if len(compNews):

compNews = pd.concat([compNews,cHeadlines])

else:

compNews = cHeadlines

except Exception:

pass

compNews

compNews.to_csv("microsoft_news.csv")

Tagged:

Answers

  • Hello @avinash.sonde

    Please refer to the data limits and guideline document.

    • news.get_headlines: There is no current limit value other than the aggregate data limit (see the daily limits detailed below) (14-04-2024). The depth of history is 15 month.

    For a deeper historical depth, other products like MRN, DSS or RDP bulk can be used.