簡體   English   中英

啟用延遲市場數據的 IBrokers?

[英]IBrokers enabling Delayed market data?

我正在嘗試從 IBrokers 下載數據,但當前出現錯誤。 我不確定如何解決它。

注意:我沒有訂閱實時報價,但我確實獲得了延遲的市場數據。

我的步驟是:

security = twsSTK("AAPL")
is.twsContract(security)

1

security_copy= twsEquity('AAPL')
reqMktData(tws,security)

錯誤 output:

TWS 消息:2 1 162 歷史市場數據服務錯誤消息:ISLAND STK 沒有市場數據權限 TWS 消息:2 1 366 沒有找到代碼 id:1 的歷史數據查詢 TWS 消息:2 1 10168 請求的市場數據未訂閱。 延遲市場數據未啟用

歷史數據 function 似乎也有問題。

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 的回復....失敗。 NULL 警告消息:在 errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106, :
歷史市場數據服務錯誤消息:ISLAND 沒有市場數據權限

根據 TWS 文檔( 此處),可以使用 reqMarketDataType(4) 獲取延遲的市場數據。

也就是說,我建議使用 Ewald de Wit & Co 的 ib_insync package。

下面是我用來獲取延遲市場數據的代碼示例:

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 available

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM