For most symbols, the notebook code below works. However, for some symbols like NKLA, contracts returned by GetOptionContractList contain a different symbol. In NKLA case, VTIQ is returned. GetOptionHistory then causes the error:
No option type exists for underlying SecurityType: Base
I suspect VTIQ is a shell company for NLKA which allowed it to go public.
How can I retrieve the option data in a case like this?
Here is the notebook code:
qb = QuantBook()
equity = qb.AddEquity('NKLA', Resolution.Minute) # NKLA is translated to VTIQ
#equity = qb.AddEquity('AAPL', Resolution.Minute) # AAPL is not translated
contracts = qb.OptionChainProvider.GetOptionContractList(equity.Symbol,datetime(2021, 1, 13, 12, 10))
print(equity.Symbol,contracts[0].ID.Symbol)
option_history = qb.GetOptionHistory(contracts[0].ID.Symbol, datetime(2021, 1, 13, 12, 10))
Chuck Carlson
The solution is to use the contract, instead of the symbol. So contract[0].ID.Symbol should be changed to contract[0].
Chuck Carlson
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!