R Ibrokers twsOPT 用法

标签 r quantitative-finance ibrokers

reqMktData(tws,twsOPT("AAPL 110820C00390000"))

或者
reqMktData(tws,twsOPT("AAPL110820C00390000"))

导致:
TWS 消息:2 1 200 未找到请求的安全定义

为什么?
reqMktData(tws,twsSTK("AAPL"))

工作正常。

手册页说:
twsOption(local,
          expiry="",
          strike="",
          right="",
          exch="SMART",
          primary="",
          currency='USD',
          symbol='',
          multiplier="100",
          include_expired='0',
          conId=0)

TWS 上的期权合约有一些不同于标准数据请求的规则。

本地符号是必需的。这可以在 TWS 主屏幕上的契约(Contract)详细信息下找到,或通过网站 www.interactivebrokers.com 找到

由于需要局部符号,所有其他值都是多余的。最好简单地指定本地名称并让 TWS 管理查找。

最佳答案

你没有得到正确的本地。正确的格式使用 6 个字符宽的字段(OSI 规范),您分别尝试使用 5 和 4。

当然,您不需要使用 local,但这需要跨不同 args 的更多详细信息。

> reqContractDetails(ibg, twsOPT("AAPL  110820C00390000"))
[[1]]
List of 18
  $ version       : chr "6"
  $ contract      :List of 16
..$ conId          : chr "86896934"
..$ symbol         : chr "AAPL"
..$ sectype        : chr "OPT"
..$ exch           : chr "SMART"
..$ primary        : chr ""
..$ expiry         : chr "20110819"
..$ strike         : chr "390.0"
..$ currency       : chr "USD"
..$ right          : chr "C"
..$ local          : chr "AAPL  110820C00390000"
..$ multiplier     : chr "100"
..$ combo_legs_desc: chr ""
..$ comboleg       : chr ""
..$ include_expired: chr ""
..$ secIdType      : chr ""
..$ secId          : chr ""
..- attr(*, "class")= chr "twsContract"
$ marketName    : chr "AAPL"
$ tradingClass  : chr "AAPL"
$ conId         : chr "86896934"
$ minTick       : chr "0.01"
$ orderTypes    : chr [1:44] "ACTIVETIM" "ADJUST" "ALERT" "ALGO" ...
$ validExchanges: chr [1:12] "SMART" "AMEX" "BATS" "BOX" ...
$ priceMagnifier: chr "1"
$ underConId    : chr "265598"
$ longName      : chr "APPLE INC"
$ contractMonth : chr "201108"
$ industry      : chr "Technology"
$ category      : chr "Computers"
$ subcategory   : chr "Computers"
$ timeZoneId    : chr "EST"
$ tradingHours  : chr "20110817:0930-1600;20110818:0930-1600"
$ liquidHours   : chr "20110817:0930-1600;20110818:0930-1600"

您可以使用 as.twsContract 提取契约(Contract):
as.twsContract(reqContractDetails(ibg, twsOPT("AAPL  110820C00390000")))

或者直接调用 reqMktData 请求:
reqMktData(ibg, twsOPT("AAPL  110820C00390000"))

## OR

reqMktData(ibg, twsOPT("",symbol="AAPL",right="C", strike="390", expiry="201108"))

关于R Ibrokers twsOPT 用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7087776/

相关文章:

Python 网络 x : Add duplicate or equal nodes to a tree/graph?

Python:使用谷歌财经下载索引数据

performance - 如何提高在 DolphinDB 中计算希腊语的性能?

R IBrokers。如何让货币合约在 reqHistoricalData 调用中发挥作用?例如加元兑美元汇率?而如何拉动指数价格呢?例如标准普尔、道琼斯指数?

python - reqHistoricalData() 使用 IBpy 返回空值?

r - IBrokers 历史指数数据

r - 如何将具有不同列名的数据框从宽转换为长,具有不同的列名

r - 第一个 Shiny 应用程序出错

r - 在时间序列中查找缺失值

R Zoo - 聚合具有相同时间条目的许多记录