Tactical Asset Allocation
Author: jakem5150
Creation Date: 1/10/2013 9:37 PM
profile picture

jakem5150

#1
HI,

I was wondering if it's possible to set up a code to backtest Mebane Faber's claims of tactical asset rotation that he discusses in his book Ivy Portfolio? Since etfs don't have enough history to backtest, would it be possible to backtest u.s. stocks(s@p), foreign stocks(msci eafe), u.s. bonds(10 year treasuries), commodities(gsci), and real estate(nareit)? Mebane backtests them on price performance and ranks them using a combination of 3, 6, and 12 month returns and chooses the one that performed the best. I would be very interested to know how this performed using the top etf and rotating every month. If there could be some kind of functionality that would let you choose between top 1, top 2 or top 3, that would be great. Thank you very much and I would greatly appreciate your help in this.
profile picture

Eugene

#2
As far as I understood, the task falls into Symbol Rotation group but the idea is to rotate whole asset classes, not within a given group like ETFs? But if you're willing to make things simple, we'll avoid that factor of complexity. I also saw a requirement that the instrument must also be over the 10-month SMA (i.e. roughly 200-day SMA) to be candidates. Here's a quick take on the rules:

CODE:
Please log in to see this code.
profile picture

topcat77

#3
I managed to install this strategy code onto my WL and it works usefully -with interesting results - except for one quirk.
The Results by Symbol visualiser totals bear no resemblance to the summary Performance sheet or to a summation of individual Trades. am I missing something about the strategy ?
profile picture

Eugene

#4
Actually, the fact you`re seeing this visualizer indicates that you`re incorrectly running it in Multi-Symbol backtest mode. Remember, rotational strategies should be executed in single symbol mode. Then, By Symbol will not appear at all -- and this will be correct.

FAQ: A Rotation strategy isn`t working like it should

On a related note, any rotational systems (or other code that trades with SetContext inside a DataSetSymbols loop) are not compatible with such visualizers as Analysis Series, By Symbol (maybe others).
profile picture

Lieuallen

#5
Excellent code, and an interesting strategy to consider. I tried to put together some broad "indices" (RYMEX, VBMFX, VFINX, VGSIX and VHGEX), but the results weren't what I had hoped. Just for interest's sake, run this code on the Nasdaq 100 data set -- impressive performance, although the drawdown is more than I think I could stomach. And why do so many strategies seem to "peter out" in 2011 and 2012?

profile picture

RickTg

#6
I have read

FAQ: A Rotation strategy isn`t working like it should

but it does not answer my questions.

After opening the strategy in my workspace, I clicked on a single symbol in the appropriate dataset and all I got was a plot but the test results that I got for net profit was the same as return on cash.

How do I activate a single symbol backtest for a rotation strategy? And how does the strategy know that the backtest is for all the symbols in the dataset?
profile picture

Eugene

#7
You've already "activated" it so to speak by clicking on a single symbol. Look for such things as the number of skipped trades (check position sizing) and potentially insufficient data loading settings (at least 200 daily bars are required just to get the ball rolling). If still no go, please provide more details:

1. Is Strategy code unmodified?
2. Symbol(s) and Data provider
3. Which symbol did you click?
4. Position Sizing and Data Loading settings
5. Describe the problem in detail. What does it mean "no test results"? To clarify explanations, you might want to attach a screen shot in PNG format.
profile picture

RickTg

#8
Sorry - our posts crossed paths.

Strategy code is unmodified.

BND DBC GSG RWX TIP VB VEU VNQ VTI VWO from Yahoo

I clicked the first symbol in the list.

Position sizing 33% of equity. On demand data updates.

What I got was a plot of the clicked symbol and the performance indicated no trades with a net profit which was the same as return on cash.
profile picture

RickTg

#9
I reran the strategy using a daily timeframe and it appeared to work. However, it is a monthly strategy, so 200 bars minimum would mean a start of at most 16.6 years ago.

I examined the code in more detail and I now see why it requires at least 200 bars to get the ball rolling.

I apologize for wasting your time.

Thanks

Rick
profile picture

Eugene

#10
Rick,

No problem. Glad you got it sorted.

You might also want to disable "Min.holding time" by making the following changes to the code because this logic is working incorrectly:

CODE:
Please log in to see this code.


P.S. Here's a design pattern shared by LenMoz that incorporates "Minimum holding period" without triggering the bug: click here.
profile picture

PFNikolai

#11
Eugene: Thanks for adding the TAA strategy to the pre-made Explore & Backtest section--very helpful for us newbs...

For other newbs: To download all new pre-made strategies click Home > Explore & Backtest > Download > Begin Download and they will be added to the folders in the Explore & Backtest section.
profile picture

rbryant

#12
Hi
I wanted to add two filters to this rotation strategy: I added MACD>0, and CCI>0. I have two questions:

1. Have I added the filters correctly? I don't understand the use of holder.[ ].
2. How do I call the values of MACD and CCI at an entry bar in the PrintDebug() function to check they are above 0?

Thank you very much in advance
Regards
Rod

CODE:
Please log in to see this code.
profile picture

Eugene

#13
Hi Rod,

Corrected your new CCI/MACD filter and the usage of RiskStopLevel. (The ATR should be defined inside a holder, not the way you did.) Made a couple more fixes i.e. added GetTradingLoopStartBar with a proper starting period. Also added a PrintDebug as requested:

CODE:
Please log in to see this code.
profile picture

rbryant

#14
Eugene

Thanks. You're a rockstar.

Regards
Rod
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).