ib_async
ib_async copied to clipboard
how to get option openinterest?
refer to https://github.com/ib-api-reloaded/ib_async/blob/main/notebooks/option_chain.ipynb There is no value associated with OpenInterest.
and I try ib.reqMktData option_contract = Option(stock_symbol, expiration, strike, right, exchange) ticker = ib.reqMktData(option_contract, '', False, False) ticker.putOpenInterest or ticker.callOpenInterest always get NaN
any demo code or suggestion? thanks
You have to tell ib.reqMktData() that you want additional tickers via so called generic ticks.
There is a list available here: https://interactivebrokers.github.io/tws-api/tick_types.html
Call and put open interest is generic tick 101, so your market data call should look likes this:
ticker = ib.reqMktData(option_contract, genericTickList='101')
It can take a short while till these extra ticks get filled after the first call, but it works for me.
You have to tell
ib.reqMktData()that you want additional tickers via so called generic ticks.There is a list available here: https://interactivebrokers.github.io/tws-api/tick_types.html
Call and put open interest is generic tick 101, so your market data call should look likes this:
ticker = ib.reqMktData(option_contract, genericTickList='101')It can take a short while till these extra ticks get filled after the first call, but it works for me.
Thanks man,I found that open interest doesn't even have anything to do with real time data, it looks like it will only be updated on a regular daily basis. generic tick 100 indicates the volume, but it doesn't seem to be the overall daily volume, just the volume of the previous tick, is it possible to get the total volume of the daily option?
For overall daily volume of an option I use tick 100 and then ticker.callVolume or ticker.putVolume.
Apologies for reopening this request again, but I am having trouble with getting options open interest. The code I run in terminal is
from ib_async import *
ib = IB()
ib.connect('127.0.0.1', 4001, clientId=138)
ib.reqMarketDataType(1)
option1 = [Option('GOOGL', '20250117', 195, 'C', 'SMART')]
ib.qualifyContracts(option1[0])
a=ib.reqMktData(option1[0],genericTickList='100',snapshot=False, regulatorySnapshot=False)
print(a)
print("-")
b=ib.reqTickers(Option('GOOGL', '20250117', 195, 'C', 'SMART'))
print("Volume ", b[0].volume)
print("callOpenInterest ", b[0].callOpenInterest)
print("putOpenInterest", b[0].putOpenInterest)
print("impliedVolatility ", b[0].impliedVolatility)
ib.disconnect()
and the output I get is
Ticker(contract=Option(conId=584786601, symbol='GOOGL', lastTradeDateOrContractMonth='20250117', strike=195.0, right='C', multiplier='100', exchange='SMART', currency='USD', localSymbol='GOOGL 250117C00195000', tradingClass='GOOGL'))
-
Volume 1385.0
callOpenInterest nan
putOpenInterest nan
impliedVolatility nan
Would it be possible please to update the docs with option volume and open interest examples?