Welcome to QuantHead!

Welcome to QuantHead! I hope you find some interesting ideas here that I've encountered on my journey of learning and share your wisdom with me. Enjoy!

Sunday, November 30, 2014

Short-Term Trading with Impressive Backtested Returns

One of the things in addition to racking up commission costs that I don't like about most of the short-term trading (v.s. long-term investing) strategies that I've come across, is that most of them don't backtest well across multiple assets or markets. This in my mind decreases the robustness of a strategy in a big way.

A little while ago I came across two short-term trading strategies that backtest extremely well,
with nice stable equity-curves, even through 2008. Neither of the strategies are confined to a single asset.

Both strategies require a StockFetcher.com subscription (currently about $25 / quarter) to screen for the stocks to invest in. The nice thing is that you can set up e-mail alerts for the screens, so that you get daily e-mails after the market closes with the filtered stocks listed, to be bought at the open of the next day.

The first strategy I call "ROC Buy on Dips". It is based on a technical indicator called "Rate of Change" and it filters stocks that are in an upward trend, experiencing a short-term dip. For the backtest period from January 2008 to May 2013 the CAGR was +20.65% and Max DD (realized): -6.24%. The average time held per asset was 8 days. Here's the link to read more about the details and comments on the strategy. Here's the code to use in the "My Filters" section of the StockFetcher interface:

Fetcher[ 
S&P 500 
ROC(7,1) crossed below -2 
ROC(80,1) above 20 
close above MA(200) 
add column ROC(7,1) 
sort on column 5 ascending 
draw ROC(7,1) on plot ROC(80,1) 
]

The exit parameter is "ROC(7,1) > 2", which can for example checked easily on StockCharts.





The second I call "Z-Scored Reversion to the Mean". Here's the link to read more about it. For the backtest period of 1999-2009 the CAGR was +25.92% and Max DD (realized) -12.18%. Average time held per asset was 5 days, and interestingly Percent in Market was only 46.18%, meaning over 50% of the time this strategy was in cash or "risk-off".


Fetcher[
S&P500 

/*FIRST DETERMINE HISTORICAL RATIO OF S&P STOCK TO THE SPY OVER THE LAST 16 DAYS*/ 
SET{PRICERATIO, CLOSE / IND(^SPX,CLOSE)} 
SET{RATIOMA16, CMA(PRICERATIO,16)} 
SET{RATIOSTD16, CSTDDEV(PRICERATIO,16)} 
SET{DIFF16, PRICERATIO - RATIOMA16} 
SET{ZSCORE16, DIFF16 / RATIOSTD16} 
SET{THRESHOLD16, RATIOSTD16 * 2} 

/*NEXT, SET CRITERIA NECESSARY TO TRIGGER A PAIR TRADE*/ 

SET{UPPERBAND16, RATIOMA16 + THRESHOLD16} 
SET{LOWERBAND16, RATIOMA16 - THRESHOLD16} 

ZSCORE16 BELOW -2 
WILLIAMS %R(16) BELOW -94 
CLOSE BELOW LOWER BOLLINGER BAND(16,2) 
CLOSE ABOVE MA(200) 

DRAW LOWERBAND16 ON PLOT PRICERATIO 
DRAW UPPERBAND16 ON PLOT PRICERATIO 
DRAW BOLLINGER BANDS(16,2) 
ADD COLUMN ZSCORE16 {Z-score} 
ADD COLUMN WILLIAMS %R(16) 

DRAW ZSCORE16 LINE AT -1 
DRAW ZSCORE16 LINE AT -2 
DRAW ZSCORE16 LINE AT 0 

SORT ON COLUMN 5 ASCENDING 
CHART-TIME IS 6 MONTHS 
]

The exit parameters are "zscore16 > -1" or "days held > 20". To know when to exit, add the stocks you've bought to a watch list called "zscore_portfolio", and use this filter to show what the current zscore16 is for the assets:

Fetcher[ 

watchlist(zscore_portfolio) 

SET{PRICERATIO, CLOSE / IND(^SPX,CLOSE)} 
SET{RATIOMA16, CMA(PRICERATIO,16)} 
SET{RATIOSTD16, CSTDDEV(PRICERATIO,16)} 
SET{DIFF16, PRICERATIO - RATIOMA16} 
SET{ZSCORE16, DIFF16 / RATIOSTD16} 
SET{THRESHOLD16, RATIOSTD16 * 2} 

zscore16 above -1 
]






The downsides of these strategies are commissions; "ROC Buy on Dips" generates about 100 trades / year, "Z-Scored Reversion to the Mean" about 220 trades / year. Add roundtrip costs (buy and sell) and at a regular broker charging $18 / roundtrip the average costs would be around $1800 / year and $4000 / year. This kind of regular trading is where you really want a discount broker, for example Interactive Brokers, where roundtrip costs would be around $2 / trade.

