I got an error in trading toolbox when I try to get history of an ib contract.

1 view (last 30 days)
I wrote the code of below in order to get data from de api.
ib = ibtws('',7496)
ib =
ibtws with properties:
ClientId: 0
Handle: [1x1 COM.TWS_TwsCtrl_1]
Host: ''
Port: 7496
ibContract = ib.Handle.createContract;
ibContract.symbol = 'MSFT';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
ibContract.currency = 'USD';
bizDayConvention = 13; % i.e. BUS/252
startDate = daysadd(today,-20,bizDayConvention);
endDate = daysadd(today,-1, bizDayConvention);
histTradeData = history(ib,ibContract,startDate,endDate);
HERE THE OUTPUT!!
No method 'reqHistoricalDataEx' with matching signature found for class 'COM.TWS_TwsCtrl_1'.
Error in ibtws/history (line 90)
c.Handle.reqHistoricalDataEx(1,s,endDateTime,durationString,period,ticktype,0,1)
  1 Comment
fer laser
fer laser on 3 Sep 2014
Edited: Walter Roberson on 4 May 2015
Add ib.Handle.createTagValueList as the last argument.
example:
ib.Handle.reqHistoricalDataEx(1, ibContract, '20140820 00:00:00','1 D', '30 mins','TRADES',0,1,ib.Handle.createTagValueList);

Sign in to comment.

Answers (2)

Geoff Hayes
Geoff Hayes on 10 Aug 2014
Ruben - I don't have the Trading Toolbox but the error message is indicating that there is a problem with one or more of the input parameters that are being passed to
c.Handle.reqHistoricalDataEx(1,s,endDateTime,durationString,period,ticktype,0,1)
No method 'reqHistoricalDataEx' with matching signature found for class 'COM.TWS_TwsCtrl_1' is saying that either the the code is passing an incorrect number of input parameters, or one or more of these parameters are of a data type that the function is not expecting (i.e. the function may be expecting a string for the third input, and it is being passed an integer instead).
Is it possible for you to put a breakpoint at line 90 in ibtws/history (if such a file exists)? Then you could examine each variable and see if it matches the reqHistoricalDataEx() API of Interactive Brokers API Reference Guide whose inputs can be summarized as
Parameter Data Type
tickerId Integer
contract IContract
endDateTime String
durationStr String
barSize String
whatToShow String
useRTH Integer
formatDate Integer
chartOptions ITagValueList (probably optional)
With the above info, it seems clear that the code (at the line that is throwing an error) is passing the correct number of input parameters (the last, chartOptions, is probably optional (since it is a pointer) so probably can be ignored). So that could imply a problem with one of the inputs.
Given that you are invoking the function call
histTradeData = history(ib,ibContract,startDate,endDate);
which in turn calls
c.Handle.reqHistoricalDataEx(1,s,endDateTime,...
it may be safe to assume that your input ib maps to the c, the ibContract maps to the s, and the endDate maps to the endDateTime.
From the MATLAB example of interactive-brokers-historical-data-workflow, your code seems to be matching what the example did for the instantiation of the ib and the ibContract objects. The startDate and endDate are coded a little differently
bizDayConvention = 13;
startDate = daysadd(today,-20,bizDayConvention);
endDate = daysadd(today,-1, bizDayConvention);
This code is using a function from the Financial Toolbox, with daysadd returning a date NumDays number of days away from StartDate, using the given day-count basis. It's unclear to me what the data type is for this value...
Since this code is different from the simpler MATLAB example of
startDate = floor(now) - 5;
endDate = floor(now);
which presumably works, what would happen if you try these two lines instead of yours? Do you still get the same error when you call history(ib,ibContract,startDate,endDate)?

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.

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!