for kvp in slice.OptionChains:
    chain = kvp.Value   # option contracts for each 'subscribed' symbol/key 
    traded_contracts = filter(lambda x: x.Symbol in [self.this_option_symbol], chain)
for this_option in traded_contracts:
# Do stuff with this_option

 

There must be an easier way to access contracts from the options chain than have to use two for loops? Simply looking up the stock and specific option symbols as if they were dictionary objects doesn't appear to work. slice.OptionChains['stock_symbol'].contracts['options_symbol']

There's a link here for a github pull request that adds a similar kind of functionality but this doesn't appear in the docs. Or at least not in the docs that I've found? https://github.com/QuantConnect/Lean/pull/2615

Author