3
$\begingroup$

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

$\endgroup$
10
  • $\begingroup$ 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? $\endgroup$
    – will
    Commented Oct 9, 2016 at 16:42
  • $\begingroup$ 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. $\endgroup$ Commented Oct 9, 2016 at 16:45
  • $\begingroup$ 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? $\endgroup$
    – will
    Commented Oct 9, 2016 at 16:48
  • $\begingroup$ @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.. $\endgroup$ Commented Oct 9, 2016 at 16:51
  • 1
    $\begingroup$ 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. $\endgroup$
    – will
    Commented Oct 9, 2016 at 16:52

5 Answers 5

0
$\begingroup$

The most important rule of backtesting is to ensure that you do not fall into the 'look-ahead' bias trap. IMHO, while adjusting for splits, bonuses and dividends in regular strategies does not cause look ahead bias, in case of pair trading it does influence the backtesting results. I realised this when using backtesting results of about 750 pairs to choose the best performing pairs and trade them henceforth. Since the spread in pair trading is derived from prices (or log prices), to backtest on adjusted close prices implies measuring profitability of trades in the past that would have actually not been triggered (or best been triggered at different price points) by the strategy. This is especially troublesome when only one of the instruments in the pair has an adjusted close price different from the real close price; that is only one instrument has undergone a split while the other has not.

While trading one of the pairs, I realised that profit/loss accrued from the trade as of now (say 23rd Oct 2017) might be very different from the profit/loss generated by the trade as shown in the backtest result carried out on the very same pair using adjusted close prices 2 years from now (assuming one of the stocks undergoes a split before that). In fact I would even go further to say that using the adjusted close prices two years from now in a backtest may not even trigger a signal to enter the trade on 23rd Oct 2017. Hence it is my belief (a reasonable one I hope) that adjusted close prices introduce look-ahead bias into pair trade backtesting. I haven't come across any academic paper or quant site discussing this issue but have experienced while trading myself. It would be nice if you could share the link of the paper that you ran into.

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.

$\endgroup$
2
$\begingroup$

I've had a lot of experience here.

If you are calculating % returns or momentum factors (i.e. price changes over a horizon of days/weeks/months) then you need to use adjusted prices otherwise you pick up large prices changes due to stock splits, etc. if they happen to land in the middle of your horizon, which gives you an incorrect value for change in price.

If you are using historical price levels as an explanatory variable in an expected return factor model (i.e. time-varying cross-sectional returns across a universe of stocks), then you should definitely use unadjusted prices as you need point-in-time metrics otherwise you'll be incorporating lookahead bias.

I should also add that the adjustment factor needs to be as accurate as possible. I've encountered rounding errors in Bloomberg data that resulted in predictive issues in one of my ML models. 6 decimal places may not be sufficiently accurate! This is where DataOps and MLOps are important - checking the consistency of data (i.e. adjustment factors change -> loss of accuracy -> incorrectly adjusted prices and hence slight differences in ML-based optimised parameters -> causes portfolio consistency problems).

$\endgroup$
1
$\begingroup$

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).

$\endgroup$
7
  • $\begingroup$ 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 $\endgroup$ Commented Oct 11, 2016 at 12:13
  • $\begingroup$ 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? $\endgroup$ Commented Oct 11, 2016 at 12:16
  • $\begingroup$ @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. $\endgroup$
    – berkorbay
    Commented Oct 11, 2016 at 12:47
  • $\begingroup$ 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.. $\endgroup$ Commented Oct 11, 2016 at 12:53
  • $\begingroup$ @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. $\endgroup$
    – berkorbay
    Commented Oct 12, 2016 at 13:00
1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ from everything i tested, it makes more sense (backtests more adderent to reality) to use the adjusted prices, unless you have a really reliable data base without any adjustments along with a database ONLY with the adjustments for a long enough time spam AND the time to adapt all your codes for these $\endgroup$ Commented Sep 9, 2021 at 13:51
0
$\begingroup$

We face the same issue in backtesting our long-only strategy for Indian markets. We have used the unadjusted price for signal generation and the adjusted price to calculate the performance. Example - Long A (Stock) -> A undergoes a 3-1 split(Signal from a separate Corporate action database) -> We adjust the relevant data points for stock A (52-week High, Low, CMP, purchase price, number of outstanding shares, number of shares in the portfolio) -> Exit A This happens on an ongoing basis as the algorithm traverses from the beginning of the testing period till the end. We are still facing execution issues so we wouldn't guarantee the results with this approach.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.