Giter Site home page Giter Site logo

ibgateway's Introduction

Interactive Brokers Gateway Docker

This image runs the last stable (stand-alone) version of ©Interactive Broker Gateway.


Docker Image

The image is based on 'phusion/baseimage:18.04-1.0.0', which is a minimalist image based in Ubuntu Linux with a lot of improvements to use as docker base image. If you want know more, take a look at your documentation

In addition, it uses the IBC Project to manage the configuration and launch of the ©IBGateway; and serve a VNC server to control the IBC / IBGateway interface.

Current versions:

  • Interactive Brokers Gateway: v981.3c
  • IBC: v3.12.0

You can find the latest version of this image on docker-hub: mgvazquez/ibgateway


Build the docker image

To build this image, run the following command on the root path of the repo:

$ docker build -t mgvazquez/ibgateway:latest .

IMPORTANT: Must have docker installed on your system.

Docker Compose

Here are an example of how to run this image with docker-compose:

version: '3'
services:
  gateway:
    image: mgvazquez/ibgateway:latest
    restart: always
    ports:
      - "7462:7462"
      - "4001:4001"
      - "5900:5900"
    environment:
      - VNC_PASSWORD=<vnc_pass_change_me>
      - VNC_PORT=5900
      - TWSUSERID=<usr_change_me>
      - TWSPASSWORD=<pwd_change_me>
      - TRADING_MODE=paper

In this example you will launch the Interactive Brokers Gateway in paper mode listening on port 4001, and the VNC Server listening on port 5900.

Another environment variables that you can set are:

Variable Description Required
TZ Container timezone
Default: America/Argentina/Buenos_Aires
no
TWSUSERID IB account user id
Default: <change_me>
yes
TWSPASSWORD IB account password
Default: <change_me>
yes
TRADING_MODE Indicates whether the live account or the paper trading account will be used. Allowed values are: live / paper
Default: paper
no
VNC_PASSWORD VNC Server password
Default: <change_me>
yes
VNC_PORT VNC Server port
Default: 5900
no
FIXUSERID FIX account user id
Default: <empty>
no
FIXPASSWORD FIX account password
Default: <empty>
no
IBC_INI Absolute path of the config.ini config file (*)
Default: /root/IBC/config.ini
no
TWS_CONFIG_PATH Path of the jts.ini config file (*)
Default: /root/Jts
no

(*) NOTE: The env-vars IBC_INI and TWS_CONFIG_PATH, only must be used if you mount your custom config.ini and jts.ini files in other paths than the default ones.

Can find the defaults config.ini and jts.ini files in the components folder in this repo.

Launching with docker-compose

IMPORTANT: Must have docker-compose installed on your system.

$ docker-compose up
Recreating deployment_gateway_1 ... done
Attaching to deployment_gateway_1
gateway_1  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
gateway_1  | *** Running /etc/my_init.d/10_syslog-ng.init...
gateway_1  | Jul 16 21:12:26 a0c679e721a5 syslog-ng[13]: syslog-ng starting up; version='3.13.2'
gateway_1  | *** Booting runit daemon...
gateway_1  | *** Runit started as PID 22
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: Starting Interactive Brokers Controller
gateway_1  | Jul 16 21:12:27 a0c679e721a5 xvfb: Starting Xvfb - Virtual Framebuffer 'fake' X server
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: Starting VNC server to allow remote access to an existing X session
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +==============================================================================
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: + IBController version 3.2.0.5
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: + Running GATEWAY 978
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: + Diagnostic information is logged in:
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: + /root/IBController/Logs/ibc-3.2.0.5_GATEWAY-978_Thursday.txt
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: +
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: ================================================================================
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: Starting IBController version 3.2.0.5 on 2020-07-16 at 21:12:27
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: Operating system: Linux a0c679e721a5 5.5.15-200.fc31.x86_64 #1 SMP Thu Apr 2 19:16:17 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
gateway_1  | Jul 16 21:12:27 a0c679e721a5 cron[29]: (CRON) INFO (pidfile fd = 3)
gateway_1  | Jul 16 21:12:27 a0c679e721a5 cron[29]: (CRON) INFO (Running @reboot jobs)
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: Arguments:
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: TWS version = 978
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: Entry point = ibcontroller.IBGatewayController
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: stored passwd in file: /.vnc/passwd
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --tws-path = /root/Jts
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --tws-settings-path = /root/Jts
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --ibc-path = /opt/IBController
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --ibc-ini = /root/IBController/IBController.ini
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --mode = paper
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: 16/07/2020 21:12:27 passing arg to libvncserver: -rfbport
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: 16/07/2020 21:12:27 passing arg to libvncserver: 5900
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --java-path = /usr/local/i4j_jres/1.8.0_152-tzdata2019c/bin
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: 16/07/2020 21:12:27 passing arg to libvncserver: -rfbauth
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: 16/07/2020 21:12:27 passing arg to libvncserver: /.vnc/passwd
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --user = ***
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --pw = ***
gateway_1  | Jul 16 21:12:27 a0c679e721a5 vnc: 16/07/2020 21:12:27 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 253
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --fix-user =
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: --fix-pw =
gateway_1  | Jul 16 21:12:27 a0c679e721a5 ibcontroller: =================================

