| Overall Statistics |
|
Total Trades 2 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $10.85 Estimated Strategy Capacity $410000.00 Lowest Capacity Asset HSGX VW390IT7P4YT |
class OpeningRangeBreakout(QCAlgorithm):
bar1 = bar2 = bar3 = None
def Initialize(self):
self.symbol = "OCGN"
self.SetStartDate(2021, 10, 14)
self.SetEndDate(2021, 10, 14)
self.SetCash(10000)
self.AddEquity(self.symbol, Resolution.Minute)
self.Consolidate(self.symbol, timedelta(minutes=5), self.OnDataConsolidated)
self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.At(9,47), self.ClosePositions)
#3. Create a scheduled event triggered at 13:30 calling the ClosePositions function
def OnData(self, data):
if self.Portfolio.Invested or None in (self.bar1, self.bar2):
return
self.Debug("{} {}".format(self.bar1, self.bar2))
if self.bar2.Open > self.bar1.Open:
self.Debug("Set holdings " + str(self.symbol))
self.SetHoldings(self.symbol, 1)
def OnDataConsolidated(self, bar):
if bar.Time.hour == 9 and bar.Time.minute == 30:
self.bar1 = bar
if bar.Time.hour == 9 and bar.Time.minute == 35:
self.bar2 = bar
#1. Create a function named ClosePositions(self)
#2. Set self.openingBar to None, and liquidate TSLA
def ClosePositions(self):
self.Debug("ClosePositions 1 {}".format(self.Time))
self.bar1 = None
self.bar2 = None
self.Log("Close " + str(self.Portfolio[self.symbol].Quantity) + " units of symbol " + str(self.symbol))
self.Liquidate(self.symbol)
self.Debug("ClosePositions 2")