When operating futures backtesting, I have the following code, I wonder how to get the underlying of the symbol in invested Portfolio.

I think maybe I can get the FutureContract object from the symbol, then get the underlying from FutureContract object, but I don't know how.

Any help is appreciated.

       invested:list[Symbol] = [x.Key for x in self.Portfolio if x.Value.Invested]

            for symbol in invested:            
               # here I want to get the underlying of symbol

                    
                    

Author