I am wondering whether CBOE VIX data is avaialble for backtesting.
I have been trying to get VIX data using the following code and getting this error. Any quick help is highly appreciated.
Runtime Error: 'RangeBoundIronCondorStrategy' object has no attribute 'vix'
at VolatilityChecks
if self.vix in slice:
^^^^^^^^
in main.py: line 634
My code workflow:
from AlgorithmImports import *
from QuantConnect.DataSource import *
class ICStrategy(QCAlgorithm):
def Initialize(self):
# Strategy Initialization
self.SetStartDate(2023, 1, 1)
self.SetEndDate(2023, 9, 30)
self.SetCash(100000)
equity = self.AddEquity("SPY", Resolution.Daily)
self.symbol = equity.Symbol
self.option = self.AddOption("SPY", Resolution.Daily)
self.option.SetDataNormalizationMode(DataNormalizationMode.Raw)
# loading VIX data
self.cboeVix = self.add_data(CBOE, "VIX", Resolution.DAILY).symbol
def OnData(self, slice):
# get vix data
if slice.contains_key(self.cboeVix):
self.vix = slice[self.cboeVix]
else:
self.Debug(F"slice does not have VIX data")
return
def vix_check(self):
if self.vix in slice:
vix_value = slice[self.vix].Close
Mia Alissi
Sources: Vix Predicts Stock Index Returns, Index Option Bear Call Spread Algorithm, Exploiting Term Structure Of Vix Futures, Index Option Put Calendar Spread Algorithm, Index Option Call Calendar Spread Algorithm
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.
Mitul Shah
I don't see any change in my code in your response. What corrections you've suggested?
Mitul Shah
I cannot proceed without the VIX data and would greatly appreciate it if someone from customer service could address my query as soon as possible. Thank you for your attention to this matter!"
Kal Seehra
Marc Daoust
According to the solution posted by Kal, the key is to use
Mitul Shah
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!