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?

Best Answer

  • 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.

Answers

  • 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.

  • 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

    image