Hello Shakti,
This Week's Spark: Buy Low, Sell High
Every week, I feature an idea, a "spark" to get your creative juices flowing. This week, the idea is so basic, so simple. . . and so complex.

The basic idea is from the Quantopian sample algorithm, but it was community member
Gary Chan who re-framed the idea for us. He took a very simple trigger - move up a few points over the moving average, or move down a few points under the moving average - and made it his own. He altered the code to buy when the price hits the low, and to sell when it is high.
Here is the very simplest implementation:
if price < vwap * .97:
order(stock, 100)
elif price > vwap * 1.04:
order(stock, 100)
There are so many things you can tweak:
-
What stock (or stocks) do you use? Try other ones yourself.
-
How far above or below the average is your trigger? You can try different triggers, and find different inflection points.
-
How long is your moving average? A shorter moving average will be more volatile and trade more often.
Are you ready to try it yourself? Check out Gary's
Buy Low, Sell High share, click the "Clone Algorithm" button, and start hacking!
Community PostsHere are some of the interesting posts in our community this week:
What do you have to share with the community this week?
As always, drop us an email at the
feedback address and we'll be happy to help, respond, and listen. What features do you want next?
Thanks,
Dan Dunn
P.S. Quantopian Resources
Python Resources - Be a Better Programmer
Finance Resources - Learn More Concepts