Overall Statistics |
Total Trades 181 Average Win 54.76% Average Loss -5.73% Compounding Annual Return 3629.234% Drawdown 76.700% Expectancy 3.177 Net Profit 14543.389% Sharpe Ratio 108.508 Probabilistic Sharpe Ratio 99.313% Loss Rate 60% Win Rate 40% Profit-Loss Ratio 9.56 Alpha 246.447 Beta 0.47 Annual Standard Deviation 2.272 Annual Variance 5.164 Information Ratio 108.332 Tracking Error 2.274 Treynor Ratio 524.38 Total Fees $22212.16 Estimated Strategy Capacity $5700000.00 Lowest Capacity Asset GME SC72NCBXXAHX |
# Ta-Lib Candlestick with RollingWindow import numpy as np import talib class TaLibCandlestick(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetEndDate(2021, 5, 17) self.SetCash(100000) self.SetWarmUp(15) self.sym = self.AddEquity('GME', Resolution.Hour).Symbol self.rollingWindow = RollingWindow[TradeBar](15) self.Consolidate(self.sym, Resolution.Hour, self.CustomBarHandler) def OnData(self, data): if not self.rollingWindow.IsReady: return O = np.array([self.rollingWindow[i].Open for i in range(15)]) H = np.array([self.rollingWindow[i].High for i in range(15)]) L = np.array([self.rollingWindow[i].Low for i in range(15)]) C = np.array([self.rollingWindow[i].Close for i in range(15)]) pattern = [] pattern.append(talib.CDLBELTHOLD(O, H, L, C)) pattern.append(talib.CDL3INSIDE(O, H, L, C)) self.Debug(pattern) isPattern = False for l in pattern: if l.any() > 0: # self.Debug('Pattern found') isPattern = True break if isPattern: self.SetHoldings(self.sym, 1) else: if self.Securities[self.sym].Price < L[-1]: self.Liquidate(self.sym) def CustomBarHandler(self, bar): self.rollingWindow.Add(bar)