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
Derek Melchin
Hi Chetan,
We were unable to reproduce the issue. See the attached backtest for reference.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Derek Melchin
Hi Chetan,
If we use self.EnableAutomaticIndicatorWarmUp = True, the indicator is updated with the Close. Please use
To be notified when this issue is fixed, subscribe to GitHub Issue #6701.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Chetan Prabhu
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!