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.