FOMC Cycle Trading Strategy in Quantstrat

[This article was first published on Return and Risk, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Another hotly anticipated FOMC meeting kicks off next week, so I thought it would be timely to highlight a less well-known working paper, “Stock Returns over the FOMC Cycle”, by Cieslak, Morse and Vissing-Jorgensen (current draft June 2014). Its main result is:

Over the last 20 years, the average excess return on stocks over Treasury bills follows a bi-weekly pattern over the Federal Open Market Committee meeting cycle. The equity premium over this 20-year period was earned entirely in weeks 0, 2, 4 and 6 in FOMC cycle time, with week 0 starting the day before a scheduled FOMC announcement day.

The paper can be downloaded from here http://faculty.haas.berkeley.edu/vissing/CieslakMorseVissing.pdf.

In this post, we’ll look to recreate their cycle pattern and then backtest a trading strategy to test the claim of economic significance. Another objective is to evaluate the R package Quantstrat “for constructing trading systems and simulation.”

Data

Although the authors used 20 years of excess return data from 1994 to 2013, instead we’ll use S&P500 ETF (SPY) data from 1994 to March 2015 and the FOMC dates (from my previous post here http://www.returnandrisk.com/2015/01/fomc-dates-full-history-web-scrape.html).

As there is not a lot of out-of-sample data since the release of the paper in 2014, we’ll use all the data to detect the pattern, and then proceed to check the impact of transaction costs on the economic significance of one possible FOMC cycle trading strategy.

+ Show R code to setup and pre-process the required data

FOMC Cycle Pattern

The chart and table below clearly show the bi-weekly pattern over the FOMC Cycle of Cieslak et al in SPY 5-day returns. This is based on calendar weekdays (i.e. day count includes holidays), with week 0 starting one day before a scheduled FOMC announcement day (i.e. on day -1). Returns in even weeks (weeks 0, 2, 4, 6) are positive, while those in odd weeks (weeks -1, 1, 3, 5) are lower and mostly slightly negative.

Table of Returns by FOMC Week, Days & Phase

WeekDaysPhaseAverage 5-day Return (%)
-1-6 to -2Low0.14
0-1 to 3High0.59
14 to 8Low-0.05
29 to 13High0.32
314 to 18Low-0.12
419 to 23High0.45
524 to 28Low-0.10
629 to 33High0.69
+ Show R code for the custom indicator function for the FOMC cycle and the above chart

Economic Significance: FOMC Cycle Trading Strategy Using Quantstrat

In this section, we’ll create a trading strategy using the R Quantstrat package to test the claim of economic significance of the pattern. Note, Quantstrat is “still in heavy development” and as such is not available on CRAN but needs to be downloaded from the development web site. Nonetheless, it's been around for some time and it should be up to the backtesting task…

Based on the paper’s main result and our table above confirming the up-phase is more profitable, we’ll backtest a long only strategy that buys the SPY on even weeks (weeks 0, 2, 4, 6) and holds for 5 calendar days only, and compare it to a buy and hold strategy. In addition, we’ll look at the effect of transaction costs on overall returns.

A few things to note:

  • We’ll use a bet size of 100% of equity for all trades. This may not be optimal in developing trading systems but will allow for easy comparison with the buy and hold passive strategy, which is 100% allocated
  • Assume 5 basis points (0.05%) in execution costs (including commission and slippage), and initial equity of $100,000
  • Execution occurs on the close of the same day that the buy/sell signal happens. Unfortunately, Quantstrat does not allow this out-of-the-box, so we need to do a hack - a custom indicator function that shifts the signals forward in time (see “get.fomc.cycle” function above)

The following are the resulting performance metrics for the trading strategy, using 5 basis points for transaction costs, and comparisons with the passive buy and hold strategy (before and after transaction costs).

Summary Performance for Trading Strategy

##                           return
## Annualized Return         0.0855
## Annualized Std Dev        0.1382
## Annualized Sharpe (Rf=0%) 0.6183

Trade Statistics

##     Symbol Num.Trades Percent.Positive Net.Trading.PL Profit.Factor
## spy    spy        525         59.61905       468196.8      1.587279
##     Max.Drawdown
## spy    -107436.8

Monthly Returns

##       Jan  Feb  Mar  Apr  May  Jun  Jul  Aug   Sep  Oct  Nov  Dec Total
## 1994   NA -2.4 -1.8  0.5  1.2  2.6  0.1 -0.9   0.2  5.7  0.3  0.4   5.8
## 1995  0.9  3.2  0.3  1.9  1.8  0.8  2.1  0.1   1.7 -0.9  1.0  0.2  13.9
## 1996  3.6 -3.3  1.5 -1.6  2.9  1.3 -0.8  3.1   0.8 -1.5  1.2 -0.3   6.9
## 1997  3.1 -0.3  0.4 -3.5  3.1  1.5  3.6  2.8   5.8 -2.6  3.1  5.3  24.1
## 1998  4.5  3.2  2.5  3.7  1.1  1.8  1.2 -5.6  -0.1  9.4  0.0  5.4  29.6
## 1999  1.9  0.9  2.2 -3.8 -0.5  8.9  0.8  3.2  -4.7  8.3  0.9  5.8  25.4
## 2000 -2.7 -0.3  6.1  6.3  1.0  2.9  0.6  0.3  -2.5  2.3 -3.7  0.6  10.8
## 2001  0.1 -6.1  0.0  2.2  2.3 -2.7  3.5  0.8 -15.7  0.5  4.2 -2.2 -13.9
## 2002 -3.1 -3.9  2.5 -0.5 -3.9 -2.1  0.6 -1.1  -2.5  5.8 -0.1 -5.9 -13.8
## 2003  2.6  1.5  3.4  6.8 -0.9  3.4  1.4  2.9   1.4  4.6  1.8  1.7  35.2
## 2004 -1.3  1.2  1.6  0.7 -1.3  0.6 -1.2  1.0  -0.9 -2.4  1.6  0.4   0.0
## 2005 -0.6  1.2  0.4  1.5  3.3  0.9  1.8 -1.4   0.0 -3.2  1.2 -0.3   4.6
## 2006 -0.8 -0.4  1.9 -0.6 -0.6  0.3 -1.5 -1.8  -0.8  1.6 -1.3  1.6  -2.6
## 2007  2.6 -0.8 -0.6  2.3 -1.0 -0.4 -0.7  2.9   1.3 -2.1  2.1 -3.2   2.2
## 2008  0.5 -1.4  2.3  6.4  5.6 -4.2 -2.5  1.9  -8.4 15.3 -2.2 -5.9   5.5
## 2009 -2.8 -6.4  5.0  3.9  7.8  4.7  3.5 -3.3   2.8  0.6  4.4 -0.5  20.5
## 2010 -1.7  3.0  2.1 -1.8  0.6  0.0  9.7 -4.4   2.4  2.0  2.6  4.0  19.5
## 2011  1.2 -0.1 -1.1  1.7 -0.5 -1.1  0.8  2.8  -5.2 13.3  0.0 -4.0   6.9
## 2012  0.5  1.0  3.1  0.1 -2.3  0.0 -2.1  1.9   1.6 -1.4 -1.4  0.8   1.8
## 2013  0.3  1.7  0.7  0.8  2.0 -3.6  2.2 -3.0   0.1  1.2  1.8  2.4   6.5
## 2014 -0.3  0.5 -0.9  1.3  0.5  1.2 -1.8  2.3   0.1  3.8  0.0  2.1   9.0
## 2015 -5.4  3.3  0.6   NA   NA   NA   NA   NA    NA   NA   NA   NA  -1.7

Summary Performance for Benchmark Buy and Hold Strategy

##                           return
## Annualized Return          0.0915
## Annualized Std Dev         0.1935
## Annualized Sharpe (Rf=0%)  0.4727

Comparison of Trading Strategy with Buy and Hold (BEFORE transaction costs)

Comparison of Trading Strategy with Buy and Hold (AFTER transaction costs)

+ Show R code for the trading strategy using Quantstrat

Conclusion

FOMC Cycle Pattern

We were able to clearly see the bi-weekly pattern over the FOMC cycle using SPY data, a la Cieslak, Morse and Vissing-Jorgensen.

Economic Significance: FOMC Cycle Trading Strategy

Before transaction costs, we were able to reproduce similar results to the paper, with the long only strategy of buying the SPY in even weeks and holding for 5 days. In our case, this strategy added about 2% p.a. to buy and hold returns, reduced volatility by 30% and increased the Sharpe ratio by 70% to 0.82 (from 0.47).

However, after allowing for a reasonable 5 basis points (0.05%) in execution costs, annualized returns fall below that of the buy and hold strategy (9.15%) to 8.55%. As volatility remains lower, this means the risk-adjusted performance is better by only 30% now (Sharpe ratio of 0.62). See table below for details.

Buy and HoldLong Only before Transaction CostsLong Only with 5bp Transaction Costs
Annualized Return0.09150.11290.0855
Annualized Std Dev0.19350.13820.1382
Annualized Sharpe (Rf=0%)0.47270.81690.6183

Execution costs (brokerage and slippage) can have a material impact on trading system performance. So the key takeaway is to be explicit in accounting for them when claiming economic significance. There are a lot of backtests out there that don’t…

Quantstrat

There is a bit of a learning curve with the Quantstrat package but once you get used to it, it’s a solid backtesting platform. In addition, it has other capabilities like optimization and walk-forward testing.

The main issue I have is that it doesn’t natively allow you to execute on the daily close when you get a signal on that day’s close - you need to do a hack. This puts it at a bit of a disadvantage to other software like TradeStation, MultiCharts, NinjaTrader and Amibroker (presumably MatLab too). Hopefully the developers will reconsider this, to help drive higher adoption of their gReat package…

Click here for the R code on GitHub.

To leave a comment for the author, please follow the link and comment on their blog: Return and Risk.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)