I am trying to test some very basic options strategy where I sell OTM call and put contracts and short the underlying in some cases. Now I'm trying to create some indicator to know If I still hold the put contract I sold.

for that I iterate self.Portfolio as follows:

option_invested = [x.Key for x in self.Portfolio if x.Value.Invested and x.Value.Type == SecurityType.Option]
option_invested = [x for x in option_invested if x.OptionRight == OptionRight.Put]

Which results the following error:

Runtime Error: AttributeError : 'Symbol' object has no attribute 'OptionRight'
  at <listcomp>
    option_invested = [x for x at option_invested if x.OptionRight == OptionRight.Put]

Which is really odd because according to the documentation a symbol object has OptionRight attribute. So the only option is that the first filter (first line in code) doesn't filter any non-option positions ?

Author