I am trying to get the information about the option contracts: namely the expiry date and the type (whether they are puts or calls), straight from the Portfolio holding object.  So far in backtesting I have had to save the option contracts that I trade to my own list and access that contract info later on to check the expiry.  The idea is I want to be able to close out the trade before the option expires.  I am trying to improve the algo so that it doesn't need to "remember" the contracts from when they are traded.  The algo should be able to tell the expiry of the contracts just from accessing them in the Portfolio object.  

 

The way I am currently accessing the portfolio holdings is like this:

 

for sym in self.Portfolio.Keys: holding = self.Portfolio[sym] if holding.HoldStock and holding.Symbol.SecurityType == SecurityType.Option: '''We have an Option'''

 

I would like to find attributes in the holding object like holding.Symbol.Type ( put or call ) and holding.Symbol.Expiry.  Does something like this exist?  It doesn't seem like it according to the documentation here: https://www.quantconnect.com/lean/documentation/topic7826.html

 

I am afraid that storing my traded options in my own list will not work when I need to take the live strategy offline and restart, etc.  The algo should be able to know the details of the option without having to save them from the time of the trade, imo.  

 

Thanks!

Author