Overall Statistics |
Total Trades 3358 Average Win 0.46% Average Loss -0.34% Compounding Annual Return 3.206% Drawdown 14.900% Expectancy 0.070 Net Profit 44.702% Sharpe Ratio 0.431 Probabilistic Sharpe Ratio 1.514% Loss Rate 55% Win Rate 45% Profit-Loss Ratio 1.36 Alpha 0.013 Beta 0.139 Annual Standard Deviation 0.066 Annual Variance 0.004 Information Ratio -0.592 Tracking Error 0.148 Treynor Ratio 0.206 Total Fees $4514.60 Estimated Strategy Capacity $48000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
# 12268 dynamic universe warm up with Ken Lu's original setup class FocusedAsparagusBeaver(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) self.SetCash(25000) self.userlist = ["QQQ"]; self.symbolData = {} self.AddUniverse(self.MyCoarseFilterFunction) self.UniverseSettings.Resolution = Resolution.Hour def MyCoarseFilterFunction(self, coarse): symbols = [x.Symbol for x in coarse if x.Symbol.Value in self.userlist] return symbols def OnSecuritiesChanged(self, changes): for added in changes.AddedSecurities: self.symbolData[added.Symbol] = SymbolData(self, added.Symbol) for removed in changes.RemovedSecurities: if removed.Symbol in self.symbolData: del self.symbolData[removed.Symbol] def OnData(self, data): if not len(data.Bars) > 0: return if not(self.IsMarketOpen(self.userlist[0]) and self.Time.hour >= 10):return for symbol, symbolData in self.symbolData.items(): price = self.Securities[symbol].Price currentHma = symbolData.hma.Current.Value previousHma = symbolData.delayed_hma.Current.Value tenkan = symbolData.ichimoku.Tenkan.Current.Value kijun = symbolData.ichimoku.Kijun.Current.Value chikou = symbolData.ichimoku.Chikou.Current.Value senkou_span_a = symbolData.ichimoku.SenkouA.Current.Value senkou_span_b = symbolData.ichimoku.SenkouB.Current.Value cloud_top = max(senkou_span_a, senkou_span_b) cloud_bottom = min(senkou_span_a, senkou_span_b) if not self.Portfolio.Invested and currentHma > previousHma and price > previousHma and price > chikou and price > cloud_top and (tenkan >= kijun or price > kijun): self.SetHoldings(symbol,1) elif not self.Portfolio.Invested and currentHma < previousHma and price < previousHma and price < chikou and price < cloud_bottom and (tenkan <= kijun or price < kijun): self.SetHoldings(symbol, 0) # Liquidate if self.Portfolio[symbol].IsLong and currentHma < previousHma and (price < previousHma or tenkan < kijun or price < tenkan or price < kijun or price < cloud_top or price < chikou): self.Liquidate() elif self.Portfolio[symbol].IsShort and currentHma > previousHma and (price > previousHma or tenkan > kijun or price > tenkan or price > kijun or price > cloud_bottom or price > chikou): self.Liquidate() class SymbolData: def __init__(self, algo, symbol): # initialize the indicators self.hma = HullMovingAverage(12) self.ichimoku = IchimokuKinkoHyo(9, 26, 26, 52, 26, 26) self.delayed_hma = IndicatorExtensions.Of(Delay(2), self.hma) # warm up history = algo.History(symbol, 52, Resolution.Hour) for bar in history.itertuples(): tradeBar = TradeBar(bar.Index[1], bar.Index[0], bar.open, bar.high, bar.low, bar.close, bar.volume) self.hma.Update(bar.Index[1], bar.close) self.delayed_hma.Update(bar.Index[1], bar.close) self.ichimoku.Update(tradeBar) # subscribe to auto update algo.RegisterIndicator(symbol, self.hma, Resolution.Hour) algo.RegisterIndicator(symbol, self.delayed_hma, Resolution.Hour) algo.RegisterIndicator(symbol, self.ichimoku, Resolution.Hour)