Overall Statistics |
Total Trades 25 Average Win 39.43% Average Loss -19.44% Compounding Annual Return 14.113% Drawdown 47.700% Expectancy 1.271 Net Profit 586.750% Sharpe Ratio 0.568 Loss Rate 25% Win Rate 75% Profit-Loss Ratio 2.03 Alpha 0.53 Beta -17.389 Annual Standard Deviation 0.324 Annual Variance 0.105 Information Ratio 0.506 Tracking Error 0.324 Treynor Ratio -0.011 Total Fees $1782.89 |
class LazyAssStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2004, 1, 1) self.SetEndDate(2018, 8, 1) self.SetCash(100000) self.monthCounter = 0 # Country index ETFs according to https://seekingalpha.com/etfs-and-funds/etf-tables/countries self.countryETFs = ["KSA", #Saudi Arabia "QAT", #Qatar "ENZL", #New Zealand "EIS", #Israel "EWL", #Switzerland "EWC", #Canada "EWH", #Hong Kong "SPY",#USA "EWZ", #Brazil "PIN", #India "GXG", #Colombia "EWU", #United Kingdom "EWA", #Australia "RSX", #Russia "NORW", #Norway "IDX", #Indonesia "EPHE", #Philippines "EWQ", #France "EPU", #Peru, "EWN", #Netherlands "EWD", #Sweden "PLND", #Poland "EWP", #Spain "PGAL", #Portugal "EIRL", #Ireland "EWT", #Taiwan "UAE", #United Arab Emirates "EWS", #Singapore "EWM", #Malaysia "EWJ", #Japan "VNM", #Vietnam "EGPT", #Egypt "THD", #Thailand "EWI", #Italy "EWW", #Mexico "GXC", #China "ECH", #Chile "EWG", #Germany "EWK", #Belgium "GREK", #Greece "EWO", #Austria "EWY", #South Korea "NGE", #Nigeria "EZA", #South Africa "PAK", #Pakistan "TUR", #Turkey ] for etf in self.countryETFs: self.AddEquity(etf, Resolution.Daily) self.weight = 1 self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY"), self.Rebalance) def OnData(self, data): pass def Rebalance(self): if self.monthCounter is 12: closes = self.History(self.countryETFs, TimeSpan.FromDays(365),Resolution.Daily).close grouped=closes.groupby(level=0) returns = (grouped.last()-grouped.first())/grouped.first() worstEtf = returns.idxmin() self.SetHoldings(worstEtf, self.weight, True) self.monthCounter = 1 else: self.monthCounter = self.monthCounter+1