Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
SMA 200/50 crossover for AMZN

Simple known strategy, when SMA 50 crosses over SMA 200, BUY, otherwise SELL if shares were previously bought. Next algorithm will actually open short positions on SMA 200 cross over SMA 50, as well as SMA 10 and SMA 20 crossover, with SMA 50 as Confirmation status.

5 responses

nice

Use AMZN instead of SPY as the benchmark to see if your strategy would perform better than a simple buy and hold

Thanks for the previous work guys. I am new to Qantopian and Phyton. If I am correct this backtest runs every second when the market is open (takes a while to run the backtest). How can I change the periodicy to every minute?

Tried it with using the schedule function ( date_rules.every_minute(), ) which is not working that easy unfortunately.

Welcome!

Actually, backtests run every minute on the online Quantopian platform. There's no way to change this. In the early years of Quantopian there was also a daily mode but that was eliminated.

By default, the 'handle_data' method is automatically called every minute (during trading hours). To schedule something less frequently use the schedule function (https://www.quantopian.com/help#ide-schedulefunction). The 'date_rules.every_minute()' isn't implemented on the Quantopian platform. If you are offline in Zipline then it may work but the same can be accomplished by placing code in 'handle_data'.

So, if you are working in the online Quantopian platform you don't need to do anything to change to 1 minute periodicity. That's the only mode backtests run in.

Thanks a lot Dan! Already had the idea after using the search function that the data frequency is every minute automatically. Thanks for confirming that.