Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Custom Moving Average creation?

Hello,

I'm having some trouble here.. I have a custom value that is the difference between the 30 day mavg price and 30 day mavg stdev, Is it possible to create a 30 day mavg of the difference between these two? Any help would be greatly appreciated.

Thanks in advance!
Jamie

3 responses

Hello Jamie,

I'd start by getting familiar with 'history' described on the help page (https://www.quantopian.com/help#ide-history). It'll get you a Pandas DataFrame that can be used to compute the quantities of interest. If I understand correctly, you'll want to use rolling_mean and rolling_std described on http://pandas.pydata.org/pandas-docs/stable/computation.html, take the difference of the results and then compute the mean of the differences, for each security.

A thread to get you started: https://www.quantopian.com/posts/working-with-history-dataframes.

Grant

These might help: https://www.google.com/#q=mavg+site:quantopian.com
(Results can easily show over twice what you see there, try initial capital at 35000. why?)

Thanks guys! I have a lot to learn!