Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Simple Relative Strength Strategy is not trading - Help needed please

Hello Community,
I created a simple, long-only strategy that holds the top 3 stocks with the highest momentum over its 50-day average. In the Research Environment, my pipeline seems to work and outputs 3 stocks each day. I can't get the darn thing to actually trade in the IDE.

I've attached a notebook that contains both the research & IDE code I created.

Any help would be much appreciated.
Thank you,

2 responses

Hello Michael,

Fix for this problem is fairly easy. On line 67 your code is

long_weight = 1 / len(context.longs)  

Which causes Python to do integer math and result get rounded down to 0. Just changing that 1 to 1.0 will allow Python to do floating point math instead of integer math and your code will run.

Wow, thank you so much Mikko. You are an absolute genius. As you can probably tell, I just learned Python this month from a Udemy course, so I'm very new to this. I really appreciate your help!