In the last post, the reader was introduced to the 10 stock custom universe and the Rank screen (module). Now it is time to find out what the conditional node does and how it is different from an Eval ( ... ) function.
Lets start by constructing a one factor (stock formula) node with an Eval function. MktCap will be used to identify the 5 highest market capitalization stocks in the stock universe as shown below.
Now lets examine how the stocks are ranked by using the Ranking module.
The five highest market capitalization stocks are ranked in order from 90 down to 50 (by 10's). The last 5 stocks are lumped together with a ranking of 40. These results are acceptable for a very simple ranking system.
Eval ( ... ) In Combination With Other Stock Factors
Lets suppose the designer doesn't want the lower 5 stocks showing up near the top of the ranking system at all. Then the use of the Eval (...) function is not effective. This can be demonstrated by adding a second stock factor to the ranking system as shown below.
In this example, Price/Earnings Growth (PEG) has been added as the second stock factor. Lets have a look at the stock rankings now.
One of the lower market cap stocks has snuck into the third spot in the rankings. This is not a good thing because the port / sim has to deal with this situation in the buy rules. If the same liquidity rule is used as a buy rule (i.e. FOrder("MktCap") <= 5) then there will be a hole in the rankings where that stock (JPM) was ranked.
This becomes a problem when using such functions as RankPos in the Buy rules because the designer has to account for the uncertainty of where to apply the cutoff limit. The designer may only want the top 5 stocks but he/she will have to use a buy rule of RankPos <= 8 (or something like that) just to account for low liquidity stocks that are filtered out.
Replacing Eval ( ... ) With a Conditional Node
Now lets try changing the Eval ( ... ) function to a conditional node in the ranking system.
The ranking system now employs a conditional node with the formula shown above. The formula is True if the stock is one of the top five stocks ranked by MktCap. Otherwise the stock is processed as part of the FALSE condition.
For the True condition, the formula MktCap will be used i.e. the stocks will be ranked in order of market capitalization.
For the False condition, the stock will simply be branded NA. Lets have a look at the stock rankings.
As can be seen from the figure above, the lowest market cap stocks have been sandwiched in between the top mktcap stock and the next four. This wasn't expected and is even worse than what we got for the Eval ( ... ) function!
A Better Solution
Next the False condition is modified so that MktCap is called out instead of NAs. Starting to get desparate here :( Lets have a look at Portfolio123 did with the stock rankings.
The results are the same as when using an Eval ( ... ) function.
Stay tuned ...