Hello all!

I have been stuck for a while trying to figure out how to track the live bid or ask price of my purchased option contract in the OnData() method.  When I purchase the contract, it is in its own BuyCall()/BuyPut() method, however, I want to access the live price from the OnData() in order to track % gain or loss to make sell decisions.  The issue is that the contract is in another method and I can't figure out how to either pass the contract back to OnData() or access the live price through a qc function call.  I have tried using Securities, but again I dont have the contract information in the OnData method to use that.  I have also tried using the different Portfolio SecurityHolding calls from the following page, but to no avail.  Below is a code snippet where it prints that we are invested, but then gives 0.0 for both.  Is it because it is looking for holdings of shares and not contracts?  What is the best way to track live option prices in OnData() if you buy the contract in a method that is not OnData()?

if self.Portfolio:
            self.Debug("We are invested!")
            self.Debug(str(self.security_holding.UnrealizedProfitPercent))
            self.Debug(str(self.security_holding.HoldingsValue

Author