placeOrderEx function not working

조회 수: 6 (최근 30일)
Mike
Mike 2014년 7월 13일
답변: Yair Altman 2014년 9월 4일
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)

답변 (1개)

Yair Altman
Yair Altman 2014년 9월 4일
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.

카테고리

Help CenterFile Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by