我正在使用Matlab內置的Interactive Broker庫來連接和使用TWS。我試圖要求實時數據,但是,過了一段時間,它就陷入了同樣的價格。它通常會更新幾分鐘,然後它會停止更新並給出相同的價格。Matlab IB實時數據卡住一段時間
我的代碼有問題嗎?
try
close(ib);
close(conn);
catch
end
clear all;
ibBuiltInRealtimeData = struct('id',0,'BID_PRICE',0,'BID_SIZE',0,'ASK_PRICE',0,'ASK_SIZE',0);
ib = ibtws('',7496);
f = '233';
ibContract = ib.Handle.createContract;
ibContract.symbol = 'EUR';
ibContract.secType = 'CASH';
ibContract.exchange = 'IDEALPRO';
ibContract.primaryExchange = '';
ibContract.currency = 'USD';
ibContract2 = ib.Handle.createContract;
ibContract2.symbol = 'M6E';
ibContract2.secType = 'FUT';
ibContract2.exchange = 'GLOBEX';
ibContract2.primaryExchange = '';
ibContract2.currency = 'USD';
ibContract2.expiry = '201609';
contracts = {ibContract;ibContract2};
tickerid = realtime(ib,contracts,f);
while true
d2 = ibBuiltInRealtimeData
tickerid
pause(1)
end