New posts are disabled while we improve the user experience.

You can browse the site, or for urgent issues, raise a query at MyAccount.

question

Upvotes
1 0 0 0

Pulling snippet date VCHAIN data LSEG Workspace via Refinitiv API

I have question about the LSEG Workspace value chains data (VCHAIN). For some time we've been pulling the VCHAIN data via the Refinitiv API.

This works like a charm for the following fields: TR.SCRelationship', 'TR.SCRelationship.ScorgIDOut', 'TR.SCRelationship.instrument', 'TR.SCRelationshipConfidenceScore', 'TR.SCRelationshipFreshnessScore', 'TR.SCRelationshipUpdateDate'.

We use this Python code:

value_chains = dl.get_data(
    universe=inputList,
    fields=['TR.SCRelationship', 'TR.SCRelationship.ScorgIDOut',
            'TR.SCRelationship.instrument', 'TR.SCRelationshipConfidenceScore', 'TR.SCRelationshipFreshnessScore','TR.SCRelationshipUpdateDate']
)

However, we also want to pull the data of the news snippets (not the snippets themselves, only the dates) available in the Workspace. See screenshots below for how to find them in the Workspace. We'd like to do this via the API because we work with a big dataset of companies, but we cannot find a field code to do so. Is this possible via the API?

Best regards, Maarten Gubbels

Data Librarian for the Nijmegen School of Management, Radboud University Nijmegen (Netherlands)

snippet date, the fiels we'd like to pull

snippet-dates.png

Where to find this date in the LSEG Workspace (VCHAIN app):

snippet-column.png

#contentrefinitiv-data-library
snippet-dates.png (67.7 KiB)
snippet-column.png (191.9 KiB)
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.

Upvotes
11.1k 22 6 9

@MaartenG Thanks for your question - so the snippet count is defined as the following:

Snippet evidence text is the sentence extracted from the source document (e.g. News, Filings) that provides evidence signaling the supplier-customer relationship. The Snippet Count is the total number of de-duplicated evidence texts collected from all the source documents for the supplier-customer relationship pair.

This number is calculated from news query as well as filing queries - it is not delivered via API. So the Filings are not available via API in Eikon/Workspace - so you will not be able to replicate this. However, you could try to do a News Search for both the supplier and customer pair and try to de-duplicate the articles and then count them. Something like the following will get the news headlines:

Now = datetime.now().date()
maxenddate = dNow - timedelta(days=365) #upto months=15
compNews = pd.DataFrame()

for ric in riclist:
    try:
        cHeadlines = rd.news.get_headlines("R:VOD.L AND R:BRTI.NS AND LANGUAGE:LEN", start= str(dNow),end = str(maxenddate), count = 10000)
        #cHeadlines['cRIC'] = ric
        if len(compNews):
            compNews = pd.concat([compNews,cHeadlines])
        else:
            compNews = cHeadlines
    except Exception:
        pass
        
compNews

1730201823216.png

Then you would need to de-duplicate the headline (maybe if headline and source are similar/same) and then count. This would not be as sophisticated as say getting the story and looking for sentences where both are mentioned - it might be possible to to that by requesting a story and then searching for both names in the same sentence - a relatively straightforward task for a vectordb - though you would need to get each story for each headline and then create embeddings / tokenise for each sentence say.

Another approach could be to use the news metadata component to actually check the News Codes that were applied to each news headline. This can be done using :

baseurl = "/data/news/v1/stories/"
fullcodelist = pd.DataFrame()
compNews['storyText'] = str()
compNews['q_codes'] = str()
compNews['pIDs_mentioned'] = str()
compNews['RICs_mentioned'] = str()
compNews['urgency'] = str()

for i, uri in enumerate(compNews['storyId']):
    request_definition = rd.delivery.endpoint_request.Definition(
        url = baseurl + uri,
        method = rd.delivery.endpoint_request.RequestMethod.GET
    )
    response = request_definition.get_data()
    time.sleep(0.1)
    rawr = response.data.raw
    if 'newsItem' in rawr.keys():
        compNews['storyText'][i] = rawr['newsItem']['contentSet']['inlineData']['$']
        topics = rawr['newsItem']['contentMeta']['subject']
        rics = [x for x in rawr['newsItem']['assert'] if x['_qcode'].startswith("R:")]
        compNews['q_codes'][i] = [d['_qcode'] for d in topics]
        compNews['pIDs_mentioned'][i] = [x for x in compNews['q_codes'][i] if x.startswith("P:")]
        compNews['RICs_mentioned'][i] = [d['_qcode'] for d in rics] 
        compNews['urgency'] = rawr['newsItem']['contentMeta']['urgency']['$'] # 1 = hot, 3 = regular
            
compNews

1730202621111.png

Here you can see the Column RICs_mentioned - you could try counting articles where only the two RICs of interest are mentioned - ignoring articles where more RICs are mentioned as these are more likely to be sector general articles possibly. I hope this can help.


1730201823216.png (93.2 KiB)
1730202621111.png (161.5 KiB)
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.

Upvotes
1 0 0 0

Dear @jason.ramchandani01 ,

Thanks so much for this elaborate answer. I'll share it with our researchers, and we'll see if we can make this work.

Best regards,

Maarten

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.

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.