How to stress test a Buy Rule

If you have to use a buy rule (ranking systems are more robust!) I recommend testing the rule using the mod(stockid)-method:

This way you can test the rule in many subset of your full universe. If it's a good rule it should work in most of them.