newbie questions: Pairs trading and ex-Dividend?

Discussion in 'Strategy Development' started by losemind, Jul 17, 2011.

  1. losemind

    losemind

    Hi all,

    I am a newbie trying to backtest some very simple pairs trading strategy.

    My strategy is (non-HFT or intraday):

    Based on close prices, if stock A - stock B > entry threshold, I will go short A and long B and I will hold them for a few days until

    stock A - stock B < exit threshold.

    All trades are upon closes.

    But what happens if the two stocks ex-Dividend on different dates?

    Lets say today is stock B ex-Dividend day, stock B drops in prices,

    stock A - stock B > entry threshold is satisfied and I enter long B and short A at close.

    Then tomorrow is stock A's ex-Dividend day, stock A drops in prices,

    stock A - stock B < exit threshold is satisfied and I exit the positions at close.

    So my newbie questions are:

    (1) shall I use dividend adjusted stock prices to do the historical backtest or not?

    (2) I am short A when A goes on ex-Dividend, what happens to the dividend?

    Please help me clear my thoughts. Thank you!
     
  2. 1. I think the relationship should be strong enough such that you can ignore the dividend adjustment in backtest.

    1a. If not, then I suppose then answer is something like building a curve and valuing the non-paid dividend at each time interval. Something like that. See point 1. It is easier.

    2. You pay it.
     
  3. Just thinking out loud.

    I wasn't sure if the short had to pay the dividend so I did a little thought experiment.

    Lets try to establish a baseline truth. It should not be possible to make a know (arbitrage) profit by going long and short the same stock at the same time.

    Lets say you went long and short the same stock at the close the day before the xdiv date. At the xdiv date open, the net of these two positions should be 0.

    So in this example, lets say the stock pays a .50 dividend. At the open on the xdiv date, the long price lost .5 but you capture the .5 dividend, so the long side is breakeven. The short side would have gained .5 (the open price will be down .5) which means the net for going long and short would be +.5. That can't be right. This must mean the short has to pay the .5 dividend.

    cT
     
  4. shorts pay it.
     
  5. losemind

    losemind

    I am seeing some big special dividends, so I am not sure if the dividends are ignorable.

    So if I use dividend-adjusted historical open and close prices for backtesting, I should be able to avoid dividend-related pitfalls in pairs-trading, right?
     
  6. losemind

    losemind

    Very nice thought experiment cT. I like this one. Thank you!
     
  7. Yea, some of the higher dividend yielding stocks really gap down at the xdiv date open.

    This is probably obvious but it seems like the best way to backtest this would be to use regular non dividend adjusted prices for each side and factor in the long side gets the dividend and the short side pays it.

    Unfortunately, I don't think most of the retail backtesting software out there lets you add in the dividend or subtract the dividend from the PL (I wish they did).

    So perhaps another thought experiment :).

    How could you adjust your data to take into effect the dividend which of course was your original question.

    The stock that you hold long at the xdiv drops by the dividend but you get the dividend payout, so it seems like, for the long side, just forward adjust the data by adding the dividend to the price.

    Now for the short stock. At the short stocks xdiv date open, the stock will drop by the amount of dividend. Buy we also have to pay the dividend. It sure seems like the short stocks data series would have to be adjusted by 'subtracting' the dividend from the profit that occurs from the gap down. For the short side that would be equivalent to adding the dividend to the price (forward adjusted).

    If my logic was correct, then I think you are right, to all the stocks involved, longs and shorts, just add to the open price of each stocks xdiv date, the amount of the dividend payout and of course adjust each price going forward in the data series. I think I would call that forward adjusted data. For backadjusted data, I think you would start at today and walk backwards and "subtract" the dividend from each xdiv dates open price. Either way, you are basically removing the xdiv date open price gap.

    Of course, just like other types of adjusted data (rollover dates in the futures world), over time these dividend adjustments to the stock price will eventually skew the prices quite a bit which could effect other calculations in the strategy. For backadjusted data, if you go far enough back, the prices might actually go negative.

    Again, ideally the backtest software would just automatically credit a position that is long at the close the day before xdiv date with the dividend and automatically debit a position that is short at the close the day before the xdiv date by the amount of the dividend. Maybe someday.

    cT
     
  8. Right .. ok, I don't want to be a dick .. but this nets to nothing, no?

    You are long. You get paid the div, and the stock drops by the div amount. Net nothing.

    You are short. You pay the div, and the stock drops by the div amount. Net nothing.

    Sheesh...
     
  9. losemind

    losemind

    yeah, you said it... the thing is the backtest software doesn't handle dividend separately and knowingly, it only operates on the price series, therefore, I have to massage the price data before feeding into the backtest software(i.e. adjustments)
     
  10. losemind

    losemind

    Nice! Thank you! That's exactly what I did. In my backadjustment, I substract the dividend from all OHLC prices series prior to the ex-Div date and going backwards...
     
    #10     Jul 17, 2011