CustomMenu

Sunday, September 14, 2014

Historical Data and Momentum Rotation Strategies

We are going to take a slight detour with this post, and look at stock/ETF/mutual fund rotation strategies.  I actively trade rotation strategies in several accounts, and have been evolving my rotation strategies for about ten years.  If you'd like some information on how to build a rotation strategy, please take a look at the articles below:


These articles are from the blogs of MarketSci and Woodshedder who have both written a number of posts (more than I've listed above) on the topic of rotation strategies.  Both seem to be semi-retired now and do not blog much.  In my post we will not look at the strategies themselves, but rather the data that they use.

----

A few years ago I began to realize that the signals I was receiving (and trading on!) from my rotation strategies were occasionally inconsistent with the backtests of these same strategies.  I didn't spend much time digging into the issue at the time, but it remained in the back of my mind until late December, 2013.

For the trades that were generated from my systems for December 2013 (my rotation systems reassess monthly), I not only recorded the vehicles that were selected, but also their associated rotation rank/score.  I have been tracking this information in spreadsheets since that time...a period which currently includes nine rotation cycles (9 months).

In the middle of last month, August 2014, I decided to backtest my live rotation strategies across the same period that I had actively traded with these same rotation strategies.  I was not surprised to find that a number of the trades in the backtests did not match the trades I had actually executed and recorded in my spreadsheets.

I use AmiBroker and Yahoo! end-of-data data (Yahoo Data Info 1, Yahoo Data Info 2) for my rotation strategies.  I knew that Amibroker was configured by default to use the adjusted close rather than the actual close in it's database, but I didn't think too much about this detail.  I had been consciously using this adjusted close rather than the actual close for nearly ten years, but had not truly considered the impact of using adjusted close data with rotation/ranking strategies. The line in the AmiBroker aqh.format file that you should be aware of is highlighted below:

 
# AmiQuote historical quotes download format (.AQH extension)
# Revision 1.1 - removed $VOLFACTOR 0.01
$FORMAT Date_DMY,Open,High,Low,Close,Volume,AdjClose
$SKIPLINES 0
$BREAKONERR 0
$SEPARATOR ,
$DEBUG 1
$AUTOADD 1
$CONT 1
$GROUP 254
# the following switches are optional - please consult
# the read-me for description of those options
# $RAWCLOSE2OI 1   
# $RECALCSPLITS 1
# $ROUNDADJ 4

If you would like to use the actual close rather than the adjusted close in Ambroker, replace the highlighted line above, with the line below and re-download all of your historical data from Yahoo.

 
$FORMAT Date_DMY,Open,High,Low,Close,Volume

As a reminder, the adjusted close time series is a modified version of the actual close time series that includes gains from dividends and capital gains.  This means that a buy price shown in a backtest will not be the actual buy price that you could have received trading on that day (for any stock or ETF that at some point later in time issued a dividend or capital gain).  It is very important to think about this point and the impact it can have on your backtest versus live results!

This issue has a big impact on trade entry and exit signals with rotation/ranking systems...a system where a group of stocks/ETFs/mutual funds are being compared to each other based on open/high/low/close (OHLC) price data.

As an example, take a look at the historical data for the iShares Core US Aggregate Bond (AGG).  An excerpt of this historical data is shown in the image below.



If your rotation system happened to be using adjusted close prices and had AGG in its basket of rotation vehicles, AGG's score for August 29 would have been different on August 29 when you traded it, than when you run your backtest for that date on say September 2 (after the dividend issuance).  You will notice that the August 29 close is 109.98, but the adjusted close is 109.79...and this issue compounds with every dividend and capital gain that is issued...every past adjusted close is modified when a new dividend is issued.  Take a look at the difference between the adjusted close and actual close just two years ago:



The close on August 29, 2012 is 111.95, while the adjusted close on that date is 106.33.  As new dividends are issued in the future, the 106.33 adjusted close price will get increasingly smaller, which will have an impact on the rotation ranking/score for AGG in all backtests.  This same issue occurs with any vehicle that issues dividends and capital gains.

----

If we use actual closing prices for our backtests, we will generate signals based on prices that actually occurred in the past.  The trade off is that we will not see the positive impact of dividends and capital gains in the returns of our backtests.  As an illustration, I can show the results of several rotation strategy variations run against the following basket of ETFs:


In the image below, you can see the equity curves for several different rotation strategies run against the 10 ETFs in the list above, but using the adjusted close time series.  (click on the image to see a larger version).



In the top pane, the green, purple, and red lines are the equity curves for three different rotation strategies run against the 10 vehicles in the list above.  The other three curves are the "buy and hold" curves for SPY, IWM, and QQQ.  The lower pane displays SPY (orange), and the same green, purple, and red equity curves from the upper pane.  In addition, the lower pane contains seven equity curves for other rotation strategy variations on the same list of 10 ETFs.  The y-axis is percent return, while the text for each strategy lists the cumulative dollar return for that strategy (the initial capital for each strategy was $100,000).

Now let's look at the results for the exact same strategies run against the same 10 vehicles, but using the actual closing price time series data.  We expect the returns to be lower, since dividends and capital gains are not reflected in the time series.



The difference in equity curves is large, as expected.  But how do the entry and exit signals compare between the adjusted close data and the actual close data.

In the table below, is the comparison of entry and exit dates and vehicles for the strategy with the green equity curve in the above two charts.  Recall that the equity curves in the two charts above was generated by the same rotation strategy run against the same 10 ETFs in the list above...the only difference between the equity curves is the data...adjusted close data versus actual close data.


These are not vastly different selections between the adjusted close time series and the actual close time series with this rotation strategy and the 10 ETFs in the list above.  I have noticed significantly greater differences with different baskets of ETFs and mutual funds.

So what's the point?  Ideally, for rotation/ranking strategies we should generate our entry and exit signals based on the actual close time series, but calculate our returns on those trades using the adjusted close time series.  If we can only use one time series, then we should consider using the actual close time series rather than the adjusted close time series.  If we can live with equity curves that show smaller returns, using actual close time series data will result in generated entry/exit signals in our backtests that match our actual entry/exit signals that we received in real trading.

And one last point...be sure to check the data that paid and free rotation strategy services use...it's most likely adjusted close data...which means the signals they show in their backtests may not match the signals that they actually sent you!

Good trading!


11 comments:

Anonymous said...

Great point and excellent info! thanks
AZTrader

pcavatore said...

I think you are missing some points:
-if you want to get results from your backtest including dividends and other corporate actions you must use adjusted close
-you must beware of applying signals to adjusted price time series when using multiplication/division (like adjusted close) or summation/differentiation (like moving average). You can find more on this in the bible by Murphy "Technical Analysis of the Financial Markets"

Dave R. said...

AZTrader and pcavatore - thanks for your comments.

Dave

Anonymous said...

I agree with pcavatore. Why would you not want to use adjusted prices for all calculations as that will show the real return? Adjusted prices are there for that exact reason. Real close prices can generate false signals, i.e. price drop due to dividend.

Dave R. said...

I hope you both understand that with a ranking/rotation based system that operates on a static basket of vehicles (that pay dividends and cap gains), your system will generate different back test results every month that you test your system when you use adjusted data.

I challenge you both to run a rotation/ranking system on the last day of each month starting this month, and to write down the score/rank for each of the vehicles in your basket, along with the closing price...use buy-on-close orders...on the last day of each month. Record this information in a spreadsheet. Also, trade this in a real account...no paper trading!

After doing this for 12 months, of actual trading, using actual closing prices...run a backtest of this strategy on the adjusted price time series for this same basket of vehicles. You will very likely see that vehicles selected in your backtest do not actually match the vehicles selected in live trading.

This is the crux of the issue, and a point that is of concern when you have actual money at risk as opposed to theoretical dollars.

Thanks,
Dave

Anonymous said...

Why should we care if a backtest does not replicate live trading? What's of concern is whether live trading is profitable when run on a backtested model, not that the backtest doesn't replicate live trades after the fact. The adjusted close and the actual close are the one and the same on the real time trade date. So unless you can demonstrate that backtesting a model on adjusted close prices has a negative effect when placing live orders at the real time price or makes a backtest model extra prone to failure in real time, I fail to see what the alarm is for anything other than relative ranking schemes.

Dave R. said...

You just restated my point with your last sentence

"I fail to see what the alarm is for anything other than relative ranking schemes"

This is exactly the point...this is only an issue for relative ranking schemes. Many people and companies are selling relative rotation strategies, and they are touting their backtested performance with adjusted data.

The problem is the relative rank on the day that you get the signal from one of these systems (with the live data from that day!), may be different than when you run a backtest on that day at some point in the future using adjusted data. If there is a difference, it will be due to dividends and/or capital gains being issues for one or more of the vehicles in your relative ranking list.

Most of the articles that are published on this subject, are from people who do not actually trade. As soon as actual money is on the line, and the back tests do not match the forward tests...you'll question the theoretical performance of said system. One source of this mismatch is the data used in live trading versus the backtests.

Good luck,
Dave

Anonymous said...

That makes sense. So for the problem you've outlined, further in regards to AmiBroker is it downloads unadjusted from Yahoo, but imports as adjusted and only provides you the unadjusted closing price to use for PositionScore if you turn that option on. I see an issue in comparing the unadjusted close to adjusted O, H, L. This problem must have been what Ruggerio was alluding to a couple of years ago in regards to his Trader's Studio backtest software using three separate data streams (all provided by CSI which Yahoo sources from).

So overall very interesting and I'll make the appropriate adjustments to my backtests. It won't be a simple fix.

Dave R. said...

By default, Amibroker will load adjusted data. You can modify this behavior and have it load the actual/true price series by changing the $FORMAT line in the Formats\aqh.format file as noted above.

When Amibroker uses adjusted data, it modifies all of the fields (O,H,L,C) to reflect the adjustment. Here is an example:

AGG From Yahoo:
Date Open High Low Close Volume Adj Close*
Nov 18, 2011 109.73 109.73 109.44 109.62 805,700 101.60

AGG From Amibroker - Set to Use/Load Adjusted Prices Data:
Date Open High Low Close Volume
Nov 18, 2011 101.702 101.702 101.4332 101.6 805,700

If my ranking system is using this adjusted data, then I am not using actual prices that I could have received in real trading. More importantly, with every new dividend/cap gain payout the adjusted prices time series will change. This will impact ranking scores and can easily shift a lower ranked ETF/MF/Equity to a higher ranked position in backtesting.

Thanks for your comment,
Dave

Amleth said...

Please correct me if I am wrong. The issues you have highlighted here matter only if you rely on the absolute number of the adjusted data for your calculations.

However, if I were to use a momentum measure for ranking (e.g. 6 month returns), adjusted data is fine. This is because we are comparing a ratio (i.e. adjusted data now, vs adjusted data 6 months ago), and thus even if the adjusted data were to change with the passage of time, this ratio will still be the same.

Dave R. said...

Amleth, your argument makes sense and is what I believed to be true prior to trading these systems live. What I have personally experienced in my live trading is different

What I have seen several times is this: I receive a signal one month to enter a certain fund, say FLVCX. The next month when the next rotation signal is generated, the system indicates that I should have been holding a different fund in the prior month, FSCHX.

Also, the absolute values are not used for my momentum signals. I use AmiBroker's ROC formula: http://www.amibroker.com/guide/afl/roc.html

Thanks,
Dave

Post a Comment