¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Can't seem to just get the price/greeks of an option contract in Python


 

All,

I can't seem to get my script to pull down the price of an option contract. I have this overload in my class:

''' def tickOptionComputation(self, orderId, tickType, tickAttrib: int, impliedVol: float, delta: float, optPrice: float, pvDividend: float, gamma: float, vega: float, theta: float, undPrice: float):
super().tickOptionComputation(reqId, tickType, tickAttrib, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice)
print("TickOptionComputation. TickerId:", reqId, "TickType:", tickType, "TickAttrib:", tickAttrib, "ImpliedVolatility:", impliedVol, "Delta:", delta, "OptionPrice:",
optPrice, "pvDividend:", pvDividend, "Gamma: ", gamma, "Vega:", vega,
"Theta:", theta, "UnderlyingPrice:", undPrice) '''

And in my main loop I call:

'''? under_contract = createUnderlyingContract(ticker)
contract = createOptionContract(ticker, date, strike, right)
self.reqMktData(self.nextorderId, under_contract, '', False, False, [])
self.reqMktData(self.nextorderId, contract, '', False, False, [])
'''

Is there something I'm missing here? I know I need a data subscription but I don't even get the warning message about it. Thank you in advance!


 

Probably you're defining an incorrect underlying contract on an option contract.
You can see examples of working with that method in Testbed example.
To try without market data select delayed data type in the beginning

? ? def marketDataTypeOperations(self):
? ? ? ? # ! [reqmarketdatatype]
? ? ? ? # Switch to live (1) frozen (2) delayed (3) delayed frozen (4).
? ? ? ? self.reqMarketDataType(MarketDataTypeEnum.DELAYED)
? ? ? ? # ! [reqmarketdatatype]