For more information, see the official site: github.io

Contents

Initialize session with TWS and create buffer for errors

% initialize session with TWS
session = TWS.Session.getInstance();

% create local buffer for error events
[buf,lh] = TWS.initBufferForEvent(TWS.Events.ERROR);

% connect to TWS
session.eClientSocket.eConnect('127.0.0.1',7496,0);

Print out error events

% blab about events
cellfun(@(e)disp(e.data),collection2cell(buf));
-1 501 Already connected.
 

References

Interactive Brokers API:

TWS@Github:

Apache Commons: