一段时间后,Matlab IB实时数据被卡住 [英] Matlab IB realtime data gets stuck after a while

查看:184
本文介绍了一段时间后,Matlab IB实时数据被卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Matlab的内置Interactive Broker库来连接和使用交易平台.我试图请求实时数据,但是,一段时间后,它只是停留在相同的价格上.它通常会更新几分钟,然后稍后会停止更新,并给出相同的价格.

I am using Matlab's built-in Interactive Broker library to connect and use TWS. I am trying to request real time data, however, after a while it just gets stuck on the same price. It updates normally for a few minutes and then later it just stops updating and the same prices are given.

我的代码有问题吗?

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

推荐答案

这可能是由于网络问题导致Matlab的连接器陷入无效状态,或者是IB的服务器被阻塞了.您可以尝试与IB断开连接,然后重新连接并重新请求实时数据-也许这将重置连接问题并从那时起向您发送良好的数据.

This may be due to either a networking issue that caused Matlab's connector to get stuck in an invalid state, or IB's server that might have been stuck. You can try to disconnect from IB and then reconnect and re-request realtime data - perhaps this will reset the connection problem and send you good data from that point on.

或者,尝试使用IB-Matlab连接器( http://UndocumentedMatlab.com/IB-Matlab),据报道它更健壮.

Alternatively, try using the IB-Matlab connector (http://UndocumentedMatlab.com/IB-Matlab), which is reportedly more robust.

这篇关于一段时间后,Matlab IB实时数据被卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