Markowitz Portfolio Optimization
This article describes a feature of the v1 engine, but we will eventually port it for the v2 engine. Check out our asset support packages for the v2 engine.
TuringTrader makes the design and implementation of portfolio algorithms a breeze. Today, we are releasing a set of new features to calculate the Efficient Frontier for a universe of assets. These features hugely simplify the process of creating successful portfolios.
Harry Markowitz introduced Modern Portfolio Theory back in 1952. While his ideas remain valid until today, only very few trading systems have adopted them. Probably, this is because there are only few efficient implementations for Mean-Variance-Optimization available.
A much less known fact is, that Markowitz also provided an algorithm, to calculate the Efficient Frontier in an elegant and fast way. Markowitz called his method the ‘Critical Line Algorithm’, or CLA. This algorithm was re-discovered and implemented in Python by David H. Bailey and Marcos Lopez de Prado. Together, they wrote a fabulous paper explaining the algorithm, as well as their implementation.
Features
To make the algorithm usable with TuringTrader, we ported it to C#. Furthermore, we made some additions to make it fit better with TuringTrader’s concepts of interacting with assets. With these new features we can:
- Determine the covariance matrix for a set of assets. We also provide functionality to down-sample the instrument bars on the fly, allowing for example to calculate the covariance matrix based on monthly bars, in an algorithm running on daily quotes.
- Calculate the Efficient Frontier for a set of assets. This is where the CLA algorithm mentioned above comes in.
- Calculate portfolios and asset weights along the Efficient Frontier. In addition to calculating portfolios with a given risk, we can also determine the portfolios with minimum variance, or maximum Sharpe Ratio.
Usage
That’s is a ton of functionality! Still, using this functionality is surprisingly simple. Let’s have a look at a code snippet:
With these few lines of code, we manage a complete portfolio! To illustrate these new features in a practical context, we have also release a new showcase algorithm, the Classical Asset Allocation.
We hope these new features free you from tedious work, and help you focus on what really counts: your investment ideas.
Happy coding!