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 Center および File ExchangeWind 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