# Momentum Investing with R

This is my note for learning Momentum Investing with R.

In practice, momentum entails a look back into the past to determine whether an asset has exceed some benchmark, and if it has, buy and hold that asset for some benchmark, and if it has, buy and hold that asset for some time into the future. That’s completely flying in the face of the efficient market hypothesis because it’s positing that the past is somehow giving us information that has not been reflected in the current price of the asset.

We are going to implement a simplified version of a momentum strategy that deals with 4 assets:

• SPY: an SP500 ETF
• EFA: a global equities ETF
• AGG: a bond ETF
• TLT: a treasuries ETF

The strategy logic goes as follows: compare the previous twelve month’s returns of SPY to TLT. If the returns of SPY do not exceed those of TLT, hold bonds AGG for next month. If SPY returns do exceed TLT, compare the previous 12 months’ returns of SPY to EFA, whichever of SPY or EFA had the higher previous twelve months’ returns, hold that asset for the next month. Thus, each month, our strategy will hold either AGG, SPY, or EFA and we reexamine at the end of each month, That’s twelve look-backs per year, and twelve possible buy/sell transactions per year.

That is:

SPY <= TLT => hold AGG (Stock market is a bear market, so we hold bolds)
SPY >= TLT (Bull Market), hold asset with highest returns.

Recall that we wish to implement this flow:

1. if previous 12 months’ SPY return is lower than TLT’s, buy AGG this month, else move to step 2;
2. If previous 12 months’ SPY is higher then previous 12 months’ EFA, buy/hold SPY this month, else move to step 3.
3. If previous 12 months’ EFA is higher then previous 12 months’ SPY, buy/hold EFA this month.

It might be interesting or important to know when the strategy is holding AGG, SPY or EFA, so let’s create a column called strat_label that has the values bond, spy, and ex-us depending on where the strategy invests. That would allow us to calculate and visualize, for example, the proportion of time spent invested in EFA.

Our momentum strategy did not grow as much as a pure buy-sold strategy. Let’s check some summary statistics by using tq_performance() and table.Stats.

The momentum strat didn’t grow as much as buy-hold, but it had a far smaller max drawdown.

# R

Update your browser to view this website correctly. Update my browser now

×