Tutorial: Migrating from Quantopian to IBridgePy
Migrating from Quantopian to IBridgePy can be very easy in some cases even without making code changes. This comprehensive guide will help you understand the process of migrating from Quantopian to IBridgePy as smooth as possible using Python stock trading with Interactive Brokers for algorithmic trading.
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. When migrating from Quantopian, 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


