Request historical data with API in IB

UniversalGoldmine

Junior member
Messages
26
Likes
0
Hi,

I have a question about the Historica data limitation when requesting bars at Interactive Brokers.
On this link, it is said that it is possible to request 1-min bars 2 days back.
http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/api/historical_data_limitations.htm

What I wonder for a real account (and not the demoaccount) is what will happen if you try to request 3 Days like this:

Tws1.reqHistoricalData(1, "MSFT", "STK", "", 0, "", "", "smart", "usd", 0, "", "3 D", "1 min", "MIDPOINT", 1, 1);

Since different exchanges/symbols has a different amount of minutebars within 2 Days, this will be important to know.
Will the function just ignore this and request up to the maxium wich is 2 Days automatically or will it be an error in my application.
I dont have a real account yet so I am not able to test this. The demo account let you download 1 week of minutdata wich is outside of the limitation also wich I wonder why it is possible.

I will be pleased to know if the API works in that way, that the API will return the maxium amount of bars wich is 2 Days if trying to request more than the limit wich is 2 Days. Much coding logic will depend on how the API react on this request on the real opened account.

Thank you
 
I can't give you a definitive answer, because I can't remember all the grisly details. I can tell you that this stuff is not properly documented and trial and error is the only way of finding out. Regrettable and unsatisfactory, but that's the way it is.

In general, requests may return quite a lot more bars than what the doc suggests.
 
... Will the function just ignore this and request up to the maxium wich is 2 Days automatically or will it be an error in my application. ...

You will get an error callback saying you have requested more data than is permissible for one request.

As dcraig says you can actually request more data than their limits say and it will often work, for example I have found it possible to get 6 days of data in one call for 1, 3 or 5 minute forex data when their documentation says 1 day maximum. Stocks might be different.
 
Thank you for your answers, it helps out alot.
I will also when it is possible to try it out with a real account.

I might wonder for a solution of how it would be possible to detect for a symbol to not request more than 2 Days of 1-minutdata.

For example MSFT has this tradingsession:
MSFT tradingsession is: 390 minutes (6 h, 30 min) = 390 min * 60 s = 23400 seconds

Tws1.reqHistoricalData(1, "MSFT", "STK", "", 0, "", "", "smart", "usd", 0, "", "23400", "1 min", "MIDPOINT", 1, 1);

Perheps, I wonder if it is possible to request a symbols trading session hours and by this calculate how much I can request ?

Thank you...
 
Thank you for your answers, it helps out alot.
I will also when it is possible to try it out with a real account.

I might wonder for a solution of how it would be possible to detect for a symbol to not request more than 2 Days of 1-minutdata.

For example MSFT has this tradingsession:
MSFT tradingsession is: 390 minutes (6 h, 30 min) = 390 min * 60 s = 23400 seconds

Tws1.reqHistoricalData(1, "MSFT", "STK", "", 0, "", "", "smart", "usd", 0, "", "23400", "1 min", "MIDPOINT", 1, 1);

Perheps, I wonder if it is possible to request a symbols trading session hours and by this calculate how much I can request ?

Thank you...

I can't answer your questions, you need to try it out. Even if I could answer your questions, you need to consider that this stuff is not documented and not part of any specification. As such, IB would be quite within their rights to alter the behavior at any time as long as their service still remains in compliance with the specifications that are published. This is a general problem with exploiting undocumented features in any software - you don't have any legitimate grounds for complaint if it no longer works the way it used to.
 
As I understand there is no request for Regular Trading Hours for a symbol. Perheps it will come, it would be optimal to have as it would be more easy to follow their request limits.
 
Top