1
$\begingroup$

I am using matlab and interactive brokers API. I am getting real time data using

tickerID = ib.realtime({ct},'233',@(varargin)ibEventRealTimeData(varargin{:}));

where ib is the interface to interactive brokers TWS Activex object and ct is the contract.

I am getting all the events (ticksize, tickprice and so on) but I can't aggregate data/prices (for example, in 5 minute bars). What am I missing?

Thanks.

$\endgroup$
  • $\begingroup$ What do you mean by "I can't aggregate"? Any error message? $\endgroup$ – Wisentgenus Jun 29 '15 at 18:37
  • $\begingroup$ If you've got tick data, can't you just generate quantized data using, e.g., the time series object? $\endgroup$ – Dmitri Nesteruk Jun 30 '15 at 5:08
  • $\begingroup$ Hi Wisentgenus. I mean something similar to the data provided by this example, but in real time: d = timeseries(ib,ibContract,startdate,enddate,barsize,ticktype) requests Interactive Brokers aggregated intraday data for a specific type of market data tick ticktype. $\endgroup$ – user1000650 Jul 3 '15 at 10:58
  • $\begingroup$ DMitri, could you please give me a hint on how do that? $\endgroup$ – user1000650 Jul 3 '15 at 10:58
3
$\begingroup$

Here is a pure Java library with Matlab examples for getting daily and minute aggregated bars. It is based on IB Java API. I wrapped it to have a simple interface:

http://www.spreadvectors.com/wisentgenus#code


IB has limitations when requesting historical data:

  • Making identical historical data requests within 15 seconds.
  • Making six or more historical data requests for the same Contract, Exchange and Tick Type within two seconds.
  • Do not make more than 60 historical data requests in any ten-minute period.
$\endgroup$
1
$\begingroup$

In order to aggregate the 5-min bars, you need to add code within your ibEventRealTimeData function that remembers the previous values (possibly using a global or persistent variable) and appends the new data to it.

If you do not need realtime info, you could make a single request for 5-min historical data. But here too, IB sends the results in separate events that you would need to aggregate within your callback.

As an alternative you could use the IB-Matlab product, which connects IB and Matlab, and aggregates the information for you, in both the historical/intra-day request and the realtime bars request.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.