I'm trying to create a Rolling window of Consolidated bars so that I can compare yesterday's close to today's open to see if there was a gap up during market closed hours. When I run it and debug the values the values are way off. I'm not sure what I'm doing wrong as it seems like it should be pretty simple. I've attached the relevant code.


from System import *
from QuantConnect import *
from QuantConnect.Indicators import *
from QuantConnect.Data import *
from QuantConnect.Data.Market import *
from QuantConnect.Data.Custom import *
from QuantConnect.Algorithm import *
from QuantConnect.Python import *
from QuantConnect import Market
import pandas as pd
import numpy as np
import talib
from collections import deque

class EMACrossover(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 4, 1) # Set Start Date
self.SetEndDate(2020, 7, 27)
self.SetCash(10000) # Set Strategy Cash
self.AddEquity("AMD", Resolution.Minute, Market.USA, True, 1, False)
self.sym ="AMD"
self.consolidatedwindow = RollingWindow[TradeBar](10)
self.Consolidate("AMD", Resolution.Daily, lambda x: self.consolidatedwindow.Add(x))
def OnData(self, data):
if not all([data.Bars.ContainsKey("AMD")]):
if not (self.consolidatedwindow.IsReady):
yesterdayclose = self.consolidatedwindow[1].Close
todayopen = self.consolidatedwindow[0].Open