Keyboard Shortcuts
Likes
Search
How to receive Options information (like: Open, High, Low) using reqMktData() or reqHistoricalData()
Hi,
toggle quoted message
Show quoted text
I am trying to fetch some Options data like: OPEN, LOW, HIGH, CLOSE and etc using either?reqMktData() or reqHistoricalData(). So I write the following Python code:
|
¿ªÔÆÌåÓýWhat you have supplied as 'symbol' is actually a (incorrect) localSymbol. The symbol for a stock option is the symbol for the underlying stock, in the case "MSFT", whereas the localSymbol is IB's identifier for the target contract. If you don't specify localSymbol you have to give enough other details to uniquely identify the contract you want. ? The localSymbol for the option you're after is actually: ? "MSFT? 211029C00275000" ? Note that there are two spaces after MSFT. ? If you use the localSymbol, the only other things you need to supply are the secType (which you must ALWAYS supply) and the exchange (because a contract with a given localSymbol may be tradeable on several exchanges) , thus: ? contract = Contract() contract.secType = "OPT" contract.localSymbol = "MSFT? 211029C00275000" contract.exchange = "SMART" ? |