R Ibrokers twsOPT 用法
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 主屏幕上的合约详细信息下找到,或者通过 www.interactivebrokers.com 网站找到。
由于需要本地符号,所有其他值都是多余的。最好简单地指定本地名称并让 TWS 管理查找。
reqMktData(tws,twsOPT("AAPL 110820C00390000"))
or
reqMktData(tws,twsOPT("AAPL110820C00390000"))
result in:
TWS Message: 2 1 200 No security definition has been found for the request
Why?
reqMktData(tws,twsSTK("AAPL"))
works fine.
The manpage says:
twsOption(local,
expiry="",
strike="",
right="",
exch="SMART",
primary="",
currency='USD',
symbol='',
multiplier="100",
include_expired='0',
conId=0)
Option contracts on the TWS have certain rules which are different than standard data requests.
The local symbol is required. This can be found on the main TWS screen under contract details, or via the web at www.interactivebrokers.com
Since the local symbol is required, all other values are redundant. It is best to simply specify the local name and let the TWS manage the lookup.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有得到正确的本地信息。正确的格式使用六个字符宽的字段(OSI 规范),而您分别尝试使用 5 和 4。
当然,您不需要使用本地,但这需要跨不同参数的更多详细信息。
您可以使用 as.twsContract 提取合约:
或者直接调用 reqMktData 请求:
You are not getting the local correct. The correct format uses a field six characters wide (OSI spec), and you are trying 5 and 4, respectively.
You aren't required to use local of course, but that requires more details across different args then.
You can either extract the contract using as.twsContract:
Or just call the reqMktData request as is:
您可以通过使用 R-Forge 上的 twsInstrument 包来避免此类问题
其中任何一个都会得到 twsContract
所有这些都会给你同样的东西:
不幸的是,你无法获得已经过期的期权的合同详细信息。我不知道这是否是IBrokers的问题,或者Interactive Brokers是否不支持它,但是获取已过期期货的合约详细信息是没有问题的
You can avoid these types of problems by using the twsInstrument package on R-Forge
Any of these will get the twsContract
All of those will give you the same thing:
Unfortunately, you cannot get contract details for options that have already expired. I don't know if this is a problem with IBrokers, or if Interactive Brokers doesn't support it, but getting contract details for already expired futures is no problem