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

I'm somewhat new to python and quantopian and I would like some help. Here is what I'm looking to do:

Create a list of 20 or so securities
for each security,
Buy when price > SMA period of 15 days
Sell when price < SMA period of 15 days

I know this is a basic strategy, but I would still like to explore it. Any help would be appreciated, Thank you very much.

2 responses

Take a look at the tutorials ( https://www.quantopian.com/tutorials ) and especially the pipeline tutorial (https://www.quantopian.com/tutorials/pipeline) That's a great place to start. Some of the algorithms are very similar to the one you suggest.

Attached is a sample of an algorithm which does something like what you are trying to do. The HUGE problem with this however is that is uses a fixed universe of 20 stocks. The more realistic and correct approach would be to incorporate logic to select that universe 'algorithmatically'.

@Dan when I use the pipeline you provided it gives me a single column for Date , Asset and price.. do you know how can I split it into multiple columns?