R/Finance 2012



This is a support page for the lighting talk I'm giving at the R/Finance 2012 conference. I will be speaking about "Seasonality Analysis and Pattern Matching" using R.

Here are the support documents:
To reproduce the charts for my presentation, please execute following R code:

###############################################################################
# Load Systematic Investor Toolbox (SIT)
###############################################################################
con = gzcon(url('http://www.systematicportfolio.com/sit.gz', 'rb'))
source(con)
close(con)

# Load supporting R code for R/Finance 2012 con=url('http://www.systematicportfolio.com/rfinance2012.r')
source(con)
close(con)

#***************************************************************** # Seasonality Analysis - TIME patterns #***************************************************************** # Load historical data #****************************************************************** load.packages('quantmod')
ticker = 'WMT' data = getSymbols(ticker, src = 'yahoo', from = '1970-01-01', auto.assign = F)
data = adjustOHLC(data, use.Adjusted=T)

data = data['1980::2012:04:07']
#***************************************************************** # Look at the Month of the Year Seasonality #****************************************************************** month.year.seasonality(data, ticker) #***************************************************************** # Look at What seasonally happens in the first 20 days of May #****************************************************************** # Find first day of May: it is one day after the last day of April month.ends = endpoints(data, 'months')
month.ends = month.ends[month.ends > 0 & month.ends < nrow(data)]
index = which(format(index(data), '%b')[month.ends] == 'Apr')

layout(1)
time.seasonality(data, 1 + month.ends[index], 20, ticker)



#***************************************************************** # Pattern Matching - PRICE patterns #***************************************************************** # Load historical data #****************************************************************** load.packages('quantmod')
ticker = 'SPY' data = getSymbols(ticker, src = 'yahoo', from = '1970-01-01', auto.assign = F)
data = adjustOHLC(data, use.Adjusted=T)

data = data['::2012:04:07']
#***************************************************************** # Find historical Matches similar to the last 90 days of price history #****************************************************************** matches = bt.matching.find(Cl(data), main = ticker, n.query=90, plot=TRUE) out = bt.matching.overlay(matches, plot=TRUE) #***************************************************************** # Find Classical Techical Patterns, based on # Pattern Matching. Based on Foundations of Technical Analysis # by A.W. LO, H. MAMAYSKY, J. WANG #****************************************************************** plot.patterns(data, 190, ticker)