AuthorGurumeher Sawhney2018-08-09

Introduction

The momentum effect is a classic anomaly that says what was strongly going up in the past will probably continue to go up in the near future. The calculation performed uses the rate of change in price movements. We see this effect in REITs through studies where REITs with the highest annual past performance beat lower performing trusts. This strategy will take a long position in companies with the strongest momentum and rebalance quarterly.

Method

The first step is coarse and fine universe selection. During coarse selection, we create an investment universe of stocks that have prices greater than $1, contain fundamental data and do not have a very low trading volume for liquidity purposes. During the fine selection, we take all available REITs by using the Morningstar field IsREIT.

In the fine selection, we also calculate each REIT's past 11-month return one-month lagged and rank them. This is used to determine the top tercile of portfolio.

 def CoarseSelectionFunction(self, coarse):
    if self.quarterly_rebalance:
        self.filtered_coarse = [x.Symbol for x in coarse if (float(x.Price) > 1)
                                                        and (x.HasFundamentalData)
                                                        and float(x.Volume) > 10000]
        return self.filtered_coarse
    else: 
        return []      

def FineSelectionFunction(self, fine):
    if self.quarterly_rebalance:
        fine = [x for x in fine if (x.CompanyReference.IsREIT == 1)] 

        start = self.Time-timedelta(days = 365)
        end = self.Time-timedelta(days = 30)
        for x in fine:
            hist = self.History([x.Symbol],start,end,Resolution.Daily)
            if not hist.empty:
                start_price = hist["close"].iloc[0]
                end_price = hist["close"].iloc[-1]
                x.momentum = (end_price-start_price)/start_price

        fine = [x for x in fine if hasattr(x, 'momentum')]
        sorted_filter = sorted(fine, key=lambda x: x.momentum)
        self.filtered_fine = [i.Symbol for i in sorted_filter]
        return self.filtered_fine
    else:
        return []

In OnData(), we buy the stocks in the best performing tercile for three months and the portfolio is rebalanced every three months by a Scheduled Event.

def OnData(self, data):
    if not self.quarterly_rebalance: return 
    if self.filtered_fine:
        portfolio_size = int(len(self.filtered_fine)/3)
        long_stocks = self.filtered_fine[-portfolio_size:]
        stocks_invested = [x.Key for x in self.Portfolio]
        for i in stocks_invested:
            if i not in long_stocks:
                self.Liquidate(i) 
            elif i in long_stocks:
                self.SetHoldings(i, 1/(portfolio_size))
        self.quarterly_rebalance = False
        self.filtered_fine = False

Algorithm




Previous: Trading with WTI BRENT Spread Next: Option Expiration Week Effect