RankPos - would like to have a Sector filter

My portfolios typically have a buy rule RankPos < XX and a sell rule RankPos > YY. This works quite well but I have ports that are concentrated in one sector.

I’m looking for a way to limit the number of stocks held for a specific sector while maintaining the RankPos buy/sell rules. I think the easiest way would be to add a parameter to RankPos so that the calculation is only applied to the sector that the stock resides in. For example, the buy rule RankPos(Sector)<=2 would only allow the top 2 stocks in a given sector to be purchased. The sell rule RankPos(Sector)>3 would cause the position to be sold if the sector rank position rises above 3.

I have looked for workarounds to eliminate sector concentration such as Sector Weight but such workarounds are problematic when used with RankPos.

1 Like

One workaround is as follows. Let’s say you want to limit the concentration of stocks in the tech sector. Take your ranking system and give it a new name. Add a new Boolean node that simply says Sector = Tech. Give it an absolutely huge weight, so it dwarfs the weight of your other factors put together. Then in your buy and sell rules use RatingPos(“[name of new ranking system]”) instead of RankPos along with an Eval, like Eval(Sector=Tech,RatingPos(“Techrank”)<=2,true). This will allow all non-tech stocks to be unaffected by the rule but the tech stocks have to rank high among the tech stocks alone.

Thanks Yuval. I’m looking for a more generic solution. I’m using the same RS in many ports now and the problem sector(s) change over time and port.