Interactive brokers streaming Top level market data

Discussion in 'Automated Trading' started by developerpp, Oct 5, 2018.

  1. Hi

    I am new to trading. Currently i have small java code that is subscribing to different ticker symbols streaming top level 1 market data. I am having trouble understanding/interpreting the sequence of messages received. Any help on understanding the data and making sense out of it will be really helpful.

    For example i subscribed to GOOG ticker on nasdaq and here is the stream of message i receive :

    GOOG : tickString : ticktype LAST_TIMESTAMP value 1538668896
    GOOG : tickPrice : ticktype LAST price 1165.9 canautoexecute 0
    GOOG : tickSize : tickType LAST_SIZE size 1
    GOOG : tickSize : tickType LAST_SIZE size 1
    GOOG : tickSize : tickType VOLUME size 9154
    GOOG : tickPrice : ticktype HIGH price 1197.51 canautoexecute 0
    GOOG : tickPrice : ticktype LOW price 1165.55 canautoexecute 0
    GOOG : tickPrice : ticktype CLOSE price 1202.95 canautoexecute 0
    GOOG : tickPrice : ticktype OPEN price 1195.33 canautoexecute 0
    GOOG : marketDataType : marketDataType Realtime
    GOOG : tickPrice : ticktype BID price 1165.85 canautoexecute 1
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickPrice : ticktype ASK price 1166.49 canautoexecute 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickSize : tickType BID_SIZE size 2
    GOOG : tickPrice : ticktype ASK price 1166.48 canautoexecute 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 3
    GOOG : tickPrice : ticktype BID price 1165.89 canautoexecute 1

    But i do not clearly understand how to log these events . Are there multiple messages being sent for the same event ? Does IB api send us a message for any update to the top level ? Do i need to maintain a state for the ticker and then keep updating the state as i get stream of message ?

    for example : L3-4

    GOOG : tickSize : tickType LAST_SIZE size 1
    GOOG : tickSize : tickType LAST_SIZE size 1

    Why do 2 consecutive message of this mean ? Are the messages usually streamed in or

    Then i have this sequence of streaming message :

    GOOG : tickPrice : ticktype BID price 1165.85 canautoexecute 1
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickPrice : ticktype ASK price 1166.49 canautoexecute 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickSize : tickType BID_SIZE size 2
    GOOG : tickPrice : ticktype ASK price 1166.48 canautoexecute 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 3
    GOOG : tickPrice : ticktype BID price 1165.89 canautoexecute 1

    How to understand the chronological events that happened in the market based on this stream ? I do not understand the duplicate messages with the same bid_size coming in multiple times ? Does IB guarantee that the messages always arrive in order , any guidance on how to relate this stream of messages to what actual events took on exchange would be immensely helpful

    Any direction on helping to understand this data and how usually you log these stream of data would be very helpful to get me started.
     
  2. You may want to read IB's explanation on market data subscriptions here: http://interactivebrokers.github.io/tws-api/top_data.html

    You are subscribing to market data and you have to filter out yourself which parameters are important to you. You have to store these values for your further processing. Be aware:
     
  3. I have already read the api and using that . What i want to understand is the stream of message relating to the sequence of events happening in market and the duplicated messages
     
  4. I don't think that there is a "sequence of messages" sent by IB. They send one message for each parameter, if that parameter has changed since the previous message of that parameter.
     
  5. So If i am looking at equities , does that mean every 250 ms , i will receive a message for every parameter that has changed. if that is the case why do i receive duplicated message :
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 2
     
  6. This is not a duplicate message. One line is about ask volume, the other about bid volume.
     
  7. No. Each parameter has its own clock. So, for example, it could be that you receive more often messages about changing ask price than about changing bid price.
    The only thing you do know is that for one parameter you won't receive two messages within a 250 ms time window.
     
    Last edited: Oct 15, 2018
  8. oops sorry i pasted the wrong lines : Here is the correct stream of message i received :
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickSize : tickType ASK_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 2
    GOOG : tickSize : tickType BID_SIZE size 1
    GOOG : tickSize : tickType BID_SIZE size 2
    GOOG : tickPrice : ticktype ASK price 1166.48 canautoexecute 1
    GOOG : tickSize : tickType ASK_SIZE size 2

    So the part i do not understand is that :
    1) why the ASK_SIZE 2 message comes repeatedly if it never changed ?
    2) Where did you find out that each param has its own clock , could you please point me to the documentation or how did you figure this out ? Because AFAIR the documentation said , they will send aggregated snapshot every 250 ms so i thought it will be same clock for all params.

    Thanks a lot for looking into this . Do you also use IB data ?

    My aim is to create a trading bot a s proof of concept. And i see some limitations of the number of equities symbols i can analyze , Do you know of better ways of collecting data
     
  9. Yes, I am using IB data since a couple of years as data source for my automated trading programs.
    IB has documentation for it, over here: http://interactivebrokers.github.io/tws-api/index.html
    There is a users group forum, at https://groups.io/g/twsapi Browse their historical information carefully before asking new questions though. One person made a compilation of many interesting topics which he came across at this users group. It is here: https://dimon.ca/dmitrys-tws-api-faq/

    But the best way to learn about the IB API is by experimenting with it. My advice: don't wonder why certain things work in certain ways. Just use them to your advantage.
     
  10. very helpful , thanks a ton. Had a few more questions for you since you seem very well experienced and have already gone through the path of what i am trying to do. Sent you few additional question on PM.
    Thanks again.
     
    #10     Oct 15, 2018