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
0 个评论
回答(2 个)
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
Yair Altman
2019-1-4
编辑:Yair Altman
2019-1-4
>> 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'}
...
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!