Help with sector ranking

Hi - I am trying to write a ranking system and/or set of simulation rules to do the following:

  1. Sort sectors by an aggregate fundamental metric (say, earnings yield… sum of earnings in the sector divided by sum of market cap in the sector)
  2. From the top X sectors, buy the top Y stocks sorted by that same fundamental metric (but applied to each stock)

I’ve tried making an individual custom series for each sector. I also tried making a series of conditional rankings where the conditional nodes were “GICS(10)”, “GICS(20)” etc and then did Close(0,GetSeries(“my custom series for GICS 10 earnings yield”)) if true, but that didn’t seem to work (it just returned all the stocks in alphabetical order).

Any thoughts/suggestions? Thanks so much!

I too have played around with this but with no luck. I am looking forward to any responses you get as well.

I don’t think this is the perfect solution, but it could be a starting point.

The two rules of this screen
a) select the two industries with the highest dividend yield,
b) identify the three best-performing stocks per industry


Thanks Cyberjoe but what I was hoping for was a solution that is more generic using these two ranking tools to create a generic ranking system:



Since sector ranking systems are not currently supported, it has to be expressed as rules.
[font=courier new]SetVar(@NumSectors, 2)
SetVar(@NumStocks, 3)
SetVar(@EarnYieldAvg, Aggregate(“EarnYield”, #Sector))
FOrder(“@EarnYieldAvg”, #All, #DESC, 1) <= @NumSectors
FOrder(“EarnYield”, #Previous, #DESC) <= @NumStocks[/font]

Aaron - thanks for that. I had missed the Aggregate() function, seems very useful once I wrap my head around all the options.

David,

I think you are on the right track. Set up 2 ranking systems, one that ranks the “sectors” based on a number of factors and/or functions and one that ranks “stocks” based on the same and/or additional factors and/or functions. Then set up a Sim or Screen using the “sector” ranking system and add a buy rule using the Rating(“stocks”) > xx ranking system. That way you can select sectors & stocks based on many factors/functions without adding dozens of buy rules to a Sim or Screen.

Denny, there’s currently no way to assign ranks to sectors with a ranking system.
The rule-based approach is the only accurate way of expressing the logic capturing the desired result.

Ignoring the command with #Previous, how should the code be modified to work in the simuator? I get a ‘Value not set for temp variable @EarnYieldAvg uid 8892’ error in the sim.

Walter

It is not currently possible. An upgrade should be released not too long from now that will allow SetVar in custom universes.
After that, one could put these rules in a custom universe to support this kind of filtering.

Well, I kept tinkering with this and came up with the following:
https://www.portfolio123.com/port_summary.jsp?portid=1347015

I also created a screen to check my work and it looks like it is selecting about the same stocks. So play with it and give any feedback.

There are several ‘knobs’. You can change the minimum rank for selecting sectors to include (I selected 60%. It gives several sectors). Rank>95 seems to give only the top 1 sector, for instance.
Play with how many of the top stocks per sector in the FOrder buy rule.
Then the number of stocks selected by the Sim as well as the universe itself.

I find this interesting because I have always heard that the SP500 has a strong sector play to it, in addition to selecting individual stocks. That is why I selected SP500 to try this idea out on. I ran it using other universes and it did best with SP500 and R1000. Large caps. I guess this makes sense becuase large caps are slower growing and looking for high EarnYield (as long as it is not just a value trap) could make sense. This sim did poorly against the R2000 and since the R2000 has smaller caps with higher P/Es, then looking for just low P/Es would point me in the wrong direction.

A fun exercise. Any feedback is appreciated.