Overall Statistics
Total Trades
424
Average Win
0.09%
Average Loss
-0.05%
Compounding Annual Return
-42.647%
Drawdown
3.300%
Expectancy
-0.240
Net Profit
-2.736%
Sharpe Ratio
-5.145
Probabilistic Sharpe Ratio
0.032%
Loss Rate
71%
Win Rate
29%
Profit-Loss Ratio
1.60
Alpha
-0.213
Beta
0.255
Annual Standard Deviation
0.062
Annual Variance
0.004
Information Ratio
0.986
Tracking Error
0.103
Treynor Ratio
-1.258
Total Fees
$444.52
Estimated Strategy Capacity
$57000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
class OpeningRangeBreakoutRevision(QCAlgorithm):
    
    openingBar = None 
    
    def Initialize(self):
        self.SetStartDate(2022, 1, 1)  
        #self.SetEndDate(2020, 12, 31)  
        self.SetCash(100000)
        self.AddEquity("SPY", Resolution.Minute, extendedMarketHours = True)
        self.Consolidate("SPY", timedelta(minutes=30), self.OnDataConsolidated)
        self.window = RollingWindow[TradeBar](2)

    def OnData(self, data):
        self.window.Add(data["SPY"])
        
        if self.openingBar is None:
            return
        
        if data["SPY"].Price > self.openingBar.High and not self.Portfolio.Invested:
            self.SetHoldings("SPY", 1)
        
        elif data["SPY"].Price < self.window[1].Low and self.Portfolio.Invested:
            self.Liquidate("SPY")
         
    def OnDataConsolidated(self, bar):
        if bar.Time.hour == 9 and bar.Time.minute == 00:
            self.openingBar = bar