The demonstration ranking system built in Part 8 was very simple, consisting of just four growth factors with just two of them (both relating to EPS growth) combining for a 90% weighting. Now, we’re ready to learn how to use the advanced Portfolio123 ranking features to build much more sophisticated systems.

Assuming you’re comfortable with the basics that were covered in Part 8, the material here will address the rest of your important “how to do it” questions. The next installment, Part 10, will turn to the “what to do” questions by focusing on Ranking System Design.

**Simple steps to complex ranks**

There are just four techniques you need in order to be able to create just about any sort of ranking system you want.

- Working with nodes based on composites and sub-composites (i.e. analogous to folders and sub-folders)
- Using formulas in addition to stand-alone factors
- Learning to create complex custom formulas
- Using special features (such as adjusting the impact of NA items and working with conditional nodes)

We'll tackle each topic in turn.

**Organizing your composites (folders)**

Figure 1 is a top-level view of a general purpose ranking system created for demonstration purposes. It has many factors distributed across many sub-composites. Some would see this as the type of system they'd like to create. Many would regard it as overkill. It was created for instructional purposes, to demonstrate the techniques to be discussed here.

**Figure 1**

Notice that there are no factors visible in Figure 1. All you see are composite nodes. The top-most composite bears the name of the ranking system and must, by definition, have a 100% weight since it includes everything.

Below that, we see four more composites each bearing the label of an investment style. (Labels for all sub-composites are assigned by the user). Recall that these sub-composites can be created by putting the mouse on a "parent" node, clicking on "Add Node" and selecting "Composite."

Each of the sub-composites I created has a weight and the four weights at this level sum to 100%. Notice, too, the "+" sign next to each one. This should be familiar; we've seen it in many directories including Windows Explorer. It means we can click on it and see additional content inside the "folder."

If you click on the "branches" link, all the sub-composites, factors, and formulas will become visible. Clicking again will cause all the lower nodes to close up. For purposes of clarity, we'll work with one small section at a time.

If you want to re-order nodes, click on the "Reordering" link. Here's what you'll see.

**Figure 2**

You can use your mouse to grab any of the four-arrow icons to the left of a node and move it to a different position.

Figure 3 shows what we see if we open (click on) the Growth sub-composite.

**Figure 3**

We're still not seeing any factors. Instead, we see more sub-composites. And again, the weights of all items (sub nodes) within the same level must sum to 100%.

Continuing on, we click on the Value composite.

**Figure 4**

Now, we see factors. Notice four things.

- A particular level need not consist entirely of sub-composites or factors. We can mix and match.
- The weights of all items (factors and/or sub-composites) within the same level must add to 100%.

**Figure 5**

We see that the five items (four factors and one sub-composite) directly under the value composite add to 100%. Notice, too, how the two items within the EV ratios sub-composite add to 100%.

- The direction of the sort arrows depends on the data-point. Higher growth rates are usually preferable to lower growth rates, so higher rates will be associated with higher ranks. On the other hand, we usually expect to see lower P/E ratios associated with higher ranks, hence the downward-pointing arrow that accompanies these items. But when it comes to ranks, greater number are preferable, so we see upward-pointing arrows next to all composites, even if there may be down arrows associated with some of the underlying factors.
- Notice the "f(x)" symbols next to the factors within the EV ratios composite. That tells us that these are formulas rather than factors. We'll see more about formulas below.

Figure 6 presents a full view of the contents of the Growth composite.

**Figure 6**

Figure 7 presents a full view of the Sentiment composite.

**Figure 7**

The Quality portion of the rank illustrates how we can pack a composite with lots of sub-composites and factors. Figure 8 provides and overall view of the Quality composite.

**Figure 8**

Figures 9, 10 and 11 present details of the three main sub-composites within the Quality section.

**Figure 9**

**Figure 10**

**Figure 11**

Note that none of these sub-composites is really necessary. All factors (and formulas) could simply be listed under the primary composite. But use of sub-composites is a tremendous convenience.

As systems get larger, failure to use sub-composites would make them very difficult to manage. To get a sense of that, try to recreate this rank without using sub-composites, making sure each individual item has the same weight impact as it does in the system presented here. For example, the weight of OpMgn%TTM works out to .014063. Most other items would have weights of similar magnitude. Next, consider what it would take to make the entire Quality group a bit more prominent. Just thinking about this is daunting, enough so that I suspect few readers will actually try to recreate the system without sub-composites.

**Creating ranking formulas**

Above we saw that we can use formulas in lieu of stand-alone factors within ranking systems. Accomplishing this is very easy. On the dropdown menu that invites you to add something within a composite, simply select "Stock Formula" (or "Industry Formula") in lieu of "Stock Factor" or "Industry Factor." Figure 12 shows the interface you'll see if you select Stock Formula.

**Figure 12**

The name must be typed manually. You can populate the formula box by typing, or you can click on the "Show Formula Builder" link and get an interface that should by now be very familiar to you.

**Figure 13**

The Formula box is populated the same way you would populate a screening rule. Notice the drop-down menu above the Category box. This is similar to one you’ve seen in the Screening Reference area. You can choose FUNCTIONS, STOCK FACTOR, INDUSTRY FGACTOR or CUSTOM FORMULA.

You can enter your formula via point and click (using Type, Category and Variable). You can type. You can mix and match. Click the "Done Editing" button when you are finished.

Notice, too, from Figure 13, that just like screening, you can use custom formulas.

**Developing complex custom formulas**

We already learned the basics of custom-formula creation in Part 6 (My 123). There, we demonstrated the creation of a fairly simple formula for EPS Acceleration:

(EPS%ChgPYQ - EPS%ChgTTM) / Abs(EPS%ChgTTM)

But in fact, our custom formulas can be considerably more complex than that. You can use up to 250 characters, which is more than what’s visible at one time within the formula box. If your formula is big, you can see other characters simply by moving your cursor (as you do that, different characters will scroll out of view). The key to creating complex custom formulas is to do so in a way that allows you to easily keep track of what you have and to easily edit.

We'll demonstrate by creating a custom formula for the Altman Z-score, a well-known predictor of financial default. The formula is as follows:

Z = (1.2 * X1) + (1.4 * X2) + (3.3 * X3) + (.6 * X4) + (.999 * X5)

X1 = Working Capital / Total Assets

X2 = Retained Earnings / Total Assets

X3 = EBIT / Total Assets

X4 = Market Capitalization / Total Liabilities

X5 = Sales / Total Assets

According to Altman, the lower the score, the greater the risk of default; 1.8 is often being seen as a critical threshold. Companies with scores of 3.00 or better are considered to the safest, from a financial standpoint.

We won't be thinking, here, in terms of cutoffs. We're simply going to rank companies based on Z-score. (If you use something like this in a model, you can always add a screening rule requiring Z scores to be greater than or equal to a particular numeric value.)

Here is how it translates to a portfolio123 custom formula:

(1.2*((CurAstQ- CurLiabQ)/AstTotQ))+(1.4*((IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ))+(3.3*(EBITTTM/AstTotQ))+(.6*(MktCap/LiabTotQ))+(.999*(SalesTTM/AstTotQ))

That's an eyeful. If you try to input it directly into the formula box, the probability of error will be high and you'll find it difficult to keep track of and edit what you're doing. And bear in mind that even this is not the most complex formula you can create!

There are two keys to executing a task like this.

- Don't work in the formula box. Instead, do the main part of your work in a word processor or text editor. When you are finished, transfer it to the formula box via conventional copy-and-paste.
- Break your formula down to simple components, and then build it up gradually.

Let's demonstrate.

Start by translating everything into Portfolio123 language.

X1 = (CurAstQ- CurLiabQ)/AstTotQ

X2 = (IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ

X3 = EBITTTM/AstTotQ

X4 = MktCap/LiabTotQ

X5 = SalesTTM/AstTotQ

By the way, you don't have to actually type those formulas manually. Instead, go to the screener interface, set up a new screen, and then create each formula using the same click-and-type combination you would if you were building a screen.

**Figure 14**

But instead of continuing on with your screen, simply transfer the rule to your word processor via copy-and-paste. After you've done that for each rule, here's what you'd have in your word processor.

(CurAstQ- CurLiabQ)/AstTotQ

(IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ

EBITTTM/AstTotQ

MktCap/LiabTotQ

SalesTTM/AstTotQ

Now, let's start building.

First, since we know we're going to combine each of these simple formulas into a single bigger formula, let's put parentheses around each item.

((CurAstQ- CurLiabQ)/AstTotQ)

((IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ)

(EBITTTM/AstTotQ)

(MktCap/LiabTotQ)

(SalesTTM/AstTotQ)

Next, we'll multiply each expression by the amount (coefficient) required in the Altman formula.

1.2*((CurAstQ- CurLiabQ)/AstTotQ)

1.4*((IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ)

3.3*(EBITTTM/AstTotQ)

.6*(MktCap/LiabTotQ)

.999*(SalesTTM/AstTotQ)

Because we're going to combine these items, let's again make our lives easier by surrounding each with parentheses.

(1.2*((CurAstQ- CurLiabQ)/AstTotQ))

(1.4*((IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ))

(3.3*(EBITTTM/AstTotQ))

(.6*(MktCap/LiabTotQ))

(.999*(SalesTTM/AstTotQ))

Don't worry about mathematical rules governing the order of operations. If we sometimes add parentheses that aren't absolutely necessary, that's fine. Our goal is formula construction convenience, not optimization of parentheses.

Since we know we'll be adding all these expressions, we'll next put a plus sign after each expression (except for the last).

(1.2*((CurAstQ- CurLiabQ)/AstTotQ))+

(1.4*((IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ))+

(3.3*(EBITTTM/AstTotQ))+

(.6*(MktCap/LiabTotQ))+

(.999*(SalesTTM/AstTotQ))

Now, all we need do is delete redundant line-breaks so we can make one large expression, instead of five smaller ones.

(1.2*((CurAstQ- CurLiabQ)/AstTotQ))+(1.4*((IncAftTaxTTM*(1- PayRatioTTM))/AstTotQ))+(3.3*(EBITTTM/AstTotQ))+(.6*(MktCap/LiabTotQ))+(.999*(SalesTTM/AstTotQ))

That's it. We're done. I saved this as a custom formula called $Z_Score and then referenced it in the ranking system formula box.

**Figure 15**

By the way, it's also a good idea to save the word processing file you used to build up the formula, in case you want to edit it later on.

The illustration shows a ranking system in which each company’s z-score is evaluated relative to the universe as a whole. As with all ranking factors, you could choose to evaluate a company’s z-score relative to industry and/or sector peers.

**Conditional Rank Nodes/Factors**

Let’s assume you want to include value as one of your rank nodes and that you’d like to use Price/Book and Price/Earnings. Price/Book is pretty basic, but that’s not necessarily the case with Price/Earnings.

How do you measure EPS? Many like to use forward PEs; i.e. price divided by a consensus analyst estimate of EPS for the current or next fiscal year. But how will the model handle companies that don’t have analyst coverage? Those PEs will come back as NA (Not Available). And you might not be keen on using the estimated earnings if analyst coverage is skimpy, as is often the case for small- and micro-caps.

By setting up a conditional node, you can use the forward PE for companies that have reasonable analyst coverage, and switch to PE based on trailing-12 month EPS for the others.

When you select 'Conditional Node,' you articulate a formula under which there will be two composite nodes: one labeled True and the other labeled False. Depending on the formula evaluation for each stock being ranked it will pass through the rank of either the True or False composite rank.

Figure 16 demonstrates a conditional node that tests to see whether the stock has 3 or more analysts following it. If so, it uses the rank from the True branch than includes the forward-looking PE for the Valuation part of the system. If less than 3 analysts follow the stock, it uses the False node that works with trailing 12 month PE.**Figure 16**

The motivation for this is to create a more flexible ranking system. Many times for example you may wish to rank large caps in a slightly different than small caps. Or you may want to use different factors for Financials, etc.

**Handling “NA” Items**

NA stands for “Not Available.”

In an ideal world, data would be available for every factor for every company.

Unfortunately, that’s not the case in reality. We very often encounter situations where important data items are nonexistent for some companies. These are reported in portfolio123 as NA. A good example is PE, which is undefined for almost 60% of our nearly 8,000 stock universe (because of negative EPS or EPS at such low levels as to result of PEs in the hundreds or thousands).

When a screening rule encounters an NA item, it is assumed that the company failed the test and, hence, is omitted from the screen. Ranking systems present more complex challenges since, unlike screens, the factors are not all-or-nothing. All companies are ranked somewhere on a best to worst scale. We therefore need to decide what NA means in terms of best-to-worst.

The traditional portfolio123 approach puts NA values at the bottom of the sort, in the worst position. But while we do penalize companies for NA items, we do so with a sense of moderation. When it comes to translating NA to a number, we don’t assign it a value of zero or one. Instead, for each factor in the ranking system, we consider all companies with NA as being in a tie, and the number assigned is just below the rank of the worst company that had meaningful data. The extent of the NA penalty varies from item to item. If NA is a rarity for a particular factor, a company that has one will be penalized sharply. If NA is commonplace, the penalty will be mild, but still a penalty.

Let’s examine this by ranking PEs in a hypothetical five-stock universe.

All ranks are on a 0-100 percentile basis. Because the universe has only five stocks, the possible scores will be 100, 80, 60, 40 and 20.

The lowest (best) PE earns the highest rank, 100. The next best merits a score of 80 and the third best is scored 60. Now suppose there are two companies whose PEs are NA. These two are tied, and they’ll get the numeric score that would have been assigned to the fourth company had it had a meaningful PE, which in this case would have been 20.

**Table 1**

As you see, NA values do count against a company when it comes to computing its rank. This can be important when rankings are computed relative to industries, some of which may be very small.

It can also have a more general impact. Financial companies in particular are prone to being pushed downward in ranking systems that use several factors that don’t exist for them because of the way they report (e.g., turnover). And where financials are still able to pass user models (because they are sufficiently strong in the non-NA factors), they’re more likely to hover near the borderline and fall out of portfolios more easily when rebalancing takes place.

Portfolio123 users can, if they wish, modify this situation and choose to have NA play a neutral role in rank computations.

The default status is as described above, with NAs having a negative impact on ranks. But if users opt for the alternative, the neutral approach, all NA values will, when the computation process begins, be put to the side. Percentile rankings from zero to 100 will be computed for all firms that have the necessary data. Then, at the end of the process, all NA companies will be assigned a rank in the middle of the valid ranks, a perfectly neutral score. The rank assigned to NA’s will usually be around 50, except when the there are very few ranked stocks (such as in a small universe or industry).

The more NA rank factors a company has, the harder it will be for the firm to appear in any of your rank-driven result sets. That’s because it will be harder for the company to come in near the top and harder for the company to come in near the bottom (as you might seek if you are looking to short poorly ranked stocks).

Let’s look how the example above changes.

**Table 2**

This approach should not change long-oriented systems since they pick from the top, where you’ll mostly find stocks with valid values. This would be most useful is in a long/short system that buys top ranked stocks and shorts lower ranked stocks using the same ranking system. In this example a long/short system of the best/worst stock would go long A and short C, all with valid values. In the first example the long would be A, and the short either D or C (each with NA).

**Functional Odds and Ends**

As we moved through this material, we progressed from simple rank factors to complex formulas. So as you work it’s important that you know how to display these alongside the simple factors if you wish to view your work as a whole.

You probably noticed, among the links at the top of the rank interface, one labeled "f(x)." This allows you to show complete formulas, in addition to their names, in your display.

**Figure 17**

You may also have noticed, in the "Node Properties" section of the interface, a button entitled "Copy & Paste . . ." The Cut, Copy and Paste choices do exactly what you would expect, based on your general Windows experience. "Cut Sub-nodes" and "Copy Sub-nodes" lets you put your mouse on a node and do the cut or copy (and paste) operation only on the sub-nodes.

Those who are comfortable with HTML/XML-type code can input their ranking criteria more directly. One way to do this would be to click on the "text editor" link.

**Figure 16**

You can type directly into the text area, or type elsewhere (i.e. and HTML or XML editor) and copy into the interface.

The "Insert Node: menu at the upper right will give you a head start by allowing you to automatically input a template for the node of your choice.

**Figure 17**

If you would like a more pure approach, without any scripts or templates, use the "raw editor (no ajax)" link instead.

**Figure 18**