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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
43 3 1 7

calcdate not equal for all fields in eikon api

I would like to have historical values for closing price and target price per trading date. I run the following code:

start_date = datetime.datetime.now().strftime("%Y%m%d")
start_date = str(20071113)
end_date = str(20071108)
chunk = ['IBM']
fields = ['TR.CLOSEPRICE','TR.CLOSEPRICE.calcdate','TR.PRICETARGETMEAN', 'TR.PRICETARGETMEAN.calcdate']
data, error = eikon.get_data(chunk, fields, 
                                    {"SDate":start_date, "EDate":end_date, "frq":"D"})
data

Unfortunately, the calcdates do not allign (20071112 is missing for PRICETARGETMEAN). Is there a way to make sure the calcdates are always equal for all columns?

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonindex
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
Accepted
39.2k 75 11 27

The way this is solved in Excel is through RH:Date parameter, which adds the master date row headers to the return table. Unfortunately at the moment there's no equivalent in Eikon Python API. Thomson Reuters is looking at ways to address this deficiency. In the meantime merging the dataframes as advised by Joris is all I can suggest as a workaround.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thank you, Alex. The drawback is I need to import twice as many columns (calcdate for every individual column) and then merge everything back into one dataframe. Any ideas when this deficiency will be solved?

The workaround:

start_date = str(20071113)
end_date = str(20071108)
ric = ['IBM']
df1, error = eikon.get_data(ric, ['TR.CLOSEPRICE','TR.CLOSEPRICE.calcdate'], 
                                    {"SDate":start_date, "EDate":end_date, "frq":"D"})
df2, error = eikon.get_data(ric, ['TR.PRICETARGETMEAN', 'TR.PRICETARGETMEAN.calcdate'], 
                                    {"SDate":start_date, "EDate":end_date, "frq":"D"})
df3 = df1.join(df2.set_index(['Calc Date']), on='Calc Date', rsuffix='_x')
del df3['Instrument_x']
df3

calcdatejoin.jpg (48.2 KiB)
Upvote
166 10 17 21

In Excel, it's possible to add "NULL:NA" to the formula (in the lay-out part). Is there something similar available for the Eikon Scripting API with Python? A temporary workaround could be to retrieve the series with separate requests and merging the pandas data frames on dates as index.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea