Dynamic Algorithmic Trading Systems in Python
Algorithmic Trading System Design Patterns
Introduction
Efficiency and reusability is critical, especially when building systems that trade multiple securities. I have discussed development using Interactive Broker’s Java and Python API in the past:
I would suggest reading those articles first if you are unfamiliar with Interactive Broker’s API. In this article, I want to further the notion of algorithmic trading by exhibiting a system design pattern that allows for ease of extension to multiple securities.
Establishing a Controller
EClient and EWrapper Classes
The EWrapper class is responsible for receiving data from the server that is requested by the EClient class. More intuitively, we can think of this as a sender (EClient) receiver (EWrapper) relationship. The EClient class houses functions that allow for market data requests, trade execution, and portfolio updates, etc…, while the EWrapper class houses callback functions for processing what is returned by the server. During instantiation, the EClient class takes an instance of the EWrapper…