Problem with history function. Trading toolbox

2 vues (au cours des 30 derniers jours)
Andrea Cavallo
Andrea Cavallo le 27 Déc 2018
Modifié(e) : Yair Altman le 4 Jan 2019
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

Réponses (2)

Alok Nimrani
Alok Nimrani le 3 Jan 2019
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 commentaire
Andrea Cavallo
Andrea Cavallo le 3 Jan 2019
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

Connectez-vous pour commenter.


Yair Altman
Yair Altman le 4 Jan 2019
Modifié(e) : Yair Altman le 4 Jan 2019
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

Catégories

En savoir plus sur Transaction Cost Analysis dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by