Migrating from Quantopian to IBridgePy can be very easy in some cases even without making any code changes. In this thread, I am going to talk about how to make the migration as smooth as possible. In the following, I will explain the detailed steps assuming you are using a Microsoft Windows system.
As a short description, in the runMode of run_like_quantopian, the initialize function will run once at the beginning of the algorithm and  handle_data function will run every minute, just like how they perform at Quantopian.
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
step 2. 1 Install Anaconda
For Windows users, Anaconda is required.
- For your convenience, use this link Anaconda3-5.0.1-Windows-x86_64.exe to download Anaconda Python 3.6 for windows users.
- Use this link Anaconda2-5.0.1-Windows-x86_64.exe to download Anaconda Python 2.7 for windows users.
For Ubuntu users, do NOT install Anaconda. You need to use native Python 2.7 64-bit
For Mac users, you can choose to install Anaconda or not. You may refer to this tutorial to debug on Mac if any issues.
step 2.2 Configure TWS or IB Gateway
The detailed steps are described in this webpage.
step 2.3 Log into IB TWS or IB Gateway
IBridgePy can trade in IB live accounts and 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, IB’s public demo account does not behave as same as live accounts or paper accounts do.
User name is “fdemo” Â —- 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: Copy and Save your Quantopian algorithms
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 5: Check what Quantopian functions you are using in your algorithm
The Quantopian functions that are supported by IBridgePy are listed here. These functions are supposed to behave as similar as they do in Quantopian. Â You are welcome to send an Email to IBridgePy@gmail.com if you find out that any functions perform very differently. We will try our best to fix them.
* You need to delete any Quantopian functions that are not supported by IBridgePy in your algorithms. As of Aug 27th 2017, IBridgePy does not support Quantopian’s pipeline yet.
* You need to install any 3rd part Python packages that you are using in your algorithms, for example, TaLib, if these 3rd part Python packages are not automatically installed with Python XY or Anaconda. As an example, pytz is a Python package to handle time zones and it has been automatically installed with Python XY or Anaconda so that you don’t need to install it again.
- 1.1 initialize — similar as initialize at Quantopian
- 1.2 handle_data — similar as handle_data at Quantopian
- 1.3 before_trading_start — similar as before_trading_start at Quantopian
- 1.4 Data method — similar as Data method at Quantopian
- 1.5 data.current — similar as data.current at Quantopian
- 1.6 data.history — similar as data.history at Quantopian
- 1.7 order — similar as order at Quantopian
- 1.8 order_target — similar as order_target at Quantopian
- 1.9 order_percent — similar as order_percent at Quantopian
- 1.10 order_target_percent — similar as order_target_percent at Quantopian
- 1.11 order_value — similar as order_value at Quantopian
- 1.12 order_target_value — similar as order_target_value at Quantopian
- 1.13 cancel_order — similar as cancel_order at Quantopian
- 1.14 get_open_orders — similar as get_open_orders at Quantopian
- 1.15 get_order  — similar as get_order at Quantopian
- 1.16 get_datetime — similar as get_datetime at Quantopian
- 1.17 symbol — similar as symbol at Quantopian
- 1.18 symbols — similar as symbols at Quantopian
- 1.19 schedule_function– similar as schedule_function at Quantopian
- 1.20 record — similar as record at 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 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:
- The bugs come from IBridgePy. We will try our best to fix the bugs coming from IBridgePy.
- 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.
- Demo account, paper account and live account behave differently.
- Bugs in customer’s algorithms.
Hi,
Have you guys thought about Robinhood integration? Does it sound like a project you would work on?
Vincent
We would love to integrate Robinhood with IBridgePy. Robinhood will support IBridgePy if there are a lot of customer requests.
Awesome! Are you guys collecting any signatures or forms to get Robinhood to support us? I would love to help
You can contact with Robinhood and ask them to consider IBridgePy as a partner.
they have an unofficial api. I don’t believe partner status is really needed, they will be rolling out an official api here soon and it would be really nice to not have to migrate code.
I am a loyal Robinhood algo trader. I asked Rh for help / direction on viable options for live trading algo traders such as myself.
@IBridgePy
Do you have plans to support pipeline soon?
We plan to support pipeline later but not soon.
Thank you!
Following mail sent yesterday (traceback,last line:
File “C:\Python27\lib\site-packages\IPython\core\ultratb.py”, line 617, in _format_exception_only
Colors.Normal, s))
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xf3 in position 38: ordinal not in range(128)
Any sugestion?
I am installing and trying to connect thru run_me.py and getting historical data
https://ibridgepy.com//q-a/#Q_8216ascii8217_codec_can8217t_decode_byte_0xb2_in_position_20_ordinal_not_in_range128_What_cause_this_error
success!!: changing to IBridge 32 from 64
Anyone here have any success experience running the IBridgePy in Ubuntu with https://ibridgepy.com//wp-content/uploads/2017/09/IBridgePy_ubuntu.zip
I’m hitting the following roadblock:
Traceback (most recent call last):
File “RUN_ME.py”, line 35, in
exec(script)
File “”, line 8, in
File “/root/ib-api/IBridgePy/IBridgePy/quantopian.py”, line 1, in
from IBridgePy import IBCpp
ImportError: /root/ib-api/IBridgePy/IBridgePy/IBCpp.so: undefined symbol: GENERAL_NAME_free
Any idea what went wrong? The following is my python environment:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import struct
>>> print(8 * struct.calcsize(“P”))
64
Thanks in advance.
https://ibridgepy.com//q-a/#Q_I_am_using_IBridgePy_on_Ubuntu_but_see_the_error_message_of_8220undefined_symbol_GENERAL_NAME_free8221_Can_you_help
Please try the latest version of IBridgePy on Ubuntu. Thanks
Please try the latest version of IBridgePy on Ubuntu. Thanks
The bug is fixed in version 1.20170913. Thanks
Has order_target_percent been implemented? Don’t see any references to it in the release notes.
I am running an algo but it hasn’t placed any orders yet so I am worried that it will fail when it comes onto that command.
order_value ( ), order_target_percent ( ), order_target_value ( ) and record ( ) are added from version 2.20171012
order_value ( ), order_target_percent ( ), order_target_value ( ) and record ( ) are supported by IBridgePy version 2.20171012
Hi,
I read the Tutorial again and have the following questions:
1. before_trading_start
>>The time when before_trading_start is called can be configured by users.
In the ‘configuration.txt’? But how?
2. sid()
Do you support the sid() as in Qauntopian?
3. Order types
It seems you have only three order functions: oder(), order_target() and order_percent(). How about the others as by Quantoipian such like: order_value(), order_target_value() and order_target_percent()
4. ocaGroup in create_order()
Seems the oca = oco (one cancle the other), right?
5. Relation betwwen create_order() and place_combination_orders()
I understand one has to use the create_order() to create order legs and then use the place_combination_orders() to place these legs. Correct?
Hi,
Will IBridgePy have the pipeline function as in Quantopian in the future?
Yes, we are developing pipeline functions.
Hi,
Looking forward to trying this out. Just installed and setup everything, will try porting over my algo today and running for the next few days.
Qustion: How do we run multiple algos? Do we clone RUN_ME.py for each algo and run them simultaneously? Example: RUN_ME_algo1.py, RUN_ME_algo2.py, etc.
Thank you.
Use schedule_function to separate different algos and everything is included in one py file.
This means you run multiple algos on a single account. I am not sure if this is a good idea.
The best way is to run single algo on single account, the so-called multiple account. But you would chage for that. :-/
I’m running into the same issue. Has anyone resolved this?
It is solved in the version 2.20171004
Can the IBridgePy placed in any directory?
Yes. Anywhere.
How can I edit the run_me.py for FA account to manage client accounts?
You cannot make it happen in IBridgePy free community version. Please contact with IBridgePy@gmail.com and ask for IBridgePy for Multi Account. Thanks
Can’t I use IbridgePy stand-alone or I have to use it with platform provided by http://www.interactivebrokers.com?
If you want to live trade, you need to use IBridgePy with http://www.interactivebrokers.com
I can’t get historical data for some etfs. Is there a exhaustive list of security_info.csv?
For e.g. I can’t get prices for EWG
Also, if I want the index price for Shanghai index , or SENSEX what should I do?
https://ibridgepy.com//q-a/#QIt_seems_the_stock_of_8220XYZ8221_is_not_in_the_file_of_IBridgePysecurity_infocsv_I_wonder_for_what_purpose_you_use_this_csv_file_What_should_I_do
I simply cloned an algo from quantopian to see if I could figure this all out. I have IB, everything nearly set. Forgive my ignorance as im no expert at this but I get an error “no module: quantopian.pipeline.data.builtin” What do I do?
Is pipeline already supported?