Markowitz’ Critical Line Algorithm for Matlab and Python

Markowitz’ Critical Line Algorithm for Matlab and Python

A Matlab toolbox written in Fortran for a fast computation of the constrained efficient frontier for asset portfolio choice. Software (for Windows and Linux) available upon request from the authors: afniedermayer@gmail.com.  We also provide a Python interface to the Fortran routines (Linux only).


The algorithm is described in the paper Niedermayer, A., & Niedermayer, D. (2010). Applying Markowitz’s critical line algorithm. Handbook of Portfolio Construction, 383-400. See “Applying Markowitz’ Critical Line Algorithm” for the working paper version.


The software is available as a Matlab toolbox (tested for Matlab 7.0 on Windows and Matlab 7.3 on Linux) and as a Python module (32-bit Linux and 64-bit Linux). (See the Github repository with the source code. Note that the Matlab and the 32-bit Linux Python version haven’t been updated for a while, so you’ll probably need to make changes to the code to get it running on newer systems. The 64-bit Linux version for Python is more recent and should work.)


See also a reference implementation in Julia. The reference implementation is meant as an illustration and sacrifices performance for the sake of simplicity.

ABSTRACT

 

We provide a Matlab quadratic optimization tool based on Markowitz’s critical line algorithm that significantly outperforms standard software packages and a recently developed operations research algorithm. As an illustration: For a 2000 asset universe our method needs less than a second to compute the whole frontier whereas the quickest competitor needs several hours. This paper can be considered as a didactic alternative to the critical line algorithm such as presented by Markowitz and treats all steps required by the algorithm explicitly. Finally, we present a benchmark of different optimization algorithms’ performance.