Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted

Unable to extract valuable information from Ticker using Python.

I am reaching out today, since for the past few days some of the analysis that we perform using the Eikon Python Package that Reuters provides (link here) has been failing to grab the necessary details we need, which was causing our code to break (Dates this was breaking was from 19/09/2021-22/09/2021). Specifically, we are using the eikon API, to extract some macro indicators, which are futures contracts and used to contain the following details in their fields:

  • EXPIR_DATE
  • CRT_MNTH
  • DSPLY_NAME

These fields used to be returned without any issues for the future contracts, but we haven’t been able to successfully get them for the last 2 days. Logging into eikon, we can also see that these fields are passed as null values there in the top description, but we can see them under the Quote details tab now. I am attaching screenshots to demonstrate this:

I am also attaching an example snippet of the code I am running, which uses a .env file that contains my REUTERS_API_KEY,

import eikon as ek
import pandas as pd
from datetime import datetime, timedelta
from tqdm import tqdm
from dotenv import find_dotenv, load_dotenv
import os

load_dotenv(find_dotenv())

print(os.getenv("REUTERS_API_KEY"))

ek.set_app_key(os.getenv("REUTERS_API_KEY"))

required_fields = ['EXPIR_DATE', 'CRT_MNTH', 'DSPLY_NAME']

st_dt = (datetime.now() - timedelta(days=5)).strftime("%Y-%m-%d")

margins_indices = [
"BRTDTDMc%s",
"LCOc%s",
"LGOc%s",
"PROCNWEMc%s",
"NAPCNWEAMc%s",
"EBOBNWEMc%s"
]

months = list(range(1, 37))

results = {}

with tqdm(total=len(margins_indices) * len(months)) as process_bar:
for ticker in margins_indices:
for month in months:
process_bar.set_description(f"Downloading { ticker} at contract M+{ month}")

contract_ticker = ticker % str(month)

field_data, err = ek.get_data([ticker], required_fields)

timeseries = ek.get_timeseries([contract_ticker], ["CLOSE"], start_date=st_dt,
end_date=datetime.now().strftime('%Y-%m-%d'))

instrument, exp_date, current_month, current_name = field_data.iloc[0].values

current_month_date = pd.to_datetime(str(current_month), format='%b%y').strftime('%Y-%m-01')

contract_month = pd.to_datetime(str(current_month), format='%b%y').strftime('%b')

contract_year = pd.to_datetime(str(current_month), format='%b%y').strftime('%Y')

results[contract_ticker] = {
"series": timeseries,
"current_month_date": current_month_date,
"contract_month": contract_month,
"contract_year": contract_year,
"expiry_date": exp_date
}

process_bar.update(1)

print(results)

When you try to run the above script, it will lead to the error bellow:

Which is due to the fact that the current month is returned as a Null.

Could please have a look into this and let me know what is causing this error, and which would be the best way forwards?

Thank you for your help,

Constantinos Spanachis

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
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.

@constantinos.spanachis

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.


Thanks,

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
25.3k 87 12 25

Hi @constantinos.spanachis

If the code was working perfectly fine and returning data and if now the same code is not returning expected data, then it is most likely a data or service issue and I would recommend raising an Eikon Support ticket via Eikon or via My.Refinitiv.

Also, the lack of indentation in the code snippet above makes it ambiguous. Can you insert the code using the code snippet option in the toolbar <> OR upload the code as a .txt file?

Thanks.


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.