Back to Community
Command Line Program - IB API

I have a command line program that does a lot of scraping/parsing and other algorithmic calculations to come together with a set of buys/sells after the markets have closed every night. Some of these trades are market orders for market open the next day, while others are limit orders aimed to be filled at some point mid-day. I'm at the point where I have backtested the system as well as forward tested it for a while and I'm ready to try running it algorithmically with a small funded account with Interactive Brokers. Given the nature of the algorithm, I cannot run it through Quantopian/Amibroker/NinjaTrader etc. but I'm hoping to find a way such that I can make IB/TWS API calls every evening instead of having to manually put them in (my last case resort - it will do the job but will take 15-20 minutes of tedious copying and pasting every night).

I have experience in C++/Python and would like to ideally use one of those two (definitely prefer Python) to do this job. I looked at IBPy, but the documentation and general discussion on it seems scarce. I believe I have already got the Python code working such that it will submit orders, but I can't figure out how to use IBPy to retrieve current positions in my account. Moreover, I heard that these Python APIs are very buggy and unreliable.

What path would you recommend I take in this case? Are there any good, reliable and well-documented Python APIs available for IB/TWS?

3 responses

I cannot run it through Quantopian/Amibroker/NinjaTrader etc. but I'm hoping to find a way such that I can make IB/TWS API calls

Quantopian has integration with Interactive Brokers already.But you need to decide which stocks will you trade US Stocks or Indian Stocks.
To trade on US Stocks you will need to have US bank account and register an account via IB US.For Indian Stocks the account will be opened with IB India division.IBPy is not the official API for trading with Interactive Brokers as far as I know

I understand that Quantopian already has an integration with IB. The issue for me is that my algorithm cannot be hosted on Quantopian because of the way that it works.

There is a yahoo group for TWSAPI which is a better venue for this question.