Goals of the Tutorial
The purpose of this tutorial is to demonstrate the basic functionality of the Interactive Brokers (IB) Java Application Programming Interface (API) used for accessing Historical market data in the IB trading platform. Concepts learned in this tutorial can be applied to larger projects such as building quote screens, capturing live market data and developing automated trading systems.
Tutorial Pre-Requisites
Prior to starting this tutorial, participants should have a basic user-level familiarity with the Interactive Brokers Trader Workstation (TWS) application. Follow this link for notes on installing the Interactive Brokers Gateway and API under the Linux Operating System. In addition, some experience with Java programming within Linux OS is preferable. All of the examples in this tutorial were developed using Ubuntu Linux with the OpenJDK (Java Development Kit). If you are new to programming in Java you should first complete a Java Programming tutorial such as: one of the tutorial on this page.
The following environment was used to develop the steps outlined in this tutorial:
- Host OS: Windows 7 Professional 64-Bit.
- Virtualization: Virtual Box version 4.3.10 (VirtualBox-4.3.10-93012-Win.exe) downloaded from http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html
- Linux Operating System: Ubuntu Linux 14.04 (Trusty Tahr) Desktop downloaded from http://releases.ubuntu.com/14.04/
- Interactive Brokers Gateway Build 944.3c April 29, 2014.
- IB TWS API version 9.71.01
- Compilers installed in Ubuntu Linux:
$ g++ -version gcc/g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc.
- Java Version:
$ java -version java version "1.7.0_55" OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1) OpenJDK Client VM (build 24.51-b03, mixed mode, sharing)
If you do not have these compilers installed, use the apt-get command (or other software installer such as yum) to download and install them. For example, to install the OpenJDK 7 Java Development Kit under Debian or Ubuntu Linux use the command:
$ sudo apt-get install openjdk-7-jdk
To install OpenJDK under CentOS, Fedora and other RedHat/Oracle distributions that use YUM, use the following command as root user:
yum install java-1.7.0-openjdk
Important Notes: Interactive Brokers routinely releases new versions of the IB Gateway, Trader workstation application and the API. In a given release, some of the method calls and parameters to those calls may change. Any changes will be reflected in their on-line documentation. Interactive Brokers typically shuts down their system every Saturday to do maintenance. If you are trying log in over a weekend and cannot, it is probably because their systems are down for maintenance.
The next section provides some links to on-line documentation for the Interactive Brokers API.