Good evening,
I have a problem using the Eikon API on Python.
I wrote a function that extracts different fields for a given company and that organizes them according to the dates in a dataframe. I want to retrieve quarterly data. The problem is that for some fields the function get_data returns correctly the data for each quarter (december, march, june, september), while for other fields (e.g., TR.Revenue) it returns the data only for the month of december of each year. I checked the fundamentals of the company through Refinitiv Workspace and the data that I want to extract are available from there for each quarter. Can somebody help me? This is the code:
def extract_data(company_tickers, fields_to_extract, custom_fields_option, standard_options, print_info=False, save=False):
df_list = []
while len(custom_fields_option) < len(fields_to_extract):
custom_fields_option.append({})
for i, field in enumerate(fields_to_extract):
extracted_field, error = ek.get_data(company_tickers, [field+'.date', field if bool(custom_fields_option[i]) == False else custom_fields_option[i]], standard_options)
extracted_field = extracted_field.drop('Instrument', axis=1)
for row in range(len(extracted_field)):
extracted_field['Date'].iloc[row] = extracted_field['Date'].iloc[row][:7]
extracted_field = extracted_field.set_index('Date')
extracted_field = extracted_field.drop_duplicates()
df_list.append(extracted_field)
if error:
print("ERRORS:", error)
if print_info:
print("Extracted data at iteration:",i)
print(extracted_field)
concatenated_df = pd.DataFrame()
for i, df in enumerate(df_list):
if i == 0:
concatenated_df = df
else:
concatenated_df = concatenated_df.join(df, how='left')
concatenated_df = concatenated_df.rename(columns={"Net Income Incl Extra Before Distributions": "Net Income", "Price Target - Mean": "Price Target",
"Total Shareholders' Equity incl Minority Intr & Hybrid Debt": "Tot Shareholders Equity",
"Net Cash - Ending Balance": "Net Cash"})
if print_info:
print(concatenated_df)
if concatenated_df.index[0] > concatenated_df.index[1]:
if print_info:
print("FLIP APPLIED")
concatenated_df = concatenated_df.iloc[::-1].copy()
concatenated_df = concatenated_df.fillna(method='ffill')
concatenated_df = concatenated_df.dropna(axis=0)
concatenated_df = concatenated_df.astype(float)
if save:
concatenated_df.to_csv('DATA.csv', header=True, index=True)
return concatenated_df
The function is called in this way:
company_ticker = 'AZMT.MI'
field_to_extract = ['TR.PriceClose', 'TR.Revenue', 'TR.GrossProfit', 'TR.NetIncome', 'TR.RevenueMedian', 'TR.PriceTargetMean', 'TR.F.TOTASSETS', 'TR.F.TOTLIAB', 'TR.F.TOTSHHOLDEQ', 'TR.F.NETCASHENDBAL']
custom_field_option = [{'TR.PriceClose' : {'params':{'Scale': 0}}}]
standard_option = {'Scale': 6, 'SDate': 0, 'EDate': -130, 'FRQ': 'Q', 'Curn': 'EUR'}
df1 = extract_data(company_ticker, field_to_extract, custom_field_option, standard_option, True, False)
While the function extracts the data it prints the retreived data, here you can see for example that the field 'TR.PriceClose' works correctly giving results for all the different quarters.

Unfortunately, the most of the fields behave like 'TR.Revenue', giving me only the value for the month of december.
