The Gateway to Algorithmic and Automated Trading

Interactive Brokers: The API of Many Flavours

Published in Automated Trader Magazine Issue 32 Q1 2014

Interactive Brokers (IB) was at the forefront of API development in the earliest days of automated trading and now has thousands of individual and institutional clients using the various flavours of its API. Automated Trader's founder, Andy Webb, talks to Pete Spiro, Senior Programmer at IB, about the API and its users.

Pete Spiro

Pete Spiro

Automated Trader: When did you first launch the API and what versions did you initially deploy?

Pete Spiro: The API first launched in 2004, with the C++ and Excel versions coming out at pretty much the same time.

Automated Trader: What was your personal involvement then and now with the API?

Pete Spiro: I was the original developer of the IB API and was responsible for maintaining it for a number of years. I now oversee everything on the IB Trader Workstation (our client trading workstation application) side of the API development, but I no longer have day to day involvement with API client development.

Automated Trader: Where do you see the most demand as regards the API in terms of programming languages?

Pete Spiro: We don't have exact metrics on that because (with the exception of Excel based API trading) all the orders coming in via the API to the Trader Workstation look the same to it - they are just standardised message types irrespective of programming language. However, I would say that on the basis of the webinars that we give that Java is definitely one of the most popular.

Automated Trader: What are the biggest programming challenges associated with the API?

Pete Spiro: These days it is all fairly straightforward, as we are essentially now just maintaining the various versions and adding functionality to them as required, so there aren't really any major challenges. However, in the initial development phase we had a number of interesting challenges. In the case of the Excel API we originally wanted to implement it using ActiveX but found that too problematic so switched to using DDE. Although that is regarded as rather old technology, we've managed to get it working really well, though we obviously can't support it for Mac users as there is no concept of DDE on the Mac OS.

As regards the other API flavours, we had some issues at the beginning in the way sockets were implemented, which resulted in some data going missing between the API and the Trader Workstation. However, since we resolved that, there really haven't been any many challenges on that side either.

Automated Trader: How did you come to join IB?

Pete Spiro: My background was originally in C++, but 13 years ago when I applied for a post IB were advertising, they were actually looking for a Java programmer. At the time I had no previous financial nor Java experience, so it was nice that they were willing to hire somebody who didn't match up perfectly on paper to their requirements! Fortunately my general programming experience was regarded as a good enough proxy, even though I didn't have the exact qualifications required. But back then, making the migration to Java from a language such as C++ really wasn't that big a step. If you were to try and do the same today it would be far more challenging.

Automated Trader: Do you put a lot of emphasis on API development?

Pete Spiro: Yes, as there is definitely a lot of demand and interest in its use among traders. You can see that simply by looking at the various message boards that we run for users. The one we have dedicated to the API has 10 times more posts than any other board, and the Yahoo Groups API board is very active too. We also have a comment/suggestion link on the IB website and a large percentage of messages from that tend to be about the API.

Our API webinars, which we run for the various flavours of API, are also very popular. About a year ago we added a Q&A session so I could directly interact with users. These sessions generate some interesting technical questions from advanced API users, plus enable us to gauge at first hand the likely level of demand for new features.

Therefore, it certainly seems that the API is gaining in popularity and looks set to continue that way.

Automated Trader: What is the demographic of your API users?

Pete Spiro: We don't maintain data for API users specifically, but our total client breakdown might not be that dissimilar: 56% of our accounts are what you might call individuals, with the remaining 44% being institutional. The majority of our institutional traders tend to be from small to medium-sized institutions. For them, a combination of the 60+ different order types we can offer, the API, sound financials and competitive pricing is an attractive alternative to trying to set up a conventional prime brokerage account.

Some of our institutional traders are putting some decent volume through the API. One institutional client that we helped implement an automated trading model through the API now trades around one million shares a day with it.

Automated Trader: What about individual API traders and other participants?

