Hi,
What contracts available in option_chain property of slice?
I have option filter which explicitly selects options which are in 300-370 days to expiry.
But I am seeing some options which are 200 days to expiry? If we have a position in an option contract, does it always get included in option_chain?
Mia Alissi
Here's a detailed explanation for "Creative":
What contracts are available in the
option_chainsproperty of aSlice?The
slice.option_chainsproperty in QuantConnect provides you with all option contracts for each underlying symbol in two specific categories:Contracts matching your filter criteria:
These are contracts that satisfy your universe filter, e.g., for DTE (days to expiry) in the range of 300-370 days, only contracts within this window will be included (when you have no positions in other contracts).
Contracts with open positions:
Importantly, if you have an open position in an option contract (e.g., you bought it when it had 350 days to expiry), that contract will always appear in
option_chainseven after it has moved out of your filter window (now 200 days to expiry, for example).This is by design, so you can continue to receive market data and manage/close/margin that position as long as you hold it.
Why do you see contracts with 200 DTE if your filter is 300-370?
Summary:
If you are holding a position in an option contract, it will always stay in
slice.option_chainsas long as you hold that position—even if the contract drops below your minimum expiry filter. This ensures you never lose visibility or the ability to manage those investments.Debug tip:
If you notice contracts outside your filter and you do not have positions in them, review your filter logic and check for any manual subscriptions via
AddOptionContract,AddSecurity, etc.Let me know if you want code to quickly check which contracts in the chain you are holding positions in!
Sources: Index Options - QuantConnect.com, Equity Options - QuantConnect.com, Future Options - QuantConnect.com, Greeks and IV Implementation, Option Chain Provider 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.
Creative Cubs
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!