def Initialize(self): self.option_filter_ran = False
self.SetStartDate(2021, 3, 18) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
es = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, Market.CME)
es.SetFilter(lambda futureFilter: futureFilter.Expiration(0, 365))
self.AddFutureOption(es.Symbol, self.OptionContractUniverseFilterFunction)
self.symbol = es.Symbol
def OptionContractUniverseFilterFunction(
self, universe: OptionFilterUniverse
) -> OptionFilterUniverse:
self.option_filter_ran = True
return universe.IncludeWeeklys().Expiration(
timedelta(40), timedelta(60)
)
def OnData(self, data: Slice):
# self.Debug(f"Has data? : {data.HasData}")
if not data.HasData:
return
for i in data.OptionChains: # only one option chain in this case, which is ES
optionchain: OptionChain = i.Value
if len([x for x in optionchain]) == 0:
continue
self.Debug("underlying price:" + str(optionchain.Underlying.Price))
Jay Ma
Basically, the options on ES is having the same expiration cycles as ES.
Say ES has three expiration cycles, and if each cycle has three options expiration DTE, we should have 3 x 3 = 9 in total.
However the only thing that we get from options on ES contract is three expiration cycles with the SAME DTE as ES itself
Louis Szeto
Hi Jay
We do not support weekly options for Futures yet.
Meanwhile, please note that if multiple Debug messages are sent within 1 second, the rate of its emission will be limited. Also, the message will be cropped to show only the first 2 lines within 200 characters. Please check this doc to find out more.
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.
Jay Ma
Hello @Louis Szeto,Â
This is NOT the root cause problem about weekly options.
As you can see, even if we print the distinct expiration dates without expiration filtering, we could only still get ONLY ONE expiration date….
Do you know why?
Louis Szeto
Hi Jay
The date of this algorithm started at 18-03-2021, while the contract fetched expires at 18-06-2021, which is not expired yet.
Also, you've set a filter for the future option chain to get only the contract expires in the following 40-60 days. So, given weekly contracts are unavailable, it is expected to get only 1 expiration date or none at all.
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.
Jay Ma
Hello Louis Szeto,
Do you know when would we have weeklies available for index options / future options?
Thanks
Louis Szeto
Hi Jay
We will include American weekly options for Futures and Index in the future, but right now, we do not have an exact ETA.
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.
Jay Ma
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!