Quantitative investment is quite a mouthful – seven syllables. Why is it even worth caring about? We’re going to break it down into manageable pieces.
Investment is the art of forgoing current pleasure to gain something more tomorrow – at least in theory. Squirrels invest: they bury nuts for the winter. Humans invest all the time – even for as trivial a thing as standing in line to buy Starbucks. Nobody particularly enjoys the standing in line part of the process: it is all about the coffee at the end. We’ll use this coffee metaphor throughout, as we talk about investing. We’ve all has the experience of going to a coffee shop, waiting 20 minutes in line, and then fuming at the terrible cup of coffee that resulted in the end. Some coffee is just better than other coffee.
Most people invest the same way they buy coffee: they simply go to the nearest (or most convenient) coffee shop and throw down $4 for a latte. They are likely to keep buying coffees from that shop, day after day.
Investment wise, this is like deciding they want to invest in stocks, and then just going and buying one. We can model this via our Single Letter portfolio.
Here we have just invested in shares of Agilent Technologies. Why Agilent? Because it is the stock that has the ticker A, and A is the first letter of the alphabet. We made some money at this: every dollar put in January 1st, 2000 returned 150%, turning into $2.50. Why did we pick such an arbitrary choice? For the same reason most people go to the nearest coffee shop, and order a latte: it is easy. We’re modeling a typical investor. Perhaps they work at Agilent. Or they heard something nice about it. Or Cramer pitched it. As far as this article is concerned, we don’t really know or care. With just one stock, none of the results tabs are going to tell us much about our pick. That said, that is a lot of Agilent. 22 years worth. That would be like going to decide, once and for all, what drink we were going to use as our morning cup of Joe for the rest of our lives. Perhaps we should look at it over a smaller time span, and treat each year as a separate investment.
Now we take just one year of Agilent, from 2000 to 2001.
Wow, that is a lot of red. Our dollar turned into $0.76. Maybe we do better next year?
Nope, same story, but even worse! We lost 42% in that year. Maybe the next year will be better. If this were a coffee shop (or an investment advisor), it would surely be out of business by now.
It is even worse!!! Why, oh why did we pick this stock. Oh yeah, because it has the ticker A. You are probably wondering how to get the total performance from 2000 to 2003. You could just pull out a calculator, but Equities Lab can cough up that number in a trice, with hardly any effort on your part. Give it a try now, if you have Equities Lab open. Our dog, London, will wait patiently.
It turns out, it is as simple as adjusting the “bought on” date back to 2000, while leaving the “returned on” date at 1/1/2003.
If we look at the red number in the bottom next to Medical Diagnostics and Research, we see that they lost almost three quarters of their value over the period. Simply brilliant. We could also get that information (and more) by clicking on the giant red box.
This is informative, yet oddly tedious. It would be super nice if we could just get the performance each year in one place, rather than having to adjust all those dates. To do this, let us imagine we have (had) a portfolio of $100,000 in 2000. We set that by creating a tab (use the button or Ctrl T) to create a tab named “initial_cash” and setting the value to 100000. That done, we need to specify the time interval want to use (in our case, yearly, starting in January). We’ll do this with the
tab (middle left of the screen). The backtest trading rules section has a rebalance frequency. Rebalance 01/01 means rebalance every January first. That all done, we can see what happened through time by backtesting (use the
button in the upper right corner. This will create a dialog box, which confirms the yearly rebalance, and no stop losses, etc. It also gives us a date range, which we need to adjust, so it starts in 2000
. Having adjusted it we can click on “Run”. Once it runs, we’ll get a very useful screen packed with information, which we’ll get back to. For now, click on the Positions tab (
in the lower right).
Happiness is … a collection of single year studies, gathered here for easy viewing. We can see that Agilent has a terrible first few years. After that things settled into mostly years of good performance, with a few stark exceptions. Hovering over the boxes will reveal which ones are the exceptions. It should be no surprise that 2008 was awful: -55%.
Having backtested, the very next question is what happened, behind the covers? We’ll definite it inductively. Imagine a portfolio, at some point in time. To figure out what happens next, do this:
In essence, according to desky.ca the computer is doing the heavy lifting of buying and selling each stock each quarter (or year or month, or whatever), and keeping the equity curve, and doing all the bookkeeping. One can view the screener as defining an index (that changes over time based on the rules set forth), and the backtest as a sample ETF or fund that follows the index.
Our first backtest was very simple. Just invest in A. It underperformed the SPY index fund, but not by a lot.
If we just invest in B, we get a similar stock, that outperforms in different times:
And when we combine them both, we get this:
Which underscores why a tools can be so helpful. One would assume that two stocks that both got about 250% returns, combined, would get 250% returns. Apparently not. Notice that B was late in coming to the party. That line is flat until 2005. Agilent could be 100% of the portfolio until then. And, as we saw, it got to be 100% awful during that time period. Then B comes along to dilute Agilent’s remarkable recovery.
Clearly they do. Even if we aren’t using any actual algorithm (beyond buy A and B), the timing of rebalancing matters. If we are willing to make more trades, we can rebalance monthly. This gives better performance.
Of course, we could rebalance weekly. Would that be better?
It is. Probably not enough better to justify all those trades, but it is better.