Backtesting different Types of Instruments

Adrian Reid breaks down how backtesting works differently for stocks, crypto, futures, forex, and options. Stocks are the safest starting point. Watch out for liquidity filters, survivorship bias, and continuous futures contracts, which can wreck your results. Options backtests are too expensive and unreliable for most retail traders right now.
Chapters
Have you ever wondered whether backtesting stocks or crypto or forex or futures or options works the same way? My name is Adrian Reed. I'm the founder of Enlightened Stock Trading. And in this video, I'm going to talk through each of the different asset classes and how backtesting in those asset classes differs. To save you a whole lot of trauma, avoid a bunch of mistakes that could really hold you back. But before we go any further, make sure you hit the subscribe button and give this video a thumbs up. Subscribe so that you get notified of all of my future videos, because I've got new trading content coming out all the time and I don't want you to miss a thing. So let's first talk about backtesting in stocks, because stocks is probably the most tricky to get right initially because there's quite a lot of considerations. But once you understand backtesting in stocks, you can very easily apply that to many of the other asset classes. So here's the challenge. In stocks, there are literally thousands or tens of thousands of different stocks you can choose from. And so when you're back testing a trading strategy in stocks, you need to have rules that sort through that huge volume of stocks and data to find the trades that you actually want to take. So first thing you want to do is filter out the stocks that are basically trash, stocks that have no liquidity, stocks that don't that that have extreme volatility, or stocks that don't trade very often. So you need rules in your trading strategy to eliminate all of the garbage. Now, for me, one of the best rules to do that is having a liquidity filter. So requiring that your stocks turn over half a million dollars per day on average or a million dollars per day on average eliminates most of the garbage that's listed on the market. That's not really tradable. You can go lower than that. But you've got to be a little bit careful. If you start going into stocks that are only turning over 50 or $100,000 a day, they can be really patchy and hard to get in and out of. They also move erratically. So the more liquidity typically the better. You don't need tens of millions of dollars per day because you're only a retail trader. You've probably only got a modest size account like most of us. But you do need some level of liquidity, so you need a ruling strategy to achieve that. The second thing you need to do is realize that in stocks, the market goes through long bull phases. Bear markets and also sideways markets. And most strategies will only work well in one or two of those different market conditions. Typically a trading strategy won't work across all market conditions. So in stocks what you do or what we do is we have rules that isolate the market regime that we're most interested in. Typically we call this an index filter or a market regime filter. So for example, if you're trading long side trend following, you only want to do that when the market is going up. You don't want to be taking trades in a long side trend following system when the market is hammering down in a bear market. So you have market regime filter rules in your trading strategy to make sure you only take signals at the right time. So that's the second consideration in stocks, it's the market regime. And then once you've got the market regime right, then you get down to the individual stock. Because just because a stock is trending up now and the whole market is trending down, doesn't mean that stock will continue to trend up. In fact, if the whole market is trending down and one stock is trending up a little bit, chances are that move will be short lived. But if the whole market is trending up, then a rising tide lifts all boats. If you buy a stock that's trending up, it'll more likely to continue trending up. So you want to trade in the direction of the primary market trend. That's the regime filter. The second thing you want to do is for find your buys and sells on each of the different stocks. Now again, we have tens of thousands of stocks that we can trade on the US market alone, let alone all the other markets around the world, which you should be interested in trading by the way. Don't just stick to the one market.
So how do we find our buys and sells? Well, you've got to put your entry and exit rules into your backtesting software so that it can scan the historical data and find every single bar where there was a buy or every single bar where the sell conditions were true. Once you've got that, the trading software is then in a position to assemble what a portfolio would have looked like had you traded that strategy. The trouble is you're going to have too many trades. There's way more signals in the past than what you could possibly have taken with your real capital. In fact, could be 10, 20 or 100 times more signals than you could actually take. So the next thing you need is in stocks. Once you've got your buy and sell rules, you need Your position scoring rules. The position score is the priority of each trade based on some sort of price behavior. An example of a position score rule might be.
Trade the stock that has moved the furthest today compared to 100 days ago. Or trade the stock that is the lowest volatility first. Or trade the stock that is the highest volatility first. Or trade the stock that that is the furthest above its 200 day moving average first. Those are all examples of position score rankings that you can use in order to prioritize which signals you should take. Now, you're not prioritizing these in your mind. You're putting this rule into your trading strategy and then inputting it to your backtesting software to evaluate that rule objectively. So we've got our instrument rules to get rid of all of the crap. We've got our market regime rule to market regime filter to tell us whether we're in a bull market or a bear market or a sideways market. We've got our buy and sell rules and we've got our position scoring rules to rank the trades. That allows us to figure out the relative priority of the trades. Then we need the position sizing rules. The position sizing rules tell us how much capital to put into each trade. And you want to put those position sizing rules into your backtesting software so so that it can assemble a portfolio and show you how that portfolio would have performed over time with all the buys and sells, with all the position sizing and the position scoring. So to give you an indication of how that strategy would have performed in the past, all of those considerations come together to give you a complete stock backtest. The next thing you have to worry about with stocks is things like survivorship bias and delisted stocks. If you backtest over 30 years or more of history, a lot of stocks come and go. Stocks come into the S&P 500, and stocks leave the S&P 500. So on stocks, you've got to be very careful to avoid survivorship bias. Now, there's two types of survivorship bias. There's index constituency bias, and there is stock delisting survivorship bias. The Index Constituency 1 is by far.
The most risky, the worst one to suffer from. If you take 10 today's SP 500 stocks, the 500 stocks that are in the S&P 500 today, and back test your strategy over the last 30 years on that list of 500 stocks, you're going to get a really positive backtest. Why? Because the backtest is cheating. Because you're telling 30 years ago, your backtesting software knows that today that stock will be in the S&P 500. So chances are that stock has gone through a big growth phase in that preceding 30 years. So that's cheating. What you've got to do instead is look, on the day of the signal, was that stock in the S&P 500? If it was in the S&P 500 on that day, then take the signal. So if you don't have that index constituency data for every single day of market history, then you can't trade, you can't back to stocks that are members of an index. You have to back test the entire universe, the entire market. And in fact, I actually prefer to backtest the entire market anyway, because often the systems work better, believe it or not. But if you do have the historical index constituency, then you can backtest strategies in stocks that only trade, say, stocks in the S&P 500 or stocks in the ASX 200 or stocks in the ASX top 50 or the NASDAQ 100. You can use those lists, but you've got to backtest it correctly. The second type of survivorship bias is stock delisting. Now, if you can get delisted stock data so you've got the currently listed stocks and all the stocks that delisted in the past, it gives you a much bigger database. That's great because it gives you far more information about how the strategy would have worked and you're not missing any trades that would have appeared had you been trading that strategy in the past. Now, a lot of educators will talk about how you absolutely have to have delisted stock data, and if you don't, you're fooling yourself and all of this. But delisted stock information is nowhere near as important as index constituent information. I've back tested most of my strategies with and without delisted stock data. And in most cases, when you include delisted stock data, the performance of the strategy historically actually gets better because it gets more trades. And a lot of stocks have delisted not because they've gone bankrupt, but because they've delisted because they've gone up and then they've been acquired by another company. So delisted stocks are important. Important to understand whether you are backtesting with them, but not the be all and end all of survivorship bias. So there's some considerations for backtesting with stocks. Let's talk about backtesting with crypto, which is quite a different beast because in stocks, we have 30 to 50 years or more data in some markets. In crypto, we've only got a handful of years of data. So in crypto, the biggest problem is getting enough data history to really correctly evaluate your strategy. All of the other considerations around liquidity and market regime and so on that you have in stocks also apply to crypto, because you don't want to be trading very small cap illiquid cryptocurrencies, where the bidder spread is really, really wide and they move really erratically. It's quite hard to make money in that. But if you trade crypto tokens that have a little bit of liquidity or a bit more liquidity, then they behave much more sensibly in your trading strategy. So they're both really important. But how do we deal with the data issue? So if you download your crypto data from one of the exchanges that you trade on, you're only going to get a couple of years of history, and the history that you get will be limited to the tokens that that exchange traded at that particular point in the past. So the backtest will be limited because the further back in time you go, the less instruments are going to be in your database and the less trades you're going to generate. And then as you come forward in time to the present day, you're going to have more instruments and more trades. Gives you a very lopsided database. So the key thing in crypto when you're back testing and developing trading systems, is to get the biggest, biggest, longest data set that you can. That's why in crypto, when I'm developing trading systems, I use data from Brave New Coin. Brave New Coin has gone through all of the different exchanges and pulled data from all of them and assembled them together into one unified data set. And so what it's got is a much longer time series of many more tokens than what you would get from any individual exchange. So, so with crypto, you want to have the biggest data set possible, the longest history possible, for backtesting your trading software, your trading strategies. And even if you've got all of that data, you're still going to have to be careful, because five years ago, there were far less tokens than there are now.
When Bitcoin first came out, Bitcoin was the only one, and then followed quickly by a small number of others. And then eventually it started exploding into huge numbers of different tokens. Brave New Coin can give you most of that history, and you can import that data into your trading software and Get a more complete backtest of your crypto trading strategy, so don't fall victim to the limitations of your individual exchanges data. You want the biggest data set you can possibly get, and that's going to give you the edge in crypto backtesting. So now let's talk about backtesting futures. Backtesting futures is quite a different beast than stocks and crypto. And the reason is that futures contracts expire. So you can't just buy one futures contract and hold it for six months or a year, because chances are it's going to expire many times in that whole period. So with backtesting futures, you're instead going to backtest on continuous contracts. Continuous contracts take all of the different expiry months and splice them together, back adjusting as it goes to give you a continuous and smooth price series that mimics what your account would have done had you bought that contract, held it to near expiry, and then rolled to the next contract and held that one, and then rolled to the next contract and held that one, and so on. So you need to use those continuous contracts or have trading software that does the contract rolls for you. So that's generally going to be more specific trading software specific to futures. So software like Trading Blocks can do that. Software like amibroker, which is what I use, would use the continuous contracts rather than managing each individual.
With futures. The other consideration is whether you're doing portfolio backtesting or single instrument backtesting. Most retail traders probably don't have enough capital to do serious portfolio futures trading strategies. You'll need several hundred thousand dollars in your account to run a diversified trend following strategy in futures, for instance, because the margin requirements are quite high now. Over time, as they introduce more and more mini and micro contracts, that becomes less and less of an issue, which is fantastic for traders. But right now there's still a lot of contracts you can't trade unless you can stomach a really big margin requirement. So most futures traders currently at least have single instrument strategies because you can trade in and out on a single instrument basis without having a huge account. So if you're trading single instrument, then obviously you're going to backtest that way. It's quite different to backtesting a port portfolio of instruments like you do in stocks. So backtesting futures is quite different to stocks and you want to make sure that you really learn and understand all of those considerations in detail before launching into futures trading. If we talk about backtesting forex next, backtesting forex is very Similar to futures, except the contracts don't expire. So spot Forex doesn't expire. You can just buy it and hold it. There are costs to holding those contracts, so financing costs. But you typically don't trade a strategy on a diversified portfolio of currencies. It would be one strategy per currency. That's not always the case, but often it is the case. Most Forex traders are using single instrument systems. That makes it very quick and easy to back test. You don't have contract roles like you do in futures. You don't have lots of garbage stocks to filter out like you do in stocks and crypto. So Forex is actually quite simple. You can have trading strategies in Forex that are just literally a couple of rules. Now, getting profitable, it's a completely different story. Getting consistent, also a different story. But the strategies can be very, very simple because you don't need rules to filter out all of those different things. So backtesting Forex is probably one of the easier markets to back test. You can certainly generate simple rules, but it's probably not the best one to trade. I think Forex is one of the most competitive markets and I found certainly that it's far easier to generate very profitable strategies and stocks in crypto compared to Forex. Let's talk about backtesting options. This is an area that a lot of people ask about, but backtesting options is very, very difficult because there is a huge volume of data. You've got all of the different stocks, all of the different options strike prices, you've got calls and puts and all of the different expiries. So there's masses of data. And to assemble those, pull those into trading software and correctly backtest it all is a huge and very, very difficult task. And to put it bluntly, most trading software is just not up to the task. In fact, I'm yet to find an options backtesting software that I'm really happy with. And even if I did, the data is very, very expensive because you've got to get a huge volume of data from the exchanges. So backtesting options is very problematic. So unfortunately, a lot of options traders resort to paper trading and chart replays and they're not backtesting properly. The reason I don't actively trade options is because I can't effectively backtest the strategy strategies over a long period of time. And in options, a lot of strategies might look very good, but there's a big tail risk and I want to backtest and know the impact of that tail risk. So that's why I'm not actively trading options, because the backtesting software is just not up to the task. There are increasingly more and more backtesting platforms online for options trading and I'm hopeful in the very near future those will become competitive and perform form as well as the software driven or the locally driven backtesting software that I use for stocks and crypto. But they're just not there yet. So that's why I'm not backtesting in options right now. So there are the considerations for backtesting. All of the different instruments we've talked about considerations for stocks, crypto, futures, forex and options, they all have a few different nuances.
I like my traders to start in stocks because it's the most understandable and it's the simplest to conceptualize really. Once you know that you've got to filter out the garbage. Stocks, once you know that you want to trade only long in a bull market, once you know that you need buy and sell rules and a rule to prioritize your stocks, it becomes really powerful because you can assemble that portfolio and see how it would have performed over time time and get really great insights into your trading strategy. So stocks, I feel is the place to start. Crypto works amazingly well and is a great way to diversify your stock portfolio. Futures is also great if you have enough capital to do it or if you trade single instrument systems. Forex is very easy to back test but very competitive and hard to win in long term. And options just you can't backtest effectively with the current technology we have available to us can be done but just cumbersome and very, very expensive for the retail trader. So that's all for this video. In the next video I'm going to talk about setting up a trading strategy for backtesting. So I'll give you the considerations of how to do that. So scroll down on the blog if you're watching on the blog or click to watch the next video in this series if you're on my YouTube channel. I'll see you in the next video. Bye for now.











