Hello,
I'm sure that's something easy but I couldn't find any info on that in the forum or in the documentation. I was able to filter the option contracts, select the one I need and buy it but then I'm not sure how to track the price of this option contract.
Based on the straddle template this is how I select the option contract:
def TradeOptions(self,chains):
# sorted the optionchain by expiration date and choose the furthest date
expiry = sorted(chains,key = lambda x: x.Expiry, reverse=True)[0].Expiry
# filter the call and put contract
call = [i for i in chains if i.Expiry == expiry and i.Right == OptionRight.Call]
# sorted the contracts according to their strike prices
call_contracts = sorted(call,key = lambda x: x.Strike)
if len(call_contracts) == 0: return
self.optionCall = call_contracts[0] => I store the contract in a self variable
But then if I want to access the latest bid price for the same contract, I only get the bid price that I paid for buying the contract:
self.Plot("Main", "Option Price", self.optionCall.BidPrice) => only show the same constant value.
How can I get the latest bid price for an option contract that's in my portfolio?
Thanks,