Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
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.
toggle quoted message
Show quoted text
You can see examples of working with that method in Testbed example. To try without market data select delayed data type in the beginning
|
to navigate to use esc to dismiss