I want to get weekly options, but when I change codes from:
option.set_filter(lambda option_filter_universe: option_filter_universe.standards_only().Strikes(-20, 20).Expiration(0, 90))
to
option.set_filter(lambda option_filter_universe: option_filter_universe.weeklys_only().Strikes(-20, 20).Expiration(0, 90))
The first one worked, the second one will have problems:

Mia Alissi
Here's a revised version of the initialization method to address the issues identified in Miranda's code:
Make sure to import all necessary libraries and define any missing methods or variables.
Sources: Initialization - QuantConnect.com, History Auxiliary Data Regression Algorithm, Standardized Unexpected Earnings, Basic Template Index Daily Algorithm, Index Option Bull Call 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.
Louis Szeto
Hi Miranda
It is not guaranteed that the received slice has SPY data. There could be events like splits and dividends that happened outside trading hours. You can just put an “if” condition to filter and run the logic only when “SPY” data is received:
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.
Miranda Lu
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!