That's weird. I see all the fluff you are talking about. that backtest doesn't look that way in my portal. only in the forums here. I'm just baffled that the RB specifically can't load an SMA when i copy pasted this verbatim from my NQ/ES algo that Jack Simonson helped me with.
from datetime import timedelta
import decimal
class BasicTemplateFuturesAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1)
self.SetEndDate(2019, 5, 20)
self.SetCash(1000000)
# Subscribe and set our expiry filter for the futures chain
futureCL = self.AddFuture(Futures.Energies.CrudeOilWTI)
futureCL.SetFilter(timedelta(30), timedelta(180))
futureRB = self.AddFuture(Futures.Energies.Gasoline)
futureRB.SetFilter(timedelta(30), timedelta(180))
self.frontCL = None
self.frontRB = None
self.rbsma = self.SMA(self.frontRB, 60, Resolution.Minute)
def OnData(self,slice):
for chain in slice.FutureChains:
contracts = list(filter(lambda x: x.Expiry > self.Time + timedelta(45), chain.Value))
for contract in contracts:
if ('RB ' in str(contract.Symbol)) and (self.frontRB is None):
self.frontRB = sorted(contracts, key = lambda x: x.Expiry, reverse=True)[0]
self.Consolidate(contract.Symbol, timedelta(minutes=120), self.twoforty)
if ('CL ' in str(contract.Symbol)) and (self.frontCL is None):
self.frontCL = sorted(contracts, key = lambda x: x.Expiry, reverse=True)[0]
self.clsma = self.SMA(self.frontCL.Symbol, 60, Resolution.Minute)
self.clrbsma = IndicatorExtensions.Minus(self.clsma, self.rbsma)
def OnOrderEvent(self, orderEvent):
pass
def twoforty(self, consolidated):
self.consolidated45Minute = True
if not self.Portfolio.Invested:
self.MarketOrder(self.frontRB.Symbol , -1)
self.MarketOrder(self.frontCL.Symbol , 1)
self.Debug("clrbsma!!!: " + str(self.clrbsma.Current.Value))
self.Log("front rb cont symbol: " + str(self.frontRB.Symbol))