Overall Statistics |
Total Trades 2 Average Win 7.29% Average Loss 0% Compounding Annual Return 295.861% Drawdown 6.800% Expectancy 0 Net Profit 7.290% Sharpe Ratio 6.486 Probabilistic Sharpe Ratio 92.860% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 2.065 Beta -0.429 Annual Standard Deviation 0.273 Annual Variance 0.074 Information Ratio 3.491 Tracking Error 0.309 Treynor Ratio -4.125 Total Fees $0.00 Estimated Strategy Capacity $500000.00 Lowest Capacity Asset HUBS VUL3FDOXHN51 |
class MuscularFluorescentOrangeGoat(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 10, 1) self.SetEndDate(2021, 10, 19) self.SetCash(100000) self.hubs = self.AddEquity("HUBS", Resolution.Minute).Symbol self.sma = self.SMA(self.hubs, 15, Resolution.Minute) self.HighPrice = 0 self.stopPricePct = .98 self.entryTicket = None self.stopMarketTicket = None # schedule "ExitPositions" to run every day 10 minutes before market close self.Schedule.On(self.DateRules.EveryDay(self.hubs), self.TimeRules.BeforeMarketClose(self.hubs, 10), self.ExitPositions) def OnData(self, data): price = self.Securities[self.hubs].Price sma = self.sma.Current.Value self.Securities[self.hubs].FeeModel = ConstantFeeModel(0) if not self.sma.IsReady: if price > self.HighPrice: self.HighPrice = price return if price > 1.01 * sma and price > self.HighPrice: if not self.Portfolio[self.hubs].IsLong: quantity = self.CalculateOrderQuantity(self.hubs, .95) self.entryTicket = self.LimitOrder(self.hubs, quantity, price * 1.005, "Entry Order") if price > self.HighPrice: self.HighPrice = price #move up trailing stop price if self.stopMarketTicket is not None and self.Portfolio.Invested: updateFields = UpdateOrderFields() updateFields.StopPrice = price * self.stopPricePct self.stopMarketTicket.Update(updateFields) #self.Plot("Benchmark","SMA", self.sma.Current.Value) #LEAN calls OnOrderEvent if it exists and an order has occurred def OnOrderEvent(self, orderEvent): if orderEvent.Status != OrderStatus.Filled: return #send stop loss order if entry order was filled if self.entryTicket is not None and self.entryTicket.OrderId == orderEvent.OrderId: self.stopMarketTicket = self.StopMarketOrder(self.hubs, -self.entryTicket.Quantity, self.stopPricePct * self.entryTicket.AverageFillPrice) def ExitPositions(self): self.Liquidate(self.hubs)