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
Best Answer
-
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.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 251 ETA
- 556 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 648 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 916 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