December 2014 Allocations




Friday, November 21, 2014

All-Weather Permanent Portfolio

To mix things up again, amidst introducing various rotation strategies, I recently came across an interesting article on Seeking Alpha about a permanent portfolio that backtests pretty well over the last 42 years.

The portfolio consists of 30% U.S. stocks, 15% intermediate-term treasury bonds, 40% long-term treasury bonds, 7.5% gold and 7.5% commodities. Aggregate ETF's that can be used to implement this strategy are VOO (Vanguard S&P 500), IEF (iShares 7-10 Year Treasury Bonds), TLT (20+ Year Treasury Bonds), GLD (SPDR Gold Trust) and DJP (iPath Dow Jones-UBS Commodity Index Total Return). Schwab commission-free substitutes are SCHX, SCHZ, TLO, SGOL and USCI.

The only measure required after the initial investment is an annual re-balancing of the portfolio.

I tested the strategy on Portfolio Visualizer and came up with a CAGR of +9.55% and Max Drawdown -3.35%  vs. just holding U.S. stocks CAGR +10.35% and Max Drawdown -40.61%.

Yes, the CAGR is almost a percent lower than just holding stocks, however the difference in volatility is staggering. If you only looked at your portfolio once a year and suddenly noticed a decline of 40%, would you be worried, or be able to keep a cool head and hang tight? How about a decline of 3%, would you feel less inclined to sell your assets?

One of the things I like in addition to the long back-test period is the stable equity curve, which is almost at an optimal 45 degree angle. Of course to be noted is that the intra-year volatility (drawdown) can be higher than indicated in the stats or the graph.


.

Saturday, November 15, 2014

Simple Pair Switching and Multi-Asset Performance

Jan 22, 2015 Update: I've also created an automatically updating Google spreadsheet for this strategy.

Here's a similar strategy as the "KISS Low Volatility Rotation" I presented a few posts ago.
It's based on an article on Seeking Alpha by Marc Cohn: "Return Like a Stock, Risk Like a Bond",
which TrendXplorer optimized on Amibroker. With pair switching between FDVLX (Fidelity Value Fund) - VUSTX (Vanguard Long-Term Treasury Fund), he backtested the strategy to give a CAGR of 16.54% and Max DD of 14.90% during the test period of 1991-2013, with the look-back period set to 65 days and a smoothing value set to 15 days. The funds can be replaced with ETFs: SPY-TLT, MDY-TLT, SCHM-TLO (commission free on Schwab) or for a leveraged combination SSO-EDV. Notice how before the recent volatility spike in October 2014, the allocation was switched to the bond fund (VUSTX). I've attached a modified version of TrendXplorer's TOS (ThinkOrSwim) script below, which I call "Simple Pair Switching". 






Inspired by Marc Cohn's article, I also created a "Multi-Asset Performance Study" for TOS, which takes up to 10 user-specified assets and looks at the performance over a user-specified look-back period. The default settings for the assets are the ETFs in the screenshot below and for the look-back period, 85-days, which Marc used in his article. The cash proxy SHY is indicated by the white line in the middle. Note that the lines don't represent current price, but the return (for example SSO 1.09 means 9% return over the last 85 days).
There are several ways one could use this as a basis for a strategy, for example: invest in a balanced, diversified basket of all assets, unless an asset is under-performing the cash proxy SHY (i.e. below the white line), in which case substitute that asset with SHY/cash.  This cash-protection measure ensures that if assets become too correlated, or we enter an extended bear-market, one is either partially if not totally out of the under-performing markets.



I also included a version with smoothing, defaulting to a 65-day look-back period and a 15-day smoothing.




Simple Pair Switching Google Spreadsheet

Simple Pair Switching ThinkOrSwim Study

Multi-Asset Performance ThinkOrSwim Study

Multi-Asset Performance with Smoothing ThinkOrSwim Study

Friday, November 14, 2014

Spotlight: Varan

Varan is a regular contributor at Seeking Alpha, who among other things, presents and backtests various rotation strategies. Here are some of the most interesting strategies to me that he has devised or presented over the last few years.

I have not programmed Excel sheets or TOS codes to follow these strategies. If you find any of these intriguing, feel free to do so and share!

What I generally look for in a strategy is a good return, low drawdown and long enough backtest, which includes various market conditions. Of the following strategies, I'm most intrigued by the first one, because it has a backtest history of 20 years (and being a quarterly strategy, more data-points than the tri-annual strategies), a nice return and a very low drawdown. Though to be noted with any of the strategies, is that the intra-period drawdown can be higher; the drawdown indicated only takes into account the moment of rotation.

