Hey Guys,

I have just started delving into the futures side of building algos and boy are they more complicated than equities. With equities I've managed to have a different indicator resoltuion to the data feed resolution i.e. self.AddEquity(self.ticker, Resolution.Minute) with a Resolution.Daily indicator. But, when it comes to futures I have hit a brick wall. I have tried consolidators but my knowledge is lacking even after watching the consolidator help videos. 

I have created an algo which rolls the front month ES contract when it has less than 10 days and it updates the SMA accordingly but now I want to be able to have a Resolution.Tick for the ES data and a Resolution.Minute for the SMA, but when I change the ES Resoltuion to Tick. I get this error message:

"Runtime Error: AttributeError : 'NoneType' object has no attribute 'Symbol'
at OnData in main.py:line 29
:: if not self.UpdateSMA(data): return
at UpdateSMA in main.py:line 77
:: if self.currentSMAsymbol != self.frontContract.Symbol:
AttributeError : 'NoneType' object has no attribute 'Symbol' (Open Stacktrace)"

Any ideas on how I could go about do running Resolution.Tick for the ES and Resolution.Minute for the indicators?

Here is my code which working using the self.AddFuture("ES", Resolution.Minute):

class DynamicCalibratedContainmentField(QCAlgorithm):

frontContract = None
currentSMAsymbol = None
futureSma = None
newDay = True

def Initialize(self):
self.SetStartDate(2019, 3, 3) # Set Start Date
self.SetEndDate(2019, 12, 4) # Set End Date

futureES = self.AddFuture("ES", Resolution.Minute)
futureES.SetFilter(timedelta(0), timedelta(182))

def OnData(self, data):

# Check to see if I have rolled to a new contract
if not self.UpdateContract(data):

# If I have rolled to a new contract and I am currently invested then liquidate any positions
if self.Portfolio.Invested:

self.Debug("Liquidated old contract positions")

# Update SMA and if it isn't ready then return
if not self.UpdateSMA(data): return

# If I am not currently invested then go long
if not self.Portfolio.Invested:

self.MarketOrder(self.frontContract.Symbol, 1)

def UpdateContract(self, slice):

if not self.newDay: return True

# If we haven't already stored the front contract, we need to find it
if self.frontContract is not None and self.frontContract.Expiry > self.Time + timedelta(10): return True


# Get front month symbol
for chain in slice.FutureChains:

# Get contracts expiring no earlier than in 90 days
contracts = list(filter(lambda x: x.Expiry > self.Time + timedelta(90), chain.Value))

# If there is any contract, store the front month contract
if len(contracts) == 0: continue

# If there are no contracts in the list above then just sort the contracts by closest expiry
self.frontContract = sorted(contracts, key = lambda x: x.Expiry, reverse=True)[0]

self.newDay = False

self.Debug(f"Front month contract found: {self.frontContract.Symbol}")

return False

# Create and update SMA
def UpdateSMA(self, slice):

# If we haven't already created the SMA, we need to create it
if self.futureSma is None and self.frontContract is not None:

self.futureSma = self.SMA(self.frontContract.Symbol, 2, Resolution.Minute)

self.currentSMAsymbol = self.frontContract.Symbol

self.Debug("SMA created")

# If the frontContract changes then we need to update the SMA to the new symbol
if self.currentSMAsymbol != self.frontContract.Symbol:

self.futureSma = self.SMA(self.frontContract.Symbol, 2, Resolution.Minute)

self.currentSMAsymbol = self.frontContract.Symbol

self.Debug("SMA Updated")

# If our SMA isn't ready then we don't want to enter the market
if self.futureSma is not None and self.futureSma.IsReady:

self.Debug("SMA is ready")
return True


self.Debug("SMA is not ready yet")
return False

def OnEndOfDay(self):
self.newDay = True

def OnEndOfAlgorithm(self):

self.Debug("The SMA ending value was %f" % (self.futureSma.Current.Value))
self.Debug("The SMA was following the %s" % (self.currentSMAsymbol))
self.Debug("The SMA should be following %s" % (self.frontContract.Symbol))

If anyone has the answer to this it would mean the world as I have been stuck on this for a while!

Thanks again,