Sunday, 4 February 2018

Get The Unique id conId Number from TWS

Learn how to get the unique id (conId) from Interactive brokers using a gui application. Every option has a different number since there are so many variations. The contract id (conid) is a number not a symbol, and this number you will need in order to trade options. For example the IBM 170 CALL option with an expiry on January 6, 2017 has a unique id number of  256910869. The number may be different on the next trading day.  I am not sure if they stay the same from now, until the next day until they expire. You can search for a contract id number here: https://pennies.interactivebrokers.com/cstools/contract_info/v3.9/index.php see the code here To access a September 2016 $40 Call option on Netflix : I believe there is a data fee for options. You need to pay for a data feed for the options in order to request data through the API
conID = 3 # Contract ID
symbol = "NFLX" # Netflix’s stock symbol
secType = "OPT" # Security type is an Option (OPT)
expiry = "20170120" # January 2017 Expiry format yyyymmdd
strike = 90 # $90.00 strike price
right = "CALL" # Call option
multiplier = "100" # multiplier 100 shares per contract for options
exchange = "SMART" # Use IB’s Smart Order router to get the prices
currency = "USD" # USD Currency

To access a June 2017 Crude Oil Futures contract set the properties:
conID = 2 # Contract Id
symbol = "CL" # Crude Oil underlying symbol (CL)
secType = "FUT" # Security type is an Future (FUT)
expiry = "20170120" # January 20, 2017 Expiry third Friday of month
exchange = "NYMEX" # Use IB’s Smart Order router to get the prices
To access a foreign exchange quote such as Euro/USD:
conID = 6 # Contract Id
symbol = "EUR" # Euro underlying (base currency) symbol (EUR/USD quote)
secType = "CASH" # Security type is Cash / FX
exchange = "IDEALPRO" # Use the IDEALPRO FX data source
currency = "USD" # Quoted currency is USD
 
Save Save

1 comment:

  1. Thanks for the posts.
    I saw your recent video about C# trading platform. Can you post something to get the conId, position, or orderId for C#. I'm struggling to adapt your later video to the new IB API Handlers.

    ReplyDelete