FBNDX FSUTX FSVLX FSAIX FSHOX FSENX FCYIX FSESX FSHCX FWRLX FBIOX FSAVX FSLBX FGMNX FSCSX FSRPX FIGRX FDLSX FFGCX FSDCX FSMEX FSLEX FSCGX FBMPX FSAGX FBSOX FSCPX FSPHX FSELX FIUIX FIDSX FSCHX FPHAX FSRBX FSPTX FFXSX FSTCX FDCPX FNARX FSNGX FSPCX FDFAX FSDAX FSDPX TLT (VUSTX)
- at the close of the first full week of each quarter, invest in top1 asset of best relative performance preceding 8 weeks, ending on the close of the previous week, for 13 weeks
- if the top ranked fund performed worse than TLT (bonds), invest in TLT for 13 instead
- 1991-2011 CAGR +25%, Max DD -11% (note that as with other strategies, intra-quarter drawdown can be more than 11%)
- note that these are mutual funds rather than ETFs, apart from TLT (VUSTX was used in the backtest prior to 2003 instead of TLT)

AWR AWK WTR ARTNA CTWS MSEX SJW YORW UGI WR SRE WEC ED SO BIP D NEE NGG OKE DUK
- annual rotation, first trading day of every year, select 10 assets of best annual performance prior year, if any performed worse than VBMFX (bonds), replace the assets with VBMFX
- 1991-2013 CAGR +15.3%, Max DD -12%  

GAB PDI PHK ETO GPM AWF BKT MMT CEF BIF MIN TLT IEF
- every four months (first trading day of January, May and September), invest in top2 assets of best relative performance over preceding 3 months
- 1991-2013 CAGR +23.8%, Max DD -12.7%

PIXDX, PIPDX, PETDX, PCRDX, PTTDX, PFSDX and PSSDX
- every four months (first trading day of January, May and September), invest in top2 assets of best relative performance over preceding 3 months
- 2004-2013 CAGR +25%, Max DD -16%
- note that these are mutual funds rather than ETFs

WPZ, SXL, RNF, PAA, NS, MWE, KMP, EXLP, FGP, DPM, BPL, BBEP, and BWP
- every four months (first trading day of January, May and September), invest in top2 assets of best relative performance over preceding 3 months
- if either two top assets performed worse than TLT (bonds), replace one or both with TLT
- 2004-2013 CAGR +32%, Max DD -20%

Thursday, November 13, 2014

Thoughts On Taxes And Commissions


One of the criticisms of rotation strategies, or any kind of active investment vs. a buy-and-hold-forever strategy is added costs involved, more specifically taxes and commissions.

Some methods to reduce or avoid taxes are to trade most actively in an IRA retirement account, where any earnings are tax-free. There are certain considerations to take into account when trading in an IRA or non-margin account. For example short-selling is not allowed, therefore one cannot execute a strategy such as the aforementioned "Hedged Convexity Capture".

Commissions vary wildly between brokerage companies. Charles Schwab charges $8.95 / trade for stocks and non-commission-free ETF's. Interactive Brokers charges around $1 / trade, however if monthly commissions are below $30, a $10 monthly market data subscription fee is collected. I've provided a table below with commission-free substitutes (at the time of this writing) for ETFs introduced in previous posts for both Schwab and TD Ameritrade. Note that the substitutes available are not exact equivalents, and there may be some price fluctuation between the assets.
For some of the ETFs there are no substitutes and a few are very illiquid, meaning a potential of a high bid-ask spread because of a low-traded volume.




KISS Low Volatility Rotation

The rotation strategies that I've introduced so far have been monthly, top1, 3-month momentum, no volatility weighting strategies. Let me explain: the usual variables for backtesting rotation models are frequency of rotation (e.g. weekly, bi-monthly, monthly, quarterly), asset quantity (e.g. invest in the top1, top2 or top3 performers at a time), momentum look-back period (e.g. x-months or x-days) and volatility (e.g. x-months or x-days).

The 3-month period momentum has worked well with various models, backtested over the last 10 years. This isn't to say though that in the future another look-back period wouldn't work better. In the interest of diversifying the look-back period and also including asset volatility in the mix (which often lowers the CAGR but also lowers the Max DD, making the strategy less volatile) I want to introduce a few other strategies, which may have not performed quite as well as some of the other strategies I've previously presented, but may or may not outperform the other strategies in the future.

First up is "KISS Low Volatility Rotation". I named it as KISS (keep it simple stupid), since rather than a big basket of ETFs, it only invests in either SPY (SPDR S&P 500 ETF) or TIP (iShares Treasury Inflation Protected Securities Bond ETF). If neither asset performs as well as holding cash, the model will rotate into cash or cash proxy SHY (Barclays 1-3 Year Treasury Fund). The return over the last 10 years has been a lot better than just holding the US total market (279% vs. 127% total return). The momentum look-back period is divided into two different look-back periods, and asset volatility is also taken into account, all with their own weightings. The CAGR is around +14%. Though quite a bit lower than in other strategies I've presented in previous posts, the Max DD is only around -13%, which is one of the lowest I've seen in models backtested for this long a period.

