Overall Statistics |
Total Trades 17 Average Win 0% Average Loss -0.11% Compounding Annual Return 9.975% Drawdown 5.000% Expectancy -1 Net Profit 10.137% Sharpe Ratio 1.369 Probabilistic Sharpe Ratio 63.256% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.103 Beta 0.001 Annual Standard Deviation 0.076 Annual Variance 0.006 Information Ratio -0.413 Tracking Error 0.343 Treynor Ratio 102.265 Total Fees $49.08 |
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, 1010) self.currents = self.Time.day global stopMarketTicket stopMarketTicket = self.StopMarketOrder(self.symbol, -1010, 0.90 * self.Securities[self.symbol].Price) 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 = self.highestPrice * 0.90 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