Overall Statistics |
Total Trades 10 Average Win 0% Average Loss -1.48% Compounding Annual Return -48.469% Drawdown 7.600% Expectancy -1 Net Profit -7.177% Sharpe Ratio -4.964 Probabilistic Sharpe Ratio 0.000% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.492 Beta 0.081 Annual Standard Deviation 0.098 Annual Variance 0.01 Information Ratio -3.137 Tracking Error 0.178 Treynor Ratio -5.978 Total Fees $0.00 |
class BounceBack(QCAlgorithm): def Initialize(self): self.SetStartDate(2015, 1, 1) self.SetEndDate(2015, 2, 10) self.SetCash(100000) # Volatile ETFs tickers = 'UVXY,XIV,NUGT,DUST,JNUG,JDUST,LABU,LABD,GUSH,DRIP,TVIX,GASL,GASX,DWTI,UWTI,DGAZ,UGAZ,UBIO,ZBIO,BRZU,RUSS,SCO,UCO,RUSL,ERY,ERX,BIOL,SVXY,VXX,SILJ,BIB,BIS,VIXY,SOXL,VIIX,SOXS,BZQ,USLV,SLVP,DSLV,GDXJ,GLDX' resolution = Resolution.Hour security = self.AddEquity('TQQQ', resolution) security.FeeModel = ConstantFeeModel(0) self.sym = security.Symbol self.ma = self.SMA(self.sym, 50, resolution) self.priceWindow = RollingWindow[float](2) self.SetWarmUp(50) self.threshold = 0.005 self.limitTicket = None self.stopTicket = None def OnData(self, data): if self.IsWarmingUp or not self.ma.IsReady: return if self.sym not in data or data[self.sym] is None: return price = data[self.sym].Price self.priceWindow.Add(price) if not self.priceWindow.IsReady: return ma = self.ma.Current.Value # long crossover if self.priceWindow[0] > ma * (1 + self.threshold) and self.priceWindow[1] < ma * (1 - self.threshold): if not self.Portfolio.Invested: limit = 0.03 stop = 0.01 quant = self.CalculateOrderQuantity(self.sym, 0.80) self.MarketOrder(self.sym, quant) self.stopTicket = self.StopMarketOrder(self.sym, -quant, price * (1 - stop)) self.limitTicket = self.LimitOrder(self.sym, -quant, price * (1 + limit)) self.Plot('Chart', 'MA', ma) self.Plot('Chart', 'Price', price) def OnOrderEvent(self, orderevent): if orderevent.Status != OrderStatus.Filled: return if self.stopTicket != None and orderevent.OrderId == self.stopTicket.OrderId: self.Debug(f"STOP FILLED, LIMIT CANCELLED @ {self.Time}") response = self.limitTicket.Cancel() if self.limitTicket != None and orderevent.OrderId == self.limitTicket.OrderId: self.Debug(f"LIMIT FILLED, STOP CANCELLED @ {self.Time}") response = self.stopTicket.Cancel()