This strategy is very easy to implement for free, perfect if you don't prefer to deal with Excel sheets I've provided for other strategies or don't have access to the TOS platform.

Clicking on this link takes you to the ETF Relative Strength Backtest section of ETFreplay.com,
where you plug in the info from the screenshot below: First ETF: "SPY", Second ETF: "TIP", Update Schedule: "Monthly". You can select the backtest to start in "2004" if you want to see in detail how the strategy has performed. ReturnA: "6-months" (Weight: 60%), ReturnB: "36-months" (Weight: 10%), Volatility: "20-days" (Weight: 30%). At the beginning of each month you come back and check what the new asset is, for November it is "SPY" (scroll down to the bottom of the page and you see the signal was issued on Oct 31, 2014).


Tuesday, November 11, 2014

Simple GMR Rotation Model

Jan 8, 2015 Update: I've also created an automatically updating Google spreadsheet, which uses adjusted close prices.

Here's another momentum rotation strategy I'm currently using that goes by the name "Simple GMR" (simple global market rotation). It is very similar to the "Global Market Rotation" model that I presented a few posts ago. Instead of the leveraged SSO (ProShares Ultra S&P500) this strategy uses the non-leveraged MDY (S&P MidCap 400); instead of FEZ (Euro Stoxx 50), IEV (iShares S&P Europe 350) and instead of EDV (Vanguard Extended Duration Treasury) a less volatile TLT (iShares 20+ Year Treasury Bond). The basket of ETFs therefore consists of: MDY, IEV, ILF, EPP, EEM and TLT. IJJ can also be used instead of MDY, but I like MDY because of the higher traded volume.

The advantage of this model is that the assets are old enough to be backtested to 2003.
Courtesy of Portfolio Visualizer, for the backtest period of 2003-2013 the CAGR (compound annual growth rate) is an excellent +30.95% and Max DD (maximum drawdown) -17.67%.




The mechanics are similar as with "Global Market Rotation" and "Global Transportation with Commodities". At the beginning of each month the strategy invests into an asset that has outperformed the other assets with a look-back period of 3 months. At the beginning of the next month, if the new leading asset is different from the previous month, the current held asset is sold and the entire allocation is invested into the new asset. No cash-stop is used with this strategy.

As with the other rotation strategies, I've attached an Excel Sheet and a TOS study to help with figuring out which asset to rotate into at the beginning of each month:

QH Simple GMR Spreadsheet

Here are some links explaining more about similar models, including detailed backtests:

TrendXplorer
Varan (Seeking Alpha) 

Monday, November 10, 2014

Hedged Convexity Capture

Leveraged funds and inverse funds inherently suffer from degradation, especially over a longer time-period. This happens because they're rebalanced daily, so although a leveraged 3x ETF might meet its goal of performing at 300% of its benchmark on each individual day, over time the fund's performance in relation to the benchmark or index will likely be significantly different due to the effects of compounding, and won't be able to maintain its 3:1 performance. This degradation is referred to as "negative convexity".

Here's a strategy that takes advantage of this inherent degradation of the assets. I don't in any way advocate it as a safe investment. It involves short-selling leveraged inverse ETP's (exchange traded products), and carries additional risks, such as the broker closing the position early and theoretically unlimited risk. Since the ETP's are young, this strategy also hasn't been tested during a true down-market, such as 2008. However, the backtested returns are pretty amazing (CAGR: +53.5%, Max DD: -22.40%) and I like the idea of the strategy attempting to gain on the "crappiness" of inherently "crappy" products.

I've personally been using this strategy for a few months with a small allocation, and so far it has been very successful. An additional cost for this strategy is the interest rate that the broker charges for borrowing the assets; at Interactive Brokers it's currently 3%-3.5% per year.

1. Short TZA (Direxion Daily Small Cap Bear 3x ETF), 50% allocation
2. Short TMV (Direction Daily 20+ Year Treasury Bear 3x ETF), 50% allocation
3. Rebalance weekly to maintain the 50%/50% dollar value weighting between the two instruments




To help with the weekly rebalancing, I've attached a Rebalancing Tool that will automatically calculate how much to buy or sell, using the "Rebalance by Desired Target Percentage" section.
Enter the current values in their respective columns and the "Reallocation Target %" to 50% and 50%. You'll get values under the "Funds to transfer" column and whether to buy or sell under the Direction column. You can also use this tool to help with rebalancing your portfolio in general.


QH Rebalancing Tool (Excel)

To read more about this strategy, please see:
http://seekingalpha.com/article/2110753-part-v-hedged-convexity-capture-continues-to-be-the-worlds-best-performing-etf-strategy