¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: How to get longer historical data?


 

David,

Why IB returns only 42 historical bars on your request - that depends. It might be one of the cases:
? - you only asked for that much, so they deliver
? - you've reached end of available historical data for given bar size
? - your app is crashing somewhere along the way and didn't have a chance to process the rest

What are the "bar size" and "duration" values you use for reqHistoricalData() request? There is a table of the max possible duration values for different bar sizes that IB would allow for your request in this question:?

IB API never left my reqHistoricalData hanging or unanswered.
The call to?reqHistoricalData() will lead to the?resulting bars returned in form of?int reqId, Bar bar
callbacks. The very last callback from IB will deliver Bar object with time string which?starts with "finished", which will trigger
??callback.?

Basically you need to implement 2 EWrapper methods:
? 1) historicalData() - to get next bar and store it somehow
? 2)?historicalDataEnd() - to consider request complete / done

Well and of cause "3)" for the error case when IB server response to your?reqHistoricalData() request: error number 162 with text "HMDS query returned no data", which would mean there's no point to try to dig any deeper in time.

Also note: you can use the reqHeadTimeStamp method to find the timestamp for the earliest data available for the contract.

Cheers,
Dmitry Shevkoplyas

On Wed, Jan 13, 2021 at 2:55 PM <david03kimo@...> wrote:
Hi,Dmitry,

Thanks for your recommendation of value 2.I checked my formateDate and glad to find mine is value 2 copied from IB's video courses.
And I used oldest timestamp of data-frame in?"20210113 23:59:59 GMT" format to call next?reqHistoricalData() and I got 42 times data and idled.
How can I get a feedback of no data to close it or change another pair of FX to call?reqHistoricalData()?Now I use 42 to get the end.

Cheers,
--


------
Forex trader
David Liao

Join [email protected] to automatically receive all group messages.