Hi Everyone,
I’ve been encountering an issue with the option contracts returned by slice.OptionChains that seems inconsistent with what I typically observe in the market. Specifically, I'm seeing contracts with strike prices significantly above the current stock price on their expiration day (0DTE), which I’ve never seen in actual trading scenarios.
Here is how I'm looking for the contracts. Thank you!
option_chain = slice.OptionChains.get(self.option.Symbol, None)
if option_chain:
for contract in sorted(option_chain, key=lambda x: x.Strike):
if contract.Expiry.date() == self.Time.date() and contract.Right == OptionRight.Call:
if contract.Strike > self.avgP:
Mia Alissi
The
slice.OptionChains.get()
method you're using is getting the option chain for theoption.Symbol
from the current slice. If the option chain for this symbol is not in the slice, it returnsNone
. The availability of option contracts in the slice or in the list returned byGetOptionContractList
depends on the market. If a contract with a certain strike or expiration is not available, it means that there is no such contract in the market at the current time.If you are trying to access an option contract symbol from
slice.OptionChains
and it returnsNone
, it could be because you have not subscribed to that particular option contract. You can subscribe to an option contract using theAddOptionContract()
method.Here is an example in Python:
(Source: QuantConnect Forum Discussion 16185)
If you're interested in weekly contracts, you might want to check if the underlying symbol has weekly options available. For example, the SPX index has both standard (monthly) and weekly options. The weekly options are denoted with the symbol "SPXW".
Here's an example of how you can request weekly contracts:
(Source: QuantConnect Forum Discussion 16178)
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.
Anthony
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!