issue retrieving data from interactive brokers
3 次查看(过去 30 天)
显示 更早的评论
i'm using matlab 2021b with the most recent IB TWS, the example code provided by mathworks seems to run fine (no errors are produced), but no data is retrieved from IB.
%% connect to IB TWS
clear all; close all; clc
ib = ibtws('',7497);
%% Create the IContract Object
ibContract = ib.Handle.createContract;
ibContract.symbol = 'MSFT';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
ibContract.primaryExchange = 'NASDAQ';
ibContract.currency = 'USD';
d = getdata(ib,ibContract)
%% request last 20 days of data
bizDayConvention = 13; % i.e. BUS/252
currentdate = today;
startDate = daysadd(currentdate,-20,bizDayConvention);
endDate = daysadd(currentdate,-1,bizDayConvention);
%%
histTradeData = history(ib,ibContract,startDate,endDate);
the same problem occurs when trying to retrieve live market data and create orders.
On a seperate note if someone from mathworks sees this, the documentation regarding Interactive Brokers needs updating/more detail adding as there is no documentation provided by IB for MATLAB.
0 个评论
回答(1 个)
Shivam Lahoti
2023-11-3
Hi Philip Curran,
As per my understanding, you want to use the “ibtws” function. As stated in the question, you are able to extend the connection to IB TWS but facing difficulty while retrieving the data.
Please try the steps mentioned in the answer attached below and observe if it solves your problem. Though it does not throw an error for your connection step, following the mentioned steps might help in retrieving the data, as the answer discusses about using this functionality in releases after r2021a.
Have a look at the references attached below as they discuss the similar issue.
I hope this helps.
Regards,
Shivam Lahoti.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!