IBrokers历史指数数据

时间:2013-03-21 03:24:49

标签: r ibrokers

如何从Interactive Brokers获取IND的历史数据?如果是期货,我会使用这个命令(如IBrokers request Historical Futures Contract Data?所示):

library(twsInstrument)
a <- reqHistoricalData(tws, getContract("ESJUN2013"))

但对S&amp; P指数connid的相应指挥给出了错误:

> a <- reqHistoricalData(tws, getContract("11004968"))
Connected with clientId 110.
Contract details request complete. Disconnected.
waiting for TWS reply on ES ....failed.
Warning message:
In errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106,  :
  Error validating request:-'uc' : cause - HMDS Expired Contract Violation:contract can not expire.

P.S。有足够积分的人应该为IBrokers

创建一个标签

2 个答案:

答案 0 :(得分:5)

我没有对索引数据的市场数据访问,但我认为以下应该可以正常工作。

reqHistoricalData(tws, twsIndex(symbol = "SPX", exch = "CBOE"))
## waiting for TWS reply on SPX ....failed.
## NULL

## Warning message:
## In errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106,  :
##  Historical Market Data Service error message:No market data permissions for CBOE IND

以下是reqContractDetails使用上述类似方法的结果,证明合同对象是由twsIndex

正确创建的
reqContractDetails(tws, twsIndex(symbol = "SPX", exch = "CBOE"))
## [[1]]
## List of 18
##  $ version       : chr "8"
##  $ contract      :List of 16
##   ..$ conId          : chr "416904"
##   ..$ symbol         : chr "SPX"
##   ..$ sectype        : chr "IND"
##   ..$ exch           : chr "CBOE"
##   ..$ primary        : chr ""
##   ..$ expiry         : chr ""
##   ..$ strike         : chr "0"
##   ..$ currency       : chr "USD"
##   ..$ right          : chr ""
##   ..$ local          : chr "SPX"
##   ..$ multiplier     : chr ""
##   ..$ combo_legs_desc: chr ""
##   ..$ comboleg       : chr ""
##   ..$ include_expired: chr ""
##   ..$ secIdType      : chr ""
##   ..$ secId          : chr ""
##   ..- attr(*, "class")= chr "twsContract"
##  $ marketName    : chr "SPX"
##  $ tradingClass  : chr "SPX"
##  $ conId         : chr "416904"
##  $ minTick       : chr "0.01"
##  $ orderTypes    : chr [1:22] "ACTIVETIM" "ADJUST" "ALERT" "ALLOC" ...
##  $ validExchanges: chr "CBOE"
##  $ priceMagnifier: chr "1"
##  $ underConId    : chr "0"
##  $ longName      : chr "S&P 500 Stock Index"
##  $ contractMonth : chr ""
##  $ industry      : chr "Indices"
##  $ category      : chr "Broad Range Equity Index"
##  $ subcategory   : chr "*"
##  $ timeZoneId    : chr "CST"
##  $ tradingHours  : chr "20130321:0830-1500;20130322:0830-1500"
##  $ liquidHours   : chr "20130321:0830-1500;20130322:0830-1500"
## 

答案 1 :(得分:0)

如何请求非美国股票的合约信息,我已经尝试了下面的两个电话,我在合同细节中得到错误,但这些是两个证券的符号和交换,我可以在TWS中提取信息

reqContractDetails(tws,twsEquity(symbol =&#34; BMW&#34;,exch =&#34; IBIS&#34;)

reqContractDetails(tws,twsEquity(symbol =&#34; BP&#34;,exch =&#34; EBS&#34;))

我甚至尝试过exch =&#39; SMART&#39;但它没有为宝马公司带来纽约证券交易所的BP线。这个电话只针对美国股票吗?