我正在尝试从IBrokers下载数据,但目前出现了一个错误。我不知道该怎么解决。
注:我没有订阅实时报价,但我确实得到延迟的市场数据。
我的步骤是:
security = twsSTK("AAPL")
is.twsContract(security)1真
security_copy= twsEquity('AAPL')
reqMktData(tws,security)错误输出:
TWS消息:2 162个历史市场数据服务错误消息:没有岛屿STK TWS消息的市场数据权限:2 1366没有为代码id找到的历史数据查询:1 TWS消息:2 1 10168请求的市场数据未被订阅。未启用延迟的市场数据
历史数据函数似乎也有问题。
data_AAPL=reqHistoricalData(tws, security)我还在链接中尝试了这个例子
IBrokersRef() # IBrokers Reference Card in PDF viewer
tws <- twsConnect() # make a new connection to the TWS
reqCurrentTime(tws) # check the server's timestamp
contract <- twsEquity('IBKR','SMART','ISLAND') # equity specification
reqHistoricalData(tws,contract) # request historical data结果:
在IBKR ....failed上等待TWS答复。空警告消息:在errorHandler中(con,verbose,OK = c(165,300,366,2104,2106 ),: 历史市场数据服务错误消息:岛屿没有市场数据权限
发布于 2022-03-29 17:41:08
基于TWS文档(这里),可以使用reqMarketDataType(4)获得延迟的市场数据。
尽管如此,我还是建议使用来自Ewald & Co的ib_insync包。
下面是一个用于获取延迟的市场数据的代码示例:
from ib_insync import *
util.startLoop()
ib = IB()
ib.sleep(2)
ib.connect('127.0.0.1', port=7490, clientId=12) # NB: Non default port could be 7498 on your machine by default when using TWS
ib.reqMarketDataType(4) # This line is the one that counts to get delayed data without subscription if availablehttps://stackoverflow.com/questions/50891905
复制相似问题