[R-SIG-Finance] Fteching options data using package IBrokers and interactivebrokers
Enrico Schumann
es at enricoschumann.net
Sun Jun 25 21:46:18 CEST 2017
On Sun, 25 Jun 2017, amol gupta writes:
> Hello,
>
> I have been trying to fetch contract details and finally fetch contract
> historical data. I have been able to do it with stock futures but I have
> been failing with options. Here is a very small snippet.
>
>
> c<-twsOPT(local = 'HDFC17JUN1780CE',strike = 1780, right = 'C',
> currency = 'INR',primary = 'NSE',multiplier = 1,
> conId = 271618757)
> d<-reqContractDetails(tws,c)
>
> Warning message:
> In reqContractDetails(tws, c) : error in contract details
>
>
> here
> <https://misc.interactivebrokers.com/cstools/contract_info/v3.9/index.php?action=Conid%20Info&wlId=IB&conid=271618719&lang=en>
> are the contract details. Please help me figure out what am I doing wrong.
Use 'twsContract' and specify only the local symbol, the
exchange, the currency and the security type:
require("IBrokers")
c <- twsContract(local = 'HDFC17JUN1780CE', sectype = "OPT",
currency = 'INR', exch = 'NSE',
include_expired = 1,
conId = "", symbol = "", primary = "", expiry = "",
strike = "", right = "", multiplier = "",
combo_legs_desc = "", comboleg = "", secIdType = "",
secId = "")
tws <- twsConnect()
reqContractDetails(tws, c)
## List of 18
## $ version : chr "8"
## $ contract :List of 16
## ..$ conId : chr "271618757"
## ..$ symbol : chr "HDFC"
## ..$ sectype : chr "OPT"
## ..$ exch : chr "NSE"
## [....]
See also
https://github.com/enricoschumann/IButils#finding-the-contract-specification
--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net
More information about the R-SIG-Finance
mailing list