Overall Statistics |
Total Trades 190 Average Win 1.18% Average Loss -0.95% Compounding Annual Return -1.923% Drawdown 22.400% Expectancy -0.055 Net Profit -5.662% Sharpe Ratio -0.21 Probabilistic Sharpe Ratio 1.864% Loss Rate 58% Win Rate 42% Profit-Loss Ratio 1.24 Alpha -0.01 Beta -0.037 Annual Standard Deviation 0.078 Annual Variance 0.006 Information Ratio -0.75 Tracking Error 0.249 Treynor Ratio 0.44 Total Fees $343.38 Estimated Strategy Capacity $71000000.00 |
class GapReversalAlgo(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 1, 1) self.SetEndDate(2021, 1, 1) self.SetCash(100000) self.symbol = self.AddEquity("SPY", Resolution.Minute).Symbol self.rollingWindow = RollingWindow[TradeBar](2) self.Consolidate(self.symbol, Resolution.Daily, self.CustomBarHandler) self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.BeforeMarketClose(self.symbol, 15), self.ExitPositions) def OnData(self, data): if not self.rollingWindow.IsReady: return if not (self.Time.hour == 9 and self.Time.minute == 31): return # Gap Up => Sell if data[self.symbol].Open >= 1.01*self.rollingWindow[0].Close: self.SetHoldings(self.symbol, -1) # Gap Down => Buy elif data[self.symbol].Open <= 0.99*self.rollingWindow[0].Close: self.SetHoldings(self.symbol, 1) def CustomBarHandler(self, bar): self.rollingWindow.Add(bar) def ExitPositions(self): self.Liquidate(self.symbol)