ib_insync icon indicating copy to clipboard operation
ib_insync copied to clipboard

Timeouts on historical contract data

Open 8W9aG opened this issue 5 months ago • 1 comments

I have a script that attempts to find the historical data for futures (lets say ZF), and in doing so loops through the contract months from 3 years ago to 3 years in the future, for example 202103, 202106, 202109.

An example of this call is like so:

bars = self._ibtw.reqHistoricalData(
    contract,
    endDateTime=dt,
    durationStr="10 D",
    barSizeSetting="1 min",
    whatToShow="TRADES",
    useRTH=True,
    formatDate=1,
    timeout=30.0,
)

Some of these result in a timeout (no matter what the value of the timeout is). Its reasonable that I receive no bars for my request having said that I suspect that if the contract month is not valid or too far in the past something gets lost and it just times out instead of giving me an empty bars result. Given I make a lot of these requests I would much prefer empty results rather than waiting for a timeout, its also hard for me to determine whether the timeout is valid in this case or whether the API doesn't want to give me the data.

8W9aG avatar Feb 01 '24 01:02 8W9aG