如何启用交易平台延迟的市场数据? [英] How to enable TWS delayed market data?

查看:226
本文介绍了如何启用交易平台延迟的市场数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用来请求市场数据的脚本.

Here is a script I am using to request market data.

我还没有订阅数据馈送,因此尽管它会自动返回延迟的市场数据,但是显然我必须启用它,但是找不到在哪里做.
这是脚本和我得到的错误,我所需要的只是接收延迟的数据,因此我可以测试我的算法.

I am not subscribed to the data-feed yet, so I though it would automatically return delayed market data, but apparently I have to enable it, but cannot find where to do that.
Here is the script and the errors I get, all I need is to receive delayed data, so I can test my algorithm.

from ib.opt import ibConnection, message
from ib.ext.Contract import Contract
from time import sleep

def fundamentalData_handler(msg):
    print(msg)

def error_handler(msg):
    print(msg)

tws = ibConnection(port=7496, clientId=100)
tws.register(error_handler, message.Error)
tws.register(fundamentalData_handler, message.fundamentalData)
tws.connect()

c = Contract()
c.m_symbol = 'AAPL'
c.m_secType = 'STK'
c.m_exchange = "SMART"
c.m_currency = "USD"

print "on it"

tws.reqMktData(897,c,"",False)
sleep(50)

tws.disconnect()

错误:

<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:hfarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:eufarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:jfarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfuture>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:cashfarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfarm.us>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfarm>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ilhmds>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:euhmds>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:fundfarm>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ushmds>
<error id=897, errorCode=10168, errorMsg=Requested market data is not subscribed. Delayed market data is not enabled>

推荐答案

文档建议(重点和添加的格式):

API可以通过IBApi.EClient.reqMarketDataType

# Switch to live (1) frozen (2) delayed (3) delayed frozen (4).

.reqMarketDataType( MarketDataTypeEnum.DELAYED )

.reqMktData()发出市场数据请求之前必须先被称为

.

that has to be called before making a market data request with .reqMktData().

这篇关于如何启用交易平台延迟的市场数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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