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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
21 2 1 5

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

1 Answer

Upvotes
Accepted
39.2k 75 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 5.0 MiB each and 10.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)})
Click below to post an Idea Post Idea