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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 0 3

Translating Refinitiv Excel Formula to Eikon Python API

I have an excel plugin formula which I want to convert to Python Code and get the same result via eikon Python API.

My excel formula is : =@RHistory("DEBMK2;DEBMM2;DEBMN2;DEBQN2;DEBQV2;DEBQF3;DEBYF3;DEBYF4;DEBYF5;DEBYF6;DEBYF7;DEBYF8;DEBYF9;DEBYF0",".Timestamp;.Close","NBROWS:365 INTERVAL:1D",,"TSREPEAT:NO CH:IN;Fd",B27)

I used ek.get_timeseries method but it is showing error for few tickers in the list. I was told I can get the same output using ek.get_data method. But I unable to find the correct params for this.

I tried the following code but it is not working for me:

df, err = ek.get_data(['DEBMc1', 'DEBMc2', 'DEBMc3', 'DEBQc1', 'DEBQc2', 'DEBQc3', 'DEBYc1', 'DEBYc2' , 'DEBYc3' , 'DEBYc4' , 'DEBYc5' , 'DEBYc6' , 'DEBYc7' , 'DEBYc8' ], 
['TR.Timestamp','TR.Close'], {'SDate' : startDate, 'EDate': reportDate})

Where startDate and reportDate are defined elsewhere.

Can someone explain me how to find relevant fields to be provided here?

eikon-data-apipython apieikon-for-office
icon clock
10 |1500

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

Upvote
Accepted
12.1k 59 39 61

Hi @Mohit.Rai

Using the refinitiv-data library, you can try this:

import refinitiv.data as rd
from refinitiv.data.content import historical_pricing

# Within CodeBook, this will automatically use the Desktop Session
rd.open_session()

...

items = ['DEBMc1','DEBMc2','DEBMc3','DEBQc1','DEBQc2','DEBQc3',
         'DEBYc1','DEBYc2','DEBYc3','DEBYc4','DEBYc5','DEBYc6',
         'DEBYc7','DEBYc8']

response = historical_pricing.summaries.Definition(
    universe = items,
    start='2021-05-01',
    end='2022-06-08',
    fields=['SETTLE']
).get_data()
response.data.df

teams.png

The 'SETTLE' field is defined as the official closing price. In addition, there are no duplicates in this data set. As suggested, I would follow up with the helpdesk to confirm the content.


teams.png (177.2 KiB)
icon clock
10 |1500

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

Upvotes
47.3k 111 44 60

@Mohit.Rai

You can try ['TR.ClosePrice.Date','TR.ClosePrice'] fields.

df, err = ek.get_data(['DEBMc1','DEBMc2','DEBMc3','DEBQc1','DEBQc2','DEBQc3','DEBYc1','DEBYc2','DEBYc3','DEBYc4','DEBYc5','DEBYc6','DEBYc7','DEBYc8' ], 
['TR.ClosePrice.Date','TR.ClosePrice'], {'SDate' : '2021-05-01', 'EDate': '2022-06-08', 'FRQ':'D'})

However, I found duplicated entries.

1654676447227.png

The =TR function in Eikon Excel also returns the same duplicated entries. The get_data method can be used to retrieve the same content as the =TR function in Eikon Excel. Therefore, you need to contact the Eikon Excel support team directly via MyRefinitiv to verify the content. You may ask for the =TR formula in Eikon Excel which can be used to get the required data. Then, you can apply it to the get_data method.


1654676447227.png (37.8 KiB)
icon clock
10 |1500

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