Institutional investors periodically reallocate their portfolios to shift asset mixes or change their investment managers. They face a variety of costs when they undertake these transitions, including commissions, bid-ask spreads, opportunity cost, and market impact (see Perold  and Almgren and Chris ). Opportunity cost refers to adverse changes in price arising from exogenous market forces, while market impact refers to adverse price movements that occur in response to the purchase and sale of securities. Opportunity cost and market impact are especially interesting because these costs represent the largest share of total cost and because investors influence these costs by how they trade. We introduce an algorithm for determining the optimal sequence and size of trades that minimize opportunity cost for portfolio transitions. Our algorithm differs from other models intended to minimize opportunity cost because we are concerned with the relative performance of the legacy and the target portfolios rather than the absolute performance of a single security or a group of securities targeted for purchase or sale. Moreover, we assume the investor does not use leverage to execute the transition; hence we constrain the trades to be self-financing.