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