Overall Statistics
class VentralOptimizedContainmentField(QCAlgorithm):

     # In Initialize, create the rolling windows
    def Initialize(self):
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2019, 2, 1)
        self.AddEquity("SPY", Resolution.Minute)
        # Define and register thirty minute consolidator
        consolidator = TradeBarConsolidator(timedelta(minutes=30))
        self.SubscriptionManager.AddConsolidator("SPY", consolidator)
        # Define DataConsolidated event handler
        consolidator.DataConsolidated += self.OnThirtyMinuteBar
        # Create a Rolling Window to keep the close values
        self.closeWindow = RollingWindow[float](4)
        # Create a Rolling Window to keep the TradeBars
        self.tradeBarWindow = RollingWindow[TradeBar](2)

    def OnData(self, data):
        if self.tradeBarWindow.IsReady:
            currentBar = self.tradeBarWindow[0]
            previousBar = self.tradeBarWindow[1]
    # In event handler, update the rolling windows
    def OnThirtyMinuteBar(self, sender, bar):
        self.Debug(f"Bar consolidated start: {bar.Time}, end: {bar.EndTime}, close: {bar.Close}")