I'm new to Python so this is all a little confusing to me as of now. I'm trying to create a list of stocks from four sectors (consumer cyclicals, tech, consumer defensives an industrials). I'm trying to combine all those stocks in a list and then rank them by return on invested capital (roic) and go long the top 50 and short the bottom 50, rebalanced monthly. I'm pretty sure the attached code does all this
I'm trying to add a wrinkle to it but can't seem to figure it out. I would like to only go long the high roic stocks if the sma 50 > sma 200 and only go short the bottom stocks if sma 200 < sma 50. I would like this new screen/filter to run daily. Any help would be very much appreciated.