Back to Community
IBridgePy Setup


I've installed IBridgePy on my local machine to see if it is a suitable replacement for Quantopian. It says on the website that it should be able to run Quantopian algorithms with little or no changes. I have been able to use it to get my account balance and holdings using the basic "" through the IB Gateway. However, I don't really see how to run a quantopian algorithm, even though I uncommented the line "runMode='run_like_quantopian'". I copied an algo into a new file and included it in the, but I get tons of errors.

Would anyone be kind enough to put together a tutorial that includes the version of Python they are using and any other dependencies? I'm on Windows, and any help would be most appreciated. Thinking I'm not the only one who will have issues getting the local environment set up correctly.

31 responses

I think the best way to solve your issues is to send an email to [email protected]

It seems to me, you should do
1. save the code into a file ""
2. call this file using fileName='' in the
3. execute

I have a different question:
Since IbridgePY does not support pipeline, can someone show me by a sample code how to get historical data for VIX?


I would like to say one of the posibilities to get the VIX historical data is to use something like fetch_csv() to access the CSV files by CBOE. I do this in my algo here.

Hi Hui Liu,

I understand little bit why should write you personally if we have questions? Thi sis somewhat not transparent and I doubt you have so much time to answer the questions individually. If you don't want to discuss the questions here you can at least discuss in the Community by IBridgePy. I've visited your page yesterday and find the Community there is quite "calm".

how does importing datasets work in IBridgepy? is it the same? Is access to all the quantopian datasets there?

I find one of the shortage by IBridgePY is, one has to shutdown the connection to IB after the market is closed and reconnect it before the market open the next day.

Please send email to [email protected] if you are having difficulty to run the three examples provided by IBridgePy because there is not a one-fit-all solution. We can use Teamviewer sessions to remotely debug for you.

@Jon Chen
IBridgePy does not have its own database yet. It needs to obtain data from Interactive Brokers. IBridgePy is able to obtain any information from Interactive Brokers if you have the permission to access information from Interactive Brokers. However, we are working on building IBridgePy database.

@Thomas Chang
You don't need to shutdown the connection to IB after the market is closed if you don't want to do that. IBridgePy can detect disconnection between your client to IB Gateway/ TWS and disconnection between IB Gateway/ TWS to IB server and it will reconnect if you instruct IBridgePy to do so.

@ Jeff Liu Please refer to this blog to download any historical data from IB.

@Joseph Everly
We are working on a tutorial about migrating from Quantopian to IBridgePy.

Awesome, a tutorial would be great!

Attempt to get the historical data for VIX by using the following code and get an error message
"IBridgePy.quantopian::ReqHistClass::_init: EXIT, cannot handle security.secType=IND"


def initialize(context):
context.vix = superSymbol(secType='IND', symbol='VIX', currency='USD')
def handledata(context, data):

request_data(historyData=[(context.vix, ‘1 day’, ‘2 D’) ])
print ('Historical Data of VIX')
print (data[context.vix].hist['1 day'].tail())

The bug has been fixed. Thank you very much for letting us know the issue.

IBridgePy has a function of data.history to request historical data from IB server

def initialize(context):  
                            exchange='SMART', primaryExchange='CBOE')  
def handle_data(context, data):  
    print (data.history(context.sec, 'open', 5, '1d'))  

Hi Everyone - I would like to provide an update, because I believe I have it working!!!

