Interactive Brokers TWS Connector
(Trader Work Station Desktop)
Interactive Broker Connector (Glean Preferred)Glean's Preferred Broker


Pre-requisites

  1. Install IB TWS and Glean
  2. An IB account. We recommend testing with a paper trading account.
  3. if you don't have an account, use demo account: user: edemo password: demouser

Setup

  1. In TWS, choose Configure->API and enable socket connections
  2. Make TWS run on a port 7496
  3. You should add the IP address 127.0.0.1 to the Trusted IP Addresses field (see screenshot)
TWS API Global Configuration

Testing

Once you have TWS running and pre-requisites configured:

  1. open quotopia design in Glean
  2. select your broker as interactive brokers to start TWS connector
  3. enter a symbol and verify you see a quote
  4. edit the design to customize your quote, add entry actions as needed

IB Security Symbols

IB has very particular (and also sometimes inconsistent) ways of providing a particular contract.

<symbol/localsymbol/classname> <exchange> <security type>

Examples:

  • EUR.USD CASH IDEALPRO (spot FOREX currency)
  • 6BU1 GLOBEX FUT (GBP.USD September 2011 currency futures)
  • AAPL ('STK' is implied by default)
  • FSFX_OCT_11 FUT DTB
  • IBM CALL 201111 165

The easiest way to determine the correct symbol :

  1. right click the symbol in TWS
  2. choose Contract Info -> Description,
  3. "Symbol/LocalName?/LocalClass?", "Security Type" and "Exchange".
  4. If you need to determine letter codes for futures contract months, look here.

With Verbose enabled you can also send an order from TWS and you'll see the correct symbol to use in Glean in the tws connector window/log.

Problems?   Ctrl+H us.

Overriding Defaults w/Symbol Overrides

Future options and FX symbols on IB sometimes have contract particulars that need to be provided along with the symbol.

If for your security you need to provide extra information like :

  • contract multiplier
  • security currency differs from account currency
  • easily specify or change local symbol or expiry, while always using the abstract symbol name (eg ES vs ESM3)

OR override defaults used by most securities like :

  • account name
  • whether trading after hours is allowed
  • disable automatic broker order transmission
  • etc

you can do this on a per symbol basis using Symbol Override Files.

To provide per-symbol contract information :

  1. copy the example SymbolOverrides?.csv in your installation folder
  2. add or edit the security information you want to override
  3. save the file somewhere
  4. edit Symbol Override line of TwsServer?.Config.txt to provide path to your override file
  5. restart TWS server
  6. the next time you send order or subscription requests for the TLSymbol in your override file, the connector will automatically convert them to the contract you provided in the file.

You may also want to checkout this post on Medium.

Common Questions

  • You can enable verbose logging by setting line below VERBOSE to 1 in TwsConfig?.txt in folder you installed Glean.
  • If you need to change your account currency, see TwsServer.Config.txt in folder you installed Glean.