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
5 0 2 3

How do I apply a simple function (E.g. AVG) to a python API time-series style request?

Hi! My question relates to minimising my total number of API calls by applying functions to time series data on the server side.

I understand that the 'get_timeseries' method in the python Eikon module - as of this version - can only return a limited number of fields. But it is possible to query time series via the 'get_data' method using a construction like:

exp = 'MSFT.O'
fields = ['TR.TotalReturn.Date','TR.TotalReturn']
params = {"SDate":"2018-10-01","EDate":"2018-10-17","Frq":"D","CH":"Fd"}
manual_ts = ek.get_data(exp,fields,params)

Now, what if I want to apply an aggregate-style function to my time series, and just return a single value? In excel, you would use a formula like this:

=TR($B14,"AVG(TR.FwdPe)","Period=FY1 Frq=M SDate=0D EDate=-10AY")

This returns the average Forward Price/Earnings over the last 10 years.

How would I implement this in the python API? I've tried something like this, but to no avail:

ek.get_data('MSFT.O',['AVG(TR.FwdPe)'],{"SDate":"2018-10-01","EDate":"2018-10-17","Frq":"D"})
eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apitime-series
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.

Hello @steven.sellers

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query? If yes, please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

AHS

Hello @steven.sellers

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query? If yes, please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

AHS

I've accepted the answer :-)

1 Answer

· Write an Answer
Upvote
Accepted
39.4k 77 11 27

The capability to use server side functions in data requests is not yet supported in Eikon Data APIs. For the time being you have no choice but to retrieve all the timeseries you need and perform the calcs on the desktop.

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.

Thanks - very clear. I hope that support for server-side functions is on the development backlog :-)

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.