It really is as simple as the tutorial on the IBridgePy website, but there is potentially some massaging required of your algorithm. So here is my experience on Windows 10, but keep in mind that I am not a hard-core developer, so some of this might not be required:

  1. Started by installing the 32-bit 2.7 version of Python via Anaconda, mostly because that is what I read was required for Zipline, and that was one of the things that I initially wanted to check out. (I DID add python to the PATH even though it said it wasn't recommended)
  2. Installed IB Gateway and got logged into my paper trading account.
  3. Downloaded IBridgePy and placed it in the Lib folder of Python.
  4. Got the basic examples working by using the IBridgePy instructions - placed paper trading order, etc.
  5. Now I tried copying my algorithm to a text file and saving it to the "strategies" folder in the IBridgePy set of folders and tried to run...
  6. What I didn't fully appreciate is that my algorithm had a few things that IBridgePy didn't support:
  7. I had to remove anything related to pipeline and fetcher. I had to change "order_target_percent" to "order_target", I removed set_asset_restrictions(security_lists.restrict_leveraged_etfs), I also removed the VWAPBestEffort order type, though I'm not completely sure that was necessary.
    1. Additionally, I have thus far been unable to install talib on my machine, so I removed anything to do with it.

So I can't completely confirm that it is working until Monday when hopefully I see some paper trades, but I feel like I am making progress. I do have a couple of open items that I would love to get some input on:

  1. Any thoughts on why I can't get talib to install? I have tried easy_install, pip, and conda, but I keep getting an error that says "INCLUDE environment variable is empty" - and I haven't found a solution googling it.
  2. I know I will have to sign up for a data subscription to get historical data through IB (mostly for talib, which I can't get working yet). Does anyone know which one(s) I need? I plan on calling them at some point next week.

Finally, Hui has been helpful via email, and I would like to publicly thank him!

1. handle_data seems to run every SECOND under the new version with bug fixed; and the error message is gone for 'IND'; but it doesn't extract any historical VIX from IB. Instead, it shows the following message:

IBridgePy.IBAccountManager::checktimer: requestdata failed after 30 seconds
IBridgePy.IBAccountManager::checktimer: notDone items in self.endchecklist
historyData reqId=7 IND,VIX,USD,SMART,CBOE status=Submitted waiver=False
IBridgePy.IBAccountManager::requestdata: Re-send request info

is the step 3 in Joseph post necessary
Downloaded IBridgePy and placed it in the Lib folder of Python.

I am thinks my that step 3 should not be necessary if python is in the path.

@ Jeff Liu
It is not necessary to place IBridgePy in the Lib folder of Python. You can place IBridgePy anywhere and add it to Python Path is recommended.

@ Joseph Everly
I will add the function of "order_target_percent" to IBridgePy soon.
set_asset_restrictions(security_lists.restrict_leveraged_etfs) and VWAPBestEffort : I did not see these functions are in Quantopian's API document so that they are not supported by IBridgePy yet.

@Hui Liu

Thank you for quick response. I downloaded the new version and re-ran the example code using data.history you recommended. The error message with IND is gone. However, historical VIX data is still NOT received except the following.


def initialize(context):
exchange='SMART', primaryExchange='CBOE')
def handledata(context, data):
print (data.history(context.sec, ‘open’, 5, ‘1d’))

IBridgePy.IBAccountManager::checktimer: requestdata failed after 30 seconds
IBridgePy.IBAccountManager::checktimer: notDone items in self.endchecklist
historyData reqId=7 IND,VIX,USD,SMART,CBOE status=Submitted waiver=False
IBridgePy.IBAccountManager::requestdata: Re-send request info
IBridgePy.IBAccountManager::checktimer: requestdata failed after 30 seconds
IBridgePy.IBAccountManager::checktimer: notDone items in self.endchecklist

@Hui Liu,

When I get history data by these code by IBridgePy:

context.stocks  = symbols('SPY','DIA','EFA','EEM','EWJ','HYG','IEF','BIL')  
for s in context.stocks:  
        price = data.history(s, 'price', '252', '1d').dropna()  
        print(str(len(price)) + str(s.symbol))  

I found for stock IEF, it only returns 17 days of data, and for EWJ, only returns 202 days data, for the rest it returns 252 days data. I tried many times and the return is the same. What's the reason? Do we have a way for get at least 252 days history price for all of them?


@ Jeff Liu
I got the same error on my side. It seems that IB server has received the request correctly but it simply did not response. I will try to debug when the market is open on Monday.

@ David Qi
Can you print out IEF's data? May IB does not have enough data on their server.

@Hui Liu,
Yes, I can print out IEF data, but only for recent 17 days. I noticed in TWS that for the price of IEF, it also only shows recent 17 days, not like other securities, very strange. Could you take a look on your TWS?

By the way, there are 2 things will be needed in IBridgePy I think:
1, order_target_percent is very useful but not supported by IBridgePy yet, will you support it?
2, Debug is not convenient now. All errors in strategy will be blocked by, can we find a way to know the detailed error in strategy?

Anyway, IBridgePy is the only way I want to move to, hoping it improved soon.


Hi all,
A blog about migrating from Quantopian to IBridgePy is posted here
Please let me know if you have any issues by sending an email to [email protected]

@ Jeff Liu
open high low close
2017-08-22 12.60 12.94 11.35 11.35
2017-08-23 11.51 12.59 11.39 12.25
2017-08-24 12.06 12.83 11.55 12.23
2017-08-25 12.20 12.45 11.10 11.28
2017-08-28 12.09 12.11 11.23 11.90
The code ran well on my side.
IB server may not response historical data requests as expected during sometimes, especially midnight of Eastern time and 5PM~6PM Eastern time

@David Qi
We are working on order_target_percentage. It will be supported by IBridgePy soon.
If you are using Spyder, error messages can be used to debug the code.
By the way, IBridgePy backtester will come soon.

@Hui Liu

Is the historic price data from IB dividend or split adjusted? In the data.history manual there was no discussion of dividend adjusted prices.

@Hui Liu,

I find it's good idea that you open a new post in the IBridge Community to discuss the migration since who knows when QuantOpian will close this Forum later?

I suggest that you no answer question here any more and simply keep the discussion going in your IBridge Community.

@ Minor Edge
IB's equity historical data is adjusted for splits, but not dividends

@ Thomas Chang
Everyone is welcome to continue the discussion on this webpage.

We are really excited to announce that IBridgePy is able to run Quantopian strategies to trade with TD Ameritrade, who offers ZERO commission for US equity tradings. The YouTube tutorial of IBridgePy trading with TD Ameritrade is here:
In this tutorial, the following topics are covered
- Download and unzip IBridgePy
- Set up to trade with TD Ameritrade
- Show real time prices
- Get historical data
- Place order
- Cancel order
If you have any questions, please feel free to email [email protected]
Disclaimer: This is Dr. Hui Liu, the creator of IBridgePy