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!

Best Answer

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭
    Answer ✓

    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()

Answers