Overall Statistics |
Total Trades 234 Average Win 2.11% Average Loss -1.44% Compounding Annual Return 9.306% Drawdown 8.400% Expectancy 0.305 Net Profit 61.951% Sharpe Ratio 0.736 Probabilistic Sharpe Ratio 19.742% Loss Rate 47% Win Rate 53% Profit-Loss Ratio 1.46 Alpha 0.069 Beta -0.012 Annual Standard Deviation 0.092 Annual Variance 0.008 Information Ratio -0.211 Tracking Error 0.187 Treynor Ratio -5.527 Total Fees $329.09 Estimated Strategy Capacity $46000000.00 Lowest Capacity Asset TSLA UNU3P8Y3WFAD |
# Fading The Gap # -------------------------------- STOCK = "TSLA"; THRESHOLD = -6.5; # -------------------------------- class FadingTheGap(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 1, 1) self.SetEndDate(2022, 6, 1) self.SetCash(100000) self.symbol = self.AddEquity(STOCK, Resolution.Minute).Symbol self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.BeforeMarketClose(self.symbol, 0), self.ClosingBar) self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen(self.symbol, 1), self.OpeningBar) self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen(self.symbol, 45), self.ClosePositions) self.window = RollingWindow[TradeBar](2) def ClosingBar(self): if self.symbol in self.CurrentSlice.Bars: self.window.Add(self.CurrentSlice[self.symbol]) def OpeningBar(self): if self.symbol in self.CurrentSlice.Bars: self.window.Add(self.CurrentSlice[self.symbol]) if not self.window.IsReady: return delta = self.window[0].Open - self.window[1].Close if delta < THRESHOLD: self.SetHoldings(self.symbol, 1) def ClosePositions(self): self.Liquidate()