This is a Python implementation of Robert C. Merton’s efficient or minimum-variance portfolio algorithm from the paper An Analytic Derivation of the Efficient Portfolio Frontier (1972). Building on the work of Harry Markowitz, Merton describes a way to assign weights to a list of securities to make a portfolio that has the lowest variance in returns for a given level of expected returns, based on historical returns data. Each weight may be positive or negative corresponding to long and short positions, or zero when no position should be taken, and sum to 100%.