How to connect and retrieve data from Interactive Brokers

I am facing the following error when i type this function:
>> data = IBMatlab('action','account, 'AccountName','DU12345');
data = IBMatlab('action','account, 'AccountName','DU12345');
|
Error: Unexpected MATLAB expression.
I was reading through some undocumented matlab manuals and official IB manuals indicating that i would need some jar. failes namely: IBMatlab.jar
I couldnt find these files on the internet neither could Matlab provide me these files and neither Interactive Brokers.
Would someone be so kind and lead me through the process of connecting Matlab to IB or Trading Working Station which is the interface of IB?
Thanks in Advance

8 Comments

Paul - if you have the Trading Toolbox you can use the link interactive brokers to access market data and submit orders through Interactive Brokers® using IB Trader Workstation. There are some example that should get you started.
FYI, there seems to be a quotation mark missing after "account":
data = IBMatlab('action','account', 'AccountName','DU12345');
@GEOFF HAYES, yes indeed i have the trading toolbox but the examples there are not very helpful to be honest.
@Mischa Kim: when i try
data = IBMatlab('action','account', 'AccountName','DU12345');
its still gives me the following error:
>> data = IBMatlab('action','account', 'AccountName','DU12345')
Undefined function 'IBMatlab' for input arguments of type 'char'.
and like i mentioned in the initial thread i do not have the files which are necesarry to trade via the IB TWS namely IBMMatlab.jar and i cannot find it on the internet either.
best regards
Paul - IBMatlab is not part of the Trading Toolbox, so continuing to run the above command will give you the undefined function error. A Google search will show you where you can request a trial version of this software.
But since you have the Trading Toolbox, what in particular is causing you problems? The documentation seems straight forward. Have you tried to create an IB order?
i am currently trying to retrieve trade data with the following function
ib = ibtws('',7496)
eventNames = {'errMsg','tickSize','tickString','tickPrice'};
for i = 1:length(eventNames)
registerevent(ib.Handle,{eventNames{i},...
@(varargin)ibExampleRealtimeEventHandler(varargin{:})})
end
f = findobj('Tag','IBStreamingDataWorkflow');
if isempty(f)
f = figure('Tag','IBStreamingDataWorkflow','MenuBar','none',...
'NumberTitle','off');
pos = get(f,'Position');
set(f,'Position',[pos(1) pos(2) pos(3)+37 109])
colnames = {'Trade' 'Size' 'Bid' 'BidSize' 'Ask' 'AskSize' ...
'Total Volume'};
rownames = {'MSFT','IBM','APPL'};
data = cell(3,6);uitable(f,'Data',data,'RowName',rownames,'ColumnName',colnames,...
'Position',[10 30 582 76],'Tag','SecurityDataTable');
uicontrol('Style','text','Position',[10 5 497 20],'Tag','IBMessage');
uicontrol('Style','pushbutton','String','Close',...
'Callback',...
'evalin(''base'',''close(ib);close(findobj(''''Tag'''',''''IBStreamingDataWorkflow''''));'')',...
'Position',[512 5 80 20]);
end
but it just gives me an empty table with these three securities mentioned in the code above. anybody can me help on this?
Paul - don't you now have to create and place the orders so that the table will be populated? The majority of the above code, from create blotter, is to create the blotter (though I'm not sure why you added the row names in as the sample code did not).
Perhaps before placing orders, you should just try the examples on retrieving historical data from get historical IB data.
First, thanks for the Answer Geoff, we were able to retrieve some historical data concerning volume last price high low etc.. Anyways, we would like to retrieve the equity trades from our Admin account which impact our equity portfolio. The idea is to have the equity portfolio updated in realtime. Therefore we would need to retrieve the internal trades of our institution. I've been contacting IB API helpdesk and Matlab but the help is really scarce they provide. Have you ever retrieved your own trades in Matlab?
Unfortunately, I don't have the Trading Toolbox so have never tried to retrieve my own trades.

Sign in to comment.

Answers (2)

Have you copied that entire example into a MATLAB file and called it?
I would expect the example to work and if it doesn't Tech Support should surely be able to help.
The IBMatlab function is part of the IB-Matlab product, sold separately from the MathWorks Trading Toolbox. You can see more information about it here: http://undocumentedmatlab.com/ib-matlab
Feel free to contact me to get a free trial of IB-Matlab. You could then compare it to your Trading Toolbox if you wish. I will be happy to assist you with such a comparison.

1 Comment

I did not know that the function IBMatlab was a third party function so that clears my question.

Sign in to comment.

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Products

Asked:

on 27 Aug 2014

Commented:

on 13 Oct 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!