IBKR Quant Blog


Resources for Getting Started with IBKR Python API


Why choose Python?

Python has been crowned #1 in the “The 2017 Top Programming Languages” by IEEE Spectrum, the world’s largest technical professional organization dedicated to advancing technology for the benefit of humanity.

In addition, StackOverflow, a popular “question and answer site for professional and enthusiast programmers” recently published an article on its Blog noting how popular Python has become. Visit their website to read the “The Incredible Popularity of Python”.

Python language offers robust programming capabilities and is the preferred language for many quant hedge funds and finance professionals. The Python Software Organization offers a Quick Start Guide that walks you through Python installation: https://www.pytho n.org/about/gettingstarted/. You will also need to pick an IDE to code in Python. There are many choices - some of the most popular seem to be Jupyter Notebook, PyCharm, and Spyder.

Why choose IBKR Python API?

API users who build their own automated rules-based trading application can use our API solutions. Due to the demand for a framework written in this high performance language, our developers added support for Python in 2017.

If you are a finance professional who’s realized that it is time to start coding, the Python API provides an easier framework compared to Java or C++. Python syntax is more relaxed, and you can practice with the sample code we provide.

To the next generation of traders: college and high school students who have taken classes in Python will appreciate the plethora of complimentary finance educational resources we offer that will go along with the Python reference guide.


Getting Started Resources

Here is a short list of resources that will help you get started:


  1. Visit IBKR GitHub https://interactivebrokers.github.io/tws-api/ and click on the Python tab.

    Get familiar with the all the resources we offer, including information on Initial setup, Architecture, Streaming Market data, Obtaining Historical Data for backtesting, error handling and message codes, and a list of classes, structs, unions and interfaces with brief descriptions.

  2. Install
    1. IBKR API from here http://interactivebrokers.github.io/

      Please note that the Python sample Program.py is installed automatically in samples/Python/Testbed directory
    2. Trader Workstation Latest from here https://www.interactivebrokers.com/en/index.php?f=16040

  3. Watch "Introduction to the TWS Python API" webinar Recording presented by our API Team:



    In this video, the API team will show you:
    1. Capabilities and requirements of the TWS API
    2. API architecture and general programming considerations
    3. Basic flow of an API program as demonstrated by the IB sample Program.py
    4. Current API reference guide
    5. Common API tasks in Python - receiving market data, performing Financial Advisor specific operations

  4. It is important to understand how to establish connectivity because the API requires connectivity via Trader Workstation (TWS) or IB Gateway.

    Learn more with this article "Establishing an API connection"

  5. Practice

    IBKR reminds you to always test your API components with your simulated trading account or the TWS Demo System before you implement any new API system.
    • Finance professionals
    • Students are invited to work with their professors and join the IB Student Trading Lab to practice with a university simulated trading account.


The analysis in this article is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IB to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.



We appreciate your feedback. If you have any questions or comments about IBKR Quant Blog please contact ibkrquant@ibkr.com.

The material (including articles and commentary) provided on IBKR Quant Blog is offered for informational purposes only. The posted material is NOT a recommendation by Interactive Brokers (IB) that you or your clients should contract for the services of or invest with any of the independent advisors or hedge funds or others who may post on IBKR Quant Blog or invest with any advisors or hedge funds. The advisors, hedge funds and other analysts who may post on IBKR Quant Blog are independent of IB and IB does not make any representations or warranties concerning the past or future performance of these advisors, hedge funds and others or the accuracy of the information they provide. Interactive Brokers does not conduct a "suitability review" to make sure the trading of any advisor or hedge fund or other party is suitable for you.

Securities or other financial instruments mentioned in the material posted are not suitable for all investors. The material posted does not take into account your particular investment objectives, financial situations or needs and is not intended as a recommendation to you of any particular securities, financial instruments or strategies. Before making any investment or trade, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice. Past performance is no guarantee of future results.

Any information provided by third parties has been obtained from sources believed to be reliable and accurate; however, IB does not warrant its accuracy and assumes no responsibility for any errors or omissions.

Any information posted by employees of IB or an affiliated company is based upon information that is believed to be reliable. However, neither IB nor its affiliates warrant its completeness, accuracy or adequacy. IB does not make any representations or warranties concerning the past or future performance of any financial instrument. By posting material on IB Quant Blog, IB is not representing that any particular financial instrument or trading strategy is appropriate for you.