Instructions for Installing Interactive Brokers IB Gateway in Linux Bash
Tags: linux, ib, gateway, fmzquant
Published: 2024-05-28 07:44:17

FMZ platform now supports the integration of Interactive Brokers (IB). It's quite simple on Windows, so we won't explain how to install it here. For Linux users who generally rent servers without a graphical interface and only have SSH, the installation is more challenging. This article will explain how to install IB Gateway for quantitative trading. We usually choose to install IB Gateway instead of TWS client, because the TWS client shuts down periodically and is not suitable for quantitative trading. Here we take Debian as an example:

**Step 1: Install Desktop Services and VNC**

First, you need to install desktop services and a VNC server to enable remote desktop access. Here, we will use xfce and TightVNC as examples. Execute the following commands in the terminal to install:

```
sudo apt update
sudo apt install xfce4 xfce4-goodies dbus-x11
sudo apt install tightvncserver
tightvncserver
```
Please note that the maximum length for the password during installation is 8 characters. Please set a highly secure password. The default startup port for the first session is 5901.

**Step 2: Connect to VNC and Install IB Gateway**

The default address is vnc://IP Address:5901, you can log in by entering the password. For Windows, please download and install the VNC client yourself.

Download page: https://www.interactivebrokers.com/en/trading/ibgateway-stable.php
Please use a tool similar to wget for downloading. If you can't find the corresponding version, please click on "Download for Other Operating Systems" on the page to search.

```
wget https://download2.interactivebrokers.com/installers/ibgateway/stable-standalone/ibgateway-stable-standalone-linux-x64.sh
```
If it's inconvenient to download within VNC, you can initiate a separate SSH download and then install it under the VNC desktop environment.

```
bash ibgateway-stable-standalone-linux-x64.sh
```
The interface can already be displayed here, you can manually run the installation directory directly by running ./ibgateway.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ynbmi5mf8na8s12y8ovl.png)

After installation, log in and find the API option. Make sure to uncheck "Read-Only API". The port number is also in the settings. Please configure the exchange correctly according to this port number.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tq1w4agq5rbvkw4p5mnp.png)

The exchange is configured as follows: Client ID. If you have multiple robots that need to connect, this needs to be set to different IDs, as IB does not allow the same Client ID to connect simultaneously.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wta7aqwm4euwwmk0i6c9.png)

It should be noted that localhost and 127.0.0.1 are not the same network address at the lower level of the Linux operating system, here we use localhost.

IB's market data requires a paid subscription. If you need real-time ticker and depth information, please subscribe for a fee, otherwise you can only receive delayed tickers.

From: https://blog.mathquant.com/2023/12/04/instructions-for-installing-interactive-brokers-ib-gateway-in-linux-bash.html