Hi, I'm developing a trading bot based on IB api (actually, I almost finished and it's working jast well), but jast found out that I can make only 60 requests for historical data in 10 minutes. I'm going to trade on around 170 instruments and I need 2 last closed bars for every instrument every 5 minutes(I'm trading on 5-minute chart). Does it mean that I will be able to get this data only for 60 instruments in every 10 minites? I didnt think that it will be a problem to get 340 bars of historical data every 5 minutes. I guess I need to use another data service like IQFeed(they have API and fees bot very Expensive) or maybe you have some advice how to get this solved. Thank you.
In case you only need the closing price of each bar you could build your own database by using streaming market data instead of using historical data bars. You split your list of 170 tickers into two groups, each group having less than 100 tickers. You wait until the clock is at a multiple of 5 minutes. Then you subscribe to streaming market data to all tickers in the first group. Wait until you have received the latest price for all tickers. Then unsubscribe from these tickers and subscribe to all tickers in the second group. Wait until you have received the data and unsubscribe. Now you wait until five minutes have passed and repeat the process. Streaming market data is not subject to the 10 minute rule, as far as I know. More fancy solutions based on this principle are probably also possible.
Thought about that, but I need not only closing price, but also low, hight and open prices. That's why I need historical data. I read their rules a few more times and it seems like this limitations only for small bars(30 sec or less) (https://interactivebrokers.github.io/tws-api/historical_limitations.html )and for bigger bars there is no limitstions except 50 simultaneous requests what can be increased with boost bandles (additional 100 simultaneous requests for 30$/month). But still, I'm not sure on 100% percent. Seems like I should jast try to run bot on papertrading account and see what happens.
The 50 messages per second implies that you have to spread out your 170 reqHistoricalData() requests over 4 seconds, plus any other message that you would submit to IB at that time. This "50 messages" limitation only counts the messages you send to IB (e.g. data requests, orders sent, etc). The amount of messages (and data) from IB to you is not involved in this calculation. Rereading that web page you could be correct about downloading historical data. Pay attention to note #1 at the bottom of that page though:
Thank you for the compliment. I don't consider this "smart", but rather basic. I think that better solutions are possible, but those require more lines of code.