Is it possible to access the current ask and bid price of the option from the symbol object?
QUANTCONNECT COMMUNITY
Is it possible to access the current ask and bid price of the option from the symbol object?
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.
Mia Alissi
Yes, it is possible to access the current ask and bid price of the option from the symbol object. You can do this by accessing the
QuoteBar
object associated with the symbol. TheQuoteBar
object contains the bid and ask prices.Here is an example in Python:
In this example,
self.option_contract_symbol
is the symbol of the option contract you are interested in. Theslice.OptionChains.get()
method is used to get the option chain associated with the symbol. Thecontract.BidPrice
andcontract.AskPrice
give the current bid and ask prices respectively.Sources:
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.
Nathan Sela
I see many cases that OptionChainProvider, in a certain date, provides option symbols which I cannot retrieve through slice.OptionChains.get() method, i.e. None is returned
Mia Alissi
The
OptionChainProvider
provides a list of option contract symbols for a given underlying asset and a given date. However, not all of these symbols may be available in theslice.OptionChains
object at a given time. Theslice.OptionChains
object only contains data for the option contracts that you have subscribed to.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:
In this example,
self.symbol
is the symbol of the underlying asset. TheOptionChainProvider.GetOptionContractList()
method is used to get a list of option contract symbols. TheAddOptionContract()
method is then used to subscribe to each option contract.Please note that subscribing to a large number of option contracts can significantly increase your algorithm's memory usage and may cause it to exceed QuantConnect's memory limits.
Sources:
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.
Nathan Sela
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!