Given a stock symbol, how to get all expirys and strikes of its option chain on IB API? I can't find such an API function yet.
I don't either. How did IB TWS do that? Is there a good algorithm to find all expiries and strikes without too much server communication?
the function is available in TWS, but for the IB API, I suspect you need to build your own functions, shouldn't be that difficult to build you could create the different instrument in a loop and test if a "close" attribute is present.
If you call reqContractDetailsEx and don't specify the strike price or expiry date you get back the whole chain.
I just tested this in Python, and the IB server did return a long string of replies with different contract objects.
Butterfly, did you read this thread? http://www.elitetrader.com/vb/showthread.php?s=&threadid=204724 I met the same problem. The old API version (maybe 2009) works but the 9.69 API doesn't work for me. How did you set the parameters of reqContractDetails( int reqId, const Contract &contract)? Thanks!
This is what I did in Python to receive all the contract details. Don't forget the currency attributes, it's always something we tend to forget. Code: # INSERT code for IB Connect etc... order_ticker = Contract() order_ticker.m_symbol = 'MSFT' order_ticker.m_secType = 'OPT' order_ticker.m_currency = 'USD' # You need to enter a dedicated RequestID, can be arbitrary or automatically incremented. # Here we use ReqID = 1 ibgw_conTradeChannel.reqContractDetails(1,order_ticker) This will give the following raw output, a number of contract details objects for you to catch and assign properly. A lot of work would need to be done to filter out what you need and don't need. I haven't experienced this yet as I just found out about it like you did.