IB request historical data error

1 次查看(过去 30 天)
Shiang Qiu
Shiang Qiu 2017-11-4
编辑: Shiang Qiu 2017-11-4
Hello, I'm trying to create a timer object to continuously call history function in trading toolbox @ibtws so that I can collect enough trading data and avoid IB data request restriction issue, yet error pops out as "You cannot set the 'DataRequest' property of ibtws." I wonder if there's a better way to send data request to IB without violating data restriction. Thank you.
I've attached my code here.
ib = ibtws('',7496)
ibContract = ib.Handle.createContract;
ibContract.symbol = 'ABX';
ibContract.currency = 'USD';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
startDate = floor(now) - 5;
endDate = floor(now) - 4;
period = '1 min';
tradehours = 1;
ticktype = 'TRADES';
e.ib = ib;
e.Contract = ibContract;
e.startDate = startDate;
e.endDate = endDate;
e.tradehours = tradehours;
e.period = period;
e.ticktype = ticktype;
e.stockInfo = [];
ibTimer = timer('ExecutionMode','singleShot',...
'Period',2,'TimerFcn',@ibHist);
set(ibTimer,'UserData',e);
start(ibTimer);
stop(ibTimer);
delete(ibTimer)
function ibHist(obj,~)
message = obj.UserData;
fun = @history;
ib = message.ib;
ibContract = message.Contract;
startDate = message.startDate;
endDate = message.endDate;
ticktype = message.ticktype;
period = message.period;
tradehours = message.tradehours;
ibData = fun(ib,ibContract,startDate,endDate,ticktype,period,tradehours);
message.stockInfo = ibData;
set(obj,'UserData',message);
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Wind Data Feed Services (WDS) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by