Which one to take as 'tick' price from the IB snap-shot?

As I am trying to retrieve tick data from IB through python API. I encountered a 'definition' problem. As far as I know, IB does not offer real tick by tick data, but a 250ms snap-shot(for US stock and futures etc.). So, the 'tick' price is a mini bar having its own open, high, low, close prices.

The tick I get from ib_insync looks like this:
Code:
Ticker(contract=ContFuture(conId=497954518, symbol='MES', lastTradeDateOrContractMonth='20220916', multiplier='5', exchange='GLOBEX', currency='USD', localSymbol='MESU2', tradingClass='MES'), time=datetime.datetime(2022, 8, 24, 11, 46, 21, 340415, tzinfo=datetime.timezone.utc), bid=4134.0, bidSize=30, ask=4134.25, askSize=7, last=4134.0, lastSize=1, prevBid=4134.25, prevBidSize=18, prevAsk=4134.5, prevAskSize=15, prevLast=4134.25, prevLastSize=2, volume=117929, open=4129.0, high=4136.75, low=4110.5, close=4130.5, halted=0.0, ticks=[TickData(time=datetime.datetime(2022, 8, 24, 11, 46, 21, 340415, tzinfo=datetime.timezone.utc), tickType=4, price=4134.0, size=1), TickData(time=datetime.datetime(2022, 8, 24, 11, 46, 21, 340415, tzinfo=datetime.timezone.utc), tickType=5, price=4134.0, size=1)])

While I tried several options at a short time, it gives price quote with a larger gap than I expected:
data.last = 4134.75;
data.close=4130.5;
data.marketPrice()=4135.25;

maybe, when press the button, 1 second eclipsed and price changed. but, could it be as large as 5 points in a second ?
You would be helped by studying the API's help pages which are here:
https://interactivebrokers.github.io/tws-api/index.html
You will see that there are multiple ways to get market prices. There is reqHistoricalData() to get price bars, reqMktData() which gives a sort-of aggregated value, and reqTickByTickData() for tick data. The online help pages can clarify what would be suitable for your use-case.
 
IB's API is great but it's not meant to be used as a data source. You will drive yourself crazy. Polygon.io is the best I have found for reliable data and an API that is clean and straight forward. So use IB to enter orders and polygon to get data.

Thanks
 
Back
Top