ETFs Selection (Correlation matrix)
One way to select exchange-traded funds (ETFs) to include in your trading systems is by using a correlation matrix.
The idea is to pick two or three ETFs then select the remaining (depends on the number of exchange traded funds you want to use in your trading strategy) by choosing the ones that are less correlated with the first ETFs you have chosen.
Here is how to create the correlation matrix:
How to create a correlation matrix of several securities
In the next paragraphs, we will show you how to implement and optimize a trading system based on ETFs. This system will include the following ETFs:
SPY: SPDR S&P 500 ETF
=> Represents the stock market of the world's largest economy
IWM: iShares Russell 2000 Index
=> Small caps often behave differently from large cap stocks. One average, the annual return of small cap stocks exceeds the return of large cap stocks.
EFA: iShares MSCI EAFE Index ETF
=> Represents developed economies of several countries (Europe, Australia, Asia...)
EEM: iShares MSCI Emerging Markets
=> Emerging countries are very important because they are major contributors to the global economic growth. They have higher volatility (riskier) but they also offer great potential for higher returns.
AGG: iShares Barclays Aggregate Bond ETF
=> The Bond market is usually less volatile than the stock market and thus could reduce the drawdown and volatility of our strategies
VNQ: Vanguard REIT ETF
=> To add further diversification, it is important to include REITs (real estate investment trusts) investments.
GLD: SPDR Gold Shares
=> This ETF allows us to invest in a very attractive market: the gold market
DBC: PowerShares DB Commodity Index Tracking Fund
=> Based on the DBIQ Optimum Yield Diversified Commodity Index Excess Return, this fund invests in commodities futures, including light, Sweet Crude Oil (WTI), Heating Oil, RBOB Gasoline, Natural Gas, Brent Crude, Gold, Silver, Aluminum, Zinc, Copper Grade A, Corn, Wheat, Soybeans, and Sugar.
ETFs-based Trading System
The trading system consists of a buying the top four ETFs based on their momentum (or any other measure) and rebalance monthly. This means that each month, we will sell all active positions and buy the new top four ETFs.
Implementing the Trading System
Select "Analysis -> Simulator" then create a new trading system.
In order to buy the top 4 exchange traded funds, we will use the "comp" function. This function ranks securities, each trading bar, based on a specific criterion. In our case, we want to rank ETFs based on momentum and thus we will use the 25-bar (one month) rate of return to do this.
We should exit any position on the beginning of a new month only if it is not on the new buy list (top 4).
Here is the trading system formula:
buy = comp(roc(25), "rank") <= 4;
sell = month() != ref(month(), 1) and !buy;
Now, select "Symbols & Dates" tab, add a "Custom Symbols" condition under "Symbols" then copy the symbol names of the different exchange traded funds (see above).
Don't forget to set "The number of positions" field of the trading system to "4".
Momentum or any other measure
The next lines will show you how to choose a better measure to rank ETFs. We have previously used momentum as a measure but we can use QuantShare optimizer to analyze hundreds of measures and choose the one that performs best in our trading system.
This technique consists of creating several trading rules (measures in this case) then use the "ApplyRule" function to create several trading systems each one using a rule from the trading rules list.
- Select "Analysis" then "Rules Manager"
- Click on "Create" to add a new list
- Select your list then add several measures
close - sma(30)
hhv(30) - llv(30)
Here is how to create thousands of trading rules using the "Rules Manager" tool:
How to create and backtest thousands of trading rules in less than 10 minutes
10 masks to create thousands of rules to use into your trading system
Optimize your trading system
Now that we have created the initial trading system and a list of measures, let us combine them to create and backtest several trading systems in order to find the most profitable ones.
Update the original trading system then replace its formula by this one:
nbRules = ApplyRule("", "MyList", -1);
Optimize("m", 0, nbRules - 1, 1);
measure1 = ApplyRule("", "MyList", m);
buy = comp(measure1, "rank") <= 2;
sell = month() != ref(month(), 1) and !buy;
Line 1: Get the total number of rules/measures in your trading rules list "MyList" by specifying "-1" as last argument of the "ApplyRule" function
Line 2: Create an optimizable variable "m"
Line 3: Calculates the measure that is located at index (m) in the trading rules list "MyList"
Line 4: Use that measure when ranking ETFs
Save your trading system then click on "Optimize" to backtest the different variations of the trading system. Pick the most profitable one or choose one given your own metrics.
After selecting the best trading system, note the "m" index value, open the "Rules Manager", select your list of rules then select "Tools -> Display All Rules".
In the new form that appears, you can get the measure formula that corresponds to the "m" index.