Introduction

Pre-holiday days on the market are often characterized with lower liquidity as a lot of market participants are not involved in the market or they lower their exposure. Historical research shows that stock prices often behave in a specific manner in each of the two trading days preceding these holidays. This anomaly in Equities is often called the pre-holiday effect. It is the market in-efficiency for short-term traders to gain on the final trading day before a holiday. In this algorithm, we'll construct a simple strategy to exploit this pre-holiday effect in the Equity market.

Method

The TradingCalendar class can help us find all the available holidays during a period of time. GetDaysByType returns trading days of the specified TradingDayType that contains trading events associated with the range of dates. Here we choose the type to be TradingDayType.PUBLIC_HOLIDAY and list all holidays from today to the next two days. As PublicHoliday includes weekends, we use the type TradingDayType.WEEKEND to subtract weekend holidays.

def on_data(self, data):
    calendar1 = self.trading_calendar.get_days_by_type(TradingDayType.PUBLIC_HOLIDAY, self.time, self.time+timedelta(days=2))
    calendar2 = self.trading_calendar.get_days_by_type(TradingDayType.WEEKEND, self.time, self.time+timedelta(days=2))
    holidays = [i.date for i in calendar1]
    weekends = [i.date for i in calendar2]
    public_holidays = list(set(holidays) - set(weekends))

The investment vehicle is SPDR S&P500 ETF. The algorithm will trade the ETF if there are holidays within the next two days and stays in cash during other trading days.

if not self.portfolio.invested and len(holidays)>0:
    self.set_holdings("SPY", 1)
elif self.portfolio.invested and len(holidays)==0:
    self.liquidate()


Reference

  1. Quantpedia - Pre-Holiday Effect