Two seasonal investors – R snippet

October 24, 2011

(This article was first published on » R, and kindly contributed to R-bloggers)

In “A tale of 2 Seasonal Investors“, the Big Picture discusses the simple idea of comparing two simple investment approaches: being exposed to the market 6 months every year (from November to April), as opposed to investing in the other 6 months of every year (from May to October).

Going back 50 years in the past, the first partition of the year gives more than 40 times the initial investment, whereas the other partition is barely profitable. This is the idea that brought on seasonal investing, with those who are money-savvy and who like to visit sites like for savings tips cottoning on to what was going on. The market can reach important lows and highs at certain times of the year and it is very valuable if you can keep track of these and work from them. Those who can capitalise on such statistics will find that they will go far in the investment world.

Below is some R code to verify this, and one could take this to research other highly asymmetries in seasonality.

getSymbols('^GSPC', from='1900-01-01')
d <- index(GSPC)
getMonth <- function(i) {
        as.numeric(format(i, format="%m"))
firstHalf <- function(i) {
        ifelse(getMonth(i) <= 4 || getMonth(i) >= 11, 1, 0)
hold1 <- unlist(lapply(d, firstHalf))
hold2 <- 1-hold1
hold1 <- xts(hold1, d)
hold2 <- xts(hold2, d)
perf <- merge(hold1 * ROC(GSPC[,4], type='discrete', n=1), hold2 * ROC(GSPC[,4], type='discrete', n=1))
colnames(perf) <- c("Nov - Apr", "May - Oct")

To leave a comment for the author, please follow the link and comment on their blog: » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


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)