0

有没有人在 IBrokers 上尝试过不同的交易所?我正在尝试获取在 ASX(澳大利亚交易所)上市的股票的市场数据或历史数据。我订阅了 Chi-X Australia。

library("IBrokers")
tws <- twsConnect()
security = twsSTK("TLS",primary = "ASX")
is.twsConnection(security) #says false 
security_copy = twsEquity(symbol = "TLS",primary = "ASX")
reqMktData(tws,security)
data_stock = reqHistoricalData(tws, security)

我收到此错误消息。

TWS 消息:2 1 200 没有为请求找到安全定义 TWS 消息:2 1 300 找不到带有 tickerId 的 EId:1 等待 TWS 在 TLS 上回复 ....失败。

4

1 回答 1

0

我不使用 Chi-X,但作为示例,下面的代码适用于 ASX 和 Globex 交易所。我希望这有帮助。

    library(IBrokers)

    tws = twsConnect()

    #ASX
    contract <-  twsSTK(symbol="BHP",exch="ASX",primary="ASX",currency="AUD")
    BHPHistorical <-  reqHistoricalData(tws, contract)
    BHPRealTime <- reqMktData(tws,contract,snapshot = TRUE)

    #SNFE futures data
    contract <-  twsFuture(symbol="SPI",exch="SNFE",primary="SNFE",currency="AUD",expiry="201712")          
    SPIHistorical <-  reqHistoricalData(tws, contract,barSize="30 mins",duration="1 M")
    SPIPRealTime <- reqMktData(tws,contract)

    #ASX Options data
    #using twsOption hasn't always worked
    contract <-  twsOption(local="XJOHU9",expiry = "20171116",strike="5750",right="C",exch="ASX",primary="",currency="AUD",symbol="",multiplier = 10,include_expired = FALSE,conId = 0)
    OptRealTime <- reqMktData(tws,contract)
    OptHistorical <-  reqHistoricalData(tws, contract)

    contract <-  twsContract(0,symbol="AP",sectype="OPT",exch="ASX",primary="ASX",expiry= "20171116",strike="5750",currency="AUD",right="C",local="",multiplier = "10",combo_legs_desc = "",comboleg = "",include_expired = "",secIdType = "",secId = "")
    OptRealTime <- reqMktData(tws,contract,snapshot = TRUE)
    OptHistorical <-  reqHistoricalData(tws, contract)


    #USA
    contract = twsFuture(symbol="ES",exch="GLOBEX",primary="GLOBEX",currency="USD",expiry="20171215")
    ESHistorical = reqHistoricalData(tws, contract)
    ESRealTime = reqMktData(tws, contract)
于 2017-09-28T00:18:02.520 回答