Setting Up Interactive Brokers Trader Workstation on Ubuntu 13.04
Trader Workstation(TWS) is a Java desktop trading platform for use with an Interactive Brokers account. I think that this is one of the better options out there for straightforward non-professional trading: the software has more features than any one individual is ever likely to even look at, let alone use, is frequently updated, and the commissions are low. I've used it for some years on Windows, but the time comes to make the move to Linux.
Here, then, is a recipe for setting up TWS on a new desktop machine running Ubuntu 13.04. This uses the January 6th 2014 build 943.1c of TWS, but I would expect it to work for future updates for a while yet: Interactive Brokers makes few changes to the fundamental structure of this application.
Log in As Your User
Log in with your user, the one who will be running TWS, and open up a command prompt.
Install Oracle Java 7
It may or may not matter which Java 7 JDK you use. But if there are issues with your choice then you might only discover that fact at a late and inopportune moment, while deep in use of TWS. The balance of online opinion and the requirements provided by Interactive Brokers point to going with Oracle Java over OpenJDK.
You'll want to run all of the following as root:
Head off to Oracle's Java site and download the tar.gz file for the latest JDK. Unpack it into a subdirectory of /user/local/java. For example:
mkdir /usr/local/java mv jdk-7u51-linux-x64.tar.gz /usr/local/java cd /usr/local/java tar -xf jdk-7u51-linux-x64.tar.gz rm jdk-7u51-linux-x64.tar.gz
Then place some necessary environment additions into /etc/profile.d/java.sh, ensuring that each new bash session will have them:
cat <<EOF > /etc/profile.d/java.sh JAVA_HOME=/usr/local/java/jdk1.7.0_51 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH EOF
Then update alternatives to make this the default Java:
update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_51/bin/java" 1 update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_51/bin/javac" 1 update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_51/bin/javaws" 1 update-alternatives --set java /usr/local/java/jdk1.7.0_51/bin/java update-alternatives --set javac /usr/local/java/jdk1.7.0_51/bin/javac update-alternatives --set javaws /usr/local/java/jdk1.7.0_51/bin/javaws
Now drop back out of root and into your user - it's never a good plan to leave a command prompt open as root. You'll forget and do things that will be annoying to clean up, such as launching desktop applications as the root user rather than as your user.
Install Java Browser Plugins
Since there are Java-based browser applications offered by Interactive Brokers, adding the necessary plugins to your browser is probably a good plan.
For Firefox, you just have to create a symlink to the plugin in the JDK such that Firefox can see it:
cd /usr/lib/mozilla/plugins sudo ln -s /usr/local/java/jdk1.7.0_51/jre/lib/amd64/libnpjp2.so
Chrome or Chrome-derived browsers like Iron should automatically discover the plugin on the next restart - so simply close any open browser windows and reopen them.
You can check to see whether the plugin is installed at the Java website. Note that Java-enabled pages in either browser will by default not automatically run Java applications, but will show a bar at the top of the page requesting permission for to use Java. This is the way you want things you be: automatically running Java applications in a browser is the road to ruin.
Install Interactive Brokers Trader Workstation
First create a place for TraderWorkstation in your home directory:
mkdir ~/TraderWorkstation mkdir ~/TraderWorkstation/logs
Download the TWS JAR for Linux from Interactive Brokers. Then unpack it and move the resulting directory into ~/TraderWorkstation:
jar xf unixmacosx.jar mv IBJts ~/TraderWorkstation/IBJtsNow create a script to launch TWS in ~/TraderWorkstation/launch.sh:
#!/bin/bash DIR="$( cd "$( dirname "$0" )" && pwd)" JTS_DIR=$DIR/IBJts JTS_LOG_DIR=$DIR/logs java -cp $JTS_DIR/jts.jar:$JTS_DIR/total.2013.jar \ -Xmx1024M -XX:MaxPermSize=256M jclient.LoginFrame $JTS_DIR \ >> $JTS_LOG_DIR/tws.log 2>&1
Give the script executable permissions:
chmod 744 ~/TraderWorkstation/launch.sh
You can now run TWS from the command line as your user with this script, and it will log its output to ~/TraderWorkstation/logs/tws.log. You should try it out at this point to make sure that everything works. No need to go beyond the login window: if you see that, then it is working.
Add Trader Workstation to the Launcher
But why run from the command line when you can have an icon in the launcher on the Ubuntu desktop? The first thing to do in order to achieve this goal is obtain a suitable icon. Fortunately there are many included in the TWS jar files. For example, this obtains a blue "IB" icon:
cd /tmp cp ~/TraderWorkstation/IBJts/jts.jar . jar -xf jts.jar cp trader/common/images/ibapp_icon.gif ~/TraderWorkstation
Create a file /usr/share/applications/trader-workstation.desktop that specifies how to launch TWS and which icon to display. Replace "/home/myuser" with the path to your user home directory:
sudo cat <<EOF > /usr/share/applications/trader-workstation.desktop [Desktop Entry] Type=Application Terminal=false Name=Trader Workstation Icon=/home/myuser/TraderWorkstation/ibapp_icon.gif Exec=/home/myuser/TraderWorkstation/launch.sh EOF sudo update-desktop-database
Lastly search for "Trader Workstation" in the Unity Dash (click the top icon in the launcher) and then launch it. Lock the icon to the launcher when it appears, and you are good to go.
Cautions and Issues
Workspaces are multiple desktop windows in Ubuntu, enabled under Appearance -> Behavior in the settings panel. They are not enabled by default in 13.04, but if you do use workspaces then you may experience a blocking issue when launching TWS in anything other than the top left default workspace. You may find that some of the TWS windows, such as chart displays, don't render, but are instead fixed invisibly to the foreground, blocking access to all other windows in the workspace. This happens about half the time if you have four open windows in your TWS configuration.
Fortunately this issue doesn't manifest in 13.10 or later versions, and ideally everyone on 13.04 should be upgrading shortly.