Hi all, was trying to use Automatic indicators in a SelectionData class, and was seeing some odd behavior, Treat this as just test code, as I was just trying to understand behavior. It is not meant to do anything particularly useful:

# region imports
from AlgorithmImports import *
# endregion

class MetricCheck(QCAlgorithm):

    def Initialize(self):
        self.EnableAutomaticIndicatorWarmUp = True
        self.ticker = "TWTR"
        self.SetStartDate(2022, 10, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.AddEquity("SPY", Resolution.Daily)
        self.AddEquity(self.ticker, Resolution.Daily)
        self.UniverseSettings.Resolution = Resolution.Daily
        self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Adjusted
        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", -60), self.FillOpenPositions)
        
        symbol = self.Symbol(self.ticker)
        self.vsma20 = self.SMA(symbol=symbol, period=20, resolution=Resolution.Daily, selector=Field.Volume)
        self.sma20 = self.SMA(symbol=symbol, period=20, resolution=Resolution.Daily, selector=Field.Close)
        self.averages = {}

    def FillOpenPositions(self):
        symbol = self.Symbol("TWTR")
        self.averages[symbol] = SelectionData(self, symbol)

class SelectionData():
    def __init__(self, algo, symbol):
        self.vsma20 = algo.SMA(symbol=symbol, period=20, resolution=Resolution.Daily, selector=Field.Volume)
        self.sma20 = algo.SMA(symbol=symbol, period=20, resolution=Resolution.Daily, selector=Field.Close)

Using the automatic indicators, self.vsma20 and self.sma20 in the Initialize method seem to compute correctly. The same self.vsma20 and self.sma20 in the SelectionData both give the same value (the Closing Price SMA). For some reason, the “Field.Volume” selector is being ignored in SelectionData. 

Again, the code above is just some scratchpad code that I wrote because I was seeing some strange behavior in my main algos, and wanted to isolate things.

Can anyone see what I'm doing incorrectly?

Thanks,

Chetan