Overall Statistics |
Total Trades 17 Average Win 0% Average Loss 0.00% Compounding Annual Return -0.007% Drawdown 0.000% Expectancy -1 Net Profit -0.007% Sharpe Ratio -0.627 Probabilistic Sharpe Ratio 5.591% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.749 Tracking Error 0.334 Treynor Ratio -1.033 Total Fees $17.00 Estimated Strategy Capacity $190000000.00 |
import time class Trial2(QCAlgorithm): # Order ticket for our stop order, Datetime when stop order was last hit stopMarketTicket = None stopMarketOrderFillTime = datetime.min highestPrice = 100 openingBar = None def Initialize(self): self.symbol = "BNGO" self.SetStartDate(2020, 2, 20) self.SetEndDate(2021, 2, 24) self.SetCash(100000) self.currents = None self.AddEquity(self.symbol, Resolution.Minute) self.Securities[self.symbol].SetDataNormalizationMode(DataNormalizationMode.Raw) self.Consolidate(self.symbol, timedelta(minutes=10), self.OnDataConsolidated) def OnData(self, data): if self.openingBar is None: #self.Debug("Part1") return if self.openingBar.High < self.Securities[self.symbol].Price: if not self.Portfolio.Invested: if self.Time.day != self.currents: self.MarketOrder(self.symbol, 1) self.currents = self.Time.day global stopMarketTicket stopMarketTicket = self.StopMarketOrder(self.symbol, -1, round(0.90 * self.Securities[self.symbol].Price, 2)) #self.Debug("Part2") if self.Portfolio.Invested and self.Securities[self.symbol].Price > self.highestPrice: #self.Debug("Part3") self.highestPrice = self.Securities[self.symbol].Price updateSettings = UpdateOrderFields() updateSettings.StopPrice = round(self.highestPrice * 0.90, 2) updateSettings.Tag = "Stop Price Updated for Trade" response = stopMarketTicket.Update(updateSettings) def OnOrderEvent(self, orderEvent): if orderEvent.Status != OrderStatus.Filled: return if self.stopMarketTicket is not None and self.stopMarketTicket.OrderId == orderEvent.OrderId: self.stopMarketOrderFillTime = self.Time def OnDataConsolidated(self, bar): if bar.Time.hour == 9 and bar.Time.minute == 30: self.openingBar = bar