IBrokers历史指数数据



如何从Interactive Brokers获取INDEX的历史数据到R中?如果是期货,我会使用以下命令(此处建议IBrokers请求历史期货合约数据?):

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

但是与标普索引的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.

注:有足够的分数的人应该为IBrokers创建一个标签

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

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"
## 

相关内容

  • 没有找到相关文章

最新更新