VNC screenshots

ibcontroller01

ibcontroller02


TODO

  • none

hacker emblem


Powered by Interactive Brokers


Sponsored by TradeSpark

ibgateway's People

Contributors

mgvazquez avatar yarimiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ibgateway's Issues

cannot connect using this code

`from ibapi.client import EClient
from ibapi.wrapper import EWrapper

class IBapi(EWrapper, EClient):
def init(self):
EClient.init(self, self)

app = IBapi()
app.connect('127.0.0.1', 4001, 123)
app.run()
`
i get the following: Disconnected; resetting connection
tried port 4002 as well with no luck

Which port to access in Docker (synology)

In the docker container I did the following port mapping:

Local port 32778 to container 5900
Local port 32776 to container 4001
My Synology Nas is 192.168.2.6.

When I connect from my local pc using vnc to 192.168.2.6:32778 it works perfectly.

Now, In my Python script I do:

from ib_insync import * ib = IB() ib.connect('192.168.2.6:32776', 4002, clientId=1)

When I run the script I get "Getaddrinfo failed".

What can be the issue here?

‘bash\r’ not such file, after building the container locally

I'm facing an issue running the ibgateway container, only when building it locally.

The following log appears after running either docker-compose up or docker run (with the required environment variables and ports)

Creating network "ibgateway_default" with the default driver
Creating ibgateway_gateway_1 ... done
Attaching to ibgateway_gateway_1
gateway_1  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
gateway_1  | *** Running /etc/my_init.d/10_syslog-ng.init...
gateway_1  | Dec 10 06:27:53 c09fbb0543d4 syslog-ng[14]: syslog-ng starting up; version='3.13.2'
gateway_1  | *** Booting runit daemon...
gateway_1  | *** Runit started as PID 23
gateway_1  | /usr/bin/env: /usr/bin/env: ‘bash\r’‘bash\r’: No such file or directory
gateway_1  | : No such file or directory
gateway_1  | /usr/bin/env: ‘bash\r’: No such file or directory
gateway_1  | /usr/bin/env: ‘bash\r’: No such file or directory
gateway_1  | Dec 10 06:27:54 c09fbb0543d4 cron[30]: (CRON) INFO (pidfile fd = 3)
gateway_1  | Dec 10 06:27:54 c09fbb0543d4 cron[30]: (CRON) INFO (Running @reboot jobs)
gateway_1  | /usr/bin/env: /usr/bin/env: /usr/bin/env: ‘bash\r’‘bash\r’: No such file or directory
gateway_1  | : No such file or directory
gateway_1  | ‘bash\r’: No such file or directory
gateway_1  | /usr/bin/env: ‘bash\r’: No such file or directory

This happens only if I'm trying to run a locally built container, using docker build ., as specified in the readme.

I tried building and running the container on Windows 10 and WSL2 Ubuntu but the issue persist.

This is probably because the EOL in the run files are using \r\n for some reason, even though I've built the container using WSL2, which is supposed to not add the windows style EOL to existing files.

Update:
Building the image using MacOS solves the issue. But the windows compatibility is a bug that should be fixed.
I'll try fixing it my own and creating a PR, but not sure yet how to fix it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.