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
21 4 5 6

Is there any time series objects for moving average?

We are looking for Moving Average time series objects which can return data on a historical date like 12/31/2018, as opposed to only current data. And we should be able to get that data through API.

For example, we want to find the value of the 20-day moving average of AAPL on 12/31/2018.

Is this doable? Thank you!

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
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 @aryer,

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question.

Thanks,

-AHS

Hello @aryer,

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

-AHS

1 Answer

· Write an Answer
Upvotes
Accepted
39.4k 77 11 27

Sure this is doable, and there's more than one way to go about this. Here's one way.

import datetime as dt
import eikon as ek
... edate = dt.date(2018,12,31) sdate = edate + dt.timedelta(days=-20) df, err = ek.get_data('AAPL.O',['TR.PriceClose'], {'SDate':str(sdate), 'EDate':str(edate)}) ma = df['Price Close'].mean()
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.

Sorry I need to clarify a little bit: I am looking at the "TR.PriceAvg10D" field on the Eikon terminal, and trying to get the data on a historical date like 12/31/2018, as opposed to only current data. I don't mean to pull all historical data out and using python to process it. Is there a way to do it?

Thanks!

Hi @aryer,

The 'TR.PriceAvg10D' is a convenience field that calculates average daily price close over the most recent 10 trading day. I don't believe the servers keep track of every rolling window of average daily prices based on date. I believe if you want to go back in time, you will have to perform the calculation as @Alex Putkov. suggested.

@aryer
There's no history available for TR.PriceAvg10D field. To see how you can tell if a field has history in Eikon take a look at the answer on this thread.

@aryer

or you can use ADC to calculate it for you:

import datetime as dt
import eikon as ek
...
edate = dt.date(2018,12,31)
sdate = edate + dt.timedelta(days=-20)
df, err = ek.get_data('AAPL.O',['AVG(TR.PriceClose)'],
                      {'SDate':str(sdate), 'EDate':str(edate)})

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.