Closed suuuch closed 6 years ago
Try something like this:
In [1]: from ib_insync import *
: util.startLoop()
: ib = IB().connect(clientId=2)
In [2]: def onUpdate(ticker):
: for t in ticker.ticks:
: if t.tickType == 86:
: print(t)
:
: es = Future('ES', '20180921', 'GLOBEX')
: ticker = ib.reqMktData(es, '588', False, False, None)
: ticker.updateEvent += onUpdate
In [3]:
In [3]: TickData(time=datetime.datetime(2018, 6, 5, 17, 39, 5, 145144, tzinfo=datetime.timezone.utc), tickType=86, price=-1.0, size=225089)
TickData(time=datetime.datetime(2018, 6, 5, 17, 39, 5, 145144, tzinfo=datetime.timezone.utc), tickType=86, price=-1.0, size=225089)
TickData(time=datetime.datetime(2018, 6, 5, 17, 39, 5, 146659, tzinfo=datetime.timezone.utc), tickType=86, price=-1.0, size=225089)
TickData(time=datetime.datetime(2018, 6, 5, 17, 39, 5, 146659, tzinfo=datetime.timezone.utc), tickType=86, price=-1.0, size=225089)
TickData(time=datetime.datetime(2018, 6, 5, 17, 39, 5, 147057, tzinfo=datetime.timezone.utc), tickType=86, price=-1.0, size=225089)
In [3]:
The open interest is returned in the tick.size.
Btw, I've just added ticker.futuresOpenInterest
for in the next version.
@erdewit Thank you very much!
How can we retrieve the Daily Historical Open Interest on Futures? Thanks
I found in this api link
http://interactivebrokers.github.io/tws-api/tick_types.html
, I found a new data type , Futures Open Interest , and I tried to add this to code, but I failed.Can I get some help?