I'm working through the tutorial for using options in QuantConnect and am stuck on getting the option chain from an options object. The code below is from the tutorial and I'm trying to adapt it into a ipynb file so I can explore the data:

def OnData(self,slice):
for kvp in slice.OptionChains:
if kvp.Key != self.symbol:
continue
optionchain = kvp.Value
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(f"Underlying price: {optionchain.Underlying.Price}\n{df}")

I'd like to follow the tutorial to get a dataframe of data from the optionschain variable and am erroring on the slice class. Am I missing something?

My code so far...

101680_1589310236.jpg