reqHistoricalData and historicalDataUpdate

Discussion in 'Interactive Brokers' started by purrfessor, Jan 9, 2020.

  1. In the IB API to get historical data we use reqHistoricalData

    then the historicalData function is called to receive the bars/candles.

    if I requested 100 bars of data, is historicalData called 100 times?

    Also, if I have update turned on, historicalDataUpdate is called, perhaps 100 times. After that, how is the next bar/candle delivered or maintained?

    The manual says...
    Otherwise updates of the most recent partial five-second bar will continue to be returned in real time to IBApi::EWrapper::historicalDataUpdate

    But I don’t understand that sentence. I did not see a reference to a five second bar above the sentence. I guess I’m wondering whether historicalDataUpdate is called one more time when a bar or candle is complete or if the pending candle is continually updated til closed.

    Thanks
     
  2. I like the way ib_insync does it. You can probably look at their code to see how to do it.
     
  3. gaussian

    gaussian

    If I recall correctly, yes. In the languages I used (C++, Python, C#) there is a callback (I believe it's `historicalData`) that receives an individual bar. `historicalDataUpdate` is used for real-time data. I never used real-time data so I can't help with that part. You may wish to contact their API support.
     
  4. d08

    d08

    Only one request is made but each unit of time is received one by one in the receiving function.
    Can't help you with historicalDataUpdate.
     
  5. Thanks all. Helpful
     
  6. aboatya

    aboatya

    did some experiments with it lately, hope this helps if someone got here via google

    Yes, historicalData will be called 100 times.

    as for historicalDataUpdate, it will be called multiple times(whenever it supposed to be).
    e.g. within 5 secs interval, a partial 5 sec bar will continue updating itself until the bar is closed