The strategy invests in stocks near their 52-week lows, going long on the bottom 5% and shorting the remaining 95%. The portfolio is value-weighted, held for one month

I. STRATEGY IN A NUTSHELL

Investment universe: Common stocks listed on NYSE, AMEX, and NASDAQ with monthly price data from CRSP.

Sorting measure (LOW): Calculated as the stock’s nearness to its 52-week low over the prior month.

Portfolio formation:

Positions are held for one month, with a one-month skip between formation and holding to avoid look-ahead bias.

Go long on stocks in the lowest 5% of LOW (closest to 52-week lows).

Go short on the remaining 95%.

Portfolios are value-weighted.

II. ECONOMIC RATIONALE

Although the source study does not provide a definitive explanation, it shows that 52-week low proximity, 52-week high, and momentum strategies each contain unique, unpriced information relevant for cross-sectional stock returns.

This suggests that nearness to 52-week extremes reflects investor behavior not fully captured by traditional risk factors, potentially tied to anchoring, reference points, or market sentiment.

III. SOURCE PAPER

Nearness to the 52-Week High and Low Prices, Past Returns, and Average Stock Returns [Click to Open PDF]

Chen, National Chung Cheng University; Yu, National University of Kaohsiung

<Abstract>

This study examines the interactions between trading strategies based on the nearness to the 52-week high, the nearness to the 52-week low, and past returns. We offer evidence that the nearness to the 52-week low has predictive power for future average returns. Our results also reveal that the nearness to the 52-week high as well as to the 52-week low and past returns each have certain exclusive unpriced information content in the cross-sectional pricing of stocks. Moreover, a trading strategy based on the nearness to the 52-week low provides an excellent hedge for the momentum strategy, thereby nearly doubling the Sharpe ratio of the momentum strategy.

IV. BACKTEST PERFORMANCE

Annualised Return7.67%
Volatility11.44%
Beta0.272
Sharpe Ratio 0.67
Sortino Ratio0.095
Maximum DrawdownN/A
Win Rate30%

V. FULL PYTHON CODE

from AlgorithmImports import *
from pandas.core.frame import dataframe
class Nearnessto52WeekLow(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2000, 1, 1)
        self.SetCash(100000)
        market:Symbol = self.AddEquity('SPY', Resolution.Daily).Symbol
        
        self.fundamental_count:int = 3000
        self.fundamental_sorting_key = lambda x: x.MarketCap
        
        self.weight:Dict[Symbol, float] = {}
        self.data:Dict[Symbol, SymbolData] = {}
        
        self.period:int = 52 * 5 + 4*5
        self.quantile:int = 20
        self.leverage:int = 5
        self.min_share_price:float = 5.
        self.exchange_codes:List[str] = ['NYS', 'NAS', 'ASE']
        
        self.selection_flag:bool = False
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverse(self.FundamentalSelectionFunction)
        self.Settings.MinimumOrderMarginPortfolioPercentage = 0.
        self.Schedule.On(self.DateRules.MonthStart(market), self.TimeRules.AfterMarketOpen(market), self.Selection)
        
        self.settings.daily_precise_end_time = False
        
    def OnSecuritiesChanged(self, changes: SecurityChanges) -> None:
        for security in changes.AddedSecurities:
            security.SetFeeModel(CustomFeeModel())
            security.SetLeverage(self.leverage)
    def FundamentalSelectionFunction(self, fundamental: List[Fundamental]) -> List[Symbol]:
        # Update the rolling window every day.
        for stock in fundamental:
            symbol:Symbol = stock.Symbol
            if symbol in self.data:
                # Store daily price.
                self.data[symbol].update(stock.AdjustedPrice)
            
        if not self.selection_flag:
            return Universe.Unchanged
        
        selected:List[Fundamental] = [
            x for x in fundamental if x.HasFundamentalData and x.Market == 'usa' and x.SecurityReference.ExchangeId in self.exchange_codes and \
            x.MarketCap != 0 and x.Price >= self.min_share_price
        ]
        if len(selected) > self.fundamental_count:
            selected = [x for x in sorted(selected, key=self.fundamental_sorting_key, reverse=True)[:self.fundamental_count]]
        LOW:Dict[Fundamental, float] = {}
        # Warmup price rolling windows.
        for stock in selected:
            symbol:Symbol = stock.Symbol
            if symbol not in self.data:
                self.data[symbol] = SymbolData(self.period)
                history:dataframe = self.History(symbol, self.period, Resolution.Daily)
                if history.empty:
                    self.Log(f"Not enough data for {symbol} yet")
                    continue
                closes:pd.Series = history.loc[symbol].close
                for time, close in closes.items():
                    self.data[symbol].update(close)
            
            if self.data[symbol].is_ready():
                LOW[stock] = self.data[symbol].get_latest_price() / self.data[symbol].minimum()
        long:List[Fundamental] = []
        short:List[Fundamental] = []
        if len(LOW) >= self.quantile:
            # LOW sorting
            sorted_by_LOW:List[Fundamental] = sorted(LOW, key = LOW.get, reverse = True)
            quantile:int = int(len(sorted_by_LOW) / self.quantile)
            long = sorted_by_LOW[-quantile:]
            short = sorted_by_LOW[:len(sorted_by_LOW) - quantile]
        
        # Market cap weighting.
        for i, portfolio in enumerate([long, short]):
            mc_sum:float = sum(map(lambda x: x.MarketCap, portfolio))
            for stock in portfolio:
                self.weight[stock.Symbol] = ((-1) ** i) * stock.MarketCap / mc_sum
        
        return list(self.weight.keys())
        
    def OnData(self, data: Slice) -> None:
        if not self.selection_flag:
            return
        self.selection_flag = False
        # Trade execution.
        portfolio:List[PortfolioTarget] = [PortfolioTarget(symbol, w) for symbol, w in self.weight.items() if symbol in data and data[symbol]]
        self.SetHoldings(portfolio, True)
        self.weight.clear()
    def Selection(self) -> None:
        self.selection_flag = True
        
class SymbolData():
    def __init__(self, period: int):
        self._price:RollingWindow = RollingWindow[float](period)
    
    def update(self, price: float) -> None:
        self._price.Add(price)
    
    def is_ready(self) -> bool:
        return self._price.IsReady
     
    # Skip last month.
    def minimum(self) -> float:
        return min([x for x in self._price][4*5:])
        
    def get_latest_price(self) -> float:
        return self._price[0]
# Custom fee model.
class CustomFeeModel(FeeModel):
    def GetOrderFee(self, parameters):
        fee = parameters.Security.Price * parameters.Order.AbsoluteQuantity * 0.00005
        return OrderFee(CashAmount(fee, "USD"))

VI. Backtest Performance

Leave a Reply

Discover more from Quant Buffet

Subscribe now to keep reading and get access to the full archive.

Continue reading