When creating a Beta indicator and passing Symbol objects for cash indices VIX and SPX, I get the following error:
Stack Trace
Please register to receive data for symbol 'NONE 0' using the AddSecurity() function. in Indicators.cs:line 2211 Please register to receive data for symbol 'NONE 0' using the AddSecurity() function.
The only explanation I can think of is due to these symbol objects being cash indices, and not tradable securities like equities, ETFs, etc. Can self.B() be used on cash indices? If so, what am I doing wrong?
Code below:
# region imports
from AlgorithmImports import *
# endregion
class HyperActiveGreenGoat(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 12, 11) # Set Start Date
self.SetEndDate(2022, 12, 11)
self.SetCash(100000) # Set Strategy Cash
self.VIX = self.AddIndex("VIX", Resolution.Hour).Symbol
self.SPX = self.AddIndex("SPX", Resolution.Hour).Symbol
self.VIX_SPX_beta = self.B(self.VIX, self.SPX, 63)
def OnData(self, data: Slice):
Louis Szeto
Hi Eli
For cash indices, please use the manual Beta indicator. Refer to the attached backtest as an example.
Best
Louis
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.
Eli Laycock
Thanks Louis! This worked
Eli Laycock
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!