IB request historical data error
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Wind Data Feed Services (WDS) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!