Introduction
Interactive Brokers (IB) is one of most popular brokers among institutional traders, professional traders and serious retail traders. IB was one of the first few brokers to provide retail traders an option to automate their trading processes using their API. IB provides access to 3 APIs for it's clients:
- TWS API
- Client Portal API
- FIX API
In this article we will look at the difference between TWS API and Client Portal API. FIX API is mostly used by institutions looking for it's high-speed order routing functionality. It has limited features, can only be used for order placement and cannot be used to access market data.
Now let's look at the differences between TWS API and Client Portal API.
API Release, Stability and Popularity
TWS API is the older, stable and fully featured API which is the most popular amongst it's clients. Whereas, Client Portal API is a relatively newer and less popular API which was released by Interactive Brokers for clients interested in RESTful API access. Since, Client Portal API is a relatively new, it still has a lot of bugs.
Architecture
TWS API has asynchronous architecture. Asynchronous architecture means that requests to API and response from API need to be handled separately. Advantage of asynchronous architecture is that it helps to reduce delays in request/response operations and makes your application fast as you don't need to wait for API response before making another request to API. However, the disadvantage is that your program can become a bit complex, since your application needs to handle request and response from API separately.
On the other hand, Client Portal API has RESTful architecture, meaning, you need to wait for API to respond to any request before moving on to another request. As a result, your application can become a bit slow if you need to make frequent requests (like requesting historical data, account details, position details, open orders, option chain data etc.). Advantage of RESTful architecture is that programming an application is simpler as you don't need to handle requests to API and responses from API separately.
Connection Methodology
While TWS API requires users to run TWS or IB gateway on their local machine, Client Portal API can be accessed either via industry standard OAuth or by downloading their proprietary headless gateway. If you use OAuth method, you wouldn't need to run any application on your local machine and wouldn't need to manually authenticate for logging in to your account. Please refer to this link for more details on how to connect.
Features Comparison
Now let's compare the features of TWS API and Client Portal API. Both APIs provide methods for:
- Placing, canceling and modifying orders
- Requesting open positions, open orders and executions
- Requesting historical data
TWS API provides access to tick-by-tick data whereas Client Portal API doesn't. Therefore if your application requires tick-by-tick data, then you should consider using their TWS API. On the other hand, Client Portal API provides some additional features like portfolio analyst, statements, transaction history, which are not provided by the TWS API.
For more details on features of TWS API and client portal API, please refer to this link.