Skip to content

Instantly share code, notes, and snippets.

Sending requests for historical (TR) LSEG-Refinitiv Fields to its Python API (Refinitiv Data Library)
import asyncio
import refinitiv.data as rd
try:
rd.open_session( # This will fail in CodeBook
name="desktop.workspace", # This (i.e.: the desktop session) nesesitates users to run Workspace or Eikon on the machine where the code is run.
config_name="C:/Example.DataLibrary.Python-main/Configuration/refinitiv-data.config.json")
except:
rd.open_session() # This sicceeds in CodeBook
fields_list =[
"TR.Revenue.date", "TR.Revenue",
"TR.FINextCallDate", "TR.FIPurposeDescription",
"TR.FIWorstRedemEvent", "TR.MUNIRating",
"TR.UltimateParentId", "TR.UltimateParent",
"TR.CompanyCntPostalCodeAddr"]
parameters_dict = {
"Scale": 6,
"SDate": 0,
"EDate": -3,
"FRQ": "FY",
"Curn": "EUR"}
tasks = asyncio.gather(
rd.content.fundamental_and_reference.Definition(
universe='VOD.L',
fields=fields_list,
parameters=parameters_dict
).get_data_async(closure='Vodafone'),
rd.content.fundamental_and_reference.Definition(
universe='AAPL.O',
fields=fields_list,
parameters=parameters_dict
).get_data_async(closure='Apple'))
await tasks
def display_reponse(response):
print(response)
print("\nReponse received for", response.closure)
if response.is_success:
display(response.data.df)
else:
print(response.http_status)
vodafone, apple = tasks.result()
display_reponse(vodafone)
display_reponse(apple)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment