HowToBuildAStockStrategy - Portfolio123
HowToBuildAStockStrategy - Portfolio123
by Yuval Taylor
August 2019
1
Contents
Introduction ..................................................................................................................................... 3
Getting Investable Ideas .................................................................................................................. 5
Creating a Strategy.......................................................................................................................... 7
Using the Screener .......................................................................................................................... 9
Backtesting a Screen ..................................................................................................................... 14
Using the Rolling Backtest ........................................................................................................... 16
Using Ranking in a Screen ............................................................................................................ 17
Creating a Custom Universe ......................................................................................................... 18
Creating a Ranking System ........................................................................................................... 20
Creating a Simulation ................................................................................................................... 27
Creating a Live Strategy ............................................................................................................... 32
Implementing a Live Strategy....................................................................................................... 34
Advanced Features and Concluding Thoughts ............................................................................. 36
2
Introduction
While there are many sites on the Internet that allow you to follow a model portfolio, very few give you
the tools to create your own investment strategy.
Some people say that it’s impossible to consistently beat the market. Those same people will admit
that it’s perfectly possible to consistently underperform the market, and that there are hundreds of funds
that do so. Given that the ―market‖ is the aggregate of all investors, if there are investors that consistently
underperform, there must be investors that consistently outperform. In fact, throughout recorded history, a
small group of dedicated investors have consistently outperformed the market by a large margin for a
number of years—so large and for so long that it would be impossible for them to have done so simply by
chance.
One way you can join the ranks of these hallowed investors is to develop your own investment
strategy.
We here at Portfolio123 believe that a systematic investment strategy that considers every investment
from a variety of angles has the potential to consistently beat the market. And we have evidence for that
belief: many Portolio123 users have demonstrated their ability to create such market-beating strategies.
A number of different services offer you the ability to create your own stock strategy through
screening rules. There are three things that make Portfolio123 unique, and far better than any alternative.
The first is data quality. The second is ranking. And the third is backtesting.
Our data is truly point-in-time. Every line has an effective date, which means that if an item is
revised, the older value will be preserved up to the date of revision. It’s completely free of
survivorship bias, both in terms of companies and securities. Our database includes data for over
30,000 stocks, some extant and some defunct. And it’s the most accurate database in the industry.
Our ranking engines have no parallel in the financial technology world. If you were so inclined,
you could create a ranking system with 200 different factors that would rank all the stocks that
pass certain rules in order from best to worst, with each factor carrying a weight. You can use
composite rankings, in which factors are grouped together and stocks are effectively ranked twice,
once within the group and again as part of the whole. You can use conditional ranking, in which a
stock is ranked differently depending on, say, whether or not it’s in a certain sector. You can rank
based on a stock’s industry or sector or based on its individual characteristics. You can use pre-
built ranking blocks or create your own systems. The possibilities are practically limitless.
We offer five very different ways to backtest your strategy. The most basic way is to use a
screener, with periodic equal-weight rebalancing. The rolling screen backtest shows you how the
stocks you buy will perform over a set period if you buy them every week. The ranking
performance test shows you how the universe of stocks you’re choosing from, if broken down
into quantiles by rank, would have performed over a certain period with periodic rebalancing. The
simulation effectively simulates your portfolio strategy with a wide variety of possible buy and
sell rules and variable position sizing. And the rolling simulation backtest shows you how your
simulation might have performed with a lot of different starting and ending dates.
Portfolio123 allows you to bridge the gap between the ideas in investing literature and real-world
hands-on investing. You have the ability to take those ideas, expand on them, research them, build a
strategy that can be rigorously tested in a fifteen-year simulation, and have that strategy run virtually on
auto-pilot as it gives you buy and sell orders.
The time has never been better for ―do-it-yourself‖ investors. You have open access through the
Internet to the most brilliant minds in financial and investment theory, and you now have the most
powerful programmable quantitative engine at your fingertips. Yet this sort of power is only available to
those willing to put forth the effort. There isn’t some big red button to push that will dream up strategies
and build them for you. The tools are all here but you need to be the craftsperson.
3
This paper is a quick guide to unleashing the potential of Portfolio123. I’ll be walking you through
the process of building an investment system from the ground up using the resources we offer. I strongly
advise you begin at the beginning and not jump ahead to one application without thoroughly
understanding the previous one. So we’ll start with our most basic tool: the screener. But first, we need to
talk about what we’re trying to do in more general terms.
4
Getting Investable Ideas
Some people think that once you have historical data and a program to test trading rules, you can stumble
across a trading system that makes millions. Should you attempt the shotgun approach and create a
system through rule-spamming to ―data-mine‖ a profitable strategy, it will prove to be a costly mistake.
Let me illustrate this.
I’ve created a model that buys stocks based on five rules and then holds them for five years. If I had
implemented this system five years ago, my annual return would be 50.6%. If I had implemented it ten
years ago, my annual return would be 38.75%.
The rules are as follows: the stock has to have a market cap between $250 and $950 million, a price
between $14 and $28, a 52-week low price between $13 and $19, a decrease in operating margin over the
past year of between 2% and 7%, and an average recommendation between 1.5 and 2.
Obviously, this model is complete garbage. It’s based on the fact that Abiomed, Paycom, and
LendingTree fulfilled all these conditions five years ago, and all of them are five-year ten-baggers. And it
just so happens that it would have also bought Rogers ten years ago, when that company was about to
triple in price. But when I ran this system on a different starting date, I ended up with an annual return of
2.5% instead.
The way to get investable ideas is not to look at companies whose returns were high and figure out
what they had in common. To build a sound investment system that generates reliable returns, you first
need a thesis or a concept of why and how you will be able to achieve better returns than the broad market.
These investment ideas should not be stuff you just make up and try. You should draw from
research—and there is decades worth of it, both from academics and from actual investors. As you
carefully read through it, try to think about why these rules may translate into market outperformance or a
reduction in risk.
But first, ask yourself a few basic questions. Remember: there are no right or wrong answers to any
of these:
Are you interested in beating the market over the short term or investing wisely for long-term
portfolio growth?
Are you interested in maximizing your returns or minimizing your risk?
Are you interested in finding a single strategy that suits you or developing a number of strategies
for portions of your portfolio?
Are you interested in making money primarily from dividend income, from stock price
appreciation, or from both?
Are you interested in stocks, ETFs, or both?
Do you consider yourself a trader, an investor, a gambler, a speculator, or some combination of
those?
Are you looking for a fully automated strategy or are you interested in getting recommendations
which you’ll then accept or reject on a discretionary basis?
Do you believe that backtesting will guide you to better strategy development, or do you believe
that backtesting offers illusory results and that it’s best to limit its use?
Do you consider yourself financially skilled enough to come up with new, untried methods of
beating the market, or do you think you’d do better to follow established paths?
How much trading and portfolio turnover is too much, and how much is too little?
Do you have an innate preference for certain sectors or industries, or for stocks of certain sizes?
Do you place any faith in technical analysis, fundamental analysis, and/or sentiment indicators?
Do you prefer to take an academic approach to investing, using sophisticated statistical analysis
and keeping up with the latest research, or are you more comfortable with approaches based on
the ideas of professional investors such as Warren Buffett, Peter Lynch, James O’Shaughnessy,
and Joel Stern?
5
No matter how you answer these questions, you’ll find a wealth of resources at Portfolio123. But it’s
important to think clearly about how you want to approach these resources. You’ll want to create a
strategy that harmonizes well with your objectives and beliefs. The point of answering these questions is
for you to form in your mind a clear idea of how you want to invest before you dip your toes in the water.
6
Creating a Strategy
Over the course of this article, I will be building an investment strategy based on the following idea: that
choosing stocks based on a variety of sensible ―factors‖ helps ensure high returns and low losses. I like to
think of it as the ―used car‖ analogy. When you’re considering buying a used car, you try to look at it
from every angle before you purchase it. You look under the hood; you look at the sticker price; you talk
to owners of similar cars; you look up its accident record; you take it for a test drive. You can’t do all that
when you buy a stock, but the philosophy is the same: by looking at every stock you buy from a large
number of angles, you are increasing the likelihood that you’re getting a good deal on a dependable
product.
A ―factor‖ is basically a reason to buy or sell a stock. But in order to use it on this platform, it has to
be measurable. Your assessment of a company’s competitive ―moat‖ may be a good reason to buy a stock,
but it’s not measurable, so it’s not the kind of factor one can use here. But if you develop a measure of a
company’s moat based on, for example, its gross profit margin, you can use it as a Portfolio123 factor.
One can break down measurable factors into six basic categories: value, growth, quality, size,
sentiment, and technical. Some factors may belong in more than one of these categories, and others may
not really fit into any of them, but this is a good, rough starting point.
Value. These are factors that compare items from the company’s financial statements to its
market price. If the price goes up, the stock becomes less worthwhile investing in, and if the price
goes down, it increases the discount you’re buying it at.
Growth. These are factors that measure the increase or decrease in a company’s sales, income, or
other growth indicators over a period of time. It’s important to keep in mind that past growth does
not correlate with future growth. In fact, a company that has grown extremely fast in the past is
likely to grow less fast in the future, and a company that has experienced recent negative growth
is more likely to experience positive growth in the future. But one can profitably look at growth
trends, and one can take advantage of the fact that high growth numbers often lead to rising prices
in the short term.
Quality. These are factors that are based on a company’s financial statements, are independent
from its market price, and do not fall in the ―Growth‖ category. Some examples might include a
company’s return on equity, its asset turnover, its accruals, its operating margin, and the stability
of its revenue.
Sentiment. These are factors that indicate how people feel about a company. They include
analyst estimates and recommendations, short interest, insider buying, earnings surprises, and so
on.
Size. These are factors that indicate how big or small a company is, like market capitalization,
daily dollar volume, total assets, yearly sales, number of employees, and so on.
Technical. These are factors based on the daily trading activity in a stock: its price movements
and changes to its volume. They include not only momentum and mean-reversion measures, but
also volatility measures.
The initial model I will illustrate will involve one factor from each of these categories, but I strongly
recommend using more than one in your final model.
7
This should be your new best friend—take some time to get acquainted with it. This is the list of factors
and rules that you can program into Portfolio123. You can use these factors and functions to build
complex formulas. Maybe you will rely exclusively on the Rule Wizard to help you create your strategy,
but you should still be fully aware of the breadth of rules and formulas available.
8
Using the Screener
The screener is the most basic tool that P123 offers, yet it is also one of the most versatile. It is not as
elegant as simulation testing when mimicking actual portfolio performance, and it does not present as
wide a picture as ranking performance tests. But it excels at testing rule-based strategies. The screener can
run many of the same strategies that the simulation can, but its strong point is that it can handle strategies
involving thousands of stocks. For example, it can test all value stocks against all growth stocks in
seconds with two massive portfolios containing thousands of stocks each.
The screener layout looks like the picture below. The rules tab is where you enter buying criteria that
must be met in order for a stock to be purchased.
Let’s start by using the ―Wizard‖ to input some rules into our screen. We’ll start with a value factor—
price to sales. Click Add Wizard Rule, then use the drop-down menu to find Value.
9
Next, we’ll use the Wizard to add a sentiment rule by clicking on Add Wizard Rule, then on Sentiment,
then on Short Sellers, then on Little Short Interest.
In terms of size, we don’t want to invest in stocks that are too illiquid, but we don’t necessarily want
large caps either, as they seem to be more resistant to fundamentals-based investing than smaller caps. In
the Wizard, we can click on Price and Volume, then on Liquidity, then on Daily $ Amount, 20 Day
Average. That takes care of liquidity. After that, using the Wizard again, we can click on Company
Basics, then Size, then Market Capitalization. Here we’ll change the ―Greater Than‖ to ―Less Than‖
and fill in $5000 million to exclude large caps.
With these four wizard rules, our screen now looks like this:
10
Next we want a growth rule: we want stocks with a recent increase in operating income (let’s say at
least 5%). Operating income is more stable than EPS as it’s a pre-tax number. Unfortunately, the Wizard
doesn’t include operating income growth, so we’ll try writing our own formula. We can click on
FUNDAMENTALS at the top of the list of formulas and functions, then INCOME STATEMENT, then
scroll down to Operating Income.
The rule of thumb when measuring growth of something that could conceivably be negative is to
take the difference between the latest period and a past period, and then divide it by the absolute value of
the past period. So we’ll start by clicking on the latest quarter’s operating income (OpIncQ) and then
clicking on ―Add‖; we’ll then subtract the same quarter one year ago (OpIncPYQ); and we’ll divide by
the absolute value of the latter. Our final formula will be
Note that spaces normally don’t interfere with the operation of a rule: feel free to use them liberally to
make your formulae readable.
Our next rule is a quality rule: we want companies with negative accruals. One of the main ways to
measure accruals is to subtract operating cash flow from net income. So we can get net income from the
income statement and operating cash flow from the cash flow statement, and our rule can be:
Finally, let’s add a technical rule. We want stocks with low systematic volatility (in other words,
stocks that are relatively unaffected by large market movements, stocks like Walmart, Coca-Cola, and
Procter & Gamble). One way to accomplish this is to limit ourselves to stocks with low share turnover.
The formula for this is simple: it’s the number of shares traded divided by the number of shares available.
That’s available in the Technical menu of functions as VolM%ShsOut (monthly volume as a percentage
of shares outstanding, measured over the last 3 months).
But what’s a good limit for share turnover?
Here I’ll introduce one of the most powerful tools in Portfolio123’s arsenal: FRank (short for
formula rank). How will we determine what is low share turnover and what is not? Picking an arbitrary
number is weak. Thankfully, Portfolio123 has developed a flexible set of instructions that allows us to
screen for the lowest relative share turnover. FRank allows us to sort stocks based on whatever factor we
choose and return stocks in a certain percentile range. Let’s say we want to only invest in companies with
share turnover in the bottom forty percent of our universe. The formula would look like this:
#all means we’re comparing the share turnover to all stocks; we could also have used #industry, #sector,
or #previous. #asc is short for ascending, which means we’re using ascending order, with the lowest
ranks best; if we wanted to invest in stocks with high share turnover, we would have used #desc, short for
descending.
We can now save our screen by pressing the little save button to the left of the red lock in the top
right, which will allow us to name it. I’m calling it Six-Factor Demo 1. In the end, it looks like this:
11
I’d now like to introduce one more very powerful tool. Portfolio123 offers a number of core ranking
systems: Core: Value, Core: Sentiment, Core: Quality, Core: Momentum, Core: Growth, and Core: Low
Volatility. Let’s say we want to take advantage of one of these ranking systems for our screen. These
ranking systems rank all stocks on the basis of a score between 0 and 100. So we can add to the screen a
rule like
Rating (―Core: Sentiment‖) > 60
Now let’s see what stocks this system has chosen for us. Press the Run Screen button at the top right.
You’ll see a list of stocks appear below.
12
Immediately, I see some problems with the screen.
First, there are too few stocks here. If I tried to work with this screen, I might end up with no stocks
at all at some points. And for the purposes of backtesting, a field of only three stocks is going to give me
a pretty meaningless sample.
Second, CLPR is an REIT (real estate investment trust). The most useful measures for REITs have to
do with their funds from operations, not their sales or operating cash flows.
These observations make it desirable to modify the screen. We’ll start by loosening up some of the
rules to be less restrictive. We can change the price to sales ratio to lowest 30%, the short interest to
lowest 40%, and the share turnover to the lowest 60%. To change the wizard rules, we just click on the
wand next to the green dot; to change the share turnover rule, we just substitute 40 for 60.
Next, we’ll add a few rules to eliminate companies in the real estate and financial sectors by using
the Wizard (click on Company Basics, then on Exclude GICS Sector). We’ll also exclude biotechs
while we’re at it, since their prices are mostly dependent on clinical trials rather than fundamentals.
We can also click on the Totals button to see how many stocks each rule excludes.
Our screen now looks like this:
Now when we run the screen, we’re up to 26 companies, which is a reasonable number, and we have
fewer problematic companies in there.
13
Backtesting a Screen
Let’s see how well our screen performs. Start by clicking the Backtest tab below the screen’s title. You’ll
see eight parameters to fill in. You can fill these in in any way you want, but here are the settings that I
normally use.
I’m using Next Open as the buy price, a ten-year backtest, no rank tolerance (rank tolerance, which
means the screen won’t sell a stock if it has decreased less than X% in rank, can only be used if you
specify a maximum number of stocks and a ranking system in the Settings tab, which we’ll get to later),
no maximum position percentage, rebalancing every four weeks, 0.5% slippage, no carry cost, monthly
risk statistics, and 100% long weight.
When I press the Run Backtest tab I come up with a chart that looks like this:
14
This tells me that my screen has outperformed the S&P 500 by about 8% per year over the past ten years.
If I scroll down I can see these figures:
This shows me that I’m holding an average of 25 stocks at a time, that my average turnover every four
weeks is 53%, and that my average return per four weeks is 1.73%, compared to 1.15% for SPY, an
excess of 0.59%. It also breaks down those figures for up markets and down markets.
Now 53% is a lot of turnover. So I’m thinking, what if I want to hold my stocks longer than four
weeks? What if I want to hold them for six months? So I can change the rebalance frequency to every 26
weeks and rerun the test. The result isn’t nearly as good: my annualized return drops from 23.19% to
18.27%.
However, these kinds of tests are very sensitive to starting dates. If I rerun the backtest starting just
one month later, my return drops to 16.22%, and if I rerun it starting one month earlier, it goes up to
20.27%.
Here’s what’s happening. A six-month rebalance only gives me a total of twenty starting dates over a
ten-year period. Six-month returns on a parcel of forty stocks can vary widely from week to week,
making your backtest relatively meaningless.
Fortunately, Portfolio123 makes another backtest tool available, which will give you more
comprehensive information.
15
Using the Rolling Backtest
Click on the Clear Results button, then on the Rolling Backtest tab. You’ll see a screen that looks like
this:
If we put in a ten-year period at the top and press the Run Rolling Backtest button, we’ll get a screen full
of numbers. If we scroll down to the bottom, we can see how well our screen performed in an average
six-month period:
The average number of holdings is still 25 and the average six-month return is now 9.02%, compared to
SPY’s 6.64%, an excess of 2.39%. If we want to know the annualized return, we can use a calculator to
perform the following function: 1.0902^2 – 1, and we’ll get 18.85%.
16
Using Ranking in a Screen
Now let’s say that the number of stocks we’re getting in our screen is too great and we want just the top
ten out of those.
Click on the Settings tab. Then, in the Ranking box, click on Ranking System. Click on P123
Ranking Systems, then on Core Investing Styles, then on Core Combination. Then, in the box marked
Max # of Stocks, type in 10. We will now get the ten highest-ranked stocks according to the ranking
system that combines Portfolio123’s six core ranking systems.
Now if you run the rolling backtest, you’ll see your results have improved. Many screening systems can
be improved by adding ranking systems to them.
If we now go back to the regular backtest by pressing the Backtest tab, we can run a more flexible
system by using the Rank Tolerance feature. With no rank tolerance and a four-week rebalance, our
average turnover is 58% per rebalance, which is very high. But with 10% rank tolerance, it goes down to
52%. Rank tolerance of 10% tells the screener not to sell a stock if its rank has fallen less than 10%.
17
Creating a Custom Universe
Now the rules that we just put into our screener can also go into another kind of screener, which we call a
universe. The advantage of putting rules into universes rather than screeners are twofold. For one, you can
define a universe quite broadly and just vary the screening rules. For another, using universe rules are
very useful for creating and testing ranking systems. My basic advice is to put your ―I’ll never buy a stock
like that‖ rules into your universe and then put your ―this is what I’d love to own‖ rules into a screen
and/or ranking system. (Personally, I put all my ―this is what I’d love to own‖ rules into ranking systems
rather than screens because they’re more flexible, but you may have some hard limits you’d like to
exercise.)
To create a new universe, click Research, then Universes, then New, then Stock. You’ll end up with
an interface very much like the screener. The main difference, though, is there are no Wizard Rules. You
have to create the formulae yourself.
The most important rule in any universe is the liquidity rule (if your starting universe is the Dow
Jones, the PRussell 1000, or one of the S&P indices, you probably won’t need one and can skip this
paragraph). There are a lot of ways to measure liquidity, but the most basic thing to focus on is the daily
dollar volume (the number of shares sold per day times the price they were sold at). Click on
TECHNICAL—INDICATORS & PRICE, then on PRICE & VOLUME, then on Volume, averages,
and liquidity. You’ll probably want to use either AvgDailyTot or MedianDailyTot and then fill in the
number of bars (20 for four weeks, 63 for three months). After that, type in a greater-than sign (>) and a
number. That number will depend on a lot of things—how much money you normally invest in a stock,
how long you hold your stocks for, whether you place limit or market orders, and so on. Personally, I
rarely invest in stocks with a median daily dollar volume of less than $35,000. But most people I know
have limits much higher than that. If you don’t set some minimum liquidity rules, you’ll end up with
misleading backtests that indicate that you can buy and sell stocks that are either very expensive to buy
and sell or actually impossible to buy and sell (some low-liquidity stocks simply don’t transact every day).
However, due to data glitches, there are some foreign stocks (ADRs) that are relatively easy to buy
and sell that will be excluded from your universe if you place minimum liquidity levels—stocks such as
Naspers, Volkswagen, Heineken, Anglo American, and Volvo, all of which have 0 volume in our
database. If it’s important to you to include those stocks, you can add an exception to your rule. For
example, your minimum liquidity rule could be
(This looks confusing because MarketCap is measured in millions of dollars and MedianDailyTot isn’t.)
You should also set a minimum price. Some companies that go into bankruptcy will show high
liquidity but their low prices signal that they’re in their terminal stages. The rule for this is simple:
18
- To exclude over-the-counter stocks: Universe (NoOTC) = 1 (warning: this will also exclude a lot
of ADRs)
- To exclude companies likely to go bankrupt: AltmanZOrig > 0 or AltmanZOrig = NA (hint: if
you’re using a rule that gives N/A to a lot of companies, you should follow it with ―or‖ and that
rule ―= NA‖)
- To exclude companies that manipulate earnings: BeneishMScore > -1.78 or BeneishMScore =
NA
- To exclude companies with high accruals: OperCashFlTTM > NetIncBXorTTM
- To exclude companies that report late: DaysLate < 40
- To exclude companies whose information in our database has not yet been updated since their
latest announcement: StaleStmt = 0
- To exclude certain stock tickers: Ticker (―CCNI, CAPC, DSS‖) = False (I’m not recommending
you exclude these stocks, I’m just giving you an example of how to exclude stocks)
- To exclude a whole list of tickers, create a list by clicking on Research, then Lists (under
Components), then New. Once you’ve created the list, in your universe include the rule InList
(―BDCs‖) = 0 (in place of ―BDCs‖ put the name of your list).
So go ahead and create a universe now, inputting your own rules. You’ll need it for implementing the
ranking system you’ll design.
19
Creating a Ranking System
Portfolio123’s ranking capability sets it farther apart from other stock-based strategy services than
anything else the company has developed. There are plenty of screeners out there, and a few half-decent
backtesting engines. But as far as I can tell, nobody but Portfolio123 offers ranking systems to individual
investors.
A ranking system consists of one or more factors. Every stock in your universe is given a score
between 0 and 100 depending on its percentile rank according to these factors.
Here’s an example from the world outside the stock market. Let’s say you’re designing a fantasy
basketball team and you want the top players according to five factors: height, rebound percentage, points
per shot attempt, assist percentage, and field goal percentage.
The ―screening‖ method would be to limit yourself to, say, the top twenty players by each metric and
see if any players fall into all the categories. If not, you’d expand to, say, the top forty players by each
metric. The chances of having one player fit into the top X in all five categories (assuming there’s no
correlation between them) if you have Y players is (X/Y)5. So if you have 100 players and are looking at
the top 20, the chance of finding one that fits into all the categories is one out of 3,125.
The ―ranking‖ method is very different. Here you would rank all the players on each of the metrics
and give them a score between 1 and 100, evenly spaced. And let’s say that height and rebound
percentage are only half as important to you as the other three factors. So you take each player and add up
her rankings, dividing the ranks of height and rebound percentage by two. Each player now has a score
between 0 and 400. You now take all the players and put them in order by score and give them new ranks
between 0 and 100, evenly spaced.
That’s how the Portfolio123 ranking systems work.
A ranking system is made up of nodes. There are seven types of nodes, but I’ll just discuss the four that
are most frequently used.
- Stock Factor. This is simply one pre-set factor that’s already in our system. For example, you
could choose ROE%TTM, which means the trailing twelve months’ return on equity. But if you
wanted to choose something more esoteric, you’d have to create your own formula.
- Stock Formula. Here you write your own formula using P123’s language, as I’ve shown you
how to do in the Screener section.
- Composite node. This is a node that consists of other nodes, each with their own weight. All of
our Core ranking systems are designed using composite nodes.
- Conditional node. This is a node that begins with a true/false question and has new nodes for
each possibility.
I’ll now walk you through the process of designing a ranking system based on the screener we designed
earlier.
Start by going to the main menu, click RESEARCH, then Ranking. Then click New and Stock. Give it a
name, then click Save. Then, on the right, click Add Node.
For our first node, choose Stock Factor.
20
First, we’ll add two of the same factors we used in our screen: price to sales (Pr2SalesTTM), ranking in
industry, and short interest (SI%ShsOut), ranking in industry.
For our next nodes, we’ll use the stock formula. Press Cancel, then Choose, then >> Stock Formula.
In Label, type in operating income growth, then in Formula, type in
Then click the Sector button, and Add. Your screen should look like this:
To add a new stock formula, just type over the previous one and click ―Add.‖ Let’s add an accruals
formula:
We want lower values better for this one, and we want universe comparisons.
21
It’s always a good idea to periodically press the save button up at the top, just to make sure you don’t lose
your data.
Now let’s add a composite node and a conditional node, just to show how they work.
Press Cancel, then choose Composite. Type in the Label box Low Volatility and then press Add.
You’ll see a black folder pop up on the left side of your screen labeled Low Volatility. Click on it to add
nodes to this folder. Now we can just add nodes like we did before. We’ll add a factor and a formula node
here. For the factor node, choose VolM%SharesOut, but change the default ranking direction to Lower
values. For the formula node, type in low price deviation in the label field, again choose Lower values,
and type into the formula box,
PctDev (120,1)
This measures the percentage deviation of daily prices over the last 120 bars.
Go to the left side of the screen and press the f(x) button. This is what you should now see:
22
For our last factor, we’ll create a conditional node. Let’s add another value ratio. A lot of investors use
EV/EBITDA instead of P/E. But you can’t use that ratio for companies in the financial and real estate
sectors. So for companies in those sectors, we’ll use P/E.
Start by clicking on the top folder again on the left, Demo 1. Then click Add Node, choose, and >>
Conditional.
We’ll label this EV/EBITDA, and in the formula box we’ll put in
This is our conditional rule: for companies in the GICS sectors 40 (financials) and 60 (real estate), we’ll
use a different value ratio.
Click Add. Now on the left you’ll see a new folder labeled EV/EBITDA with two folders
underneath, True and False. Click on the True folder. Here we want to insert a node for financial and
real estate companies. So we’ll use a factor node, PEExclXorTTM, compared to the industry. Now we’ll
click on the False folder. Here we need a formula, since EV/EBITDA is not one of the pre-set factors.
Label it EV/EBITDA, choose lower values, and in the formula box type in
EV / EBITDATTM
Now there’s a major problem with this formula. Companies with negative EBITDA are going to rate very
highly on this screen. To eliminate that, we’ll modify the formula as follows:
The Eval command is like the IF command in Excel: it evaluates the condition following the left
parenthesis; if it’s true, it follows the second term, and if it’s false, it follows the third. This modification
23
makes companies with negative EBITDA be N/A, and they’ll rank at the bottom, while companies with
positive EBITDA will just be EBITDA.
Your left-hand side should now look like this:
Now save, and then we’re ready to test our new ranking system. Go to the Performance tab. Put the
name of your universe into the Universe box (try to avoid using All Fundamentals here). Press Run. If
your universe looks like mine, you’ll end up with a result that looks like this:
24
There are all sorts of variations you can run from the performance page, and it’s fun to explore them.
Now, we haven’t assigned weights to any of our nodes. If all the nodes are zero, the system defaults
to equal weights within each folder. So right now our system has assigned 16.7% to each of our six major
nodes, and 50% to each of the two Low Volatility nodes within that 16.7%. To change the weights, click
on the Weights tab on the right and fill it in with numbers that add up to 100%. Then press Update and
save. Here are some numbers you could use:
25
Did your performance improve? Mine did, though not by a lot.
If you’d like, you can vary the weights to see how your system might perform if nodes were
weighted differently. You can assign 0% to some nodes, or 100% to one node, and check performance
again. There’s a lot to play with here.
Lastly, press the Ranks tab. Put your universe name in the Universe field. Press Run and you’ll see
which are the top-ranked stocks. Or put some tickers in the Tickers field and see how they rank.
Now that we have a new ranking system at our disposal, how do we create a tool that tells us when to buy
and sell the various holdings? For this step we need to learn how to create a Simulation and a Live
Strategy.
26
Creating a Simulation
Portfolio123’s simulations allow us to imitate an actual trading system with a real portfolio. This is as
close to the real thing as we can get. In addition, once we have the simulation settings just right, we
simply click a few buttons and it becomes an automatic and hands-free system that can trade the money in
your account.
How do we create a simulation? Click RESEARCH, then Simulated Strategies, then New, then,
under New Simulated Strategy, click Stock.
You will get a series of screens, and I’ll walk you through each one.
The first screen (General) looks like this:
I usually put my starting capital at $10,000 with no commission; I’m going to call the simulation Demo 1
to match the ranking system. For the rest of the fields in this screen, I’ll use the default values. Then I’ll
click Next.
The next screen is the Rebalance screen.
27
The Formula Weight option is for advanced users, so I wouldn’t recommend it at this point. I’m going to
want 25 positions rather than only 20, so I’m going to change the ideal size to 4%. And because I don’t
mind trading every week, I’ll change the Rebalance Frequency to Every Week. The Allow Immediate
Buyback button is useful if you have buy and sell rules that could conceivably apply to the same stock.
Once again, I’ll leave the rest of the fields their default value.
The next screen is the Universe & Ranking screen. Here’s where you choose the universe and
ranking systems you’ve just designed. If you don’t want to sell a stock if it falls out of your universe,
choose the Yes button next to Force Positions Into Universe. The Force Weekly Ranks field can be
ignored as that applies to daily rebalancing only.
The following screen is for buy rules. There’s a default rule here that defines minimum liquidity; you
can leave that in place if you’re nervous about your own liquidity minimums in your universe; otherwise
you can turn it off by pressing the green dot, or overwrite it. Here is the place to put any additional
screening rules that aren’t in your universe.
There’s an unspoken buy rule here, which is as follows: buy the top-ranked stocks that you don’t
already own to use up the cash in your portfolio. When the simulation begins, it will buy the top 25
stocks, and each time you get enough cash in your portfolio for additional stocks because of a stock being
sold or a huge dividend payment, it will buy the next stock. If this isn’t the behavior you want, you have
to write rules to modify it.
There are certain buy rules you might find useful that aren’t available anywhere except on this screen.
For example, if you want to make sure that you don’t have seven stocks in the same industry, you could
include IndCount < 7. This rule would force you to go to the next stock if the highest-ranking stock you
didn’t hold was in the same industry as six of your other stocks. Rules like these can be found in the
PORTFOLIO folder.
The next screen is for sell rules. A sample rule appears in the top line:
28
In my experience, 60 is a very low rank to sell stocks. I’d recommend 90 or 95, depending on how big
your universe is. If you have 4,000 stocks in your universe, 95 would mean your top 200 stocks. If you
only have 500 stocks in your universe, though, you might want a lower rank. I’m going to use 95. But
another option is to specify a rank position below which you want to sell your stocks, which you can do
with a sell rule like RankPos > 80. This rule sells any stock that isn’t in the top 80 by rank. Varying rank
sell rules is one way to control portfolio turnover: the lower the rank sell rule, the less turnover you’ll
have (other ways to lower turnover are to rebalance less often and to use fewer rules or ranking system
nodes that involve a stock’s price).
There are other things you might want to put in your sell rules. For example, you might not want to
sell a stock if it has a stale statement (its latest statement has not yet been processed by our data provider).
Or you might not want to sell a stock if you just bought it in the last week or two. Because the sell rules
are covered by or fields, you’d want to combine those rules with your first as follows:
Alternatively, you might have a sell rule that modifies a buy rule. For example, maybe you have a buy
rule that says that price-to-sales ratio has to be below 1, and you want to sell stocks whose price-to-sales
ratio rises above 1. You can put those in here.
There’s also a very useful rule for controlling overweight positions. It’s as follows:
This rule says that if one position goes above 25% of your portfolio, you sell one-quarter of that position.
You can choose different numbers: Eval (Weight > 6, 0.33, 0), for instance, sells one-third of a position
if the weight goes above 6%, thus bringing it down to 4%.
There are a number of other sell rules you can choose from. GainPct, for instance, allows you to sell
a position if it has gained more than a certain percentage since the time you bought it. Rules like these can
be found in the PORTFOLIO folder.
If you don’t have any sell rules, your simulation will simply hold on to the stocks it first bought until
they’re acquired by another company or go out of business.
The Stop Loss tabs and Hedge tabs are really for more advanced users, but I think you’ll find them
pretty self-explanatory if you ever use them.
29
The Period & Restrictions tab covers how long you want the simulation to run and whether you
want to add additional restrictions to it. At the bottom, I usually put Allow Mergers to No, which means
that the simulation sells any stocks that have accepted a merger offer.
The last tab is Review. Here you can see all the parameters for your simulation. Notice that there is
no save button. The only way to save a simulation is to actually run it.
Once you’ve run it, you’ll get a page that looks like this:
There’s a lot of information on this page, but that’s not all. Press the Statistics tab and you’ll have three
more views. The first tells you a lot about performance. I find the most helpful part to be the year-by-year
performance:
30
This shows that my strategy has sharply underperformed for the past six years, save one. It certainly
needs some more work.
The Trading sub-tab is also very helpful. It looks like this:
The most useful numbers on this page, for me, are the Average Annual Turnover and Avg Days Held
lines. This makes me wonder whether with shorter holding times and more turnover, I might be able to
improve the system’s performance.
You can find out by pressing the Re-Run tab and then changing the sell rule. I changed the rank for
selling from 95 to 98, re-ran the simulation, and looked at the year-by-year performance; it was even
worse, so my guess was wrong.
In order to get good out-of-sample performance, I think I’d need to design a more comprehensive
ranking system. Normally, six or seven nodes simply isn’t enough to look at a stock from every angle
before buying it, which is my goal. Alternatively, I could add some more screening-type rules as buy rules
and try to eliminate more unsafe stocks.
31
Creating a Live Strategy
Once you’re happy with the backtested performance of a simulation, you can convert it into a live strategy
and automate investing in it. Click on the gear symbol next to the name of the strategy. You’ll see a
number of options. If you click the top line, Save as a new ―Live Strategy,‖ you’ll create a new live
strategy using exactly the same settings as those of your simulation, and you’ll get recommendations
based on it. If you click on Convert to ―Live Strategy,‖ you’ll convert your simulation into a live
strategy, with its entire history of transactions.
There can be big differences between the approaches. Let’s say you have a low-turnover system and
your current holdings are ranked between 99.98 and 89.84. Those with lower rankings have been held for
a while and haven’t yet been sold. If you Convert to ―Live Strategy,‖ you’ll now own all those stocks. If
you Save as a new ―Live Strategy,‖ you’ll start afresh with brand-new recommendations based on the
current ranking, and the simulation you ran will still survive separate from the new live strategy.
So let’s say we take this strategy and save it as a new live strategy without making any changes to it.
There’s one important field in a live strategy that doesn’t appear in a simulation. It’s called Mode,
and it’s the first field in the Rebalance tab.
You have three options here: Manual, Recommend, and Automatic. If you choose Automatic, the live
strategy will run and you won’t be able to change any individual buy or sell actions in it (though you’ll
still be able to change individual buy and sell actions in your real-money strategy). If you choose
Rebalance, you’ll automatically get recommendations every week (via e-mail) which you can choose to
apply or not. If you choose Manual, you will get no recommendations unless you actually ask for them.
Once we review all the other fields, we’ll get a screen that says Get Recommendations next to a Go
button (unless you’ve chosen Automatic as your mode).
32
You’ll now see a list of recommended stocks based on your system. You can reject any of the
recommendations you get by unchecking their boxes, and new recommendations will replace them.
The next button to press is Generate Strategy. You’ll now have a live strategy you can follow. The
next page will tell you how to do so.
33
Implementing a Live Strategy
Until now, we’ve focused entirely on one side of the Portfolio123 platform, the Research side. But
there’s an entirely separate part of our platform called Invest, and this is where you can actually
implement your strategy using real money. In order to keep things clear, I’ll call live strategies that
you’ve created Research Strategies, and live strategies that you’re following with real money Invest
Strategies.
Now go to the main menu, press Invest, then Dashboard. If you don’t have an account, create one
(start with Cash only and enter the amount of cash you have). Click on the account, then in the left box
click on New Strategy, then in the next screen click on Live Strategy.
Here you’ll have an opportunity to choose which Research strategy you want to follow. Once you do so,
you’ll get a screen that looks like this:
The Follow or Drive buttons need some explanation. If your rebalance mode in your live strategy is
automatic, choose Follow. If it’s Manual or Recommend, choose Follow if you don’t mind rebalancing
your Research strategy first, and then your Invest strategy, essentially doing the same thing twice.
Otherwise, choose Drive. No matter what options you’ve chosen, you will always be able to manually
reject an action that your Research strategy wants to perform or has performed.
34
Then press Get Recommendations, uncheck any stocks you don’t want to buy, and lastly press
Create & Commit. You’re now ready to trade.
Congratulations, you have successfully created your first strategy. This strategy will run virtually
hands-free, sending you rebalance notices when necessary each Monday morning.
35
Advanced Features and Concluding Thoughts
Portfolio123 offers plenty of additional tools once you’re comfortable with these basic ones. You can use
formula weight rebalancing to vary the weights of your holdings. You can run rolling backtests on
simulations. You can create custom series. You can create ―Books‖ that combine simulations or live
strategies. You can create custom formulae and use other custom formulae within them in order to create
super-complex factors. You can create screen reports that can give you, at a glance, information about lots
of stocks at once. You can look up particular stocks and see how they ranked historically on your ranking
system, or chart how certain factors applied to them over time. You can access industry and sector data.
You can use different benchmarks. You can create and subscribe to designer models. And there’s a lot
more I haven’t mentioned.
The idea behind all these features is to give users complete access to the huge variety of automated
investing strategies possible. If you were so inclined, you could create an automated version of discounted
cash flow valuation using nested custom formulae, and invest in stocks that were hugely underpriced
compared to their intrinsic value. Or you could create a tactical asset allocation strategy using economic
indicators and switch between ETFs accordingly. Or you could create dividend income strategies with
extremely long holding periods. Or you could invest in ten different strategies at once. There’s practically
no limit to the kinds of investment strategies you can create and backtest on Portfolio123.
36