Stock Market and US elections

September 19, 2012
By

(This article was first published on Quantitative Finance & Technical Trading » r-bloggers, and kindly contributed to R-bloggers)

Quantitative Finance, Technical Trading & Analysis. Fotis Papailias, Dimitrios Thomakos Quantitative Finance & Technical Trading Stock Market and US elections

We made a very simple R file that historically gathers the period before and after the US elections. The inexperienced user has the ability to set the tickers of asset she wants to study and the look-back and look-forward periods. Most of the functions are wrapped up and can be found in a separate file here http://www.quantf.com/download2/US-elections-procs.R , so that all experienced users can open and edit the source file.

Looking at SP-500, NASDAQ-100 and RUSSELL-2000 graphs we see that in 1980, 1984, 1988, 1992, 2000, 2004 and 2008 there was rise in the market some weeks before the elections (something similar happened last week due to the QE Fed announcement). Then we have an decrease and as we approach to the elections the market goes up again. A similar decrease started last Friday at the end of day and continued on Monday and Tuesday.

Bottomline: pre-elections periods can be tricky so have it in mind and be prepared!

 

# Written by D. Thomakos and F. Papailias
#
# Contact Details: [email protected]
# [email protected], [email protected]
#
# All material is provided for use as is, with no guarrantees, either expressed or implied.
# Copyright (C) under the authors' names Papailias, Fotis and Thomakos, Dimitrios for both
#
#-------------------------------------------------------------------------#
# Quantitative Finance & Technical Trading #
# http://www.quantf.com #
#-------------------------------------------------------------------------#
# 
# PLEASE MAINTAIN THIS HEADER IN ALL COPIES OF THIS FILE THAT YOU USE
# Remove everything to start from scratch
rm(list=ls(all=TRUE))
#------------------------ USER INPUT -----------------------------#
# Select the assets you need. Here we use SP-500, NASDAQ-100, RUSSELL-2000, TNA, TZA, FAZ, FAS
tickers.all <- c("^GSPC", "^NDX", "^RUT", "SPY")
ndays <- 60 # calendar days
nrows <- 60 # trading days
source("http://www.quantf.com/download2/US-elections-procs.R")
for(i in seq(1, length(tickers.all), 1))
{
 wrap.n.plot(prices, tickers.all[i], dates, ndays, nrows, ele)
}
us-ele-1 us-ele-2 us-ele-3

Quantitative Finance, Technical Trading & Analysis. Fotis Papailias, Dimitrios Thomakos Quantitative Finance & Technical Trading Stock Market and US elections

To leave a comment for the author, please follow the link and comment on his blog: Quantitative Finance & Technical Trading » r-bloggers.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: 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.