I am quite amazed how little info and understanding there is about the infamous IB API despite the popularity of IB and its platform.
First a quick summary to understand the IB API Architecture, in an easy to understand format:
1. IB is built on a client/message server architecture offering trading execution, market data feeds, and trading logic executions. It's very important to understand that each of those functions have a different purpose and should be programmed differently.
2. IB has two Client interfaces, TWS and IBGW. TWS is the GUI trading console which offers all the features of a commercial OMS/EMS. The IBGW is the other client for IB message server but it doesn't offer the rich interface of TWS, it is simply a gateway to send and receive "IB messages" to/from the IB Message Server. It can be regarded as a bare-bone version of TWS, and for that reason all the functions found in TWS needs to be custom built through libraries of code available in another package called IB API. The IB API is available in a number of programming languages. For this guide, I will focus on Java and Python.
3. The core of programming with IB API will focus on sending Requests to IB Message Server and capturing their replies. The IB API will wrap and parse all those IB messages for the IB Message Server to process. The IB API will parse the replies into programming language objects which make it easy to structure the programming code for other IB functions.
4. The IB API offers 2 implementations of the IB message parsing/wrapping into code objects. The "ib.ext" tree which is very "low level" and kind of clumsy as most "low level" systems are, and the "ib.opt" tree which is more "elegant" and "higher level" and not as awkward as "ib.ext". The "ib.opt" tree obviously uses calls to "ib.ext", so "ib.ext" is still fundamental for your IB code to function.
To structure the IB functions into your Java and Python code, you need to perform the followings steps (see next post below):
First a quick summary to understand the IB API Architecture, in an easy to understand format:
1. IB is built on a client/message server architecture offering trading execution, market data feeds, and trading logic executions. It's very important to understand that each of those functions have a different purpose and should be programmed differently.
2. IB has two Client interfaces, TWS and IBGW. TWS is the GUI trading console which offers all the features of a commercial OMS/EMS. The IBGW is the other client for IB message server but it doesn't offer the rich interface of TWS, it is simply a gateway to send and receive "IB messages" to/from the IB Message Server. It can be regarded as a bare-bone version of TWS, and for that reason all the functions found in TWS needs to be custom built through libraries of code available in another package called IB API. The IB API is available in a number of programming languages. For this guide, I will focus on Java and Python.
3. The core of programming with IB API will focus on sending Requests to IB Message Server and capturing their replies. The IB API will wrap and parse all those IB messages for the IB Message Server to process. The IB API will parse the replies into programming language objects which make it easy to structure the programming code for other IB functions.
4. The IB API offers 2 implementations of the IB message parsing/wrapping into code objects. The "ib.ext" tree which is very "low level" and kind of clumsy as most "low level" systems are, and the "ib.opt" tree which is more "elegant" and "higher level" and not as awkward as "ib.ext". The "ib.opt" tree obviously uses calls to "ib.ext", so "ib.ext" is still fundamental for your IB code to function.
To structure the IB functions into your Java and Python code, you need to perform the followings steps (see next post below):