Back

How do I get all months of option history from GetOptionHistory?

I am brand new here, but I LOVE the platform. Trying to get my feet wet and figure my way around.  I am trying to pull monthly historical option prices for SPY into the research tool to try some backtesting.  However, I am not understanding how the months are filtered out.  When I request history from June 1, 2017,  I get the following months: Jun, Jul, Aug, Sep, Dec, Jan, Mar  But when I request history from Sep 1, 2017, then I get:  Aug, Sep, Oct, Nov, Dec, Jun, Jul   I dont understand why I am getting those months, how do I get _all_ the months from Jun 1, 2017? 

2nd question:  the last cell of the notebook will hang and the kernel will eventually die.  Any ideas? 

Really appreciate the help! Really excited to get started here! 

TIA, 
Thomas

Update Backtest







Hi Thomas, 

1) It's a data issue with the SPY options on 2017/06/01. Data files for options expiring on Oct and Nov are missing. You can check the raw data with our data explorer

https://www.quantconnect.com/data/tree/option/usa/minute/spy/20170601_quote_american.zip

Options have a large dataset. We are going to reprocessing the options data in the next few weeks to fix the issue of missing data files.

 2)  The kernel dies when the history data request is huge. Please select a shorter time period to avoid the dead kernel.

0

Thank you for your reply Jing.  I have a couple questions: 

1) If the data is missing, how come I can see Oct and Nov, when I request a different StartDate ?  See the two examples in the code, one uses StartDate of Sept 2017, the other Jun 2017.  With Sept, I get back:  Sept, Oct, Nov, Dec.  but not with StartDate of Jun 2017.  See code for more detail. 

2) This doesn't make sense to me either, because it works when I only specify the StartDate, but when I specify EndDate (that is less that today) in SetFilter it hangs.   So, there should be even less data coming back. So how can it be running out of memory if it works with even larger time frame? 

E,g,  

this works: 

option_history2 = qb.GetOptionHistory(spy.Symbol, datetime(2017,9,1), sort=True)

this hangs:  

option_history3 = qb.GetOptionHistory(spy.Symbol, datetime(2017,9,1),datetime(2018,9,1))

0

1) On a specific date, there are hundreds of files of SPY option data. Each file contains the minute data for the specified strike price and expiration date on a single day. If you check the data explorer, the SPY options data on Sep 1 contains the option data expiring on Oct and Nov. The missing files link to a specific day.

https://www.quantconnect.com/data/tree/option/usa/minute/spy/20170901_quote_american.zip

2) If you only use one date, it actually requests the history price on that day (the minute history on 09/01/2017) while "datetime(2017,9,1),datetime(2018,9,1)" is trying to retrieve the minute history data for one year, That's a huge amount of data and will account for the dead kernel.

0

Hi Jing,

Thanks for the answer, but is it possible then to get months of historical data for an option that expires on a certain date? For example, July to Sept data of an SPY call/put option that expires on Sept 27th.  

Thanks

0

Hi Elyse, 

The code above can do that, clone the notebook and play around with it.  You need to use the setFilter function to get the expirations that you are interested in.  Have you had a look at the Options Tutorials?  

https://www.quantconnect.com/tutorials/api-tutorials/using-options-in-quantconnect

Best, 

Thomas

1

Update Backtest





0

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.


Loading...

This discussion is closed