简体   繁体   English

IBrokers-reqMktData

[英]IBrokers - reqMktData

Has anyone tried different exchanges on IBrokers? 有没有人尝试过在IBrokers上进行不同的交流? I am trying to get either market data or historical data for stocks listed on ASX(Australian Exchange). 我正在尝试获取在澳大利亚证券交易所(ASX)上市的股票的市场数据或历史数据。 I am subscribed to Chi-X Australia. 我订阅了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)

I get this error messages. 我收到此错误消息。

TWS Message: 2 1 200 No security definition has been found for the request TWS Message: 2 1 300 Can't find EId with tickerId:1 waiting for TWS reply on TLS ....failed. TWS消息:2 1 200找不到请求的安全定义TWS消息:2 1 300找不到带有tickerId:1的EId,等待TLS .... TWS答复...失败。

I don't use Chi-X, but as an example the code below works for the ASX and Globex exchanges. 我不使用Chi-X,但是作为示例,以下代码适用于ASX和Globex交易所。 I hope this helps. 我希望这有帮助。

    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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM