Original link:http://tecdat.cn/?p=23141

The quantitative tactical asset allocation strategy (QATAA) model uses a 10-month moving average as a filter. If the asset’s price is above its moving average at the end of the month, stay in the market. Otherwise they will leave the market.

What’s so special about 10 months? Why 10 months is the same for all assets and zones? I came up with the idea of adjusting the moving average backtracking based on historical volatility. That is, during periods of high volatility, a shorter moving average allows us to get out of the market faster, while during periods of low volatility, a longer moving average allows us to stay in the market. However, this leads to worse results.

I spent some time analyzing the basic 10-month moving average strategy and saw quite a lot of losses. The simple solution is to use a +/-5% band around the 10-month moving average to reduce losses and increase gains.

I’ll show you how this concept works.

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # load historical data # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # agent loading save raw data tickers = 'SPY CASH = SHY + TB3Y' # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # is used for displaying the auxiliary function of the signal #***************************************************************** signal = iif(model == 'base', prices > sma, Plot (p\[dates\],type='l', plotX=F, plot(p\[dates\], plotX=F, x.highlight = highlight)

visuali('2000::2001')

The advantage of delayed entry/exit is low volume and low volume.

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # Settings #***************************************************************** models = list() #***************************************************************** # SPY #****************************************************************** run(data) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # filter SPY + 10 months #****************************************************************** apply(prices, SMA, 10*22) iif(prices > sma, 1, 0) CASH = 1 - ifna( ifna(SPY), 0) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # SPY + 5 / + 10 months - 5% filter # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (cross (prices, sma * 1.05), (prices, sma * 0.95), 0, NA)

I have also included my attempts to dynamically backtest moving averages, which are not practical in this form.

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # SPY + dynamic filter based on volatility # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * vol = matrix (ret, SD, n = 21) if (vol. Rank < 0.5, bt(prices, SMA, 10\*22),matrix(prices, SMA, 22)) data $w # 1 \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # SPY + dynamic filter based on volatility; Multiple levels # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * nbreaks = 5 sma in cash = sma * NA for (I in 1:nbreaks) { temp = data(matrix(prices, SMA, (nbreaks - I + 1) * 2 * 22)} # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # report #***************************************************************** plot(models)

SPY

SPY.CASH

SPY.CASH.BAND

SPY.CASH.VOL.SIMPLE

SPY.CASH.VOL

Period

Jan1993 – Feb2015

Jan1993 – Feb2015

Jan1993 – Feb2015

Jan1993 – Feb2015

Jan1993 – Feb2015

Cagr

9.4

9.9

12.1

9.2

8

DVR

41.9

78.3

91.4

83.8

74

Sharpe

56.7

83.6

97.1

90.8

77.1

R2

73.9

93.7

94.1

92.3

96

Win.Percent

100

41.1

100

45.7

43.3

Avg.Trade

623.7

1.9

27.6

0.7

0.7

MaxDD

55.2

20.1

19.1

15.9

22.3

Num.Trades

1

146

12

302

254

barplot(turnover, data)

Next, let’s apply the same banded strategy to the TAA model.

Data < -new.env () getSymbols(tickers); SRC = 'yahoo') # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # Settings #***************************************************************** universe = prices > 0 models = list() # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # benchmark #***************************************************************** weight\[\] = NA # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # The \ [tactical asset allocation strategy of quantitative methods (QATAA) Mebane T. Faber\](http://mebfaber.com/timing-model/) #\[SSRN \](http://papers.ssrn.com/sol3/papers.cfm?abstract_id=962461) #***************************************************************** weight = iif(prices > sma, 20/100, 0) run (data) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # bands alternative moving average # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * signal = the if (cross (prices, sma * 1.05), 1, Iif (cross.dn(prices, SMA * 0.95), 0, NA) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # report #***************************************************************** #performance(models, T)

SP500

EW

Model

Model.B

Period

Jun1996 – Feb2015

Jun1996 – Feb2015

Jun1996 – Feb2015

Jun1996 – Feb2015

Cagr

8.2

8.6

9.8

10.6

DVR

28.7

64

117.4

127.9

Sharpe

49.2

69.3

120.4

132.7

R2

58.4

92.4

97.5

96.5

Win.Percent

100

59.9

64.4

64.6

Avg.Trade

335.7

0.1

0.2

0.2

MaxDD

55.2

47.5

17.1

13.1

Num.Trades

1

1113

930

887

layout(1)
barplot(sapply(models,turnover)

The ribbon logic is easy to implement and increases revenue.


The most popular insight

1. Use LSTM and PyTorch in Python for time series prediction

2. LSTM, a long and short term memory model, is used in Python for time series prediction analysis

3. Use R language to conduct ARIMA (exponential smoothing) analysis

4. R language multivariate Copula-GARCH-model time series prediction

5. R language copulas and financial time series cases

6. R language random fluctuation model SV is used to deal with random fluctuations in time series

7. TAR threshold autoregressive model for R language time series

8. K-shape time series clustering method of R language is used to cluster the time series of stock prices

9. Python 3 uses ARIMA model for time series prediction