Chan’s encounter
First Published in Automated Trader Magazine Issue 13 Q2 2009
We’ve met Ernest P Chan before, back in the Q2 2008 issue, when he wrote about combining machine learning and regime switching to achieve profitability. Here, he tells us the story of an encounter with MATLAB that has transformed his order execution. Do you know how to use MATLAB as an automated execution system?
Many traders are familiar with MATLAB as a powerful software platform for backtesting trading strategies. This is especially true for those who would like to analyze and trade a large number (maybe thousands) of stocks simultaneously. MATLAB is a language that is built around matrix manipulation and processing, so many calculations involving multiple stocks are just as easy as calculations involving a single stock.
In my book Quantitative Trading (Wiley 2008), I have described a number of examples of how backtesting is usually done in MATLAB. However, it was also true that MATLAB suffered from a major deficiency relative to more familiar trading platforms such as TradeStation – after a strategy has been backtested, it wasn’t easy to immediately turn it into an execution system and submit orders to your brokerage account.
Brokerages that support Application Program Interfaces (API) to various other languages such as Visual Basic, Java, C# or C++ often do not support MATLAB. Therefore, building an automated execution engine involves re-programming the strategy in one of those languages that your brokerage supports, thereby losing the simplicity and ease-of-use of MATLAB.
Recently, however, I have discovered a piece of software that can seamlessly connect a MATLAB program to a brokerage account, allowing MATLAB to receive market data, plus execution and position reports from the brokerage, and to send orders for execution to the brokerage. In other words, turning MATLAB into ...