Pete Spiro: Apart from those who connect to us directly via API we also do significant business with brokers. Of this, omnibus account business (where the broker handles the client accounting) is probably also generating additional API activity.

An important additional channel of API activity for us is the third-party vendor market. These vendors have the confidence to invest in writing to the IB API because it has been around for a long time and is regularly maintained and upgraded. Although the IB Trader Workstation provides a good generic trading GUI, these applications - including the likes of ButtonTrader, NinjaTrader MultiCharts and QuoteTrader - offer some form of additional niche functionality, but use the IB API for market connectivity. We provide a marketplace on the IB website where all these third-party API vendors are listed and where customers can rate them and/or buy products from them.

Other participants also active with the IB API are third-party programming consultants. Traders without programming skills wishing to implement their ideas as automated models are thus able to do so with the aid of these consultants.

Automated Trader: What about those traders who are reluctant to entrust their IP to a third party?

Pete Spiro: If they have limited programming skills, apart from the documentation we provide, a great way to understand how to use the API is to take a look at the activity on GitHub. We've recently open-sourced the API and uploaded it there, so traders have an opportunity to collaborate and exchange code, as well as enhance the API in the open source environment. Apart from benefiting even experienced programmers, that's also a valuable initial learning resource. Plus of course there are also our webinars.

Automated Trader: Is there any significant difference between your individual and institutional traders' choice of API flavour?

Pete Spiro: Yes. In addition to the various versions of the API I mentioned earlier, we also provide API connectivity via our FIX Computer-to-Computer Interface (CTCI). The option of standard FIX connectivity is understandably of primary interest to our institutional users. There are two ways in which they can implement this, either via a dedicated connection direct to our servers, or over the Internet. In the latter case, the connection is made via an application called the IB Gateway, which simply handles authentication and passes the data through.

Automated Trader: How do API and FIX CTCI connectivity compare in terms of volume?

Pete Spiro: At present, our non-FIX API activity is about 15% of total activity, while FIX CTCI is about 12%. A year ago the figures were about 15% and 11% respectively. So activity is basically stable over the last year, with a slight increase in FIX CTCI volume.

Automated Trader: What sort activity patterns do you see over the API?

Pete Spiro: Pretty much as you might expect. Higher trade volumes per customer than for manual traders and the general style of trading tends to be akin to market making, with relatively small size being shown.

Automated Trader: What is the process for adding functionality to the API?

Pete Spiro: Particularly if it's something fairly obscure, we don't automatically add every new piece of Trader Workstation functionality to the API. That sort of item is only added if specifically requested.

The usual routine is to add functionality to the Trader Workstation first and then to the API, though sometimes it is added simultaneously. The Trader Workstation is the key here because you have to be running an instance of it to use the API, all non-FIX API connections use the Trader Workstation as a bridge to our back end servers.

Automated Trader: Does the API automatically support new instruments?

Pete Spiro: If for example a new exchange comes online, then that will automatically be available on the API. The same applies to individual financial products. The exception to this is if a new type of data is associated with orders for that instrument. If that could not be fitted into the existing data fields then it would require additional programming to update all the various API clients.

Automated Trader: How much programming differentiation is actually involved between the various flavours of the API?

Pete Spiro: As I mentioned earlier, apart from Excel (which uses DDE) all the other API variants use a socket connection to Trader Workstation. So although they have to be written in different languages, the format of the messages are just the same and the same basic parameters and methods are used.

Automated Trader: What tools do you use for API development?

Pete Spiro: For Java development we use Eclipse and Visual Studio for C++. We also make extensive use of profiling tools (such as JProbe for Java) to maximise performance as regards memory management, throughput etc.

Automated Trader: How many people are on the IB API team?

Pete Spiro: We have one dedicated programmer plus one dedicated tester, but other people will circulate in and out of API projects as needed. I oversee everything on the Trader Workstation side of the API development, but these days don't have much direct involvement in API client development.