Overall Statistics |
Total Trades 54 Average Win 4.77% Average Loss -2.07% Compounding Annual Return 10.447% Drawdown 33.300% Expectancy 0.721 Net Profit 58.676% Sharpe Ratio 0.627 Loss Rate 48% Win Rate 52% Profit-Loss Ratio 2.31 Alpha -0.005 Beta 1.164 Annual Standard Deviation 0.181 Annual Variance 0.033 Information Ratio 0.124 Tracking Error 0.094 Treynor Ratio 0.098 Total Fees $198.81 |
# https://quantpedia.com/Screener/Details/15 import pandas as pd from datetime import datetime class CountryEquityIndexesMomentumAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2015, 1, 1) self.SetEndDate(2015, 12, 21) self.SetEndDate(datetime.now()) self.SetCash(100000) # create a dictionary to store momentum indicators for all symbols self.data = {} period = 6*21 # choose ten sector ETFs self.symbols = ["VTI", "SPY", "EFA", "TLT", "EEM", "PUTW", "EMB"] # warm up the MOM indicator self.SetWarmUp(period) for symbol in self.symbols: self.AddEquity(symbol, Resolution.Daily) self.data[symbol] = self.MOM(symbol, period, Resolution.Daily) # shcedule the function to fire at the month start self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY"), self.Rebalance) def OnData(self, data): pass def Rebalance(self): if self.IsWarmingUp: return top = pd.Series(self.data).sort_values(ascending = False)[:5] for kvp in self.Portfolio: security_hold = kvp.Value # liquidate the security which is no longer in the top momentum list if security_hold.Invested and (security_hold.Symbol.Value not in top.index): self.Liquidate(security_hold.Symbol) added_symbols = [] for symbol in top.index: if not self.Portfolio[symbol].Invested: added_symbols.append(symbol) for added in added_symbols: self.SetHoldings(added, 1/len(added_symbols))