Problem with history function. Trading toolbox

4 次查看(过去 30 天)
Hello, I have a problem with Trading toolbox and IBTWS.
I downloaded and installed the TWS API and I can create the ibtws object properly, using the following code:
%% create object
ib = ibtws('',7496);
Then I set up en empty contract structure as follows:
%% set up an empty contract structure
ibContract = ib.Handle.createContract;
ibContract.symbol = 'IBM';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
ibContract.primaryExchange = 'IEX';
ibContract.currency = 'EUR';
I define the start and end date and then I try to call che history funtion:
% specify the period for which we need data
bizDayConvention = 13; % i.e. BUS/252
startDate = daysadd(today,-20,bizDayConvention);
endDate = floor(now);%daysadd(today,-1,bizDayConvention);
% call the 'history' function
histTradeData = history(ib,ibContract,startDate,endDate)
When I call the history function, I get the following error:
Error using registerevent (line 72)
Error registering events. 'historicalDataEnd' is not a valid event name.
Error in ibtws/history (line 54)
c.Handle.registerevent({eventNames{i},@(varargin)ibBuiltInHistoryEventHandler(varargin{:},c,tickerID)})
Does anyone have a solution for this?
Thanks a lot,
Andrea

回答(2 个)

Alok Nimrani
Alok Nimrani 2019-1-3
Hi Andrea,
Please verify that you have both the following installed:
1. TWS 970.1b (latest)
2. Interactive Brokers API 9.73 (i.e. 973.06 or 973.07)
Hope this helps.
Regards,
Alok
  1 个评论
Andrea Cavallo
Andrea Cavallo 2019-1-3
Dear Alok,
thank you for the reply. Unfortunately, both the TWS and the API are installed, but this did not solve the problem.
Do you have any other suggestion?
Thanks a lot,
Andrea

请先登录,再进行评论。


Yair Altman
Yair Altman 2019-1-4
编辑:Yair Altman 2019-1-4
Here's how you can fetch IB's historical data using the IB-Matlab connector:
>> data = IBMatlab('action','history', 'symbol','IBM', 'DurationValue',5, 'BarSize','1 hour')
data =
struct with fields:
dateNum: [1×78 double]
dateTime: {1×78 cell}
open: [1×78 double]
high: [1×78 double]
low: [1×78 double]
close: [1×78 double]
volume: [1×78 double]
count: [1×78 double]
WAP: [1×78 double]
hasGaps: [1×78 logical]
>> data.dateTime'
ans =
78×1 cell array
{'20181227 11:00:00'}
{'20181227 12:00:00'}
{'20181227 13:00:00'}
{'20181227 14:00:00'}
{'20181227 15:00:00'}
{'20181227 16:00:00'}
...
For additional details, see https://undocumentedmatlab.com/ib-matlab

类别

Help CenterFile Exchange 中查找有关 Transaction Cost Analysis 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by