placeOrderEx function not working
1 次查看(过去 30 天)
显示 更早的评论
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transaction Cost Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!