Overall Statistics
Total Trades
930
Average Win
0.83%
Average Loss
-1.03%
Compounding Annual Return
7.481%
Drawdown
48.800%
Expectancy
0.320
Net Profit
372.131%
Sharpe Ratio
0.448
Probabilistic Sharpe Ratio
0.189%
Loss Rate
27%
Win Rate
73%
Profit-Loss Ratio
0.80
Alpha
0.083
Beta
-0.082
Annual Standard Deviation
0.172
Annual Variance
0.03
Information Ratio
0.011
Tracking Error
0.256
Treynor Ratio
-0.94
Total Fees
$1099.76
Estimated Strategy Capacity
$23000000.00
Lowest Capacity Asset
XLB RGRPZX100F39
# https://quantpedia.com/strategies/sector-momentum-rotational-system/
#
# Use ten sector ETFs. Pick 3 ETFs with the strongest 12-month momentum into your portfolio and weight them equally. Hold them for one month and then rebalance.

class SectorMomentumAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2000, 1, 1)  
        self.SetCash(100000) 
        
        # Daily ROC data.
        self.data = {}
        
        self.period = 12 * 21
        self.SetWarmUp(self.period)
        
        self.symbols = [
                        "VNQ",  # Vanguard Real Estate Index Fund
                        "XLK",  # Technology Select Sector SPDR Fund
                        "XLE",  # Energy Select Sector SPDR Fund
                        "XLV",  # Health Care Select Sector SPDR Fund
                        "XLF",  # Financial Select Sector SPDR Fund
                        "XLI",  # Industrials Select Sector SPDR Fund
                        "XLB",  # Materials Select Sector SPDR Fund
                        "XLY",  # Consumer Discretionary Select Sector SPDR Fund
                        "XLP",  # Consumer Staples Select Sector SPDR Fund
                        "XLU"   # Utilities Select Sector SPDR Fund
                        ]  
                        
        for symbol in self.symbols:
            data = self.AddEquity(symbol, Resolution.Daily)
            data.SetFeeModel(CustomFeeModel(self))
            data.SetLeverage(5)
            
            self.data[symbol] = self.ROC(symbol, self.period, Resolution.Daily)
            
        self.Schedule.On(self.DateRules.MonthStart(self.symbols[0]), self.TimeRules.AfterMarketOpen(self.symbols[0]), self.Rebalance)
        
    def Rebalance(self):
        sorted_by_momentum = sorted([x for x in self.data.items() if x[1].IsReady], key = lambda x: x[1].Current.Value, reverse = True)
        long = [x[0] for x in sorted_by_momentum[:3]]
        
        # Trade execution.
        invested = [x.Key for x in self.Portfolio if x.Value.Invested]
        for symbol in invested:
            if symbol not in long:
                self.Liquidate(symbol)
        
        for symbol in long:
            self.SetHoldings(symbol, 1 / len(long))
            
# Custom fee model
class CustomFeeModel(FeeModel):
    def GetOrderFee(self, parameters):
        fee = parameters.Security.Price * parameters.Order.AbsoluteQuantity * 0.00005
        return OrderFee(CashAmount(fee, "USD"))