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

Discussion in 'Interactive Brokers' started by Warren, Aug 24, 2022.

  1. Warren

    Warren

    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 ?
     
  2. Robert Morse

    Robert Morse Sponsor

    Warren, It is my expectation that IB does not provide tick data to avoid non-display fees. Their data is based on some algo that calculates prices over a short time period.
     
  3. 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.
     
    Warren, murray t turtle and rb7 like this.
  4. M.W.

    M.W.

    I think the reason why IB chose to disseminate high frequency bars rather than ticks was for performance reasons, in order to display the entire market if desired even during times of high volatility. At the time this design decision was made there was no such concept as non-display fees.

     
  5. Also keep in mind that if you really want ticks you will then have to look at the trade condition for each one and decide if it is meaningful to you. This is not a trivial matter and you can't just filter out trade conditions you are not interested in and accept the others. You'll see trades coming through at prices that just won't make sense. When you get the bar data your data provider has kindly cleaned up all the tick data and put it into something that most people view as acceptable.
     
    xappppp likes this.
  6. Warren

    Warren

    So, when the bar updates, for example 1 minute, IB cleansed ticks that look ridiculous?

    And if I use a third party data source, could there be a problem that the order price I send to IB does not match with IB's current price? I am not sure, whether IB will send all orders to the exchange, or match most the orders internally first, then the rest to corresponding exchange ?
     
  7. Yes, IB does not show all trades on the charts you see. Other big brokers do not either. You'd complain and call them if they did.

    You can direct orders to a particular exchange at IB if you prefer. Or you can use their SMART router. They won't send it to PFOF guys with SMART. All orders go to an exchange. In my experience it works pretty good. IBKRATS is IB's own exchange, so they will match orders there if their own exchange has the best price.
     
  8. ET180

    ET180

  9. Warren

    Warren

    And at this moment, this is becoming even more ridiculous:

    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, 15, 37, 46, 599684, tzinfo=datetime.timezone.utc), bid=4150.25, bidSize=11, ask=4150.5, askSize=68, last=4150.25, lastSize=3, prevBid=4150.5, prevBidSize=14, prevAsk=4150.75, prevAskSize=59, prevLast=4150.5, prevLastSize=7, volume=515813, open=4129.0, high=4154.25, low=4110.5, close=4130.5, halted=0.0, ticks=[TickData(time=datetime.datetime(2022, 8, 24, 15, 37, 46, 599684, tzinfo=datetime.timezone.utc), tickType=5, price=4150.25, size=3), TickData(time=datetime.datetime(2022, 8, 24, 15, 37, 46, 599684, tzinfo=datetime.timezone.utc), tickType=8, price=-1.0, size=515813), TickData(time=datetime.datetime(2022, 8, 24, 15, 37, 46, 599684, tzinfo=datetime.timezone.utc), tickType=0, price=4150.25, size=11), TickData(time=datetime.datetime(2022, 8, 24, 15, 37, 46, 599684, tzinfo=datetime.timezone.utc), tickType=3, price=4150.5, size=68)])
    data.last = 4151.0
    data.close=4130.5

    ooh, I see. So, the close refers to daily close, or something. Does not seem to referring to the snap-shot at the moment.

    As, I am not doing high frequency, Ticker.last will be suffice for plotting purpose.
     
    Last edited: Aug 24, 2022
  10. ET180

    ET180

    Close may be referring to the close of the previous session. Last is the price of the last trade executed. See if close changes on the next ticks or if it is stuck at 4130.5.
     
    #10     Aug 24, 2022
    Warren likes this.