投资范围包括所有英国上市公司,但市值最低的25%股票被排除以考虑流动性。通过排名公司过去12个月的市场表现,计算动量利润。投资者做多表现最佳的前10只股票,同时做空表现最差的后10只股票,投资组合等权重分配,并每年重新平衡。假设投资者账户规模为10,000英镑。

策略概述

投资范围包括所有英国上市公司(此为源学术研究中的投资范围,可轻松更换为其他市场——参考Ammann、Moellenbeck、Schmid的《美国股票市场的可行动量策略》)。为了流动性考虑,市值最低的25%股票被排除。动量利润通过对公司过去12个月的市场表现进行排名计算。投资者做多表现最好的前10只股票,做空表现最差的后10只股票。投资组合等权重分配,并每年重新平衡。假设投资者账户规模为10,000英镑。

策略合理性

学术研究强烈支持动量效应。该异常现象持久存在的主要原因是行为偏差,例如投资者的羊群效应、过度反应和反应不足、确认偏差等。另一种解释是股票对信息反应不足。例如,当公司发布好消息时,股票价格仅部分反应,之后购买股票仍能获利。

论文来源

Can small investors exploit the momentum effect? [点击浏览原文]

<摘要>

本研究使用英国数据,探讨小投资者是否能利用股价的持续效应。个体交易者无力像现有学术研究建议的那样买卖数百家公司的股票,因此本研究使用表现极端的公司来实施策略。我们发现,使用极端的赢家和输家时,动量收益显著。即使考虑到交易成本(如佣金、印花税、卖空成本和买卖价差),这些回报依然强劲。总体而言,我们显示出相当多的小投资者可以享受动量收益,这对股票市场效率提出了挑战。

回测表现

年化收益率32%
波动率N/A
Beta0.211
夏普比率-0.16
索提诺比率N/A
最大回撤86.2%
胜率50%

完整python代码

from AlgoLib import *

class MomentumEffectinStocksinSmallPortfolios(XXX):

    def Initialize(self):
        self.SetStartDate(2010, 1, 1)
        self.SetCash(100000)

        self.coarse_count = 500
        
        self.long = []
        self.short = []
        
        # Daily data.
        self.data = {}
        self.period = 12 * 21
        self.quantile = 10
        self.leverage = 5
        
        self.symbol = self.AddEquity('SPY', Resolution.Daily).Symbol
        
        self.selection_flag = True
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
        
        self.month = 11
        self.Schedule.On(self.DateRules.MonthStart(self.symbol), self.TimeRules.AfterMarketOpen(self.symbol), self.Selection)
    
    def OnSecuritiesChanged(self, changes):
        for security in changes.AddedSecurities:
            security.SetFeeModel(CustomFeeModel())
            security.SetLeverage(self.leverage)
    
    def CoarseSelectionFunction(self, coarse):
        # Update the rolling window every day.
        for stock in coarse:
            symbol = stock.Symbol

            if symbol in self.data:
                # Store daily price.
                self.data[symbol].update(stock.AdjustedPrice)
        
        # Selection once a month.
        if not self.selection_flag:
            return Universe.Unchanged
        
        # selected = [x.Symbol for x in coarse if x.HasFundamentalData and x.Market == 'usa']
        selected = [x.Symbol
            for x in sorted([x for x in coarse if x.HasFundamentalData and x.Market == 'usa'],
                key = lambda x: x.DollarVolume, reverse = True)[:self.coarse_count]]
        
        # Warmup price rolling windows.
        for symbol in selected:
            if symbol in self.data:
                continue
            
            self.data[symbol] = SymbolData(symbol, self.period)
            history = self.History(symbol, self.period, Resolution.Daily)
            if history.empty:
                self.Log(f"Not enough data for {symbol} yet")
                continue
            closes = history.loc[symbol].close
            for time, close in closes.iteritems():
                self.data[symbol].Price.Add(close)
                
        return [x for x in selected if self.data[x].is_ready()]
        
    def FineSelectionFunction(self, fine):
        fine = [x for x in fine if x.MarketCap != 0]
        
        # if len(fine) > self.coarse_count:
        #     sorted_by_market_cap = sorted(fine, key = lambda x: x.MarketCap, reverse=True)
        #     top_by_market_cap = sorted_by_market_cap[:self.coarse_count]
        # else:
        #     top_by_market_cap = fine
        
        # Performance sorting.
        performance = {x.Symbol : self.data[x.Symbol].performance() for x in fine}

        if len(performance) >= self.quantile:
            decile = int(len(performance) / self.quantile)
            sorted_by_perf = sorted(performance.items(), key = lambda x: x[1], reverse = True)
            self.long = [x[0] for x in sorted_by_perf[:decile]]
            self.short = [x[0] for x in sorted_by_perf[-decile:]]
        
        return self.long + self.short
            
    def OnData(self, data):
        if not self.selection_flag:
            return
        self.selection_flag = False

        # Trade execution.
        long_count = len(self.long)
        short_count = len(self.short)
        
        invested = [x.Key for x in self.Portfolio if x.Value.Invested]
        for symbol in invested:
            if symbol not in self.long + self.short:
                self.Liquidate(symbol)        
                
        for symbol in self.long:
            if symbol in data and data[symbol]:
                self.SetHoldings(symbol, 1 / long_count)

        for symbol in self.short:
            if symbol in data and data[symbol]:
                self.SetHoldings(symbol, -1 / short_count)
        
    def Selection(self):
        # Rebalance every 12 months.
        if self.month == 12:
            self.selection_flag = True

        self.month += 1
        if self.month > 12: 
            self.month = 1

class SymbolData():
    def __init__(self, symbol, period):
        self.Symbol = symbol
        self.Price = RollingWindow[float](period)
    
    def update(self, value):
        self.Price.Add(value)
    
    def is_ready(self):
        return self.Price.IsReady
        
    def performance(self):
        closes = [x for x in self.Price]
        return (closes[0] / closes[-1] - 1)

# Custom fee model
class CustomFeeModel(FeeModel):
    def GetOrderFee(self, parameters):
        fee = parameters.Security.Price * parameters.Order.AbsoluteQuantity * 0.00005
        return OrderFee(CashAmount(fee, "USD"))

Leave a Reply

Discover more from Quant Buffet

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

Continue reading