Interactive Brokers TWS

<< Click to Display Table of Contents >>

Navigation:  daytradr Toolset > Connection Manager >

Interactive Brokers TWS

Note - As of release 2.1.0.2 - this is Production Release of the interface, versions earlier than that are Beta Releases.

 

The connection to Interactive Brokers (IB) is via their TWS Trading application which can be downloaded if you click here. We currently support TWS Version 10.12.2v.

 

 

Some notes about IB

We are connecting via TWS as IB can't take us on as an API partner right now. This is down to issues they have with a 3rd party.

Intehration requires TWS version 978.1g or later. This is REALLY important. If you don't use the right version, then the L2 for equities will not appear.

This is BETA for now - which means we advise using it with IB paper. It has been extensively tested by our QA but glitches always appear when we release something new like this.

You CAN trade IB using another data provider such as CQG or IQFeed. For Equities, IBs data is more complete than IQFeed (see below for limits).

Their Level 1 data used to be useless - but they appear to have fixed it, so from our perspective it's good to go for Order Flow

We support Equities and Futures. For Equities we consolidate the bids and offers from all of your equities subscriptions to one total.This gives you the most complete view of the depth available.

We also divide the numbers by 100. Stocks are traded in lots and a lot is 100 contracts. Now - you don't have to trade in 100's but the numbers on the DOM are huge and to display them in their entirety makes them really hard to read. The depth and the trades (L2 and L1) are all divided by 100. So the numbers trading and the depth match. You end up with something that looks like this:

 

clip0269

 

If you can imagine all of those numbers having an extra "00" on the end, then you'll get why we took this step. Our goal is always to make sure the flow is most readable.

IB limit how many depth of market feeds you can have at a time. It's 3 by default but it goes up with the amount you trade or you can pay for more. We will shortly release a feed to sit alongside IB for those that find this an issue.

Because of the limit, we are not downloading L1 data to calculate MAE/MFE or open position P&L. You can still see position P&L on the Depth & Sales. Closed P&L will of course be fine.

Like many APIs, IB doesn't carry fill information prior to today, so first time you connect, your long term positions will get time stamped with the date you connected.  As long as you don't delete the database folder in My Documents/Jigsaw Trading or logon from another PC via daytradr, this will be fine - it'll match your positions in TWS against what you last had in Jigsaw. If it can't do this, it'll either leave the trades open in Journalytix (and you can delete them after 20 days) or close the existing position and create a new one. It's quirky but as long as you don't delete the db, it'll be fine.

 

When logging in to TWS, check which time zone it's set to (this should only be necessary once). On the logon screen you will see "More Options" at the bottom. Click that and you will see the following:

 

 

clip0273

 

Either make a note of the time zone or set it to your preferred time zone.

 

Before connecting, you have to set TWS to allow API connections. You do this via the Global Configuration Menu

 

clip0266

 

 

You'll see this screen:

clip0267

 

 

First click where it says "API" and then settings. Then you need to:

Enable Active X and Socket Clients

Take a note of the Socket Port - it's usually 7497 or 7496

Allow connections from localhost only - this is recommended but you can have daytradr on one PC and TWS on another PC. In that case, you would add the IP address of the daytradr PC to the list of Trusted IPs. If you have no idea what that means, then don't worry - it's an advanced requirement.

Note - it is important that you NEVER click "RESET API order ID sequence" - we match these order id's against our database, so if you reset the id's - all orders look new to us. That's not good!

 

Next you configure the connection on the daytradr side. This is fairly simple:

 

 

 

clip0274

 

 

 

 

Connection:        The name of the connection - just something you'll remember it by.

Description:        Optional - an additional description for the connection.

Host:                If TWS is on the same PC as daytradr, enter 127.0.0.1. If not, enter the IP address of the machine running TWS

Port:                The port defined above in TWS API Settings

TWS Time Zone: The Time Zone you set for TWS above (sometimes TWS installs with a non-local time zone)

Auto Connect:        Check if you want this connection to connect automatically on start up

Auto Connect Sequence Number:        The order of connection. If you have more than one connection that will connect on startup, you can specify which one you want to connect first.