Tutorial: install IBridgePy and run an examples


Tutorial: install IBridgePy and run an example

Step 0: Install Anaconda Python for Windows users

Download and install the latest version of Anaconda, 64-bit Python, either 2.7 or 3.6. It will take up to 30 minutes to download and install Anaconda depending on your internet speed. The python packages, such as panda and numpy, IBridgePy uses will be automatically installed with Anaconda Python.

For Mac or Ubuntu user, please DO NOT install Anaconda.  IBridgePy support Ubuntu native Python 2.7 64-bit and Mac native Python 2.7 64-bit.

Step 1:  Download IBridgePy to your local folder

You need to check the version of your Python, either Python 2.7 or Python 3.x and check if it is 32-bit Python or 64-bit Python. Then, download IBridgePy according to your Python version from www.IBridgePy.com/download
Assume the path of the folder where you save IBridgePy is C:\ABC\DEF\IBridgePy

Step 2: Complete preparation steps

Please follow the instruction in this webpage http://www.ibridgepy.com/preparation/ to install and configure IB Gateway or Trader Workstation (IB TWS)

IBridgePy can trade using either IB live accounts or paper accounts. It is highly recommended to test your strategies in a paper account. If you don’t have an IB account yet, you are welcome to use IB’s public demo account. However, you need to keep it in mind that IB’s public demo account does not behave as same as live accounts or paper accounts do.
User name is “edemo”   —- without quotation marks
Password is “demouser” —- without quotation marks

After you finish this step, either IB Gateway or TWS should be open and active.

Step 3: Open Spyder

Step 4: Open an example in Spyder Editor


Save your Quantopian algorithms in a folder called “Strategies” that is a sub-folder of IBridgePy (C:\ABC\DEF\IBridgePy\Strategies). The file extension should be “.py” because they are Python scripts. In the following, assume the file name of your algorithm is MyAlgo.py , and it is saved at C:\ABC\DEF\IBridgePy\Strategies\MyAlgo.py

Step 4: Edit RUN_ME.py in Spyder

Open RUN_ME.py  (C:\ABC\DEF\IBridgePy\RUN_ME.py) in Spyder.

Put your IB account code into RUN_ME.py


Add one line in RUN_ME.py  ->   fileName = ‘MyAlgo.py’


Set runMode = ‘run_like_quantopian’


 Step 6: Run your algorithm in Spyder.

Actually, you need to run RUN_ME.py to run your algorithm in Spyder so that you can think RUN_ME.py as a main entrance to any customer’s algorithms. In Spyder, you can click “F5” or the green triangle to run a Python script.


Step 7: Watch out any error messages

After IBridgePy completes its initialization procedures, it will print out a summary of your accounts. If you see a similar summary, it means that IBridgePy gets connected with IB Gateway / TWS successfully.


If you see any error messages, you may follow the error messages to debug.

There are many reasons for errors. You may debug from the following areas:

  1. The bugs come from IBridgePy. We will try our best to fix the bugs coming from IBridgePy.
  2. IB servers may not response as you expect. For example, you may not receive historical data around 6PM eastern time, 1:30 AM eastern time because of IB maintenance or data server updates.
  3. Demo account, paper account and live account behave differently.
  4. Bugs in customer’s algorithms.

Posted in Uncategorized
One comment on “Tutorial: install IBridgePy and run an examples
  1. tony says:

    Do I need to uninstall official Python 3.6.4 and Python Launcher before installing Anaconda?

Leave a Reply

Your email address will not be published.