# Tsiakas(2010) tested since 1962 that: preholidays, postholidays, and prelong weekends
# have significantly higher mean and lower volatility than regular trading days
# whereas postlong weekends have lower mean and higher volatility.
newStrategy("holiday")
Universe("SPX")
require(timeDate)
# on the OHLCV frame, mark preholidays as TRUE, others as FALSE
HOL <- CJ(Instrument=unique(OHLCV$Instrument),
Date=as.IDate(holidayNYSE(1800:2015))) [,PreHoliday:=TRUE]
PREHOL <- HOL[OHLCV[,list(Instrument,Date)],roll=-1][is.na(PreHoliday),PreHoliday:=FALSE]
advanceBarsForSig <- 2 # anticipate signal n days in advance
preholiday <- indicator( anticipate(PreHoliday, advanceBarsForSig, pad=F), input=PREHOL)
Long <- (preholiday==TRUE) %position% shares(1)
Neutral <- (preholiday!=TRUE) %position% shares(0)
Backtest()