Simple moving average

Using Pandas or numpy  packages in python,calculate the simple moving averages of price for the following windows i)last 3 minute , ii)last 7 minute, iii)last 25 minutes. Make sure you have at least 60 time points with a given minute.

Use Roku incorporation data,27/02/2019-28/02/2019

The steps you can follow:


  1. Get the minute data from the alpha vantage. 



    Code: 



    from alpha_vantage.timeseries import TimeSeries



    ts = TimeSeries(key = 'YOUR API KEY', output_format='pandas')



    data, meta_data = ts.get_intraday(symbol='AAPL',interval='1min', outputsize='full')




  2. Calculate the simple moving average.



    To calculate the moving average, you can use the rolling function.



    DataFrame.rolling(lookback_period).mean()



    In your case, lookback_period will be 3,5 or 25.



    I hope it helps you.