Click or drag to resize

Interactive Brokers Connection

This section describes how to configure the Interactive Brokers connection.

ArthaChitra uses the IB C# API client (version 10.20)

Requirements

Please make sure you meet the below requirements to connect to Interactive Brokers.

Note: If you want to submit orders you need to register ArthaChitra. Please click here to know how to register ArthaChitra.

Configuring TWS/IB Gateway

Please configure TWS/IB Gateway as below

  • In TWS/IB Gateway menu bar goto Edit > Global Configuration... (Or File > Global Configuration)
    TWSConfiguration
  • In the Configuration dialog view click on the API > Settings node and configure the options as below:
    • Check on the option "Enable ActiveX and Socket Client" (this option is not available in IB Gateway)
    • Uncheck the option "Read-only API"
    • Check the option "Include FX position when sending portfolio"
    • Set the option "Socket port" to 7497 (4002 in case of IB Gateway)
    TWSSettings
Configuring IB Connection Settings

Once you have configured the TWS/IB Gateway settings, you need to set up the Interactive Brokers Connection in ArthaChitra. Please follow the below steps to configure the Interactive Brokers Connection settings:

  • In the "Main View" goto Connection > Add Edit Connection
  • In the Add Edit connection view click on the Add button
  • In the "New Connection View" select 'Interactive Brokers' as the Connection Type and set the settings as
    • Name - Append a suitable name of the connection in the Name textBox
    • IP address - Append a host value (default value is 127.0.0.1)
    • Port - Append the port value (as set in TWSGateway configuration settings)
    • IB client id - Set an appropriate 'Client Id' (default and recommended value is 0 (zero))
    • Default exchange - Set a default exchange for instruments in Smart Order Routing. If ArthaChitra is unable to determine the exchange it will use this user defined exchange
    • Is account name formatted - Check if you want to format the account name with the connection name
    • Is smart depth - Is market depth (Level-II data) has smart depth
    • Option computation type - Greek values to be calculated from the chosen price points
  • Click on the Close button and exit the Add Edit connection view

Now you will be able to connect to the newly created Interactive Brokers connection from, in Main View menu bar goto Connection > Available Connections > {name of the IB connection}

IBSettings
Disclaimer

Before connecting to Interactive Brokers please refer to the below scenarios for a proper understanding on how ArthaChita works with Interactive Brokers. Please do note the below list is not exhaustive. There may be scenarios in addition to what listed below

  • If you encounter the error message "No connection could be made because the target machine actively refused it" then please make sure TWS or IB Gateway is running and you have configure TWS and IB Connection settings as described above.
  • ArthaChitra supports Indices, Stocks, Forex, Futures and Options.
  • ArthaChitra supports DAY, IOC, GTC, GTD, AON, DTC and OPG TimeInForce
  • For forex, the bid price is appended as the last price.
  • 'Trades' data is pulled when historical data is requested, except for forex, for which 'Midpoint' data is pulled.
  • Interactive Brokers supports only three 'Level II' requests at any time. If additional requests are made then ArthaChitra will unsubscribe the previous requests (on FIFO basis) to accommodate the new requests.
  • Orders submitted by a Managed automated strategy, the OCO simulation for the stop and target order is simulated locally. However the orders submitted by an Unmanaged automated strategy, Order Template (Bracket orders) and 'OCO' orders the OCO Simulation is handled by the server.
  • IB supports trading for exchanges around the globe. While we have tested the popular instruments some instruments may need additional configurations. Please send an email to support@arthachitra.com in case you need any assistance while configuring the symbols of your choice.
  • IB has an order and data throttle policy. Please refer to the below links to know more about it
  • To know more about TWS order status colors please click here
  • In case realtime quotes are not streaming for any instrument and you are getting an error message like error : id = 1073741837, errorCode = 354, errorMsg = Requested market data is not subscribed.Delayed market data is not available.RELINFRA NSE/TOP/ALL then please make sure you have subscribed realtime quotes for the said instrument. In case you are connected to the paper trading account then please make sure you have shared the 'Market data subscription'. Please click here to know more
  • Forex (IdealPro) orders are rounded to nearst 5 * tick-size to conform round-off policy of IB.