Welcome to this short course on programming using the Python TWS API.
Prerequisites for this course:
- Windows, Linux, or Mac OS computer with a Graphical User Interface and Python 3.3 or higher installed.
- Familiarity with Python programming.
- The TWS API utilizes socket programming, multiple threads, and other concepts which it is recommended to be familiar with beforehand. If not, it is suggested to first try an Introduction to Python course which covers these topics.
- Programmers with experience in Python who are interested in building custom applications.
IBKR offers several trading platforms, including:
- Trader Workstation (TWS) is a Java-based application which can run on any major desktop operating system supporting a graphical user interface, such as Windows, Linux, or MacOS. For security reasons, TWS is designed to require the end user to manually enter credentials into the user interface.
- Client Portal, which is a web-based platform for trading and other account functions,
- Or IBKR mobile, the mobile trading app for Apple and Android smartphones.
In addition to using IBKR’s trading software, there are several ways by which custom or 3rd party trading applications can place orders to IBKR accounts. One common means of connection available for all clients is the TWS API. Other connections include the WEB API and FIX/CTCI connections.
The API offerings are detailed on our website, Interactivebrokers.com, under Trading and API.
The Trader Workstation API is an open-source interface to TWS which can be used by custom or 3rd party applications to automate TWS functionality, including but not limited to:
- Order placement
- Receiving account values
- Receiving portfolio data
- Receiving market data
- Querying financial instrument details
It is important to keep in mind that the TWS API itself does not provide new functionality unavailable in TWS, but rather provides the ability to automate some actions within TWS from external software.
The source code for the TWS API is provided under a non-commercial license agreement from https://interactivebrokers.github.io/ and can be used by a programmer to write a custom application that connects to TWS.
Since this code is entirely in general programming languages such as Python, Java, C#, and C++, the intended audience for the source code are experienced third party programmers with a background in one of these languages.
To develop applications which do not fit under the default non-commercial license agreement, a commercial license agreement is available on request. More than 100+ applications compatible with the TWS API have been developed by third party developers, and many are advertised on the Investors Marketplace on the Interactive Brokers website.
Disclosure: Interactive Brokers
The analysis in this material 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 IBKR 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.
The views and opinions expressed herein are those of the author and do not necessarily reflect the views of Interactive Brokers, its affiliates, or its employees.