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