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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
25 0 0 2

Descrepancy total return using EIKON API and Excel

Hello,

I am trying to pull quarterly returns for a list of stocks (the ISIN below is just and example) using the EIKON API. This is the code I am using:

for i in range(1995, 2020):     
    for z in range(1, 5):         
      ek_d, err=ek.get_data("DK0010302488",["TR.TotalReturn","TR.TotalReturn.date","TR.TotalReturn3Mo"],{"SDate": str(z)+"QCY"+str(i), "CURN": "DKK"})

I am running intwo to issues:

1) the results are very different than if I run the following formula in Excel: =TR("DK0010302488","TR.TotalReturn;TR.TotalReturn3Mo;TR.TotalReturn.date","Frq=CQ SDate=2014-01-01 EDate=2015-12-31 Curn=DKK CH=Fd RH=IN",G4)


2) Values "TR.TotalReturn" and "TR.TotalReturn3Mo" are very different for the same quarter when I use the API, while they are always the same when I use Excel.

I would be very grateful if you could help me figure out what is wrong


Best,

David

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythondata
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.

Upvotes
Accepted
18k 21 12 20

Hi @dpi.eco

You can directly transform Eixon Excel formula to Eikon Data API call:

fields = ["TR.TotalReturn","TR.TotalReturn3Mo","TR.TotalReturn.date"]
parameters = {"SDate": "2014-01-01", "EDate":"2015-12-31", "Frq":"CQ", "CURN": "DKK"}

ek_d, err=ek.get_data("DK0010302488", fields, parameters)
ek_d

This should give you the same result:


ahs1.jpg (187.1 KiB)
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.

Upvotes
39.2k 75 11 27

To add to the response by @chavalit.jintamalit, when you only specify the value of SDate parameter, TR.TotalReturn returns 1 day total return as of the date corresponding to the value of SDate. This is why the values of TR.TotalReturn and TR.TotalReturn3Mo retrieved in your example using Eikon Data API library are different. When you specify both SDate and EDate, the value of TR.TotalReturn represents total return between these dates. When you retrieve timeseries of TR.TotalReturn by specifying SDate, EDate and Frq, the interval between SDate and EDate is broken into periods according to the value of Frq, and the value of TR.TotalReturn retrieved for each period represents total return between the start and end date of the period. This is why with Frq=CQ the values returned for TR.TotalReturn and TR.TotalReturn3Mo are the same.

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.

Upvotes
25 0 0 2

@chavalit.jintamalit @Alex Putkov. thank you very much. Your answers perfectly explain my confusion.


Best,

David

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