# Close or Adjusted Prices when Backtesting

I've been doing this for some years now, but recently, since I started fiddling around with an old pairs trading strat of mine again, when updating the databases before running the tests, I was thinking about the prices used.

I was used to getting all adjusted close prices, dividends, splits, inplits, bonuses, etcs, and just running the strategy with those, but when eyeballing some of those time series and comparing them with the non adjusted series I get directly from the exchange (holy parsing, batman!) I noticed (the obvious) that some stocks are just way way away from their "raw", unadjusted prices and that that could lead to some really big data errors, contaminating the results.

I ran across a little white paper where the writer goes along about this issues and I exchanged some emails with some veterans in the industry. The latter told me that they just use adjusted prices for everything on the backtest procedures.

I was thinking, isn't it a little bit of a stretch to use adjusted prices for mimicking the execution of the trades?

I'm running a plain vanilla cointegrated pairs trading with some bells and whistles on top, and the difference between the two datasets, adjusted and non adjusted is just too big.

Would you consider using the adjusted series for in sample / cointegration / signal triggering, and then just using the real raw unadjusted prices at those times? (when triggering a trade, for example)

Or would you just use the adjusted ones and that's it?

The only part I'm sure here is about not using the raw series in cointegration and signal triggering analysis, too many jumps, gaps, with all the dividends, events, splits, etc.

Best Regards

• Which numbers would your strategy be using when released into the real world? Would a raw price actually be realised? Or would it be reversed/altered before you can act on it? – will Oct 9 '16 at 16:42
• Hi there! Thanks for the reply! In the real world I always used back adjusted prices with all included dividends, splits, etc. Then I traded on the real prices in real time, when the trades were triggered (using the adjusted time series for the signal generation). The thing is, when backtesting, I don't have the "real prices of real time" at the time of the triggering of the trade. I can only choose to use the adjusted, or the raw unadjusted ones. – Eduardo Gonzatti Oct 9 '16 at 16:45
• All I'm saying is that you need to run your back testing on the same thing it will be running on when it goes live. Of you can't, then you need the closest to it you can get. If you don't have equivalent data to what you're going to run it on when live, then what does your back test really represent? – will Oct 9 '16 at 16:48
• @will I agree, but when one doesn't have the exact data, which one would be more correct? I honestly don't know if using raw prices for triggering trades and adjusted prices for modeling (what I'm doing now) is the best way to be as close to the real world as possible. To do it correctly I'd have to get all the events that occurred to each specific stock and then adapt it in a rolling window of some sort, as the backtest goes by. That is, unfortunately, not an option.. – Eduardo Gonzatti Oct 9 '16 at 16:51
• Do you have any sets at all where you have both to compare? Or nothing at all? What would happens you were to run your algorithm and it encounters a price that gets adjusted? Would you actually realise it? I guess that's the important question. – will Oct 9 '16 at 16:52

To avoid this situation as mentioned above, I select only those pairs that have not undergone splits or bonus issue after the starting point of the backtest period. It yields less profitable but more dependable results.

If you are using unadjusted data, you need to do the adjustments yourself. For instance, not too long ago Apple made a 7-for-1 stock split. It would be astonishing if you don't account for it.

Then there is the case with dividends as they are discrete in nature. Suppose we are talking about cash dividends as the dividend amount is usually assumed to be discounted from the stock price.

If you are trading options, options are not protected against regular dividends and special dividends are decided on a case-by-case basis (at least it is what I remember from reading CBOE guidelines). Plus, if you are trading on indexes such as S&P 500 then it is not a big problem that you take adjusted returns and assume continuous dividends for discounting future returns.

Suppose you are trading a single stock (e.g. MSFT). Then you earn those dividends if you are long the stock and pay for dividends if you are short. You should take these into account when calculating your returns.

The error gap widens if the dividend paying company is generous in handing out cash. Otherwise, it might not worth the trouble for backtesting.

It also has something to do with what you want with the dividends. If you are reinvesting, you can use S&P500 total return index (SPXTR).

• Thanks for the reply, @berkorbay, I agree with everything you said. The only difference here in my country is that when trading options you get the premium adjusted after the underlying stock pays off dividends or whatever, but that's not the case here. I'm trading stocks against stocks, so it does make a difference in time, if I'm getting the adjusted time series, today, from 2012..today, I'd get prices in 2012..2013..who are way away from their "raw prices" at that time.. The question is : which one is closer to the real world? Using these back adjusted series for modeling and triggering – Eduardo Gonzatti Oct 11 '16 at 12:13
• And then using the unadjusted (raw) prices for execution of the trades (everything in backtest here) , or using the adjusted time series for every step of the procedure? – Eduardo Gonzatti Oct 11 '16 at 12:16
• @EduardoGonzatti it shouldn't matter as you are using the adjusted series for calculating the logreturns (or returns) and "fitting" parameters for your model (or strategy). Then, for out-of-sample estimation you can use the raw data as long as you take dividends and splits into account. The main problem of adjusted returns is they take dividends out of the process and it has an effect on your P&L. – berkorbay Oct 11 '16 at 12:47
• I agree, but the thing is, I only have pure raw unadjusted prices and fully adjusted prices, nothing between those. So I'll be suffering from the risk of taking a trade in the out if sample part, and not taking the dividends or whatever events into account, when using unadjusted prices. More than that. Those prices, which are prone to jumps because of the unadjustments can trigger stop losses, or take profits that don exist, even "take profits" that are actually a loss in PNL.. – Eduardo Gonzatti Oct 11 '16 at 12:53
• @EduardoGonzatti If you are covered for the dividends as you said earlier. Use adjusted prices to calculate logreturns and use unadjusted prices for $S_0$. It seems like the most convenient way. – berkorbay Oct 12 '16 at 13:00

Eduardo, what did you decide? I think I share your understanding of the dilemma: I for instance am using a 200 day simple moving average to signal when to buy/sell. I add an envelope to the SMA to avoid whiplash. Yet, if I use adjusted prices, I do better if I use a wider envelope than if I used unadjusted.

On the surface, it makes sense to use the adjusted prices to calculate the SMA. Yet, the adjusted prices from two years ago reflect dividends that we wouldn't have known about at the time. So in backtesting, I can't replicate the limited information I would have had real time were I implementing the strategy in the past. Specifically, the prices at which a stock is trading today will eventually be adjusted, but for now I don't know to what degree. Would you agree?

One thing I realize is that there's much less difference between the adjusted SMA and the unadjusted SMA for the last 200 days than there was for the 200 day SMA five years ago. So I'm leaning toward using unadjusted prices in my backtest because they are closer to the information I would have known at the time were I making a daily decision as to the best trade to make.

I'd love to know your thoughts now that you'd have more time to consider. One thought I had would be to trade based on unadjusted prices for now, while at the same time I'd run the alternative strategy in paper money.