The following attempts to extract price data from “XBU6TFX4H46E,” a 2/7/20 QQQ 221 Call. However, the output is empty, which shouldn't be since I originally pulled the data for this specific option after calling GetOptionHistory on qb.AddOption("QQQ", Resolution.Minute).
opt_from_str = qb.AddOption("XBU6TFX4H46E", Resolution.Minute)
single_symb_opt_history = qb.GetOptionHistory(opt_f_str.Symbol, datetime(2020,1,1,15,38,0), datetime(2020,1,1,15,41,0))
single_symb_opt_history.GetAllData()
BestOnionTrader123
I've resolved this via the following code. Note "qb.Symbol("QQQ XBU6TFX4H46E|QQQ RIWIV7K5Z9LX")" has the value 'QQQ 200207C00221000'.
One problem was my beginning and ending datetimes were probably wrong and refer to price history that precedes the existence. of the option. Another problem is I didn't use the full string in creating the contract symbol.. The following gave in a filled dataframe with relevant prices.
Alexandre Catarino
Hi BestOnionTrader123,
When we want to get the historical data for a particular option contract, we can use the History method, The Symbol object for that method can be created by the Symbol.CreateOption method:
BestOnionTrader123
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!