Get_news - count of news articles for a RIC, date range and topic
Hi,
As above title please, looking to run a count of news articles for a particular RIC, date range and ‘topic’. I.e. TSLA.O, 6th November 2023 - 10 November 2023, topic=SIGDEV.
I’d like a count of news articles per day.
Is this possible?
I’m aware of how to run get news story for the above, but it’s time consuming. I’d just like to run a count of news articles or headlines - that meet the above criteria - per each day within the specified date range.
Thank you
Best Answer
-
Hi @di.ti,
I believe it might be best to use the RD Lib. for Python's functionanity called 'Delivery' in the following way:
import refinitiv.data as rd
try: # The following libraries are not available in Codebook, thus this try loop
rd.open_session(
config_name="C:\\Example.DataLibrary.Python-main\\Configuration\\refinitiv-data.config.json", # this is where my config file is located
name="desktop.workspace") # rdp.platform
except:
rd.open_session()
company = "TSLA.O"
start = "2023-11-06"
end = "2023-11-10"
source = "SIGDEV"
request_definition = rd.delivery.endpoint_request.Definition(
url=f"https://api.refinitiv.com/data/news/v1/headlines?query={company} and {source} daterange:"{start},{end}"",
method = rd.delivery.endpoint_request.RequestMethod.GET)
response = request_definition.get_data()
response.data.raw['meta']['count']Does this meet your need?
N.B.: You can find info abou this endpoint (which is named a `url` above) here; e.g.: "Limit of headline (default 10, range value: [0, 100])"0
Answers
-
Hi
@jonathan.legrandThank you for this. This works at generating a count of all articles in the date range, but any chance that it could generate a count of how many articles meet this criteria for each day within the start date and end date?
0 -
@di.ti
,
in that case, this should work:company:str="TSLA.O"
start: str ="2023-11-01"
end: str ="2023-11-10"
source: str ="SIGDEV"
strt_dte:datetime=datetime.strptime(start,'%Y-%m-%d')
strt_dtep1:datetime=datetime.strptime(start,'%Y-%m-%d') + timedelta(days=1)
end_dte:datetime=datetime.strptime(end, '%Y-%m-%d')
delta:timedelta=end_dte-strt_dte
for i,j,k in zip(
[(strt_dte+timedelta(days=i)).strftime('%Y-%m-%d') for i in range(delta.days+1)],
[(strt_dtep1+timedelta(days=i)).strftime('%Y-%m-%d') for i in range(delta.days+1)],
[i for i in range(delta.days+1)]):
request_definition: rd.delivery._data._endpoint_definition.Definition=rd.delivery.endpoint_request.Definition(
url=f"https://api.refinitiv.com/data/news/v1/headlines?query={company}+and+{source}+daterange:\{i},{j}\",
method=rd.delivery.endpoint_request.RequestMethod.GET)
response:rd.delivery._data._response.Response=request_definition.get_data()
if k==0:
req_def_lst:list[int]=[response.data.raw['meta']['count']]
else:
req_def_lst.append(response.data.raw['meta']['count'])
print(f"{i}to{j}:{response.data.raw['meta']['count']} article(s)")
print(req_def_lst)1 -
Hi
@jonathan.legrand, Works perfect! Thank you very much!0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