Back

Getting Option Chains in Python

Hi, I am making a simple algo to try to get familiar with how options work on QC.  I have been following the short tutorial here: 

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

Please see the attached algo.  Option chains aren't even in the data slice every day, and when there is an option chain it shows up as empty.  Here is a sample log output.  

Here is are my main bits.  I was assuming I would have options chain data for every time OnData was called.  

def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

self.SetStartDate(2016,10,01) #Set Start Date
self.SetEndDate(2016,11,16) #Set End Date
self.SetCash(25000) #Set Strategy Cash
# Find more symbols here: http://quantconnect.com/data
# self.AddUniverse(self.CoarseSelectionFunction)
self.AddEquity("GOOG", Resolution.Daily)
option = self.AddOption("GOOG", Resolution.Daily)
option.SetFilter(-10, +10, timedelta(0), timedelta(180))

def OnData(self,slice):
self.Log("ondata")
for i in slice.OptionChains:
optionchain = i.Value
self.Log("underlying price:" + str(optionchain.Underlying.Price))
df = pd.DataFrame([[x.Right,float(x.Strike),x.Expiry,float(x.BidPrice),float(x.AskPrice)] for x in optionchain],
index=[x.Symbol.Value for x in optionchain],
columns=['type(call 0, put 1)', 'strike', 'expiry', 'ask price', 'bid price'])
self.Log(str(df))
Update Backtest








At the moment, options data is distributed with minute resolution only.

1

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.


Oh yes thank you so much, of course after taking time to write our my question i kinda of realized the same thing.  Thanks great.

0

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