gpt4 book ai didi

r - IBrokers 历史指数数据

转载 作者:行者123 更新时间:2023-12-04 11:00:52 25 4
gpt4 key购买 nike

如何从盈透证券将 INDEX 的历史数据导入 R?如果是 future ,我会使用这个命令(如这里所建议的 IBrokers request Historical Futures Contract Data? ):

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

关于r - IBrokers 历史指数数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15538921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com