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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
5 0 0 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-apipythonworkspaceworkspace-data-apirefinitiv-dataplatform-eikontime-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.

1 Answer

Upvote
Accepted
39.3k 76 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 :-)