ib_async icon indicating copy to clipboard operation
ib_async copied to clipboard

reqHistoricalData very slow even though data comes back in the logs

Open Rex90 opened this issue 7 months ago • 3 comments

I'm trying to use the reqHistoricalData method to get some prices for bonds. I'm experiencing what feels like a very strange behaviour on the surface.

The function takes a really long time to come back. But when i have logging set to DEBUG, its clear that there's actually a response coming back from the underlying API almost immediately. But reqHistoricalData doesn't return anything for a good few minutes after the DEBUG log prints the incomign data. Has anyone experienced this? Am i possibly using the method incorrectly?

LOGS

[2025-04-15 16:50:59,896][DEBUG] >>> 20,1,0,US912797PA95,BOND,,0.0,,,SMART,,USD,,,0,20250413 21:56:00 UTC,1 day,8 D,1,MIDPOINT,1,0,

[2025-04-15 16:51:00,093][DEBUG] <<< 17,1,20250405 17:56:00 US/Eastern,20250413 17:56:00 US/Eastern,8,20250402,99.77543,99.77636,99.77543,99.77609,-1,-1,-1,20250403,99.78744,99.78857,99.78743,99.78763,-1,-1,-1,20250404,99.82271,99.82334,99.82270,99.82302,-1,-1,-1,20250407,99.83579,99.83619,99.83287,99.83338,-1,-1,-1,20250408,99.84500,99.84518,99.84427,99.84454,-1,-1,-1,20250409,99.85642,99.85809,99.85616,99.85808,-1,-1,-1,20250410,99.86980,99.86998,99.86929,99.86941,-1,-1,-1,20250411,99.90509,99.90547,99.90508,99.90522,-1,-1,-1

CODE SNIPPET

            contract = Bond(
                secIdType="ISIN", symbol=isin, exchange="SMART", currency="USD"
            )
            bars = self.ib.reqHistoricalData(
                contract=contract,
                endDateTime=endDateTime,
                durationStr=period,
                barSizeSetting="1 day",
                whatToShow="MIDPOINT", 
                useRTH=True,
            )

Rex90 avatar Apr 15 '25 16:04 Rex90