placeOrderEx function not working

2 views (last 30 days)
Mike
Mike on 13 Jul 2014
Answered: Yair Altman on 4 Sep 2014
When I try to use the 'ibtws' class in MATLAB R2014a to place order from the Interactive Brokers (IB) Trader Workstation , for instance if I am trying to run the following example function 'placeOrderEx', Nothing showed up on my IB Order Blotte or Trade Station.
My code is as follows, how can I fix this? Thanks
IB = ibtws('',7496);
eventNames = {'errMsg','orderStatus'};
for i = 1:length(eventNames)
registerevent(IB.Handle,{eventNames{i},...
@(varargin)ibExampleOrderEventHandler(varargin{:})})
end
f = findobj('Tag','IBOrderBlotter');
if isempty(f)
f = figure('Tag','IBOrderBlotter','MenuBar','none',...
'NumberTitle','off','Name','IB Order Blotter');
pos = get(f,'Position');
set(f,'Position',[pos(1) pos(2) 687 335])
colnames = {'Status' 'Filled' 'Remaining' 'Avg Fill Price' 'Id' ...
'Parent Id','Last Fill Price','Client Id','Why Held'};
data = cell(15,9);
uitable(f,'Data',data,'RowName',[],'ColumnName',colnames,...
'Position',[10 30 677 300],'Tag','OrderDataTable');
uicontrol('Style','text','Position',[10 5 592 20],...
'Tag','IBOrderMessage');
uicontrol('Style','pushbutton','String','Close',...
'Callback','evalin(''base'',''close(IB);...
close(findobj(''''Tag'''',''''IBOrderBlotter''''));'')',...
'Position',[607 5 80 20]);
end
IB.Handle.reqAllOpenOrders
ibContract = IB.Handle.createContract;
ibContract.symbol = '700';
ibContract.secType = 'STK';
ibContract.exchange = 'SEHK';
ibContract.currency = 'HKD';
ibOrder = IB.Handle.createOrder;
ibOrder.action = 'BUY';
ibOrder.totalQuantity = 10000;
ibOrder.orderType = 'MKT';
orderId = 10;
placeOrderEx(IB.Handle,orderId,ibContract,ibOrder)

Answers (1)

Yair Altman
Yair Altman on 4 Sep 2014
You may wish to try the cross-platform IB-Matlab product, which is Java-based (not ActiveX):
You won't encounter such problems with IB-Matlab, it is very reliable and user-friendly.

Community Treasure Hunt

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

Start Hunting!