Problem with history function. Trading toolbox
조회 수: 5 (최근 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!