Click or drag to resize
Interactive Brokers Connection

This section describes how to configure the Interactive Brokers connection.

ArthaChitra uses the IB C# API (version to connect to TWS/IB Gateway.


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)
  • 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)
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
    • Append a suitable name of the connection in the Name textBox
    • Append a host value (default value is
    • Append the port value (as set in TWSGateway configuration settings)
    • Set an appropriate 'Client Id' (default and recommended value is 0 (zero))
    • 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
  • 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}


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 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