Monday, August 6, 2012

Sell in May and go away?

Recently came across a paper which claims that the 'Sell in May and go away' strategy continues to work in many markets.

Here is the paper abstract:
Abstract:     
We perform the first out-of-sample test of the Sell in May effect studied by Bouman and Jacobsen (American Economic Review, 2002). Surprisingly to us, the old adage "Sell in May and Go Away" remains good advice. Reducing equity exposure starting in May and levering it up starting in November persists a profitable market timing strategy. The economic magnitude of the effect is the same in- and out-of-sample: on average, stock returns are about 10 percentage points higher in November to April semesters than in May to October semesters.  


10 percentage points out-performance with just 2 trades per year? I had to try this at home.

After about 30 minutes on a rainy afternoon with R and some friendly packages (hat tip to ggplot2, plyr, lubridate, xts) my hopes were dashed.

Nope, doesn't work in India.




If anything, it is: Buy in May and stay put till Santa Clause!
(sigh, doesn't rhyme!)

R code for those interested follows:


# Script to replicate 'Sell in May and Go away strategy' from the paper
# http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2115197
require(lubridate)
require(ggplot2)
require(plyr)
require(xts)
#
# Download data from http://nseindia.com, section index history
nifty <- read.csv('nifty_data.csv')
nifty.xts <- xts(nifty$Close, order.by=dmy(nifty$Date)) # let lubridate handle date stuff
nifty.xts.monthly <- to.monthly(nifty.xts) # let xts convert daily to monthly
nifty.xts.monthly$ret <- diff(log(nifty.xts.monthly$nifty.xts.Close)) # we use log returns, so that they add up
nifty.xts.monthly$month <- month(index(nifty.xts.monthly))
df.monthly <- data.frame(month=coredata(nifty.xts.monthly$month), ret=coredata(nifty.xts.monthly$ret))
# Aggregate the data month-wise using ddply
df.ggplot <- ddply(df.monthly, .(month), function(df) {mean(df$ret, na.rm=T)})
colnames(df.ggplot) <- c("month", "returns")
ggplot(df.ggplot, aes(x=month, y=returns)) + geom_bar(stat="identity") + opts(title="Nifty average monthly returns \n Analysis period: (Nov 98 to Apr 12)")