Portfolio Construction

The ultimate goal of any trading algorithm is to hold the “best” possible portfolio of assets at each point in time, but algorithms vary in their definition of “best”. One algorithm might want the portfolio that maximizes expected returns based on a prediction of future prices (an alpha factor). Another algorithm might want a portfolio that’s as close as possible to equal-weighted across a fixed set of longs and shorts.

Many algorithms also want to ensure that their “best” portfolio satisfies some set of constraints. The algorithm that wants to maximize expected returns might also want to place a cap on the gross market value of its portfolio, and the algorithm that wants to maintain an equal-weight long-short portfolio might also want to limit its daily turnover.

Portfolio Optimization

One powerful technique for finding a constrained “best” portfolio is to frame the task in the form of a Portfolio Optimization problem. At a high level, a portfolio optimization problem is a mathematical problem that maximizes an objective function while satisfying a series of constraints. Typically, the objective function is derived from an alpha factor while constraints attempt to control the risk profile of the resulting portfolio (e.g. maximum position concentration, sector exposure, etc.).

On Quantopian, you can construct your portfolio using the Optimize API. The Optimize API constructs a portfolio of assets by defining a portfolio optimization problem. An objective function and constraints are usually defined using results of Pipeline or Risk Model computations.