Giter Site home page Giter Site logo

lshahar / ib_docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jmarks199/ib_docker

0.0 1.0 0.0 29 KB

A Docker Container for the Interactive Brokers Gateway in a Headless Environment. Supports running both Live and Paper Environments.

License: Apache License 2.0

Dockerfile 79.47% Shell 20.53%

ib_docker's Introduction

ib_docker

A Docker Container for the Interactive Brokers Gateway in a Headless Environment. Supports running both Live and Paper Environments.

As of 11/25/2020 I did not see any other currently working examples of building a docker container for the IB Gateway on Github. In order to create run this Docker container you will need to have the Docker and Docker-Compose CLI components installed on your machine.

Notes

This will make the IB Gateway available on your local machine on port 4003 regardless of whether you run the container in paper or live mode.

  • This implies you cannot run more than one container at a time. Although with minimal changes I suppose you could.

After you run the container, you need to wait 30 seconds before trying to connect to port 4003 because this is the amount of time provided for the IB Gateway to start before the ports are forked inside the container.

Configuration

  1. Clone this repository onto your local machine.
  2. Review the settings in config.ini so you understand the behavior of the gateway and change if necessary.
    • It is not required to change anything and the fields that are blank should remain so because they are set by the environment section of the yml files.
  3. Open a text editor and create a file called tws_credentials.env inside the context directory and insert the username and password you use to login to Interactive Brokers
    • Refer to the example file if necessary.
    • This is included in the .gitignore so it will not be pushed to your source control but your password is still stored as plain text on your local machine so take necessary precaution to protect this file.
    • Note - i use the same ID and password for both live and paper, but you could create two .envs, and add the appropriate .env file to the env_file section in each yml file.

To Build and Run

Then, follow these steps to build a Docker Image and run the container.

  1. cd into the context directory (where the Dockerfile lives)
  2. Run docker-compose build in the console
  3. Run docker-compose up to start the container with TRADING_MODE set to paper.
    • To run the container with trading mode set to live run docker-compose -f docker-compose-live.yml -f prod.yml up instead
  4. Connect to the IB Gateway from your local machine with ipaddress="127.0.0.1", portid=4003
    • Traditionally you can connect to IB Gateway locally by specifying ipaddress="", however, this would not work for me.

Telnet

I have not tested shutting down the container via Docker, however telnet is installed in the container so you can communicate with the IBC service on port 7462 e.g. { echo "STOP"; } | telnet 127.0.0.1 7462 in order to close the IB Gateway.

Final

If you see any issues or improvements, please let me know.

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.