Site icon R-bloggers

Stock Market and US elections

[This article was first published on Quantitative Finance & Technical Trading » r-bloggers, 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.

Quantitative Finance, Technical Trading & Analysis. Fotis Papailias, Dimitrios Thomakos Fotis 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: papailias@quantf.com
# dimitrios.thomakos@gmail.com, thomakos@quantf.com
#
# 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)
}

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

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

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.