Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can avoid these types of problems by using the twsInstrument package <a href="https://r-forge.r-project.org/R/?group_id=1113" rel="noreferrer">on R-Forge</a></p> <pre><code>library(twsInstrument) </code></pre> <p>Any of these will get the twsContract</p> <pre><code>getContract("AAPL 111217P00390000") getContract("AAPL 111217P00390000") #number of spaces does not matter getContract("AAPL20111217P00390000") #year can be 4 digits or 2 getContract("AAPL_111217P00390000") getContract("AAPL111217P00390000") getContract("AAPL111217P390") getContract("AAPL_111217P390") getContract("AAPL_20111217P390") getContract("AAPL_111217P390.00") #by conId getContract("93189601") getContract(93189601) </code></pre> <p>All of those will give you the same thing:</p> <pre><code>&gt; getContract(93189601) List of 16 $ conId : chr "93189601" $ symbol : chr "AAPL" $ sectype : chr "OPT" $ exch : chr "SMART" $ primary : chr "" $ expiry : chr "20111216" $ strike : chr "390" $ currency : chr "USD" $ right : chr "P" $ local : chr "AAPL 111217P00390000" $ multiplier : chr "100" $ combo_legs_desc: chr "" $ comboleg : chr "" $ include_expired: chr "" $ secIdType : chr "" $ secId : chr "" </code></pre> <p>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</p> <pre><code>&gt; getContract("ESM1") Connected with clientId 100. Trying to resolve error in contract details. Using include_expired=1 Contract details request complete. Disconnected. List of 16 $ conId : chr "73462897" $ symbol : chr "ES" $ sectype : chr "FUT" $ exch : chr "GLOBEX" $ primary : chr "" $ expiry : chr "20110617" $ strike : chr "0" $ currency : chr "USD" $ right : chr "" $ local : chr "ESM1" $ multiplier : chr "50" $ combo_legs_desc: chr "" $ comboleg : chr "" $ include_expired: chr "1" $ secIdType : chr "" $ secId : chr "" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload