Data Requirements for Backtesting

Adrian Reid (Enlightened Stock Trading) explains why high-quality historical price data is the single most important input for systematic traders and backtesting. He describes common data problems (bad ticks, unadjusted prices from splits and dividends, missing bars), recommends back-adjusting for splits, dividends and corporate actions, and recommends paid vendors—Norgate for AU/US/CA (and futures/FX) and MetaStock for other global exchanges.
Chapters
Do you know what the most important input is for you if you're a systematic trader? My name is Adrian Reed. This is enlightened stock trading. And in this video I'm going to talk about data requirements for backtesting for you if you're a systematic trader. But before we go any further, make sure you hit the subscribe button and give this video a thumbs up 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 there's a couple of things I want to cover here. First of all, getting historical price data. Second, secondly, data problems and challenges that you can have when choosing data adjusting data for correct backtesting, and also some recommended data sources. So let's jump in. Getting historical price data. How do you get historical price data? What do you need to be looking for? Well, what you need when you're backtesting stocks and you're developing stock trading systems is a complete data set for all stocks listed on the exchange, preferably past and present stocks with as much history as possible. Now, you can get this sort of data for free from sources like Yahoo and various other sources. The trouble is, when you get free data, there's some potential problems and risks. And as data is the most important input into your systematic trading decisions, you want the data that you're using to be high quality. Because if you've got low quality data with mistakes, errors and omissions, then you're going to get full faulty trading signals. And faulty trading signals can lead to losses and drawdowns in your account. So we want to avoid that at all cost. So my guidance is to avoid free data. It's just not worth it. You might save a few bucks on the data, but it's going to cost you thousands or more in your live trading. So getting historical price data, you want to get it from a reputable data provider. Good data vendors will get the data from the exchange, they'll clean it, they'll make sure that all of the price bars are correct, there's no bad ticks, they'll make sure all of the data is split adjusted and check for errors and omissions before serving it up to you. The other advantage of using a good end of day data provider is that they usually come with a downloading software or application to make the download quick and easy. And 2 of the data vendors that I use and recommend have really simple, easy data downloaders that can be automated. So every day Your data just updates. And you can open up your trading software and know with confidence that your trading data is up to date. So getting historical data, you need to pay for it, unfortunately, don't skimp. You will end up losing money with real time trading. So what are some of the data problems in backtesting? If you don't have good quality data, there's three problems that I want to talk to you about. The first one is bad ticks. If you get free data and you look very closely at enough of it, what you'll notice is that there's some bad ticks in the data. And typically the way this manifests is the high, the low or the open or the close is wrong for a particular bar. And sometimes what happens, for example, is let's say the stock price is $10.50 and the open and the high and the close are all around $10.50. But the low might be all the way down at 10 cents or 10.5 cents. And that's a bad tick. It's data that hasn't come through clean. So it should have been $10.50, but instead it was 10.5 cents. So it's like divided by 100, something like that. If you get cheap data or free data, you will find these bad ticks where it's just got the decimal point in the wrong place. Or maybe either the open or the high or the low or the close is set to zero or something like that. And it's just inaccuracies. And while a small number of inaccuracies may not hurt, it really casts doubt on the quality of your backtest results. And this is the problem because you want to be able to have confidence that your backtest results are valid so that you've got confidence in your system. But any data errors can cause faulty results. You might end up getting outliers.
In your backtest, really big winners or really big losers that maybe are not realistic trades. So you want to make sure that you get good quality data free of bad ticks. The second problem is unadjusted data. A lot of free sources, actually most free sources don't split adjustments their stock data. And so stock splits are. When a company, maybe a company is trading at $100 a share, they do a 10 for one stop split. So today you're holding one share at $100. Tomorrow they do a 10 for one split, which means you're holding 10 shares at $10 instead of one share at $100. It's the same dollar value, but the price of the shares has dropped dramatically. Now, if the data provider that you're using doesn't split, adjust the data. The way that'll look on the chart is the stocks up at $100 a share and then the next day it drops down to $10 a share and there's this big gap down. Now clearly that gap down is not a failing of the company. The company is not going bankrupt or anything. They just had a stock split. So what the data vendors should be doing is saying, okay, well today it's $10 a share, yesterday it was $100 a share. What we do is from yesterday back in time, all of those share prices get divided by 10 to ratio them down to match the current price post split. That way you get a nice smooth, consistent price series. And when you split adjust correctly, the performance of the chart split adjusted matches what you would have if you bought and hold that stock. So it's important to have split adjusted data. Otherwise you have these big gaps down or in the case of a reverse stock, split a big gap up in the share price on the chart, which is wrong and it'll give you faulty signals and ruin your backtest. You also need data that is dividend adjusted. Well, need, I mean it's ideal if you have dividend and capital adjustments in your data. Because if a stock declares a dividend, usually what happens again, let's say the Stock's trading at $10 and it declares a 50 cent dividend.
On the ex dividend date, the stock price will typically drop by the price of the dividend, say 50 cents and then it will continue trading. That looks like a little gap down and that looks like a negative sign on the stock chart. And often that can even trigger your stop losses. But it's a dividend, it's not a drop in the share price. It's just the fact that some of the value of that company has been taken from the share price and given to you as cash. So the price of the shares drop just a little bit. So you don't want to be getting sell signals as a result of a dividend drop. So if you get dividend data with your.
Stock history, then you can have your data provider adjust the or your data trading software adjust the historical price of the stocks for, for all of the dividend payouts, which reduces those little gaps caused by dividend payments. So dividend adjustment is also very, very helpful. Now, not all markets are easy to get dividend data for. So.
If you trade Australia, US or Canada, you can get dividend Adjusted data. And I'll tell you about the vendor shortly. For most other markets, you can't really get it. So you've got to just put up with the fact that there's these little dividend gaps down when the dividends are paid. It's not the end of the world. It doesn't completely destroy your backtest like stock splits can. But if you can get dividend adjusted data, it is better. The third problem with free data is missing or incorrect data. So if you have stocks that are missing or stocks that are missing trading days or bars, or there's gaps in your data set because your vendor is providing that service for free, so they don't have a lot of incentive or, or resources to quality check it. So having gaps in your data like that can also affect your backtest and your real time trading. You might miss signals that you would otherwise take because there's gaps or problems with your data. So data problems are a big deal for backtesting. So you want to pay for good quality data to minimize the number of problems you get to maximize the accuracy of your backtests and the confidence that you have to take into your live trading. It's it will also reduce mistakes and errors in your live trading, which will save you money in the long term. So if you've got good quality data, you want to make sure that you're back testing it with adjusted data. So how do you adjust your data for correct backtesting? My approach is to adjust to back adjust the data for stock splits, capital reconstructions, capital returns, and ordinary dividends. Now I like to do all of that because then my backtest results include or incorporate the.
Benefit of all of those things. If I'm holding a stock and an ordinary dividend is announced, then that stock price drops a little bit. That looks like a loss in your backtest. But if you dividend adjust your data, then the adjustment takes into account that dividend and that dividend is then built into the profit on that trade. So it makes your backtest more accurate. For capital returns and reconstructions, it's even more important because they tend to be much bigger relative to the stock price. So you want to have split adjusted capital adjusted and dividend adjusted data if you can. The other adjustment that sometimes you want to use is padding of the data. Not every stock trades every single day. So for example, if you trade small cap mining stocks, they'll often be trading halts. When new news is announced to the market, they have to go on trading halts so they can announce the news, everyone gets all the information at the same time. So it's a fair and equitable market. And that means that there'll be some price bars where there's just no movement. So what I do for a lot of my systems is, is pad the data so that the price of the individual stock lines up to the price of the index. Now the reason you want to do that is so that you get accurate index signals in your backtest. If you're using a market regime filter based on your index, then adding that padding to each of the stocks to make sure that each of the price bars line up between the stock and the index, even if the stock was in trading halt means you get more, you get accurate market racing filter signals. And that's really important to turn your system on and off at the right time. So they're the ways you want to adjust your data. So now that you know what you're going to do with your data, what are my recommended data sources for backtesting? Well, my number one recommended source for data for end of end of day data for backtesting is Nor Gate data. There's a link down below to get access to get to the Nor Gate website and find the data package that you need. But the reason I really love Nor Gate is they have super good quality data. I've spoken to some of the guys at Nor Gate and they go to great lengths to clean and make sure their data is high quality, make sure all of the split adjusting is done. They also provide.
Historically accurate index constituents, they provide delisted stock data, and they provide all of the dividend and capital reconstruction information as well. To top it all off, the Nor Gate data downloader is fantastic. It does all of the maintenance really, really cleanly. It always works. It can be automated, so it downloads the data constantly. Whenever there's an updated piece of data, it will just suck it in and include it in your database. So Nor Gate is absolutely hands down my number one recommendation for end of day data. The only problem with Nor Gate data is that you can only get US Stocks, Canadian stocks and Australian stocks, plus futures and forex data. If you want to trade any other markets other than those, you can't use Nor Gate. So the data provider that I recommend for any other markets is Metastock. Metastock end of day data covers a broad range, pretty much all stock markets globally for a very, very reasonable price. They have a data downloader that can be automated so at the same time you schedule a task in your Windows task manager. So at the same time every day that will run the update. And you can get data for pretty much any exchange globally. Depending on which markets you want to trade, you'll subscribe to either the Asian region, the European region, or the North American region region. And for one low price of about $30 a month, you get access to all markets in that region. So I subscribe to all of those. You may not want to do that. You might just want to choose one of those regions. But Metastock is a really great source if you want to trade some of the less less mainstream markets. Let's call it so I use nor gate, sorry, I use Metastock for the Hong Kong market, for Japan and for the European markets as well. You can get a one month free trial with the link that's down below this video to metastock data and that comes in Metastock format, the industry standard format for data, which can be used in pretty much any trading software package. So they're the data requirements for backtesting. In this video we talked about getting historical data, we talked about data problems, talked about adjusting the data for correct backtesting, and we also talked about my two recommended sources for end of day stock data. So if you want to learn more about backtesting in the next video in this series, I'm going to be talking about optimizing optimization in backtesting. So scroll down below if you're watching this on my blog to watch the next video or click the link to watch the next video in this series. If you're watching this on YouTube, I'll see you in the next video. Bye for now.
It.











