IB request historical data error
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!