Equivalent of an Excel TR Formula in Eikon Python

Hi!
I want to get similar result as the following TR Excel Formula :

=TR("RELI.NS","TR.BasicNormalizedEps","Period=FY0 Frq=D SDate=20200101 EDate=1d CH=IN RH=calcdate",B2)

I've written the following code for it so far :

rics = ['RELI.NS']
fields = ['TR.BasicNormalizedEPS']
params = {'SDate':'2021-01-01', 'EDate':'1d','FRQ': 'D', 'CH':'IN', 'RH':'calcdate'}
res = ek.get_data(rics, fields, params)

Problems :

  1. In place of each occurrence of RELI.NS i want the date of respective trading day to appear
  2. In place of header "Basic Normalized EPS", I want the ric name, ie RELI.NS (as in excel output)

Please suggest how can I do so.

Best Answer

  • RH and CH formatting parameters available in =TR function in Excel are not available in get_data method of Eikon Data APIs.

    To retrieve the dates corresponding to the values of TR.BasicNormalizedEPS field, add TR.BasicNormalizedEPS.calcdate to the list of fields in your data request.

    fields = ['TR.BasicNormalizedEPS.calcdate','TR.BasicNormalizedEPS']

    If you'd like to change the label of a column in the dataframe returned by get_data method, use pandas capabilities.