I’ve been getting this question a lot recently, so in the interest of saving time, here’s my incomplete guide to building a trading/investment model.
*Sorry if the instructions are a bit jumbled up right now. This is a big and complex topic, and I’m adding stuff to this page as thoughts come to my mind.
Things to keep in mind
The best models.
Hedge fund manager Ray Dalio says that the best models are “timeless and universal”. I disagree with half of his statement.
Yes, a good model should be timeless. It should work over a 50, 60, or even 100 year time frame (if you have data that goes that far back). The more historical data you incorporate into your model, the better. Models with limited data will fail. This is how LTCM blew up. They built their models in 1994 on 4 years of data. It just so happened that those 4 years were 1991 – 1994, which were relatively quiet years in the stock market. Then 1998 came along and their portfolio got annihilated.
However, no model is universal. Perhaps this is why Ray Dalio’s fund has been doing so poorly over the past few years. There is no one size fits all in the investment world. No trading/investment strategy works in all markets. This is because the drivers of each market are different. For example:
- The U.S. stock market’s medium-long term is driven by fundamentals (earnings, economic data, etc). Hence, a stock market model must incorporate fundamentals.
- The currency markets are driven by money-flow.
- The commodity markets are driven by a lot of secret fundamentals that even the Wall Street banks aren’t privy to. (There are 10 $100 billion+ “commodity trading companies” that dominate the commodities markets. They sell/produce commodities and also trade them). That is why in the commodity markets, a technical analysis-based model works best.
Know what you want your model to do.
There are 2 kinds of models.
- Models that predict the direction of the market. This is what our model does.
- Models that play mathematical games. These are the Renaissance Technologies’ of the world – they’re not really “trading”. From what I know, Renaissance Technologies profits from a lot of arbitrage and short term mathematical inefficiencies in the market. They’re not exactly the George Soros of quants.
Know your edge. You don’t have to be a mathematical genius to build the first kind of model. All you need to know is basic algebra. But to build the second type of models, you have to be a genius. Those hedge funds have legions of PhD’s, half of whom can probably win Nobel Prizes.
So before you create a model, decide what kind of model you want to create first.
I’m going to show you how to build the first kind of model in the rest of this page because that’s what our fund uses.
There aren’t a lot of good “how to build a model” resources out there, so this list is limited.
- Jeremy Grantham. Jeremy runs the $150 billion hedge fund GMO. He uses a long term quantitative approach that is similar to ours. His model is more long term while ours is more medium-long term. Go to his website and on the homepage, you’ll find his quarterly newsletter. www.gmo.com
- Read “Hedge Fund Market Wizards”. (You can get it on Amazon or at the library.) In particular, focus on the first 2 interviews. The first is with Colm O’Shea and the second is with Ray Dalio. The interview with Colm O’Shea is primarily useful for people who are looking to build a stock market model. The interview with Ray Dalio is a good guide to model-building in general. The interview with Ray Dalio is more valuable.
- Read a lot of financial history books. When you read history, you start to see similar patterns repeat themselves in the markets.
Before you build a model, you need to pick a market and get as much historical data on your market as possible.
- Yahoo finance is the most complete free source of data. But Yahoo finance doesn’t have commodities data.
- We use Bloomberg, which is the most complete source of data. But most people can’t afford Bloomberg.
- Some online bloggers are very nice. If you see a trader post a chart on market XYZ, send him an email/message asking him if he’ll share the data with you in an excel.
- Investing.com has a very broad range of data, including commodities. Unfortunately, most of the data on Investing.com only goes back to the 2000’s and 1990s.
*Not all markets can be modelled. Based on my experience, I have yet to see a good quant in the commodities markets.
To build our kind of model, you don’t have to buy any kind of complex software. Yes, having the software will help. But it isn’t mandatory.
When I first built the model, I used excel for all the calculations. It was that simple. Excel takes longer to use but it’s great for beginners.
You’ll need charting software.
- The best (and most expensive) option is obviously Bloomberg.
- You can also buy Metastock for a few hundred dollars. They allow you to input your own data. A lot of the charts you see here on Market History are from Metastock.
- The free option is to just create a chart in Excel!
Now let’s get into the actual building of the model.
Components of a model
Every model must have 2 main components (broken down into sub-components).
- Market outlook and trading component.
- Risk management component.
In the first component, the model should give a BUY, SELL, or HOLD signal.
The second component is just as critical. No model will always be on the right side of the market, so you need adequate risk management. If you blow up your portfolio, you won’t be able to make a comeback.
I’m going to focus on the first component in the rest of this article. The second component is very personal. Your model’s risk management will depend on:
- The market that you’re in.
- The time frame of your trades/investments.
- How big a loss you are willing to stomache.
How to create your model’s market outlook
Step 1: Look at the chart.
Do not start by looking at the data. Humans are inherently visual beings.
Fire up the chart with your data. Ask yourself 2 questions.
- What do I notice? What price patterns stand out and seem to repeat themselves?
- Which “waves” do I want my model to be able to predict?
I’ll give you a simple example using a market like silver. Here’s a weekly bar chart.
If you were to turn the chart into a log scale, you would see a repetitive pattern. Silver rises, spikes, rises, spikes, rises spikes…. Those “patterns” are the waves that you want your model to catch.
Once you’ve determined which waves you want your model to predict, write them down in a list. Now it’s time to create indicators that will enable your model to catch those price movements.
Step 2: Figure out the indicators.
This is where the real work begins. There are only 2 basic kinds of indicators.
- Trend following indicators. A trend following indicator states that “once XYZ happens, the market’s trend/wave has started and is legit (i.e. not a false breakout/breakdown).
- Contrarian indicators. A contrarian indicator states that “once XYZ happens, the market’s current wave is over and the market is about to reverse”.
*Not all indicators have to be price-dependent. Our model uses a lot of fundamental data and price data.
These indicators will be combined into your model. Together, they will predict the future of the market.
The hard part is knowing what indicators to use. I can’t tell you what indicators you should use because it depends on your market. Here’s some advice.
- If you have no idea what you’re doing, Google e.g. “why did Market XYZ fall on December 2006”. See what other traders/investors think. Take their ideas, and backtest it.
- Read up on history. This is why our U.S. stock market model is so powerful and is insanely hard to replicate. We built the basic model within a few months. Over the years, we improved it by reading the Wall Street Journal. We read 65 years of daily copies of the Wall Street Journal (16,000+ newspapers). Through our readings, we discovered a lot of patterns that we able to quantify. We were able to test the U.S. stock market’s reaction to various kinds of events, news, fundamentals, etc.
After you’ve discovered your indicators, you need to backtest them (make sure that they work with as much historical data in that specific market as possible). You need to watch out for 3 things:
- Don’t just look at how many times your indicators succeeded in catching a price movement. Watch out for the false positives (i.e. when your indicator predicted a price movement, which ultimately didn’t materialize).
- Do not overfit the data. E.g. you discover a trend following indicator that says “each time Indicator XYZ rises from 0 to 12, the market will soar”. Do not create an indicator that says “be bullish when indicator XYZ reaches 12”. Give the indicator some leeway. Create an indicator that says “be bullish when indicator XYZ reaches 10”.
- Make sure your indicator makes sense. When discovering indicators, you’ll find a lot of price patterns that are meaningless. In the vast universe of numbers, there are bound to be many patterns and indicators that work perfectly on paper (historically) but will fail the instant you use them. Make sure the indicator reflects an underlying idea that makes sense, logically speaking.
Step 3: You need 2 levels of indicators
You basically need 2 mini-models:
- A set of indicators that determine whether it’s a bull or a bear market.
- A set of indicators that tell you whether to buy or sell under that long term bull/bear market.
Too many quants focus only on the 2nd kind of mini-model. No indicator is going to work equally well in both bull and bear markets. Here’s a simple example to illustrate my point (we don’t use this in our model). In a bull market, the RSI might only need to fall to 30 before the market bottoms. In a bear market, the market might continue to crash even though RSI has fallen to 30! RSI might need to fall to 10 before the market can bottom.
*RSI is a contrarian momentum indicator.
Step 4: Watch out for correlation
Correlation will impact your model’s market. In the markets, strong long term correlation is indicative of causation. However, correlation between 2 markets won’t always exist. Correlation will only exist under certain market stages.
For example, the 2007-2009 global financial crisis was led by the U.S. stock market. The bear market in U.S. equities caused all other assets around the world to crash. European stocks, Chinese stocks, emerging markets, non-U.S. currencies commodities, etc. Everything was pulled down by the U.S. stock market.
This is why we only invest in the U.S. stock market. U.S. stock market investors are the only investors who don’t need to worry about correlation. History proves that none of the S&P’s significant corrections or bear markets were caused by foreign (non-U.S.) problems. Investors in all other markets need to be worried about correlation.
For example, the Chinese stock market soared in 2006 and 2007 because the Chinese economy was on fire. The Chinese economy was still strong in 2008, but China’s stock market was dragged down by the U.S. stock market.
Following our model to the letter is the optimal decision for U.S. stock market investors. However, we deviate from our model by adding a discretionary input. By doing so, we reduce our performance by a little but also reduce our portfolio’s risk by a lot.
You should not try to minimize your portfolio’s volatility. If you try to avoid volatility too much, your performance will greatly suffer. This is the reason why many hedge funds are performing so poorly nowadays. Their investors are micromanaging the funds. “You lost 4% this month!?!? Unacceptable!!! I’m going to withdraw my money!” You cannot make great returns if you cannot accept large losses.
You should accept as much volatility as possible. On the other hand, a 50% drawdown followed by a 400% gain is not an acceptable level of volatility.
Our model has predicted all but 3 significant corrections in the history of the S&P 500. If we followed our model during those misses, our UPRO position (3x S&P 500 ETF) would be down 50%. We would ride out the storm and then see our money double. But we are still human. If our portfolio was underwater by 50% for many months, we might just throw in the towel. Losing 50% of your money is a massive psychological hit that can take years to recover from. It’s not about the money. As long as it’s a bull market, our portfolio will be saved eventually. It’s about human psychology.
With that being said, let’s get into some specific tactics on risk management.
The common advice.
You’re probably heard the common advice.
- Never risk more than Y% of your money on one position.
- Cut your losses once your position loses X%.
The first piece of advice is mostly wrong, and the second one has some merit to it (although there is a better option).
- “Never risk more than Y% of your money” (i.e. make a lot of small trades) assumes that you know nothing about the markets. This advice is only suitable for people who have no idea what they’re doing in the markets – i.e. they’re gambling. In this era, increased correlation means that “diversification” doesn’t work well. For example, all asset classes went down in 2008 (except Treasury bonds and the USD). Investors who thought they had a “safe and diversified” portfolio in 2007 still got clobbered in 2008. The improper way to deal with risk is to run from it and play chicken. The proper way to deal with risk is to get smarter. Improve your investment skills.
- In this day and age, there are too many false breakouts/breakdowns. Some investors say “I’ll cut my position if the market falls 10%”. Well what happens if the market falls 10%, you cut your position, and then the market soars 60%? Your original market outlook was right, but you cut at the bottom!
You should cut your losses when you realize that you’re on the wrong side of the market. Cut your losses when the original rationale for your position is no longer valid. That original rationale doesn’t have to be price-dependent. For example, you bought XYZ because you’re bullish on the fundamentals. Don’t cut your position just because the stock is down 10%. Cut your position if the fundamentals deteriorate and the outlook is no longer bullish. Ignore the price.
More is coming soon!