Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
using history() to calculate 60 and 20 minute moving averages

I'm trying to creating a minute-by-minute moving average crossover using the 60 and 20 minutes moving averages for the SPY ETF. Experienced C/C++ programmer but new to python and even newer to quantopian/zipline.

My initial thought was to use a .history() after setting my universe to include only the SPY ETF. I was able to figure out how to get the price for each minute for the previous hour, but I can't find a straight answer on how to select a certain amount of previous bars of price data and calculate the mean.

I could use help with this as well as a general guide to using pandas.

1 response

Attached should get you started. Since you already know C, should take you no time to learn Python, and the libraries/framework used in Python. Just hang in there, walk through the documents, then the codes of a few popular strategies. Before you know it, your mind will be speaking to you in Python.