r语言 - IBrokers - reqMktData



有人在iBrokers上尝试过不同的交流吗?我正在尝试获取ASX(澳大利亚交易所(上列出的股票的市场数据或历史数据。我已订阅Chi-X澳大利亚。

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上的回复....失败。

我不使用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)

相关内容

  • 没有找到相关文章

最新更新