Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
18 0 1 4

Trying to use get_data() to download a series of total returns (TR.TotalReturn)

I am trying to use get_data() to download total return time-series for a selection of RICs. This works fine in excel with the following formula

=TR($E$9:$E$13;"TR.TotalReturn";"Frq=D SDate=2008-01-01 EDate=2018-01-01 CH=IN RH=date";H10)

This gives me a table with dates in the first column and with total return series in the other column, one column per RIC.

However, when I use the formula in Python using the same parameters as in the excel function call, I get a completely different output.

ek.get_data(rics, fields=ek.TR_Field("TR.TotalReturn"), parameters=
{"Frq": "D", "SDate": "2008-01-01", "EDate": "2018-01-01", "CH": "IN", "RH": "date"})

1. Why is this? Can I not replicate the excel output (which I built myself using the Layout button in the Excel Eikon Add-In)

2. Where can I find a description and a list of all possible parameters about the 'parameters' field of the method get_data()?

Thanks for any help!

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apiparameters
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.

1 Answer

· Write an Answer
Upvote
Accepted
4.6k 26 7 22

It is not as simple, I am afraid, but the result is returned in a data frame format, that you can change to meet your goals. For instance, we can change your request into this:

df, e = tr.get_data(['AAPL.O', 'TRI.N'], ["TR.TotalReturn.date","TR.TotalReturn.value"], parameters={"Frq": "D", "SDate": "2008-01-01", "EDate": "2018-01-01"})

So, after you got your results into your data frame, you can create a pivot table:

pt = df.pivot_table(values='value', index=['Date', 'Instrument']).unstack('Instrument')

After that, your date index should be recognised as a date:

import pandas as pd
pt.index = pd.to_datetime(pt.index)
pt.reindex()

That's it:

To your second question, you can use the Data Item Browser app (DIB) on Eikon, select a field and then choose the parameters tab:


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.

Thank you Zhenya. Your answer to my first question helps, I will try this approach.
My second question wasn't about the Eikon Excel AddIn. It was about how to use all parameters, which you can also set in the Eikon Excel AddIn, in the get_data(parameters) function. I can't find a description for it.

@dominique.brandl
Please refer to this tutorial, which talks at length about translating Eikon Excel syntax to get_data call and using Data Item Browser app for metadata discovery (field names and parameters) to use in get_data method.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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