Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
why is this Long and Short SPY strategy so volatile?

Hi there,

I am new here. I try to write a momentum strategy on SPY. Basically, I long the SPY when 50-days-average goes up across the 200-days-average and go short when 50-days-average goes down across the 200-days-average. It should not be hard to write it. I wrote the draft but the results are very surprising. Something must be wrong. Could any expert help me with my code? Thanks a lot.```

James

2 responses

Try order_target_percent instead of order_percent. The latter (the one you are using), I think will compound your orders. So the first time you call it you allocate 100% of your portfolio's value to SPY but the second time you call it then you allocate another 100% of your current portfolio's value. order_target_percent on the other hand will adjust your total security allocation as a percent of your portfolio.

Ideas